$(document).ready(function(){	
	
	if (document.all) {
		//jQuery("#navigation li").hoverClass("sfHover");
	}
	
	// SEARCH FORM FOCUS EFFECTS
	$('#searchForm input').focus(function(){
		if(this.value == this.defaultValue){
			this.value = '';
		}
		if(this.value != this.defaultValue){
			this.select();
		}
	});
	
	$('#searchForm input').blur(function(){
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
	
	// IE7 Menu Rollovers
	$("#IEroot7 #navigation li.cablesNav").hover(function(){
		var myList = $(this).find('ul.dropdown');
		$(myList).css('display', 'block');
	}, function(){
		var myList = $(this).find('ul.dropdown');
		$(myList).css('display', 'none');
	});
	$("#IEroot7 #navigation li.cablesNav ul li.multi").hover(function(){
		var myList = $(this).find('ul');
		$(myList).css('display', 'block');
	}, function(){
		var myList = $(this).find('ul');
		$(myList).css('display', 'none');
	});
	$("#IEroot7 #navigation li.articlesNav").hover(function(){
		var myList = $(this).find('ul.dropdown');
		$(myList).css('display', 'block');
	}, function(){
		var myList = $(this).find('ul.dropdown');
		$(myList).css('display', 'none');
	});
	$("#IEroot7 #navigation li.blogsNav").hover(function(){
		var myList = $(this).find('ul.dropdown');
		$(myList).css('display', 'block');
	}, function(){
		var myList = $(this).find('ul.dropdown');
		$(myList).css('display', 'none');
	});
	$("#IEroot7 #navigation li.gearNav").hover(function(){
		var myList = $(this).find('ul.dropdown');
		$(myList).css('display', 'block');
	}, function(){
		var myList = $(this).find('ul.dropdown');
		$(myList).css('display', 'none');
	});
	$("#IEroot7 #navigation li.aboutNav").hover(function(){
		var myList = $(this).find('ul.dropdown');
		$(myList).css('display', 'block');
	}, function(){
		var myList = $(this).find('ul.dropdown');
		$(myList).css('display', 'none');
	});
	
	$('#navigation ul li').css('opacity', 0.90);
	$('#navigation ul li ul li').css('opacity', 1); 

	$('#navigation ul li ul').hover(function(){
		var myParent = $(this).parent();
		$(myParent).addClass('active');
	}, function(){
		var myParent = $(this).parent();
		$(myParent).removeClass('active');
	});
	
	$(".homeSlideshowWrapper .homeAjaxSpinner").fadeOut("slow");
	$(".homeInnerSlideshowFade").fadeIn("slow");
	$('.rotateWrapper').innerfade({ speed: 'slow', timeout: 6000, type: 'sequence' }); 
	
	$(".slideshowWrapper .ajaxSpinner").fadeOut("slow");
	$(".slideshowInnerWrapper").fadeIn("slow");
	
	$(".riderGallery").jCarouselLite({
    	btnNext: "#riderProfileLeft .next",
    	btnPrev: "#riderProfileLeft .prev",
		circular:false
	});

	$(".bioGallery img").click(function() {
    	$("#riderImage img").attr("src", $(this).attr("src"));
	})
	
	$(".photoGallery").jCarouselLite({
    	btnNext: "#photoGalleryImages .next",
    	btnPrev: "#photoGalleryImages .prev",
		circular:false
	});

	$(".eventGallery img").click(function() {
    	$("#eventImage img").attr("src", $(this).attr("src"));
	})
	
	$('input#ratingBox').val('0');
	
	// Pro Rider Bios Rollovers
	$('#biosWrapper .riderBio').hover(function(){
		$(this).find('.riderImage').css('display','none');
		$(this).find('.riderImageGrey').css('display','block');
	}, function(){
		$(this).find('.riderImage').css('display','block');
		$(this).find('.riderImageGrey').css('display','none');
	})
	
	// Hover intent for equipment navigation
	var navConfig = {    
		sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
		interval: 75, // number = milliseconds for onMouseOver polling interval    
		over: setActive, // function = onMouseOver callback (REQUIRED)    
		timeout: 75, // number = milliseconds delay before onMouseOut    
		out: setInactive // function = onMouseOut callback (REQUIRED)    
	};

	$("#equipmentNavigation li").hoverIntent(navConfig)
	
	// Star Ratings Hover Effects
	
	var starConfig = {    
		sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
		interval: 75, // number = milliseconds for onMouseOver polling interval    
		over: starsOver, // function = onMouseOver callback (REQUIRED)    
		timeout: 75, // number = milliseconds delay before onMouseOut    
		out: starsOut // function = onMouseOut callback (REQUIRED)    
	};
	
	$("ul#ratingStars a").hoverIntent(starConfig)
	$("ul#ratingStars a").click(function(){return false;})
	
	// Vertical Align on Cable Lake Logo Images
	$('.cableLogo').each(function(i){
		var image = '#' + $(this).attr('id') + ' img';
		var top = ( 110 - $(image).height() ) / 2;
		$(image).css('margin-top', top);
	});

	/* Cable Map */
	
	$('#mapBG').css({backgroundPosition: '0 0'});
	
	$("#mapRegionWrapper").smoothDivScroll({
		scrollingSpeed: 15, 
		mouseDownSpeedBooster: 1,
		scrollingHotSpotLeft: "#mapScrollLeft", 
		scrollingHotSpotRight: "#mapScrollRight", 
		scrollWrapper: "#mapRegionScroll",
		scrollableArea: "#mapRegionContent",
		visibleHotSpots: "always"
	});		

	/* Cable Map Rollovers */

	$('a.mapPA').hover(function(){
		$('#mapBG').css('backgroundPosition', '0 -480px');
		$('#mapRegionName p span').text('Pan America');
	}, function(){
		$('#mapBG').css('backgroundPosition', '0 0');
		$('#mapRegionName p span').text('Cable Lakes Worldwide');
	});
	
	$('a.mapEU').hover(function(){
		$('#mapBG').css('backgroundPosition', '0 -960px');
		$('#mapRegionName p span').text('Europe');
	}, function(){
		$('#mapBG').css('backgroundPosition', '0 0');
		$('#mapRegionName p span').text('Cable Lakes Worldwide');
	});
	
	$('a.mapAM').hover(function(){
		$('#mapBG').css('backgroundPosition', '0 -1440px');
		$('#mapRegionName p span').text('Africa and the Middle East');
	}, function(){
		$('#mapBG').css('backgroundPosition', '0 0');
		$('#mapRegionName p span').text('Cable Lakes Worldwide');
	});
	
	$('a.mapRA').hover(function(){
		$('#mapBG').css('backgroundPosition', '0 -1920px');
		$('#mapRegionName p span').text('Russia and Asia');
	}, function(){
		$('#mapBG').css('backgroundPosition', '0 0');
		$('#mapRegionName p span').text('Cable Lakes Worldwide');
	});
	
	$('a.mapAS').hover(function(){
		$('#mapBG').css('backgroundPosition', '0 -2400px');
		$('#mapRegionName p span').text('Australia and New Zealand');
	}, function(){
		$('#mapBG').css('backgroundPosition', '0 0');
		$('#mapRegionName p span').text('Cable Lakes Worldwide');
	});
	
	$('a.mapUK').hover(function(){
		$('#europeMapBG').css('backgroundPosition', '0 -358px');
		$('#mapEuropeRegionName p span').text('United Kingdom');
	}, function(){
		$('#europeMapBG').css('backgroundPosition', '0 0');
		$('#mapEuropeRegionName p span').text('Cable Lakes Europe');
	});
	
	$('a.mapFR').hover(function(){
		$('#europeMapBG').css('backgroundPosition', '0 -716px');
		$('#mapEuropeRegionName p span').text('France');
	}, function(){
		$('#europeMapBG').css('backgroundPosition', '0 0');
		$('#mapEuropeRegionName p span').text('Cable Lakes Europe');
	});
	
	$('a.mapDE').hover(function(){
		$('#europeMapBG').css('backgroundPosition', '0 -1074px');
		$('#mapEuropeRegionName p span').text('Germany');
	}, function(){
		$('#europeMapBG').css('backgroundPosition', '0 0');
		$('#mapEuropeRegionName p span').text('Cable Lakes Europe');
	});
	
	$('a.mapHU').hover(function(){
		$('#europeMapBG').css('backgroundPosition', '0 -1432px');
		$('#mapEuropeRegionName p span').text('Hungary');
	}, function(){
		$('#europeMapBG').css('backgroundPosition', '0 0');
		$('#mapEuropeRegionName p span').text('Cable Lakes Europe');
	});
	
	$('a.mapEU-Zoom').hover(function(){
		$('#europeMapBG').css('backgroundPosition', '0 -1790px');
		$('#mapEuropeRegionName p span').text('Europe Other');
	}, function(){
		$('#europeMapBG').css('backgroundPosition', '0 0');
		$('#mapEuropeRegionName p span').text('Cable Lakes Europe');
	});


	/* Europe Click State */
	$('a.mapEU').click(function(){
		$('#mapRegionOverlay').css('display', 'none');
		$('#mapRegionName').css('display', 'none');
		$('#europeBG').css('display', 'block');
		$('#europeMapOverlay').css('display', 'block');
		$('#europeMapBG').css('display', 'block');
	});
	
	$('#europeBG').click(function(){
		$('#mapRegionOverlay').css('display', 'block');
		$('#mapRegionName').css('display', 'block');
		$('#europeBG').css('display', 'none');
		$('#europeMapOverlay').css('display', 'none');
		$('#europeMapBG').css('display', 'none');
	});
	
	// Video Archive Tabs
	$('#videoArchives ul#videoArchiveMonths li').hover(function(){
		$(this).addClass('activeHover');
	},function(){
		$(this).removeClass('activeHover');
	});
		
	// Changes Views
	$('#videoArchives ul#videoArchiveMonths li').click(function(){
		// Finds the current view and hides it 
		var current = $('#videoArchiveWrapper').find('.activeWrap');
		$(current).removeClass('activeWrap').addClass('inactiveWrap');
		
		// Gets the ID of the tab and displays the appropriate view for it
		var id = $(this).attr('id');
		
		switch(id) {
			case 'fav':
				$('#favorites').addClass('activeWrap').removeClass('inactiveWrap');
				break;
			case 'mo1':
				$('#month1').addClass('activeWrap').removeClass('inactiveWrap');
				break;
			case 'mo2':
				$('#month2').addClass('activeWrap').removeClass('inactiveWrap');
				break;
			case 'mo3':
				$('#month3').addClass('activeWrap').removeClass('inactiveWrap');
				break;
			case 'mo4':
				$('#month4').addClass('activeWrap').removeClass('inactiveWrap');
				break;
			case 'mo5':
				$('#month5').addClass('activeWrap').removeClass('inactiveWrap');
				break;
			case 'mo6':
				$('#month6').addClass('activeWrap').removeClass('inactiveWrap');
				break;
			case 'mo7':
				$('#month7').addClass('activeWrap').removeClass('inactiveWrap');
				break;
		}
		
		// Finds the current active tab and sets it to the new view
		var activeTab = $('#videoArchives ul#videoArchiveMonths').find('.active');
		$(activeTab).each(function(i){
			$(this).removeClass('active');
		});
		var newTab = "#videoArchiveMonths li#" + id;
		$(newTab).addClass('active');

	});
	
});

jQuery.fn.hoverClass = function(c) {
	return this.each(function(){
		jQuery(this).hover( 
			function() { jQuery(this).addClass(c);  },
			function() { jQuery(this).removeClass(c); }
		);
	});
};


function setActive() {
	var selected = $("#equipmentNavigation").find("li.selected");
	//remove selected class here
	//$(selected).removeClass("selected");
	//$(selected).addClass("off");
	$(this).addClass("active");
}

function setInactive() {
	$(this).removeClass("active");
	//add class to selected
	var selected = $("#equipmentNavigation").find("li.off");
	$(selected).addClass("selected");
}

// Star ratings
function starsOver() {
	var target = parseInt($(this).attr('id'));
	
	for (i=1; i<=5; i++) {
		if (i <= target) {
			var me = "#" + i;
			$(me).addClass('on').removeClass('off');
			$(me).removeClass('off');
			$('input#ratingBox').val(target);
		} else {
			var me = "#" + i;
			$(me).addClass('off').removeClass('on');
  		}
	}
}

function starsOut() {
	var target = parseInt($(this).attr('id'));
	
	for (i=1; i<=5; i++) {
  		if (i <= $('input#ratingBox').val()) {
			var me = "#" + i;
			$(me).addClass('on').removeClass('off');
  		} else {
			var me = "#" + i;
			$(me).addClass('off').removeClass('on');
  		}
	}
}


// Twitter Video Share Link
function tweetVideo(title, url){
	// set up default options
	var defaults = {
		version:    '2.0.1',
    	login:      'cablewakeboard',
    	apiKey:     'R_57d5e4d4d46b61bb397d9f630c1ed6bf',
    	history:    '0',
    	longUrl:    url
  	};

  	// Build the URL to query
  	var daurl = "http://api.bit.ly/shorten?"
    	+"version="+defaults.version
    	+"&longUrl="+defaults.longUrl
    	+"&login="+defaults.login
    	+"&apiKey="+defaults.apiKey
    	+"&history="+defaults.history
    	+"&format=json&callback=?";

    // Utilize the bit.ly API
    $.getJSON(daurl, function(data){

       	// Build the twitter URL
		var twitterURL = "http://twitter.com/home?status=Watch%20";
		twitterURL = twitterURL + escape(title);
		twitterURL = twitterURL + "%20Video%20--%20";
		twitterURL = twitterURL + escape(data.results[defaults.longUrl].shortUrl);
		twitterURL = twitterURL + "%20only%20on%20";
		twitterURL = twitterURL + escape('http://cablewakeboard.com');
			
		// Open the new window in a popup
       	window.open(twitterURL,'Cablewakeboard Tweet This Video','width=1024,height=650'); 
    });
}

// Facebook Video Share Link
function facebookSharer(title, url){
	// Build the facebook URL
	var facebookURL = "http://www.facebook.com/sharer.php?u=";
	facebookURL = facebookURL + escape(url);
	facebookURL = facebookURL + "&t=" + escape(title);
	
	// Open the new window in a popup
	window.open(facebookURL,'Cablewakeboard Share This Video on Facebook','width=1024,height=650');
}

// Digg This Video Link
function diggVideo(title, url, description){
	// Build the Digg URL
	var diggURL = "http://digg.com/submit?phase=2&url=";
	diggURL = diggURL + escape(url);
	diggURL = diggURL + "&title=" + escape(title);
	diggURL = diggURL + "&bodytext=" + escape(description);
	diggURL = diggURL + "&topic=videos_sports";
	
	// Opn the new window in a popup
	window.open(diggURL,'Cablewakeboard Digg This Video','width=1024,height=650,scrollbars=yes');
}
	
// jCarouselLite
(function($){$.fn.jCarouselLite=function(o){o=$.extend({btnPrev:null,btnNext:null,btnGo:null,mouseWheel:false,auto:null,speed:200,easing:null,vertical:false,circular:true,visible:3,start:0,scroll:1,beforeStart:null,afterEnd:null},o||{});return this.each(function(){var running=false,animCss=o.vertical?"top":"left",sizeCss=o.vertical?"height":"width";var div=$(this),ul=$("ul",div),tLi=$("li",ul),tl=tLi.size(),v=o.visible;if(o.circular){ul.prepend(tLi.slice(tl-v-1+1).clone()).append(tLi.slice(0,v).clone());o.start+=v}var li=$("li",ul),itemLength=li.size(),curr=o.start;div.css("visibility","visible");li.css({overflow:"hidden",float:o.vertical?"none":"left"});ul.css({margin:"0",padding:"0",position:"relative","list-style-type":"none","z-index":"1"});div.css({overflow:"hidden",position:"relative","z-index":"2",left:"0px"});var liSize=o.vertical?height(li):width(li);var ulSize=liSize*itemLength;var divSize=381;li.css({width:li.width(),height:li.height()});ul.css(sizeCss,ulSize+"px").css(animCss,-(curr*liSize));div.css(sizeCss,divSize+"px");if(o.btnPrev)$(o.btnPrev).click(function(){return go(curr-o.scroll)});if(o.btnNext)$(o.btnNext).click(function(){return go(curr+o.scroll)});if(o.btnGo)$.each(o.btnGo,function(i,val){$(val).click(function(){return go(o.circular?o.visible+i:i)})});if(o.mouseWheel&&div.mousewheel)div.mousewheel(function(e,d){return d>0?go(curr-o.scroll):go(curr+o.scroll)});if(o.auto)setInterval(function(){go(curr+o.scroll)},o.auto+o.speed);function vis(){return li.slice(curr).slice(0,v)};function go(to){if(!running){if(o.beforeStart)o.beforeStart.call(this,vis());if(o.circular){if(to<=o.start-v-1){ul.css(animCss,-((itemLength-(v*2))*liSize)+"px");curr=to==o.start-v-1?itemLength-(v*2)-1:itemLength-(v*2)-o.scroll}else if(to>=itemLength-v+1){ul.css(animCss,-((v)*liSize)+"px");curr=to==itemLength-v+1?v+1:v+o.scroll}else curr=to}else{if(to<0||to>itemLength-v)return;else curr=to}running=true;ul.animate(animCss=="left"?{left:-(curr*liSize)}:{top:-(curr*liSize)},o.speed,o.easing,function(){if(o.afterEnd)o.afterEnd.call(this,vis());running=false});if(!o.circular){$(o.btnPrev+","+o.btnNext).removeClass("disabled");$((curr-o.scroll<0&&o.btnPrev)||(curr+o.scroll>itemLength-v&&o.btnNext)||[]).addClass("disabled")}}return false}})};function css(el,prop){return parseInt($.css(el[0],prop))||0};function width(el){return el[0].offsetWidth+css(el,'marginLeft')+css(el,'marginRight')};function height(el){return el[0].offsetHeight+css(el,'marginTop')+css(el,'marginBottom')}})(jQuery);

// superfish
(function($){$.fn.superfish=function(op){var sf=$.fn.superfish,c=sf.c,$arrow=$(['<span class="',c.arrowClass,'"> &#187;</span>'].join('')),over=function(){var $$=$(this),menu=getMenu($$);clearTimeout(menu.sfTimer);$$.showSuperfishUl().siblings().hideSuperfishUl()},out=function(){var $$=$(this),menu=getMenu($$),o=sf.op;clearTimeout(menu.sfTimer);menu.sfTimer=setTimeout(function(){o.retainPath=($.inArray($$[0],o.$path)>-1);$$.hideSuperfishUl();if(o.$path.length&&$$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path)}},o.delay)},getMenu=function($menu){var menu=$menu.parents(['ul.',c.menuClass,':first'].join(''))[0];sf.op=sf.o[menu.serial];return menu},addArrow=function($a){$a.addClass(c.anchorClass).append($arrow.clone())};return this.each(function(){var s=this.serial=sf.o.length;var o=$.extend({},sf.defaults,op);o.$path=$('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){$(this).addClass([o.hoverClass,c.bcClass].join(' ')).filter('li:has(ul)').removeClass(o.pathClass)});sf.o[s]=sf.op=o;$('li:has(ul)',this)[($.fn.hoverIntent&&!o.disableHI)?'hoverIntent':'hover'](over,out).each(function(){if(o.autoArrows)addArrow($('>a:first-child',this))}).not('.'+c.bcClass).hideSuperfishUl();var $a=$('a',this);$a.each(function(i){var $li=$a.eq(i).parents('li');$a.eq(i).focus(function(){over.call($li)}).blur(function(){out.call($li)})});o.onInit.call(this)}).each(function(){var menuClasses=[c.menuClass];if(sf.op.dropShadows&&!($.browser.msie&&$.browser.version<7))menuClasses.push(c.shadowClass);$(this).addClass(menuClasses.join(' '))})};var sf=$.fn.superfish;sf.o=[];sf.op={};sf.IE7fix=function(){var o=sf.op;if($.browser.msie&&$.browser.version>6&&o.dropShadows&&o.animation.opacity!=undefined)this.toggleClass(sf.c.shadowClass+'-off')};sf.c={bcClass:'sf-breadcrumb',menuClass:'sf-js-enabled',anchorClass:'sf-with-ul',arrowClass:'sf-sub-indicator',shadowClass:'sf-shadow'};sf.defaults={hoverClass:'sfHover',pathClass:'overideThisToUse',pathLevels:1,delay:800,animation:{opacity:'show'},speed:'normal',autoArrows:true,dropShadows:true,disableHI:false,onInit:function(){},onBeforeShow:function(){},onShow:function(){},onHide:function(){}};$.fn.extend({hideSuperfishUl:function(){var o=sf.op,not=(o.retainPath===true)?o.$path:'';o.retainPath=false;var $ul=$(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass).find('>ul').hide().css('visibility','hidden');o.onHide.call($ul);return this},showSuperfishUl:function(){var o=sf.op,sh=sf.c.shadowClass+'-off',$ul=this.addClass(o.hoverClass).find('>ul:hidden').css('visibility','visible');sf.IE7fix.call($ul);o.onBeforeShow.call($ul);$ul.animate(o.animation,o.speed,function(){sf.IE7fix.call($ul);o.onShow.call($ul)});return this}})})(jQuery);


/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);


// Custom Innerfade implementation
(function($){$.fn.innerfade=function(options){var elements;var current_slide;var next_slide;return this.each(function(){$.innerfade(this,options)})};$.innerfade=function(container,options){var settings={'animationtype':'fade','speed':'normal','type':'sequence','timeout':2000,'containerheight':'auto','runningclass':'innerfade','slide_timer_on':'no','timer':null,'children':null};$.innerfade.setOptionsButtonEvent(settings);if(options)$.extend(settings,options);if(settings.children===null)var elements=$(container).children();else var elements=$(container).children(settings.children);if(elements.length>1){$(container).css('position','relative').css('height',settings.containerheight).addClass(settings.runningclass);for(var i=0;i<elements.length;i++){$(elements[i]).css('z-index',String(elements.length-i)).css('position','absolute').hide()};if(settings.type=="sequence"){setTimeout(function(){$.innerfade.next(elements,settings,1,0)},settings.timeout);$(elements[0]).show()}else if(settings.type=="random"){var last=Math.floor(Math.random()*(elements.length));setTimeout(function(){do{current=Math.floor(Math.random()*(elements.length))}while(last==current);$.innerfade.next(elements,settings,current,last)},settings.timeout);$(elements[last]).show()}else if(settings.type=='random_start'){settings.type='sequence';var current=Math.floor(Math.random()*(elements.length));$.innerfade.next(elements,settings,(current+1)%elements.length,current);$(elements[current]).show()}else{alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'')}}};$.innerfade.setOptionsButtonEvent=function(settings){$(".rotateCount li").each(function(){$(this).click(function(){button_id=$(this).attr("class");split_button_id_string=button_id.split("_");button_id_string=split_button_id_string.pop();current_slide=parseFloat(button_id_string);settings.slide_timer_on='no';$.innerfade.skip(settings,current_slide)})})};$.innerfade.skip=function(settings,current_slide){var elements=$('.rotateWrapper').children();for(var i=0;i<elements.length;i++){if(settings.animationtype=='fade'){$(elements[i]).fadeOut(0)}}if(settings.animationtype=='fade'){var temp_name="#rotate_"+current_slide;$(temp_name).fadeIn(0,function(){removeFilter($(this)[0])})}current=current_slide;if(current==0){last=4}else{last=current_slide-1}var timer='off';$.innerfade.next(elements,settings,current_slide,last,timer)};$.innerfade.next=function(elements,settings,current,last,timer){clearTimeout(settings.timer);if(timer=='on'){settings.slide_timer_on='yes'}if(settings.slide_timer_on=='yes'){if(settings.animationtype=='slide'){$(elements[last]).slideUp(settings.speed);$(elements[current]).slideDown(settings.speed)}else if(settings.animationtype=='fade'){for(var i=0;i<elements.length;i++){if(settings.animationtype=='fade'){$(elements[i]).fadeOut(settings.speed)}}$(elements[current]).fadeIn(settings.speed,function(){removeFilter($(this)[0])})}else alert('Innerfade-animationtype must either be \'slide\' or \'fade\'');if(settings.type=="sequence"){if((current+1)<5){current=current+1;last=current-1}else{current=0;last=4}}else if(settings.type=="random"){last=current;while(current==last)current=Math.floor(Math.random()*elements.length)}else alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');settings.timer=setTimeout((function(){$.innerfade.next(elements,settings,current,last)}),settings.timeout)}else{clearTimeout(settings.timer);settings.timer=setTimeout((function(){var timer="on";$.innerfade.next(elements,settings,current,last,timer)}),settings.timeout)}}})(jQuery);function removeFilter(element){if(element.style.removeAttribute){element.style.removeAttribute('filter')}}


/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);

/**
* jQuery.smoothDivScroll - Smooth div scrolling using jQuery.
* This plugin is for turning a set of HTML elements's into a smooth scrolling area.
*
* Copyright (c) 2009 Thomas Kahn - thomas.kahn(at)karnhuset(dot)net
*
* This plugin is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This plugin is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details. <http://www.gnu.org/licenses/>.
*
* Date: 2009-04-20
* @author Thomas Kahn
* @version 0.8
*/

(function($){jQuery.fn.smoothDivScroll=function(options){var defaults={scrollingHotSpotLeft:"div.scrollingHotSpotLeft",scrollingHotSpotRight:"div.scrollingHotSpotRight",scrollWrapper:"div.scrollWrapper",scrollableArea:"div.scrollableArea",hiddenOnStart:false,ajaxContentURL:"",countOnlyClass:"",scrollingSpeed:25,mouseDownSpeedBooster:3,autoScroll:"",autoScrollDirection:"right",autoScrollSpeed:1,pauseAutoScroll:"",visibleHotSpots:"",hotSpotsVisibleTime:5,startAtElementId:""};options=$.extend(defaults,options);return this.each(function(){var $mom=$(this);if(options.ajaxContentURL.length!==0){$mom.scrollableAreaWidth=0;$mom.find(options.scrollableArea).load((options.ajaxContentURL),function(){$mom.find(options.scrollableArea).children((options.countOnlyClass)).each(function(){$mom.scrollableAreaWidth=$mom.scrollableAreaWidth+$(this).outerWidth(true)});$mom.find(options.scrollableArea).css("width",($mom.scrollableAreaWidth+"px"));if(options.hiddenOnStart){$mom.hide()}windowIsResized();setHotSpotHeightForIE()})}var scrollXpos;var booster;var motherElementOffset=$mom.offset().left;var hotSpotWidth=0;booster=1;var hasExtended=false;$(window).one("load",function(){if(options.ajaxContentURL.length===0){$mom.scrollableAreaWidth=0;$mom.tempStartingPosition=0;$mom.find(options.scrollableArea).children((options.countOnlyClass)).each(function(){if((options.startAtElementId.length!==0)&&(($(this).attr("id"))==options.startAtElementId)){$mom.tempStartingPosition=$mom.scrollableAreaWidth}$mom.scrollableAreaWidth=$mom.scrollableAreaWidth+$(this).outerWidth(true)});$mom.find(options.scrollableArea).css("width",$mom.scrollableAreaWidth+"px");if(options.hiddenOnStart){$mom.hide()}}$mom.find(options.scrollWrapper).scrollLeft(300);if(options.autoScroll!==""){autoScrollInterval=setInterval(autoScroll,6)}if(options.autoScroll=="always"){hideLeftHotSpot();hideRightHotSpot()}switch(options.visibleHotSpots){case"always":makeHotSpotBackgroundsVisible();break;case"onstart":makeHotSpotBackgroundsVisible();hideHotSpotBackgroundsInterval=setInterval(hideHotSpotBackgrounds,(options.hotSpotsVisibleTime*1000));break;default:break}});$mom.find(options.scrollingHotSpotRight,options.scrollingHotSpotLeft).one('mouseover',function(){if(options.autoScroll=="onstart"){clearInterval(autoScrollInterval)}});$(window).bind("resize",function(){windowIsResized()});function windowIsResized(){if(!(options.hiddenOnStart)){$mom.scrollableAreaWidth=0;$mom.find(options.scrollableArea).children((options.countOnlyClass)).each(function(){$mom.scrollableAreaWidth=$mom.scrollableAreaWidth+$(this).outerWidth(true)});$mom.find(options.scrollableArea).css("width",$mom.scrollableAreaWidth+'px')}$mom.find(options.scrollWrapper).scrollLeft("0");var bodyWidth=$("body").innerWidth();if(options.autoScroll!=="always"){if($mom.scrollableAreaWidth<bodyWidth){}else{showHideHotSpots()}}}function hideLeftHotSpot(){$mom.find(options.scrollingHotSpotLeft).hide()}function hideRightHotSpot(){$mom.find(options.scrollingHotSpotRight).hide()}function showLeftHotSpot(){$mom.find(options.scrollingHotSpotLeft).show();if(hotSpotWidth<=0){hotSpotWidth=$mom.find(options.scrollingHotSpotLeft).width()}}function showRightHotSpot(){$mom.find(options.scrollingHotSpotRight).show();if(hotSpotWidth<=0){hotSpotWidth=$mom.find(options.scrollingHotSpotRight).width()}}function setHotSpotHeightForIE(){jQuery.each(jQuery.browser,function(i,val){if(i=="msie"&&jQuery.browser.version.substr(0,1)=="6"){$mom.find(options.scrollingHotSpotLeft).css("height",($mom.find(options.scrollableArea).innerHeight()));$mom.find(options.scrollingHotSpotRight).css("height",($mom.find(options.scrollableArea).innerHeight()))}})}$mom.find(options.scrollingHotSpotRight).bind('mousemove',function(e){var x=e.pageX-(this.offsetLeft+motherElementOffset);scrollXpos=Math.round((x/hotSpotWidth)*options.scrollingSpeed);if(scrollXpos===Infinity){scrollXpos=0}});$mom.find(options.scrollingHotSpotRight).bind('mouseover',function(){if(options.autoScroll=="onstart"){clearInterval(autoScrollInterval)}rightScrollInterval=setInterval(doScrollRight,6)});$mom.find(options.scrollingHotSpotRight).bind('mouseout',function(){clearInterval(rightScrollInterval);scrollXpos=0});$mom.find(options.scrollingHotSpotRight).bind('mousedown',function(){booster=options.mouseDownSpeedBooster});$("*").bind('mouseup',function(){booster=1});var doScrollRight=function(){if(scrollXpos>0){$mom.find(options.scrollWrapper).scrollLeft($mom.find(options.scrollWrapper).scrollLeft()+(scrollXpos*booster))}showHideHotSpots()};if(options.pauseAutoScroll=="mousedown"&&options.autoScroll=="always"){$mom.find(options.scrollWrapper).bind('mousedown',function(){clearInterval(autoScrollInterval)});$mom.find(options.scrollWrapper).bind('mouseup',function(){autoScrollInterval=setInterval(autoScroll,6)})}else if(options.pauseAutoScroll=="mouseover"&&options.autoScroll=="always"){$mom.find(options.scrollWrapper).bind('mouseover',function(){clearInterval(autoScrollInterval)});$mom.find(options.scrollWrapper).bind('mouseout',function(){autoScrollInterval=setInterval(autoScroll,6)})}var previousScrollLeft=0;var pingPongDirection="right";var hasChanged=false;var swapAt;var autoScroll=function(){if(options.autoScroll=="onstart"){showHideHotSpots()}switch(options.autoScrollDirection){case"right":$mom.find(options.scrollWrapper).scrollLeft($mom.find(options.scrollWrapper).scrollLeft()+options.autoScrollSpeed);break;case"left":$mom.find(options.scrollWrapper).scrollLeft($mom.find(options.scrollWrapper).scrollLeft()-options.autoScrollSpeed);break;case"backandforth":previousScrollLeft=$mom.find(options.scrollWrapper).scrollLeft();if(pingPongDirection=="right"){$mom.find(options.scrollWrapper).scrollLeft($mom.find(options.scrollWrapper).scrollLeft()+options.autoScrollSpeed)}else{$mom.find(options.scrollWrapper).scrollLeft($mom.find(options.scrollWrapper).scrollLeft()-options.autoScrollSpeed)}if(previousScrollLeft===$mom.find(options.scrollWrapper).scrollLeft()){if(pingPongDirection=="right"){pingPongDirection="left"}else{pingPongDirection="right"}}break;case"endlessloop":previousScrollLeft=$mom.find(options.scrollWrapper).scrollLeft();if(!(hasChanged)){if(options.startAtElementId!==""){swapAt=$mom.find(options.scrollWrapper).scrollLeft()+$("#"+options.startAtElementId).outerWidth()}else{swapAt=$mom.find(options.scrollWrapper).scrollLeft()+$mom.find(options.scrollableArea).children(":first-child").outerWidth()}hasChanged=true}$mom.find(options.scrollWrapper).scrollLeft($mom.find(options.scrollWrapper).scrollLeft()+options.autoScrollSpeed);if((swapAt<=$mom.find(options.scrollWrapper).scrollLeft())||((options.startAtElementId!=="")&&(previousScrollLeft===$mom.find(options.scrollWrapper).scrollLeft()))){$mom.find(options.scrollableArea).append($mom.find(options.scrollableArea).children(":first-child").clone());$mom.find(options.scrollWrapper).scrollLeft(($mom.find(options.scrollWrapper).scrollLeft()-$mom.find(options.scrollableArea).children(":first-child").outerWidth()));$mom.find(options.scrollableArea).children(":first-child").remove();hasChanged=false}break;default:break}};$mom.find(options.scrollingHotSpotLeft).bind('mousemove',function(e){var x=$mom.find(options.scrollingHotSpotLeft).innerWidth()-(e.pageX-motherElementOffset);scrollXpos=Math.round((x/hotSpotWidth)*options.scrollingSpeed);if(scrollXpos===Infinity){scrollXpos=0}});$mom.find(options.scrollingHotSpotLeft).bind('mouseover',function(){if(options.autoScroll=="onstart"){clearInterval(autoScrollInterval)}leftScrollInterval=setInterval(doScrollLeft,6)});$mom.find(options.scrollingHotSpotLeft).bind('mouseout',function(){clearInterval(leftScrollInterval);scrollXpos=0});$mom.find(options.scrollingHotSpotLeft).bind('mousedown',function(){booster=options.mouseDownSpeedBooster});var doScrollLeft=function(){if(scrollXpos>0){$mom.find(options.scrollWrapper).scrollLeft($mom.find(options.scrollWrapper).scrollLeft()-(scrollXpos*booster))}showHideHotSpots()};function showHideHotSpots(){if($mom.find(options.scrollWrapper).scrollLeft()===0){showRightHotSpot()}else if(($mom.scrollableAreaWidth)<=($mom.find(options.scrollWrapper).innerWidth()+$mom.find(options.scrollWrapper).scrollLeft())){showLeftHotSpot()}else{showRightHotSpot();showLeftHotSpot()}}function makeHotSpotBackgroundsVisible(){$mom.find(options.scrollingHotSpotLeft).addClass("scrollingHotSpotLeftVisible");$mom.find(options.scrollingHotSpotRight).addClass("scrollingHotSpotRightVisible")}function hideHotSpotBackgrounds(){clearInterval(hideHotSpotBackgroundsInterval);$mom.find(options.scrollingHotSpotLeft).fadeTo("slow",0.0,function(){$mom.find(options.scrollingHotSpotLeft).removeClass("scrollingHotSpotLeftVisible")});$mom.find(options.scrollingHotSpotRight).fadeTo("slow",0.0,function(){$mom.find(options.scrollingHotSpotRight).removeClass("scrollingHotSpotRightVisible")})}})}})(jQuery);
