// JavaScript Document
$(function(){
	$('#product_menu > li').children().hide();
	$('#product_menu > li').hover(function() {
			$(this).children().fadeIn(200).
			$(this).children().hover(function(){
					$(this).children().show();  
				});
			$(this).removeClass('normal');
			$(this).addClass('hover');
		},function(){
			$(this).removeClass('hover');
			$(this).addClass('normal');
			$(this).children().fadeOut(100);
	});
	
// 自動掀角的秒數
	var speed = 2000;
	// 計時器
	var timer;
	// 幫 #ad 加上 hover() 事件
	$("#conerad").hover(function(){	// 當滑鼠移進時..
		// 停止計時器
		clearTimeout(timer);
		// 先停止未完成的動畫後再進行新的動畫
		// 圖片放大展示
		$("a img, a .adBody", this).stop().animate({
				width: 530,
				height: 315
			}, 500);
	}, function(){	// 當滑鼠移出時..
		// 先停止未完成的動畫後再進行新的動畫
		// 圖片恢復原狀
		$("a img, a .adBody", this).stop().animate({
				width: 0,
				height: 0
			}, 200);
		// 移除 #ad 的 hover() 事件
		//$(this).unbind("hover");
		timer = setTimeout(fish, speed);	
	});
	function fish(){
		// 判斷目前是否顯示
		var _valuew = $("#conerad a img").width()>0 ? 0 : 75;
		var _valueh = $("#conerad a img").height()>0 ? 0 : 55;
		// 進行圖片的顯示/隱藏變化
		$("#conerad a img, #conerad a .adBody").animate({
			width: _valuew,
			height: _valueh
		}, 500);
		// 啟動計時器
		timer = setTimeout(fish, speed);
	}
	// 啟動計時器
	timer = setTimeout(fish, speed);		
	
	
});
