$(document).ready(function() {
	$('.fedimg').cycle({
		fx: 'fade',
		speed: 2000,
		timeout: 2000
	});
	$("#specialized a h2").tooltip({
	// tweak the position
   		offset: [30, 2],
   // use the "slide" effect
   		effect: 'slide',
   		position: "top left"});
	
	var $trigger = $('.zitem a.plink');
	$('.zitem a.plink').click(function(){
		$trigger = $(this);
	});
	$trigger.fancybox({
		'overlayShow'	: true,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'titleShow'		:	true,
		'titlePosition'	:	'over',
		'onComplete'	:	function() {
				
		
			// alert($trigger.siblings('.boxcaption').children(".pi_caption").height());			
		
//		alert($trigger.siblings('.boxcaption').children(".pi_caption").text());			
//			alert($trigger.siblings('.boxcaption').children(".pi_caption").text());
		
			$("#fancybox-wrap").hover(function() {
				// $("#fancybox-title").html($trigger.siblings('.boxcaption').children(".pi_caption").html());	
			
				$("#fancybox-title").fadeIn('slow');
			}, function() {
				$("#fancybox-title").fadeOut('slow');
			});
		}

	});
/*
	$('.zitem').hover(function(){
					$(".cover", this).stop().animate({top:'75px'},{queue:false,duration:160});
				}, function() {
					$(".cover", this).stop().animate({top:'99px'},{queue:false,duration:160});
				});
*/
	$('#slider').before('<div id="navi">').cycle({ 
		fx:     'scrollLeft', 
		delay:  0,
		timeout: 9000, 
		pager:  '#navi' ,
		easing: 'easeInQuart'
	});
	//move the image in pixel
	var move = -15;
	
	//zoom percentage, 1.2 =120%
	var zoom = 1.2;

	//On mouse over those thumbnail
	$('.zitem0000').hover(function() {
		
		//Set the width and height according to the zoom percentage
		width = $('.zitem').width() * zoom;
		height = $('.zitem').height() * zoom;
		
		//Move and zoom the image
		$(this).find('img').stop(false,true).animate({'width':width, 'height':height, 'top':move, 'left':move}, {duration:200});
		
		//Display the caption
		$(this).find('div.caption').stop(false,true).fadeIn(200);
	},
	function() {
		//Reset the image
		$(this).find('img').stop(false,true).animate({'width':$('.zitem').width(), 'height':$('.zitem').height(), 'top':'0', 'left':'0'}, {duration:100});	

		//Hide the caption
		$(this).find('div.caption').stop(false,true).fadeOut(200);
	});
	
});
