$(document).ready(function () {

	/* @Bio Toggle */
	/* ------------------------------ */
	
	$(".toggle-cont").each(function(){ 
        $(this).hide(); 
    }); 

	$("h2.toggle").click(function(){
		$(this).toggleClass("active").next().slideToggle("slow");
		return false;
	});

	/* @Index showcase */
	/* ------------------------------ */
	$('ul#showcase').cycle({
		fx: "fade",
		pause: 1,
		speed: 1200,
		 timeout: 5000, 
		prev: "#prev1",
		next: "#next1"
	});
	
	/* @Tweets */
	/* ------------------------------ */
	$('.tweet-entry').tweet({
		username: "smartsitting",
		avatar_size: 48,
		count: 2,
		template: "{text} {retweet_action}"
	});
	
	$("#select-sitter").idTabs(function(id,list,set){ 
		$("a",set).removeClass("current") 
		.filter("[href='"+id+"']",set).addClass("current"); 
		for(i in list) 
		  $(list[i]).hide(); 
		$(id).fadeIn(); 
		return false; 
	}); 
	
	var timers = new Array();
	$('#header .nav ul li.dropdown').each(function (i) {
		$(this).hover(
			function() {
				clearTimeout(timers[i*2]);
				clearTimeout(timers[i*2+1]);
				var elem = $(this);
				elem.addClass('mouseover');
				if (elem.find('.drop-cont').is(':visible')) return;
				timers[i*2] = setTimeout(function() {
					elem.find('.drop-cont').show();
				}, 0);
			},
			function() {
				clearTimeout(timers[i*2]);
				clearTimeout(timers[i*2+1]);
				var elem = $(this);
				elem.removeClass('mouseover');
				if (elem.find('.drop-cont').is(':hidden')) return;
				timers[i*2+1] = setTimeout(function() {
					elem.find('.drop-cont').fadeOut("slow");
				}, 20);
			}
		);
	});
	
	$('#logo').hover(function() {
		$('#header .reutrn-home').show();
	}, function() {
		$('#header .reutrn-home').fadeOut();
	});
	
	var timers2 = new Array();
	$('.sitter-thumb').each(function (i) {
		$(this).hover(
			function() {
				clearTimeout(timers2[i*2]);
				clearTimeout(timers2[i*2+1]);
				var elem = $(this);
				elem.addClass('mouseover');
				if (elem.find('.sitter-school').is(':visible')) return;
				timers2[i*2] = setTimeout(function() {
					elem.find('.sitter-school').fadeIn("slow");
				}, 0);
			},
			function() {
				clearTimeout(timers2[i*2]);
				clearTimeout(timers2[i*2+1]);
				var elem = $(this);
				elem.removeClass('mouseover');
				if (elem.find('.sitter-school').is(':hidden')) return;
				timers2[i*2+1] = setTimeout(function() {
					elem.find('.sitter-school').fadeOut("slow");
				}, 100);
			}
		);
	});
	
	$('.showcase_track').each(function(){
		$(this).click(function () {
			pageTracker._trackEvent('Showcase_No_Pause', 'Click', $(this).attr("href"));
			// _gaq.push(['Showcase_No_Pause', 'Click', $(this).attr('href')]);
		});
	});

});
