// JavaScript Document
//監聽=======
$(document).ready(function() {
						   
	//置換各flash
	setTitle();
	setBack();
	setIndexShow("c");
	setLogo();	
	setlimpid_X_Flash();
	
	//設定work All
	setWorkAllWidth(".workAll",143);
	
	//設定常數
	setBroser();
	setStillV(ScaleSide);
	
	
	//計算頁面上各個的位置
	header_and_footer();
	
	//改變視窗大小時，相關的設定...
	$(window).bind("resize",header_and_footer);
		
	//menu
	menusetup();
	
	// footer 的展開與收縮
	$("#footer .tag").toggle(
		function () {
			footer_move(true);
		},
		function () {
			footer_move(false);
		}
	);
	
	//footer slideshow 設定每3秒有slideshow的效果
	if($(".hot_news ul li").length>(Math.floor(($(".hot_news").width()+1)/420))){
		var setIntervalA = setInterval("newsSlideshow()", 8000);
		$(".hot_news ul li a").bind("mouseover",function(){clearInterval(setIntervalA);});
		$(".hot_news ul li a").bind("mouseout",function(){setIntervalA=setInterval("newsSlideshow()", 8000);});
	}
	
	//ajax監聽(loading圖)
	$("#loadingImg").bind("ajaxSend", function(){
	  $(this).show();
	  $("#loadingImg").css("width",$(".newslist ul").css("width")); //設定loading畫面的寬
	}).bind("ajaxComplete", function(){
	  $(this).hide();
	});
	
	//ajax==========================================
	newslistAjax(0);
	
});
/*var t1 = new Sequence();
var t2 = new Sequence();*/

function setWorkAllWidth(targetParent,oneWidth){
	var target = $(targetParent).children();	
	var totalWidth =0;
	var add = (target.length%4>0)?1:0;
	var line = Math.floor(target.length/4)+add;	
	$(targetParent).css("width",line*oneWidth+20+"px");	
	
	for(var i=0;i<target.length;i++){
		target[i].id = "work_"+i;
		//t1.addChild(new OpacityTween(target[i],Tween.regularEaseOut,0,100,0.2));
		//t2.addChild(new Tween(target[i].style,'marginTop',Tween.backEaseOut,5,0,0.2,'px'));

	}
	target.hover(workOverhandler,workOuthandler);
	/*t2.start();
	t1.start();*/
	
}

//main Menu Fun ==============================================
function workOverhandler(event) { 
  var tragetStr = event.currentTarget.id;
  $("#"+tragetStr+" .work_imgA").css("display","none"); 
  $("#"+tragetStr+" .work_imgB").css("display","block"); 
  //var nowShow = $("#"+tragetStr+" .work_imgB");
 /* if(nowShow[0].opTween == undefined){
		   nowShow[0].opTween = new OpacityTween(nowShow[0],Tween.regularEaseOut, 0, 100, 0.7);
		   nowShow[0].opTween.start();
		}else{
		   nowShow[0].opTween.start();
  }*/
}

function workOuthandler(event) {
  var tragetStr = event.currentTarget.id;
  $("#"+tragetStr+" .work_imgA").css("display","block");  
  $("#"+tragetStr+" .work_imgB").css("display","none");
  //var nowShow = $("#"+tragetStr+" .work_imgA");
 /* if(nowShow[0].opTween == undefined){
		   nowShow[0].opTween = new OpacityTween(nowShow[0],Tween.regularEaseOut, 0, 100, 0.7);
		   nowShow[0].opTween.start();
		}else{
		   nowShow[0].opTween.start();
  }*/
}