/**
* 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);

/*
	jQuery Coda-Slider v1.1 - http://www.ndoherty.com/coda-slider
	
	Copyright (c) 2007 Niall Doherty
*/
jQuery(function(){jQuery("div.csw").prepend("<p class='loading'>Loading...<br /><img src='images/ajax-loader.gif' alt='loading...'/ ></p>")});
var j=0;
jQuery.fn.codaSlider=function(settings){
	settings=jQuery.extend({easeFunc:"expoinout",easeTime:750,toolTip:false},settings);
	return this.each(
		function(){
			var container=jQuery(this);
			container.find("p.loading").remove();
			container.removeClass("csw").addClass("stripViewer");
			var panelWidth=container.find("div.panel").width();
			var panelCount=container.find("div.panel").size();
			var stripViewerWidth=panelWidth*panelCount;
			container.find("div.panelContainer").css("width",stripViewerWidth);
			var navWidth=panelCount*2;
			if(location.hash&&parseInt(location.hash.slice(1))<=panelCount){
				var cPanel=parseInt(location.hash.slice(1));
				var cnt=-(panelWidth*(cPanel-1));
				jQuery(this).find("div.panelContainer").css({left:cnt})
			}else{
				var cPanel=1
			};
			container.each(
				function(i){
					jQuery(this).before("<div class='stripNavL' id='stripNavL"+j+"'><a href='#'>Left</a><\/div>");
					jQuery(this).after("<div class='stripNavR' id='stripNavR"+j+"'><a href='#'>Right</a><\/div>");
					jQuery(this).before("<div class='stripNav' id='stripNav"+j+"'><ul><\/ul><\/div>");
					jQuery(this).find("div.panel").each(
						function(n){
							jQuery("div#stripNav"+j+" ul").append("<li class='tab"+(n+1)+"' style='line-height:30px; vertical-align:middle;'><a href='"+jQuery(this).find("a").attr("href")+"' style='line-height:30px; vertical-align:middle;' title='"+jQuery(this).attr("title")+"'><img src='"+jQuery(this).find("img").attr("src")+"' width='28' height='28' alt="+jQuery(this).attr("title")+" style='float:left; margin: 7px 6px 0 -12px; ' \/><div style='margin-top:6px; font-size:11px'>"+jQuery(this).attr("title").substring(0,29)+"<\/div><\/a><\/li>")
						}
					);
					jQuery("div#stripNav"+j+" a").each(
						function(z){
							navWidth+=jQuery(this).parent().width();
							jQuery(this).bind("click",function(){
								window.location(jQuery(this).find("a").attr("href"));
							});
							
							jQuery(this).bind("mouseover",function(){
								jQuery(this).addClass("current").parent().parent().find("a").not(jQuery(this)).removeClass("current");
								var cnt=-(panelWidth*z);
								cPanel=z+1;
								jQuery(this).parent().parent().parent().next().find("div.panelContainer").css("left", cnt+"px");
							});
						}
						/* hoverdelay
						function(z){
							navWidth+=jQuery(this).parent().width();
							jQuery(this).bind("click",function(){
								window.location(jQuery(this).find("a").attr("href"));
							});
							
							
					
							var hoverslide = function(){
								jQuery(this).addClass("current").parent().parent().find("a").not(jQuery(this)).removeClass("current");
								var cnt=-(panelWidth*z);
								cPanel=z+1;
								jQuery(this).parent().parent().parent().next().find("div.panelContainer").css("left", cnt+"px");
							};
							
							var hoverout = function(){
								return false;
							};
							
							jQuery(this).hoverIntent( hoverslide, hoverout );
							
							//jQuery(this).bind("mouseover",hoverslide);
							
						}
						*/
					);
					
					
					jQuery("div#stripNavL"+j+" a").click(
						function(){
						if(cPanel==1){
						var cnt=-(panelWidth*(panelCount-1));
						cPanel=panelCount;
						jQuery(this).parent().parent().find("div.stripNav a.current").removeClass("current").parent().parent().find("li:last a").addClass("current")
						}else{
						cPanel-=1;
						var cnt=-(panelWidth*(cPanel-1));
						jQuery(this).parent().parent().find("div.stripNav a.current").removeClass("current").parent().prev().find("a").addClass("current")
						};
						jQuery(this).parent().parent().find("div.panelContainer").animate({left:cnt},settings.easeTime,settings.easeFunc);
						location.hash=cPanel;
						return false
						}
					);
					jQuery("div#stripNavR"+j+" a").click(
					function(){
						if(cPanel==panelCount){
							var cnt=0;
							cPanel=1;
							jQuery(this).parent().parent().find("div.stripNav a.current").removeClass("current").parent().parent().find("a:eq(0)").addClass("current")
						}else{
							var cnt=-(panelWidth*cPanel);
							cPanel+=1;
							jQuery(this).parent().parent().find("div.stripNav a.current").removeClass("current").parent().next().find("a").addClass("current")
						};
						jQuery(this).parent().parent().find("div.panelContainer").animate({left:cnt},settings.easeTime,settings.easeFunc);
						location.hash=cPanel;
						return false
					}
					);
					jQuery("a.cross-link").click(
						function(){
							jQuery(this).parents().find(".stripNav ul li a:eq("+(parseInt(jQuery(this).attr("href").slice(1))-1)+")").trigger('click');
						}
					);
					jQuery("div#stripNav"+j).css("width",navWidth);
					if(location.hash&&parseInt(location.hash.slice(1))<=panelCount){
						jQuery("div#stripNav"+j+" a:eq("+(location.hash.slice(1)-1)+")").addClass("current")
					}else{
						jQuery("div#stripNav"+j+" a:eq(0)").addClass("current")
					}
				}
			);
			j++
		}
	)
};


		var theInt = null;
		var $crosslink, $navthumb;
		var curclicked = 0;
		var interval = 5000;
		var total = 6;
		
		theInterval = function(cur){
			clearInterval(theInt);
			
			if( typeof cur != 'undefined' )
				curclicked = cur;
			
			$crosslink.removeClass("active-thumb");
			$navthumb.eq(curclicked).parent().addClass("active-thumb");
			//$(".stripNav ul li a").eq(curclicked).trigger('mouseover');
			
			theInt = setInterval(function(){
				$crosslink.removeClass("active-thumb");
				$navthumb.eq(curclicked).parent().addClass("active-thumb");
				$(".stripNav ul li a").eq(curclicked).trigger('mouseover');
				curclicked++;
				if( total == curclicked )
					curclicked = 0;
				
			}, interval);
		};
		
		
		
		
		$(function(){
		
		
			
			$("#main-photo-slider").codaSlider();
			
			$tab1 = $(".tab1");
			$tab2 = $(".tab2");
			$tab3 = $(".tab3");
			$tab4 = $(".tab4");
			$tab5 = $(".tab5");
			$tab6 = $(".tab6");
			$tab1.mouseover(function() {
				curclicked = 1;
				clearInterval(theInt); 
				return false;
			});
			$tab2.mouseover(function() {
				curclicked = 2;
				clearInterval(theInt); 
				return false;
			});
			$tab3.mouseover(function() {
				curclicked = 3;
				clearInterval(theInt); 
				return false;
			});
			$tab4.mouseover(function() {
				curclicked = 4;
				clearInterval(theInt); 
				return false;
			});
			$tab5.mouseover(function() {
				curclicked = 5;
				clearInterval(theInt); 
				return false;
			});
			$tab6.mouseover(function() {
				curclicked = 0;
				clearInterval(theInt); 
				return false;
			});
			$tab1.mouseout(function() {
				theInterval();
			});
			$tab2.mouseout(function() {
				theInterval();
			});
			$tab3.mouseout(function() {
				theInterval();
			});
			$tab4.mouseout(function() {
				theInterval();
			});
			$tab5.mouseout(function() {
				theInterval();
			});
			$tab6.mouseout(function() {
				theInterval();
			});
			
			$navthumb = $(".nav-thumb");
			$crosslink = $(".cross-link");
			theInterval();
			
		});
