//************************************************************************************
// Cross Browser Funcitons ver 3.0 
// Copyright (C) by Audi audi_wang@sinamail.com
// http://www.carousel.com.tw
// http://www.toocool.com.tw
// Usage:
// 變數 adObj 可以修改成任一新名稱, 使用本程式有三個步驟
// step1: 連結本程式碼 <script language=javascript src=adjs.js></script>
// step2: 在 <body> 中加入 <body onload="adObj.start();">
// step3: 在HTML文件中放置 banner 的地方改成 <script>adObj.write();</script>

// 修改這裡變動連結的URL
 url = new Array("http://www.chinasofar.com") 
//                  "http://www.chinasofar.com")
                
// 修改這裡變動banner的來源
imgUrl = new Array("/images/banner/banner01.gif")
//                  "/images/banner/chinasofar-6.gif"

// 修改這裡變動每個 banner 停留的時間(秒)                   
delayTime=6;                   
   
var adObj=new ADArray(url,imgUrl,delayTime,"adObj","adImage");

function ADArray(url,imgUrl,delayTime,obj,srcName){
	this.url=url;
	this.imgUrl=imgUrl;
	this.delayTime=delayTime*1000;
	this.obj=obj;
	this.srcName=srcName;
	
	this.start=AD_start;
	this.rotate=AD_rotate;
	this.write=AD_write;
	this.click=AD_click;
	
	var randomSelect;
	
	randomSelect=Math.random();
	this.adseq=parseInt(randomSelect*1000000) % this.url.length;
	return this;
}

function AD_write() {
//暫時先把連結拿掉	
//	document.write('<a href="javascript://" ');
//	document.write('onclick="'+this.obj+'.click();">');
	document.write('<img name="'+this.srcName+'" border="0" ');
	document.write('src="'+this.imgUrl[this.adseq]+'">');
//	document.write('</a>');
}

function AD_rotate(){
	var totaln, randomSelect;
	this.adseq++;
	totaln = this.imgUrl.length;
	this.adseq %= totaln;
	document.images[this.srcName].src=this.imgUrl[this.adseq];
	
}

function AD_start(){
	window.setInterval(this.obj+'.rotate()', this.delayTime)
}

function AD_click(){
	window.open(this.url[this.adseq]);
}