var broadcastsObj;
function broadcasts ()
{
	this.picIndex = 0 ;
	this.picName = new Array( "images/index/index1_20.jpg" , "images/index/index2_20.jpg"  , "images/index/index3_20.jpg" , "images/index/index4_20.jpg" );
	this.explain = new Array( "images/index/describe1.jpg" , "images/index/describe2.jpg"  , "images/index/describe3.jpg" , "images/index/describe4.jpg"  );
	this.title = new Array( "『Linker商店街』聯盟官網(shop.linker.tw)" , "祝各位龍年行大運享騏璣" , "臺越高等教育交流中心" , "Taiwan Education Center Danang, Vietnam" );
	this.alt = new Array( "『Linker商店街』聯盟官網(shop.linker.tw)" , "祝各位龍年行大運享騏璣" , "臺越高等教育交流中心" , "Taiwan Education Center Danang, Vietnam" );
	// this.textContent = new Array ( "Chinese Language Class" , "March 2012, Chinese Language Proficiency Test (TOCFL)" , "2011 Taiwan-Vietnam Higher Education Forum"  );
	this.linkHerf = new Array ( "http://shop.linker.tw/" , "http://www.cheerg.com/", "http://studyintaiwan.linker.tw/" , "http://studyintaiwan.danang.linker.tw/"  );
	this.delay = 5000;
	this.winCode;
	
	
	this.showPic = function ( index )
	{
		this.picIndex = index;
		clearTimeout( this.winCode );
		this.turn();
	}
	
	this.showPrev = function ()
	{
		var nowIndex;
		if( this.picIndex - 1 < 0 )
			nowIndex = 3 ;
		else
			nowIndex = this.picIndex - 1;
		
		if( nowIndex - 1 < 0 )
		 this.picIndex = 3 ;
		else
		 this.picIndex = nowIndex - 1 ;
		clearTimeout( winCode );
		this.turn();
	}
	
	this.showNext = function ()
	{
		clearTimeout( winCode );
		this.turn();
	}
	
	this.turn = function ()
	{
		this.setPic();
		if( this.picIndex + 1 >  this.picName.length -1 )
			this.picIndex = 0 ;
		else
			this.picIndex ++ ;
		this.winCode = window.setTimeout( "broadcastsObj.turn()" , this.delay )
	}
	
	this.setPic = function ()
	{
		var img = this.picName[this.picIndex];
		var link = this.linkHerf[this.picIndex];
		var explain = this.explain[this.picIndex];
		var title =  this.title[this.picIndex];
		var alt =  this.alt[this.picIndex];
		//var text = this.textContent[this.picIndex];
		//var id = "aTag" + ( this.picIndex + 1 ) ;
		var id = "btn" + ( this.picIndex + 1 ) ;
		document.getElementById( "hotPic" ).src = img;
		document.getElementById( "hotPic" ).title = title + "\n" +  link;
		document.getElementById( "hotPic" ).alt = alt + "\n" + link;
		document.getElementById( "explain" ).src = explain;
		document.getElementById( "explain" ).alt = link;
		document.getElementById( "explain" ).title = link;
		document.getElementById( "hotLink" ).href = link;
		document.getElementById( "textLink" ).href = link;
		
		//document.getElementById( "hotLink2" ).href = link;
		//document.getElementById( "hotText" ).innerHTML = text;
		
		
		
		/*
		if( this.picIndex == 1 )
			document.getElementById( "hotText" ).style.fontSize = "9px";
		else
			document.getElementById( "hotText" ).style.fontSize = "10px";
		*/
		for( var i = 1 ; i < 5 ; i ++ )
		{ 
			document.getElementById( "btn" + i ).src = "images/index/btn_out_0" + i + ".jpg"; 
		}
		document.getElementById( id ).src = "images/index/btn_over_0" + ( this.picIndex + 1 ) + ".jpg";
	}
}


function position()
{
	var apDivkeyword = document.getElementById( "apDivkeyword" );
	var left = apDivkeyword.style.left;
	apDivkeyword.style.left = ( left + 58 ) + "px";
}

function inload()
{
	//position();
	
	broadcastsObj =  new broadcasts();
	broadcastsObj.turn();
}
