// JavaScript Document

var indexSRC="images/index/";

var bgs = new Array();

var imgDetail=new Array(
						["bg_img_kv_01.jpg","Northeast Sea shore","Close to East China Sea and Pacific Ocean, there are many peculiar Abrasion Platform, Weathering rocks , Sea Cliffs. A magnificent outdoor sculpture museum.",""],
						["bg_img_kv_02.jpg","Chia-Nan Plain","The granary of Taiwan, span length 135 KM and 250,000 hectare, supply Taiwan daily basic need.","photo by 賴榮忠"],
						["bg_img_kv_03.jpg","Kenting","At the southern Taiwan, the ocean temperature is average at 25C. Breeding of coral and tropical fishes, and no shark, one of the most friendly sea fields in the world.","photo by Colleen Yang"],
						["bg_img_kv_04.jpg","East Rift Valley","East seaside mountain against Pacific ocean and west Central mountain range with 181 mountains more over 3000M height. It has the tropical and subtropical climate and landscape co-existing.","photo by 賴榮忠"]
						);
//var imgWheelObj;
var indexStay=1; //停留時間(秒)
var indexTransform=5; //轉換時間(淡入+淡出)秒
var icon_img = "img_wheel_list0";
var icon_off = "_off.jpg";
var icon_on = "_on.png";
/*************************************************/

var indexWheelShowTimerID;

/*
var indexWheelShowTimerID;
var indexWheelHideTimerID;
var indexShowImgOrder=0;
var indexHideImgOrder=0;
var indexOpacityValue;

*/
var imgSort=0;
function indexWheel()
{
	for( var i = 0 ; i < imgDetail.length ; i++ )
	{
		img = new Image();
		img.src = indexSRC + imgDetail[i][0];
		bgs.push( img );
	}
	
	//indexOpacityValue=100/(indexTransform*1000/100);
	if( bgs.length > 0 )
	{
		//indexDisplayImg(indexShowImgOrder);
		indexWheelShowTimerID=setTimeout("indexBgWheel()",indexStay*10);
	}
}
function indexBgWheel()
{

	var wheelConten=document.getElementById('wheel').getElementsByTagName('div');
	document.getElementById('container').style.background='url('+bgs[imgSort].src+') no-repeat';
	wheelContent(imgSort);
	imgSort++;
	if (imgSort>3)
	{
		imgSort=0;	
	}
	indexWheelShowTimerID=setTimeout("indexBgWheel()",indexStay*3250);
}
function indexSwitch(imgObj,parentObj,id)
{
	document.getElementById(imgObj).style.backgroundImage='url('+bgs[id].src+')';	
	//document.getElementById(imgObj).style.backgroundImage='url('+bgs[id].src+') no-repeat';
	if( id < 3 )
	{
		imgSort=id+1;
	}
	else
	{
		imgSort=0;
	}
	wheelContent(id);
}
function wheelContent(num)
{
	imgIconSwitch(num);
	var contentObj=document.getElementById('wheel').getElementsByTagName('div');
	for(var i=0;i<contentObj.length;i++)
	{
		if(contentObj[i].className=='title bold')
		{
			contentObj[i].innerHTML=imgDetail[num][1];	
		}
		if(contentObj[i].className=='content smallfont')
		{
			contentObj[i].innerHTML=imgDetail[num][2];	
		}
		if(contentObj[i].className=='author')
		{
			contentObj[i].innerHTML=imgDetail[num][3];	
		}
	}
	
}
function imgIconSwitch(iconObj)
{
	var imgIcon=document.getElementById('lists').getElementsByTagName('img');
	//將小圖示為off
	for(var i=0;i<imgIcon.length;i++)
	{	
		imgIcon[i].src=indexSRC+icon_img+(i+1)+icon_off;
		var j=indexSRC+icon_img+(i+1)+icon_off;
		imgIcon[i].onmouseout=function()
		{
			this.src = indexSRC+icon_img+this.alt+icon_off;
		};
	}
	//指定onclick的值為on
	imgIcon[iconObj].src=indexSRC+icon_img+(iconObj+1)+icon_on;
	imgIcon[iconObj].onmouseout = null
	
}
window.onload = function(){
 indexWheel('container')
 };

/*
<body onload="imgLoad('container')">
function imgLoad(imgObj)
{
	for(var i=0;i<imgDetail.length;i++)
	{
		document.getElementById(imgObj).style.backgroundImage='url('+indexSRC+imgDetail[i][0]+')';		
	}
	document.getElementById(imgObj).style.backgroundImage='url('+indexSRC+imgDetail[0][0]+')';
}
*/
