<!--
//幻灯播放文字或图片


function slideShow(name) {
	if (!name)name = "slide_show";
	this.name      = name;         //输出时div的id
	this.width     = 400;          //输出时div的宽度
	this.height    = 400;          //输出时div的高度,如果为0将自适应高度
	this.align     = "left";       //对齐
	this.mode      = 1;            //显示模式，1渐显过渡，2 百页窗等形状过渡
	this.speed     = 3;         //速度,秒
	this.endUrl    = "";           //轮显完后要去的页面
	this.loop      = true;        //是否循环
	this.parentNode = null;       //显示内容容器,可以是ID或对象
	this.selectSpeedNode = null;           //速度选单容器
	this.selectSpeedNum = "2,4,6,8,10";  //速度秒数
	this.navBarNode = null        //导航容器
	this.navBarMode = 0; //导航模式,0:下拉选单, 1:第一前一后一最后, 2:数字, 3:1+2, 4:画面内部数字
	
    this._data     = [];           //每次过渡字符数据
	this._timerId  = -1;
	this._currKey  = 0;
	this._container = null; //总的容器
	this._objDiv   = null;
	this.defaultText = "No Data!";
	this._lastObj   = null;
	this._lastNavObj   = null;
	this._objItemSelect = null;        //下拉选单
	this._select_focus = 0;         //下拉选单是否被选中
	this._wait_num = 0;
	this._navData = [];
	this.navDiv = null;
}

slideShow.prototype.addString = function (str){
	var obj = document.createElement("div");
	//obj.style.position = "absolute";
	obj.appendChild(document.createTextNode(str));
	js.Dom.writeHTML(obj, str);
	obj.style.display = 'none';
    this._data[this._data.length] = obj;
}

slideShow.prototype.addObject = function (obj){
	obj.style.display = 'none';
	//obj.style.position = "absolute";
    this._data[this._data.length] = obj;
}

slideShow.zoom_img = function (obj, dstW, dstH)
{
	var srcW = obj.width;
	var srcH = obj.height;
	var x = srcW / dstW;
	var y = dstH > 0 ? srcH / dstH : 0;
	
	if (x > 1 || y > 1){
		if (x > y){
			srcW = Math.floor(srcW/x);
			srcH = Math.floor(srcH/x);
		}
		else {
			srcW = Math.floor(srcW/y);
			srcH = Math.floor(srcH/y);
		}
	}
	
	js.Dom.setW(obj, srcW);
	js.Dom.setH(obj, srcH);
}

slideShow.prototype.addImage = function (imgUrl, imgNote, linkUrl){
    var img = new Image();
	img.src = imgUrl;
	img.style.border = "1px solid #fff";
	var _slideShow = this;
	
	var obj_table = document.createElement("table");
	//obj_table.style.borderCollapse = "collapse;";
	obj_table.style.borderSpacing = "0";
	obj_table.style.border = "1px solid #000";
	var obj_tbody = document.createElement("tbody");
	var obj_tr_1 = document.createElement("tr");
	var obj_td_1 = document.createElement("td");
	obj_table.appendChild(obj_tbody);
	obj_tbody.appendChild(obj_tr_1);
	obj_tr_1.appendChild(obj_td_1);
	obj_td_1.style.border = "4px solid #000";
	obj_td_1.style.textAlign = "center";
	
	var objA = document.createElement("a");
	if (linkUrl){
		objA.href=linkUrl;
		objA.target = "_blank";
	}
	else {
		objA.href= "#imgDiv";
		objA.title = "下一个";
		js.Event.addEvent(objA, 'click', function(){_slideShow.next();});
	}
	objA.appendChild(img);
	obj_td_1.appendChild(objA);
	
	if (imgNote) {
		var obj_tr_2 = document.createElement("tr");
		var obj_td_2 = document.createElement("td");
		obj_tbody.appendChild(obj_tr_2);
		obj_tr_2.appendChild(obj_td_2);
		obj_td_2.style.padding = "6px";
		obj_td_2.style.backgroundColor = "#666";
		obj_td_2.style.color = "#fff";
		obj_td_2.style.textAlign = "left";
		img.onload=function (){
			slideShow.zoom_img(this, _slideShow.width, _slideShow.height);
			js.Dom.setW(obj_td_2, js.Dom.getW(this));
		}
		
		js.Dom.writeHTML(obj_td_2, imgNote);
	}
	else img.onload=function (){slideShow.zoom_img(this, _slideShow.width, _slideShow.height);}
	obj_table.style.display = 'none';
    this._data[this._data.length] = obj_table;
}

