$(document).ready(function(){

//Larger thumbnail preview 

$("ul.thumb li").hover(function() {
	$(this).css({'z-index' : '10'});
	$(this).find('img').addClass("hover").stop()
		.animate({
			marginTop: '-140px', 
			marginLeft: '-160px', 
			top: '50%', 
			left: '50%', 
			width: '274px',   //174 
			height: '241px',  //174
			padding: '20px' 
		}, 200);
	
	} , function() {
	$(this).css({'z-index' : '0'});
	$(this).find('img').removeClass("hover").stop()
		.animate({
			marginTop: '0', 
			marginLeft: '0',
			top: '0', 
			left: '0', 
			width: '200px', 
			height: '160px', 
			padding: '5px'
		}, 400);
});

var clicked = false;
var showed_index = 2;

var fshow = function(c_show) {
   $(".l1,.l2,.l3,.l4,.l5,.l6,.l7").hide();
   $("#hrefs a").removeClass("active");
   $("." + c_show).fadeIn();
   $("#hrefs #" + c_show).addClass("active");
} 

$("#l1").click(function() { fshow('l1'); clicked = true; return false; });
$("#l2").click(function() { fshow('l2'); clicked = true; return false; });   
$("#l3").click(function() { fshow('l3'); clicked = true; return false; });
$("#l4").click(function() { fshow('l4'); clicked = true; return false; });
$("#l5").click(function() { fshow('l5'); clicked = true; return false; });

function timing() {
   if(!clicked) {
      setTimeout(function() {
         fshow("l" + showed_index);
         showed_index == 5 ? showed_index = 1 : showed_index++;
         if(showed_index == 2) clicked = true;
         timing();
                     
      }, 6 * 1000);
   }
}

timing();



$("ul.thumb li:not(#hrefs) a").facebox();
$("ul.thumb li:not(#hrefs) a").click(function() { clicked = true; });
/*
	$("ul.thumb li a").click(function() {
		
		var mainImage = $(this).attr("href"); //Find Image Name
		$("#main_view img").attr({ src: mainImage });
		return false;		
	});
*/ 
});
