// SlideShow v0.9 - Copyright (c) 2006-2008 pft99.com, inc.
//
// A free SlideShow object.
//
// Version 0.9 developed by y31.
//   http://www.pft99.com
//
// 2006-8-23 21:07:15

/*
	theInstanceName	SlideShow实例的名称
	showDiv			容器
	timeOut			间隔时间
*/
function SlideShow(theInstanceName,showDiv,timeOut){
	this._name = theInstanceName;
	this._IsIE = (navigator.appName == "Microsoft Internet Explorer");
	this._count = 0;
	this._shows = new Array();
	this.id = "123";
	if(showDiv){
		this._container = showDiv;
	}else{
		this._container = null;
	}
	if( timeOut ){
		this._timeOut = timeOut;
	}else{
		this._timeOut = 1000;
	}
	this.timer = null;
	this.oldShow = null;

	this.setContainer = show_setContainer;
	this.addShow = show_addShow;
	this.randomshow = show_randomshow;
	this.start = show_start;
	this.stop = show_stop;
}

function show_setContainer(obj){
	this._container = obj;
}

function show_addShow(obj){
	this._shows[this._count++] = obj;
}

function show_randomshow(){
	if(this._container){
		if(this._IsIE){
			//newsContainer.contentEditable = true;
			//this._container.style.height = "100px";
			this._container.style.filter = "progid:DXImageTransform.Microsoft.Fade(Overlap=1.00)";//FILTER: progid:DXImageTransform.Microsoft.Fade(Overlap=1.00);
			this._container.filters[0].apply();
		}

		if(this.oldShow){
			this._container.removeChild(this.oldShow);
		}
/*
		if(bChildNodes = this._container.hasChildNodes()){
			for(i=0;i<bChildNodes.length;i++){
				this._container.removeChild(bChildNodes[i]);
			}
		}
*/
		this.oldShow = this._shows[parseInt(Math.random() * this._count)];
		this.oldShow.style.display = "";
		this._container.appendChild(this.oldShow);
		if(this._IsIE)this._container.filters[0].play();
	}
}

function show_start(){
	if( this.timer ){
		window.clearInterval(this.timer);	
	}
	if( this._name ){
		this.timer = window.setInterval(this._name + ".randomshow()", this._timeOut);	
	}
}

function show_stop(){
	if( this.timer ){
		window.clearInterval(this.timer);	
	}
}
