var _DivImgMsg = {
	
	curPage:1,				//当前标签
	picNum:0,				//页面数量
	waitTime:5000,			//自动播放间隔时间	
		
	tarDiv:null,			//目标层
	ObjDiv:null,			//显示层

	autoItv:null,			//自动播放计数
	imgListObj:[],
	
	init:function(tarDivId){
		if(this.tarDiv==null){
			this.tarDiv = document.getElementById(tarDivId);
			if(!this.tarDiv){
				this.tarDiv = null;
				return false;
			}
			
			var tempImgObjArray = this.tarDiv.getElementsByTagName("img");
			var tempAObjArray = this.tarDiv.getElementsByTagName("a");

			if(tempImgObjArray.length<1){
				return false;
			}
			this.picNum = tempImgObjArray.length;

			for(var i=0; i<tempImgObjArray.length; i++){
				this.imgListObj[i] = [];
				this.imgListObj[i]["src"] = tempImgObjArray[i].src;
				this.imgListObj[i]["title"] = tempAObjArray[i].title;
				this.imgListObj[i]["href"] = tempAObjArray[i].href;
			}
			
			// 显示页面内容
			var pageNumString = "";	
			
			pageNumString += '<div id="hot">';
			pageNumString += '<a href="'+this.imgListObj[this.curPage-1]["href"]+'" title="'+this.imgListObj[this.curPage-1]["title"]+'" >';
			pageNumString += '<img src="'+this.imgListObj[this.curPage-1]["src"]+'" style="filter:revealTrans(Transition=1,Duration=0.9);"/>';
			pageNumString += '</a>';
			
			if(this.imgListObj.length>1){
				pageNumString += '<div class="hotNum">';
				for(var i=0; i<this.imgListObj.length; i++){
					pageNumString += '<a href="#" ';
					pageNumString += ' onmouseover="_DivImgMsg.over_in('+(i+1)+')"'; 
					pageNumString += ' onmouseout="_DivImgMsg.over_out()"'; 
					if(this.curPage == i+1)
						pageNumString += ' class="on"';
					pageNumString += '>';
					pageNumString += (i+1);
					pageNumString += '</a>';
				}				
				pageNumString += '</div>';
			}
			pageNumString += '</div>';
				
			document.write(pageNumString);	
			
			if(this.imgListObj.length<=1){
				return;
			}
			
			
			this.ObjDiv = document.getElementById("hot");	
			this.ObjDiv.onmouseover = function(){ clearInterval(_DivImgMsg.autoItv); }
			this.ObjDiv.onmouseout = function(){ 
				_DivImgMsg.autoItv = setInterval( function(){
						_DivImgMsg.autoSlide();
				}, _DivImgMsg.waitTime );
			}
			
			this.autoItv = setInterval( function(){
				_DivImgMsg.autoSlide();
			}, this.waitTime );			
		}
		return;
	},
	autoSlide:function(){
		if(this.curPage < this.picNum){
			this.curPage++;
		}else{
			this.curPage=1;
		}
		this.slideTo();
		return;
	},
	slideTo:function(){
		if(!this.ObjDiv)
			return;
		var hotAObj = this.ObjDiv.getElementsByTagName("a");
		var ImgObj = this.ObjDiv.getElementsByTagName("img")[0];
		
		hotAObj[0].href = this.imgListObj[this.curPage-1]["href"];
		hotAObj[0].title = this.imgListObj[this.curPage-1]["title"];
		
		if (window.XMLHttpRequest) { //Mozilla, Safari,...IE7 
			if(!window.ActiveXObject){ // Mozilla, Safari,...
				ImgObj.src = this.imgListObj[this.curPage-1]["src"];
			} else {
				try{
					ImgObj.filters.item(0).transition = 12;
					ImgObj.filters.item(0).Apply();
					ImgObj.src = this.imgListObj[this.curPage-1]["src"];
					ImgObj.filters.item(0).Play();
				}catch(e){
					ImgObj.src = this.imgListObj[this.curPage-1]["src"];
				}			
			}
		} else {
			ImgObj.src = this.imgListObj[this.curPage-1]["src"];
		}
		
		for(var i=1; i<hotAObj.length; i++){
			if(this.curPage == i)
				hotAObj[i].className = "on";
			else
				hotAObj[i].className = "";
		}			
		return;
	},
	over_in:function(n){
		//clearInterval(this.autoItv);
		this.curPage = n;
		this.slideTo();
	},		
	over_out:function(){
		/*
		this.autoItv = setInterval( function(){
				_DivImgMsg.autoSlide();
		}, this.waitTime );		
		*/
	}
};