slideShow.prototype.display = function (parentNode)
{
	if (this._objDiv)return true;
	if (this.width < 1){
		alert("Set width, please!");
		return false;
	}
	
	if (parentNode)this.parentNode = parentNode;
	if (this.parentNode){
		if (typeof(this.parentNode) == "string")this.parentNode = js.Dom.findObj(this.parentNode);
		this._container = js.Dom.createDiv(this.parentNode);
		this._objDiv = js.Dom.createDiv(this._container);
	}
	else {
		document.write('<div id="'+this.name+'" align="'+this.align+'"></div>');
		this._container = js.Dom.findObj(this.name);
		this._objDiv = js.Dom.createDiv(this._container);
	}
	this._container.style.position = "relative";
	//js.Dom.setW(this._objDiv, this.width);
	js.Dom.setW(this._objDiv, this.width);
	if (this.height > 0){
		js.Dom.setH(this._container, this.height);
		js.Dom.setH(this._objDiv, this.height);
	}
	if (js.Browse.ie){
		if (this.mode == 1) this._objDiv.style.filter="blendTrans(duration=1)";
		else this._objDiv.style.filter="revealTrans(Duration=2.0,Transition=23)";
	}
	if (this._data.length == 0){
		this._objDiv.innerHTML = this.defaultText;
		return false;
	}
	else {
		for (var i in this._data)	this._objDiv.appendChild(this._data[i]);
		this._createItemSelect();
		this._createSpeedSelect();
		this.change();
	}
} 

slideShow.prototype.play = function (parentNode)
{
	this.display(parentNode);
	var t = this;
	this.stop();
	if (this._data.length > 1)this._timerId = setInterval(function (){t.change()},this.speed * 1000);
} 

slideShow.prototype.setValign = function (obj)
{
	if (this.height < 1)return false;
	var h = js.Dom.getH(obj);
	if (h > 0 && h < this.height){
		obj.style.marginTop = Math.floor((this.height-h)/2) +"px";
	}
}

slideShow.prototype.stop = function ()
{
	//if (this._data.length <= 1)return false;
    if (this._timerId != -1) {
    	clearInterval(this._timerId);
		//clearTimeout(this._timerId);
		this._timerId = -1;
    }
	return false;
} 

slideShow.prototype.prev = function ()
{
	if (this._data.length <= 1)return false;
	this.stop();
    this._currKey-=2;
	if (this._currKey < 0)this._currKey = this._data.length - 1;
	this.change();
} 

slideShow.prototype.next = function ()
{
	if (this._data.length <= 1)return false;
	this.stop();
	this.change();
} 

//根据key播放
slideShow.prototype.showByKey = function (key)
{
	this.display();
	if (this._data.length <= 1)return false;
	if (key < 0)key = this._data.length - 1;
	else if (key >= this._data.length)key = 0;
	this._currKey = key;
	this.stop();
	this.change();
	this.play();
} 

//创建下拉选单   
slideShow.prototype._createItemSelect = function ()
{
	if (this._data.length == 0)return false;
	//this.navBarMode = 0;
	//this.navBarNum = 5; 
	if (this.navBarMode != 4 && !this.navBarNode)return false;
	
	var _sildeShow = this;
	if (this.navBarMode == 4){
		this.navDiv = js.Dom.createDiv(this._container);
		this.navDiv.style.position = "absolute";
		this.navDiv.style.right = "0px";
		this.navDiv.style.bottom = "0px";
		function createA(i)
		{
			var objA = js.Dom.createElement("a", _sildeShow.navDiv, i);
			objA.style.display = "block";
			objA.style.cssFloat = 'right';
			objA.style.styleFloat = 'right';
			objA.style.padding = '2px 5px 1px 5px';
			objA.style.margin = '1px';
			objA.style.border = '1px solid #ffffff';
			objA.style.backgroundColor = '#ff9900';
			objA.style.color = "#ffffff";
			objA.href = "#";
			js.Event.addEvent(objA, 'click', function (){_sildeShow.showByKey(i-1);return false;});
			_sildeShow._navData[i-1] = objA;
		}
		for (var i=this._data.length; i >= 1; i-- ) createA(i);
	}
	else {
		var sel = document.createElement("select");
		for (var i=0; i < this._data.length; i++ ){
			var op = document.createElement("option");
			op.appendChild(document.createTextNode(i+1));
			op.value = i;
			sel.appendChild(op);
		}
		js.Event.addEvent(sel, 'focus', function (){_sildeShow._select_focus = 1});
		js.Event.addEvent(sel, 'blur', function (){_sildeShow._select_focus = 0});
		js.Event.addEvent(sel, 'change', function (){if (_sildeShow._select_focus == 1)_sildeShow.showByKey(sel.value);});
		this._objItemSelect = sel;
		if (this.navBarNode){
			if (typeof(this.navBarNode) == "string")this.navBarNode = js.Dom.findObj(this.navBarNode);
			this.navBarNode.appendChild(sel);
		}
	}
} 

