// JavaScript Document
$(document).ready(function(){
	$('#advertisement').css({backgroundPosition: "0 -100px"}).stop().animate({backgroundPosition: "(0 -102000px)"},6000000, "linear");
	$('#advertisement1').css({backgroundPosition: "0 -250px"}).stop().animate({backgroundPosition: "(0 -302500px)"},6000000, "linear");
});

//左菜单垂直对齐
$(document).ready( function() { 
	var a = $("#mainContent").height(); 
	$("#advertisement").height(a-140);
	$("#advertisement1").height(a-140);
}); 

//Showcase特效
$(document).ready(function(){
	$.fn.wait = function(time, type) {
        time = time || 5000;
        type = type || "fx";
        return this.queue(type, function() {
            var self = this;
            setTimeout(function() {
                $(self).dequeue();
            }, time);
        });
    };
		var t1,t2;
		var openwin=0;
		var finished=true;
		$('#showcase .product')
		.hover(function(){
			openwin=openwin+1;
			var currentwin=$(this).index();
			t1 = setTimeout(function() {
				 if (!finished) {
					 $('#showcase .product').not($('#showcase .product').eq(currentwin)).animate({width: 25},1000);
					 finished=true;
				 };
				 $('#showcase .product').eq(currentwin).animate({width: 355},1000);
			}, 200);
		}, function(){
			clearTimeout(t1);
			openwin=openwin-1;
			finished=false;
			var closewin=$(this).index();
			t2 = setTimeout(function() {
				if (openwin==0) {
			 		t = setTimeout(function() {
					 	$('#showcase .product').eq(closewin).animate({width: 25},1000);
						finished=true;
		            }, 5000);
				} else {
					$('#showcase .product').eq(closewin).animate({width: 25},1000);
					finished=true;
				}
			},200);
		})
});


