//照片輪播=================================

	var alternation_opacity = 0;	//照片的淡出效果, 0~1, 0為無色, 1為正常
	var alternation_setTimeout; 
	var alternation_object_type;    //物件本身型態
	var alternation_object_id;		//物件本身ID
	var alternation_dir;			//檔案的目錄位置
	var alternation_speed;			//淡化速度
	var alternation_speed2;			//更換圖片中間間距


	//共有幾張圖
	var playImg    = new Array();  //檔案名稱
	var myImgAlt   = new Array();  //ALT名稱
	var myImglink  = new Array(); //LINK位置	
	var myImgStyle = new Array(); //圖片樣式
	var nowIndex=1; //目前播放到第幾張




	//初始化-設定播放資訊
	function alternation_init(idname, speed, speed2, dir, setimg, setalt, setlink, setstyle) {
		alternation_object_id = idname;
		playImg  = setimg;
		if(setalt)		myImgAlt	= setalt;
		if(setlink)		myImglink	= setlink;
		if(setstyle)	myImgStyle	= setstyle;
		else {
			for(i=0; i<playImg.length;i++) {
				myImgStyle[i] = "";
			}
		}
		alternation_object_type = document.getElementById(idname).tagName.toUpperCase(); //取得物件標籤
		alternation_speed		= speed;
		alternation_speed2		= speed2;
		alternation_dir			= dir;
		if(playImg.length<2) nowIndex = 0;


		//初始化第一張
		alternation_opacity = 0; //先變淺
		$(alternation_object_id).fade(0);
		setTimeout("alternation_setfirst()",1000);
	}


	//放置第一張
	function alternation_setfirst() {
		str = "<img src=\""+alternation_dir+playImg[0]+"\" style=\""+myImgStyle[0]+"\">";
		if(alternation_object_type == "DIV") {
			if(myImglink[0]) {
				str = "<a href=\""+myImglink[0]+"\" alt=\""+myImgAlt[0]+"\">"+str+"</a>";
			}
		}
		else if(alternation_object_type == "A") {
			if(myImglink[0]) {
				document.getElementById(alternation_object_id).src = myImglink[0];
			}
			document.getElementById(alternation_object_id).alt = myImgalt[0];
		}
		document.getElementById(alternation_object_id).innerHTML = str;


		alternation_fade(true); //變深
	}



	//淡入效果
	function alternation_fade(ads_c){
			if(document.all);
			//加深
			if(ads_c == true) 	{
				alternation_opacity = Math.round(alternation_opacity*10+1)/10;
			}
			//變淡
			else {
				alternation_opacity = Math.round(alternation_opacity*10-1)/10;
			}
			if(alternation_opacity>=1)		alternation_opacity = 1;
			else if(alternation_opacity<=0) alternation_opacity = 0;

			$(alternation_object_id).fade(alternation_opacity);


			//遞迴
			if(alternation_opacity<1 && alternation_opacity>0) {
				setTimeout("alternation_fade("+ads_c+")", alternation_speed);
			}
			else 	return;
	}





		function alternation_showImg(show){
			if(show) {
				//變淡
				alternation_opacity = 1;
				clearTimeout(alternation_setTimeout);  //清除alternation_setTimeout
				alternation_fade(false);
				alternation_setTimeout = setTimeout("alternation_showImg(false)", alternation_speed2);
			}
			else {
				clearTimeout(alternation_setTimeout);  //清除alternation_setTimeout
				//變深
				str = "<img src=\""+alternation_dir+playImg[nowIndex]+"\" style=\""+myImgStyle[nowIndex]+"\">";
				if(alternation_object_type == "DIV") {
					if(myImglink[nowIndex]) {
						str = "<a href=\""+myImglink[nowIndex]+"\" alt=\""+myImgAlt[nowIndex]+"\">"+str+"</a>";
					}
				}
				else if(alternation_object_type == "A") {
					if(myImglink[nowIndex]) {
						document.getElementById(alternation_object_id).src = myImglink[nowIndex];
					}
					document.getElementById(alternation_object_id).alt = myImgalt[nowIndex];
				}
				document.getElementById(alternation_object_id).innerHTML = str;

				alternation_opacity = 0;
				alternation_setTimeout = setTimeout("alternation_fade(true)",1000);
				//若nowIndex+1後>=playImg的長度，nowIndex重0開始；否則加1
				nowIndex = (nowIndex+1)>= playImg.length?0:nowIndex+1;
			}
		}



//照片輪播=================================