//创建速度下拉选单
slideShow.prototype._createSpeedSelect = function ()
{
	if (this._data.length == 0)return false;
	if (!this.selectSpeedNode)return false;
	if (!this.selectSpeedNum)return false;
	var speeds = this.selectSpeedNum.split(",");
	var sel = document.createElement("select");
	var last_i = 0;
	for (var n in speeds){
		var i = speeds[n];
		if (last_i < this.speed && this.speed < i){
			var op = document.createElement("option");
			op.appendChild(document.createTextNode(this.speed));
			op.value = this.speed;
			sel.appendChild(op);
		}
		last_i = i;
		var op = document.createElement("option");
		op.appendChild(document.createTextNode(i));
		op.value = i;
		sel.appendChild(op);
	}
	sel.value = this.speed;
	var s = this;
	js.Event.addEvent(sel, 'change', function (){s.speed = sel.value;s.play();});
	if (this.selectSpeedNode){
		if (typeof(this.selectSpeedNode) == "string")this.selectSpeedNode = js.Dom.findObj(this.selectSpeedNode);
		this.selectSpeedNode.appendChild(sel);
	}
} 

slideShow.prototype.change = function ()
{
	//this.play();
	if (this._data.length == 0)return this.stop();
	if (this._currKey >= this._data.length){
		this._currKey = 0;
		if (!this.loop){
			this.stop();
			if (this.endUrl)location.href=this.endUrl;
			return false;
		}
	}
	if (!this._data[this._currKey])return this.stop();
	
	if (this._timerId != -1 && this._data[this._currKey]._loaded == 0) {
		if (this._wait_num > 10) this._currKey++;
		else this._wait_num++;
		return false;
	}
	this._wait_num = 0;
	
	if (js.Browse.ie){
		if (this.mode == 1){
			this._objDiv.style.filters.blendTrans.Apply();
			this._objDiv.style.filters.blendTrans.Play();
		}
		else {
			this._objDiv.filters.revealTrans.Apply();
			this._objDiv.filters.revealTrans.transition=30;
			this._objDiv.filters.revealTrans.duration=1;
			this._objDiv.filters.revealTrans.Play();
		}
	}
	if (this._lastObj)this._lastObj.style.display = 'none';
	if (this.navBarMode == 4 && this._lastNavObj){
		this._lastNavObj.style.backgroundColor = "#ff9900";
		this._lastNavObj.style.fontWeight = "normal";
	}
	this._data[this._currKey].style.display = '';
	if (this._objItemSelect)this._objItemSelect.value = this._currKey;
	//this.setValign(this._data[this._currKey]);
	if (this.navBarMode == 4){
		this._navData[this._currKey].style.backgroundColor = "#cccccc";
		this._navData[this._currKey].style.fontWeight = "bold";
	}
	this._lastObj = this._data[this._currKey];
	this._lastNavObj = this._navData[this._currKey];
	
	//var _slideShow = this;
	
	//js.Dom.setW(this._objDiv, js.Dom.getW(this._data[this._currKey]));
	//js.Dom.setH(this._objDiv, js.Dom.getH(this._data[this._currKey]));
	//js.Dom.setX(this._data[this._currKey], js.Dom.getPageX(this._objDiv));
	//js.Dom.setY(this._data[this._currKey], js.Dom.getPageY(this._objDiv));
	
	this._currKey++;
}

//-->