// JavaScript Document
$(function(){
	var lineNum=6;
	var $stage=$("#logos");
	var $screen=$("#screen");
	var $showall_btn=$("#showall");
	var sh=$("#logos").height();
	var timerID=setInterval(slideNext,6000);
	crossFade();
	$showall_btn.each(function(){$("<img>").attr("src",$(this).attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_back$2"));})
		.css("cursor","pointer")
		.mouseover(function(){
			$(this).animate({bottom: 0},"fast");
		}).mouseout(function(){
		   $(this).animate({bottom: -5},"fast");
		}).bind("click",showAll);
	function slideNext(){
		$showall_btn.unbind("click",showAll);
		var $logos=$("#logos li");
		$stage.animate({marginTop:-120},
			"slow","swing",
				function(){
					$logos.slice(0,lineNum).appendTo($stage);
					$stage.css({marginTop:"0"});
					$showall_btn.bind("click",showAll);
				})
		
	}
	function showAll(){
		clearInterval(timerID);
		$(this).unbind("click",showAll);
		$screen.animate({height:sh},
			"slow","swing",
				function(){
					$showall_btn.bind("click",closeScreen);
					$showall_btn.attr("src",$showall_btn.attr("src").replace(/^(.+)(\.[a-z]+)$/, "$1_back$2"));
		})
	}
	function closeScreen(){
		timerID=setInterval(slideNext,4000);
		$(this).unbind("click",closeScreen);
		$screen.animate({height:120},
			"slow","swing",
				function(){
					$showall_btn.bind("click",showAll);
					$showall_btn.attr("src",$showall_btn.attr("src").replace(/^(.+)_back(\.[a-z]+)$/, "$1$2"));

		})
	}
	//splash
	var images=$("#splash li");
	var screenTimer=setInterval(crossFade,6000);
	function crossFade(){
		var $images=$("#splash ul");
		var $item=$("#splash li:first");
		$item.hide();
		$item.appendTo($images)
			.fadeIn(2000,function(){
				$(this).show();	
			})
	}
	//fancy.js
	$(".fancybox").fancybox();
	
})
