
window.onload = afterLoad;
function afterLoad() {
document.getElementById('slide').style.display = "block";
};	


$('#slide').cycle({ 
    fx:      'fade', 
    speed:    1000, 
    timeout:  6000
}); 
 
 
 $(document).ready(function(){
	h = $("#site").height();
	//alert(h)
	$('.shadow').css('height', h);
	var 
	$imgsBox, $popupBox;
	$popupBox=$(".popupBox");
	$imgsBox=$(".photogalleryBox");
	$("img", $imgsBox).click(function(){
		$(".popupBox").fadeIn("normal");
		$(".shadow").fadeIn("normal");
		$this=$(this);
		params=$this.attr("name");
		location.hash='#'+params[0];
		$("img.active", $imgsBox).removeClass("active");
		$this.addClass("active");
		$("#img").attr("src", "images/temp/temp"+params[0]+"_1.jpg");
		$(".pointL1", $popupBox).fadeTo("fast", ($this.parent().prev().length?1:0.2));
		$(".pointR1", $popupBox).fadeTo("fast", ($this.parent().next().length?1:0.2));
		return false;										
	});
	$(".pointL1", $popupBox).click(function(){
		obj=$("img.active",$imgsBox).parent().prev();
		if(obj.length)
			$("img:first", obj).click();
		return false;										  
	});
	$(".pointR1", $popupBox).click(function(){
		obj=$("img.active",$imgsBox).parent().next();
		if(obj.length)
			$("img:first", obj).click();
		return false;										  
	});
	$(".shadow").click(function(){
		$(this).fadeOut("normal");
		$(".popupBox").fadeOut("normal");
	});
	$(".close").click(function(){
		$(".shadow").fadeOut("normal");
		$(".popupBox").fadeOut("normal");
		return false;
	});
	$("a",".descriptionList").click(function(){		
  		$("li.active",".descriptionList").removeClass("active");
		$(this).parents("li:first").addClass("active");
		i=$("a",".descriptionList").index(this);
		$(".item.active",".description").removeClass("active");
  		$(".item:eq("+i+")",".description").addClass("active");
		$(".item").hide();
		$(".item.active").show();
		location.hash=$(this).attr("href");
	});
	animation = setTimeout(galAnim, 5000);
	var animation=null;
	function galAnim(){
		clearTimeout(animation);
		var obj=$(".item.active", ".description");
		var obj1=$(".item.active", ".description").next();
		var obj2=$(".item.active", ".description").prev().prev().prev().prev().prev();
		var index=$(".item.active", ".description").index()+1;
		if(index==6){
			obj.fadeOut("normal", function(){
			$("li.active", ".descriptionList").prev().prev().prev().prev().prev().addClass("active");
			$("li.active", ".descriptionList").next().next().next().next().next().removeClass("active");
			obj.removeClass("active");
			obj2.fadeIn("normal", function(){
				obj2.addClass("active");
				animation = setTimeout(galAnim, 5000);
			});
		});
		}else{
			obj.fadeOut("normal", function(){
				$("li.active", ".descriptionList").next().addClass("active");
				$("li.active", ".descriptionList").prev().removeClass("active");
				obj.removeClass("active");
				obj1.fadeIn("normal",function(){
					obj1.addClass("active");
					animation = setTimeout(galAnim, 5000);
				});
			});
		}
	}
});

