/* Author: 

*/


$(document).ready(function() {

//Cufon.replace('#showinfo h2', { fontFamily: 'Whitney' });

//Default Action
	$(".tab_content").hide(); //Hide all content
	
	
	//On Click Event
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		window.location.hash = activeTab;
		$(activeTab).fadeIn(); //Fade in the active content
		//alert('t');
		return false;
	});
	
	$(window).bind('hashchange', function () { //detect hash change
	var hash = window.location.hash.slice(1); //hash to string (= "myanchor")
	if(hash==""){
		hash="fresh";
	}
	if(hash!=""){
		$("ul.tabs li#"+hash+"_tab").trigger('click');
	}
	});

if(window.location.hash) {
var hash = window.location.hash.slice(1);
$("ul.tabs li#"+hash+"_tab").trigger('click');
}else{
	
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
}

$('#slideshow').cycle({ 
    fx:     'fade', 
    speed:  'slow', 
    timeout: 8000, 
    pager:  '#slidenav', 
     before: onBefore,
    pagerAnchorBuilder: function(idx, slide) { 
        // return selector string for existing anchor 
        return '#slidenav li:eq(' + idx + ')'; 
    } 

});


function onBefore() {
	//var si = $(this).parent('slideshow'); 
	var sindex = $("#slideshow img").index(this)+1;
	 $('.showinfo').hide();
  $('.info'+sindex).show();
   $('#slidenav li a').removeClass("on");
  $('#slidenav li a').eq(sindex-1).toggleClass("on");
		
}

function onAfter() {
	
		
}



});



$(function() { 	// this function changes the slide, clicked by the li
	$("#slidenav li").hover(
	function () {
		$('#slidenav li').removeClass("on");
		$(this).click();
	});
});


$(function() { 	
	$("#slidenav").hover(
	function () {
		$('#slideshow').cycle('pause');
	},
	function () {
		var sindex = $("#slideshow img").index(this);
		$('#slidenav li').eq(sindex).toggleClass("on");
		$('#slideshow').cycle('resume');
	}
	
	);
	
});

$(function() { 	// this function changes the slide, clicked by the li
	$("#slidenav li a").click(
	function () {
		window.location.href=$(this).attr('href');
	});
});


