/* jquery.dumbcrossfade-2.0.js http://s3.amazonaws.com/storage.sebringcreative.com/jquery/dumbCrossFade.htm - 2010 Hubsoft.com && SebringCreative.com (written by Jason Sebring, mail@jasonsebring.com) - Dual licensed under the MIT and GPL licenses. */
/* CKIHE - modified the fade slideType to fade out the old slide at the same time as fading in the new one to account for transparency */
(function($){$.fn.dumbCrossFade=function(settings){var publicAccessorLabel='dumbCrossFade.publicAccessor';var configLabel='dumbCrossFade.config';if(typeof(this.data(publicAccessorLabel))!=='undefined'&&this.data(publicAccessorLabel)!==null){var pa=this.data(publicAccessorLabel);var cg=this.data(configLabel);var args=Array.prototype.slice.apply(arguments);if(args.length>0){if(typeof(args[0])==='object'){if(settings)$.extend(cg,settings);var args=Array.prototype.slice.apply(arguments);if(args.length>1){args=args.slice(1,args.length);}else{pa.start();return this;}}if(arguments.length===1){pa[arguments[0]]();}else if(arguments.length>1){var args=Array.prototype.slice.apply(arguments);args=args.slice(1,args.length);pa[arguments[0]].apply(this,args);}}return this;}var config={'slideType':'slidehorizontal','index':0,'showTime':5000,'transitionTime':1000,'doHoverPause':true,'maxZIndex':100,'slideChange':null,'direction':'forward','fadeInOut':false},timeOut=null,itemArray=[],blockAnimation=false,lastIndexRequest=-1,$self=this
$window=$(window),$body=$('body');if(settings)$.extend(config,settings);function cancelSlideShow(){if(timeOut!==null){window.clearTimeout(timeOut);timeOut=null;}}function doSlideShowNow(){if(blockAnimation){if(arguments.length>0){lastIndexRequest=arguments[0];}return;}var currentIndex=config.index;var nextIndex=(arguments.length>0)?arguments[0]:(config.index>=itemArray.length-1)?0:config.index+1;if(config.direction==='backward'){if(currentIndex===0){nextIndex=itemArray.length-1;}else{nextIndex=currentIndex-1;}}if(currentIndex==nextIndex){return;}var $f=itemArray[currentIndex].show(),$n=itemArray[nextIndex];blockAnimation=true;doneF=function(){$f.hide();if(config.fadeInOut){$f.css({'opacity':'1.0'});$n.css({'opacity':'1.0'});}blockAnimation=false;if(lastIndexRequest!=-1){doSlideShowNow(lastIndexRequest);lastIndexRequest=-1;}};$f.css('z-index',(config.maxZIndex-1)+'');$n.css('z-index',config.maxZIndex+'');switch(config.slideType){case'slidehorizontal':var pos=$f.position(),width=$f.width(),adjustX='-='+width;if(config.direction==='forward'){$n.css({'left':(parseInt(pos.left)+width)+'px'});}else{$n.css({'left':(parseInt(pos.left)-width)+'px'});adjustX='+='+width;}if(config.fadeInOut){$n.css({'opacity':'0','display':'block'});$f.animate({'left':adjustX,'opacity':'0'},config.transitionTime,'swing');$n.animate({'left':adjustX,'opacity':'1.0'},config.transitionTime,'swing',doneF);}else{$n.show();$f.animate({'left':adjustX},config.transitionTime,'swing');$n.animate({'left':adjustX},config.transitionTime,'swing',doneF);}break;case'slidevertical':var pos=$f.position(),height=$f.height(),adjustY='-='+height;if(config.direction==='forward'){$n.css({'top':(parseInt(pos.top)+height)+'px','display':'block'});}else{$n.css({'top':(parseInt(pos.top)-height)+'px','display':'block'});adjustY='+='+height;}if(config.fadeInOut){$n.css({'opacity':'0','display':'block'});$f.animate({'top':adjustY,'opacity':'0'},config.transitionTime,'swing');$n.animate({'top':adjustY,'opacity':'1.0'},config.transitionTime,'swing',doneF);}else{$n.show();$f.animate({'top':adjustY},config.transitionTime);$n.animate({'top':adjustY},config.transitionTime,doneF);}break;case'fade':$n.fadeIn(config.transitionTime,doneF);$f.fadeOut(config.transitionTime,doneF);break;}if(config.slideChange!==null){config.slideChange(nextIndex);}config.index=nextIndex;}function doSlideShow(){cancelSlideShow();timeOut=window.setTimeout(function(){doSlideShowNow();doSlideShow();},config.showTime);}$self.each(function(){(itemArray.length===config.index)?$(this).show():$(this).hide();if(itemArray.length===0){if(config.doHoverPause){$(this).parent().hover(function(){cancelSlideShow();},function(){cancelSlideShow();doSlideShow();});}}itemArray[itemArray.length]=$(this);});var publicAccessor={'jump':function(index){cancelSlideShow();doSlideShowNow(index);return publicAccessor;},'start':function(){$self.children().hide();itemArray[config.index].show();config.direction='forward';doSlideShow();},'stop':function(){cancelSlideShow();},'next':function(){config.direction='forward';cancelSlideShow();doSlideShowNow();},'previous':function(){config.direction='backward';cancelSlideShow();doSlideShowNow();}};this.data(publicAccessorLabel,publicAccessor);this.data(configLabel,config);doSlideShow();return this;};})(jQuery);

