$(document).ready(function(){
	var config = {    
	     sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
	     interval: 100, // number = milliseconds for onMouseOver polling interval    
	     over: menuOn, // function = onMouseOver callback (REQUIRED)    
	     timeout: 300, // number = milliseconds delay before onMouseOut    
	     out: menuOff // function = onMouseOut callback (REQUIRED)    
	};
	
	$("#main_nav li").hoverIntent(config);
	
	$('#main_nav li:first').attr('id','first');
	$('#main_nav li:last').attr('id','last');
	
	// var navCount = $('ul.main > li').length;
	// 	if(navCount >= 7){
	// 		$('#main_nav img.nav-bottom').css('bottom','2px');
	// 	}
	// 	else{
	// 		$('#main_nav img.nav-bottom').css('bottom','0px');
	// 	}
	Cufon.replace('#home_welcome h1'); 
	Cufon.replace('#home_welcome p');
	Cufon.replace('#content h1.page-title');
	Cufon.replace('div.dog div.name');
	
	$('div.image').cycle({ 
	    fx:     'fade', 
	    prev:   '#prev', 
	    next:   '#next', 
	    timeout: 0 ,
		'containerResize': false,
		before: onBefore
	});
	function onBefore(currElement, nextElement){
		$('#image_title').html(this.title);
		var totalImages = $('div.image img').length;
		$("#current_image").html(nextElement.id.replace("image_", '') + '/' + totalImages);
	}
	$('#gallery').cycle({ 
		    fx:     'fade',
			speed: 2000,
		    timeout: 3000 ,
			'containerResize': false,
			before: onBeforeGal
		});
		function onBeforeGal(){
			$('#image_title').html(this.title);

		}
		$('#puppies_gallery').cycle({ 
			    fx:     'fade',
				speed: 2000,
			    timeout: 3000 ,
				'containerResize': false,
				before: onBeforePup
			});
			function onBeforePup(currElement, nextElement){
				$('#image_title').html(this.title);
				var totalImages = $('div.images img').length;
				$("#current_image").html(nextElement.id.replace("image_", '') + '/' + totalImages);
			}
	$('a.trigger',this).click(function(){
		if($(this).next('div.footer-content').is(':visible')){
			return false;
		}
		else{
			$('div.footer-content').hide();
			$(this).next('div.footer-content',this).fadeIn(500);
			$(this).children('span.close').show().removeClass('closed').addClass('open');
		}
			return false;
	})

	$('span.close').click(function(){
			$('span.close').removeClass('open').addClass('closed').parent('div.footer-content').fadeOut(400);
			return false;
	});
	$('div.week-info').jScrollPane();
	$('#timeline_description').jScrollPane();
	$('#detail_desc').jScrollPane();
});
//menu hover functions
function menuOn(){  $(this).find('div.sub-nav-box').show(400);}
function menuOff(){ $(this).find('div.sub-nav-box').hide(400);}