/*
 * TypeHelpers version 1.0
 * Zoltan Hawryluk, Nov 24 2009.
 * @see http://www.useragentman.com/blog/2009/11/29/how-to-detect-font-smoothing-using-javascript/
 * 
 * Released under the MIT License. http://www.opensource.org/licenses/mit-license.php
 * 
 * Works for 
 *   - IE6+ (Windows), 
 *   - Firefox 3.5+ (Windows, Mac, Linux), 
 *   - Safari 4+ (Windows, Mac OS X), 
 *   - Chrome 3.0+ (Windows).
 * Opera 10.10 and under reports unknown support for font-smoothing.
 *
 * Modified by Christian Beier (www.beier-christian.eu) to detect the ClearType technology.
 * 
 * Required: jQuery 1.3.x
 */
var TypeHelpers=new function(){var me=this;me.hasSmoothing=function(){if(typeof(screen.fontSmoothingEnabled)!="undefined"){return screen.fontSmoothingEnabled}else{try{var canvasNode=document.createElement("canvas");canvasNode.width="35";canvasNode.height="35";canvasNode.style.display="none";document.body.appendChild(canvasNode);var ctx=canvasNode.getContext("2d");ctx.textBaseline="top";ctx.font="32px Arial";ctx.fillStyle="black";ctx.strokeStyle="black";ctx.fillText("O",0,0);for(var j=8;j<=32;j++){for(var i=1;i<=32;i++){var imageData=ctx.getImageData(i,j,1,1).data;var alpha=imageData[3];if(alpha!=255&&alpha!=0&&alpha>180){return true}}}return false}catch(ex){return null}}};$(document).ready(function(){var result=me.hasSmoothing();if(result==true){$("html").addClass("hasFontSmoothing-true")}else{if(result==false){$("html").addClass("hasFontSmoothing-false")}else{$("html").addClass("hasFontSmoothing-unknown")}}})};

// Modified from http://kawika.org/jquery/index.php?section=autolink
jQuery.fn.highlight = function (text, o) {
	return this.each( function(){
		var replace = o || '<span class="highlight">$1</span>';
		$(this).html( $(this).html().replace( new RegExp('('+text+'(?![\\w\\s?&.\\/;#~%"=-]*>))', "ig"), replace) );
	});
}

jQuery.fn.autolink = function (newWindow) {
	return this.each( function(){
		var re = /((http|https|ftp):\/\/[\w?=&.\/-;#~%-]+(?![\w\s?&.\/;#~%"=-]*>))/g;
		$(this).html( $(this).html().replace(re, '<a href="$1"' + (!newWindow ? '' : ' target="_blank"') + '>$1</a> ') );
	});
}

jQuery.fn.mailto = function () {
	return this.each( function() {
		var re = /(([a-z0-9*._+]){1,}\@(([a-z0-9]+[-]?){1,}[a-z0-9]+\.){1,}([a-z]{2,4}|museum)(?![\w\s?&.\/;#~%"=-]*>))/g
		$(this).html( $(this).html().replace( re, '<a href="mailto:$1">$1</a>' ) );
	});
}

