function slideShow(name){if(!name)name = "slide_show"; this.name = name; this.width = 400; this.height = 400; this.align = "left"; this.mode = 1; this.speed = 3; this.endUrl = ""; this.loop = true; this.parentNode = null; this.selectSpeedNode = null; this.selectSpeedNum = "2,4,6,8,10"; this.navBarNode = null 
this.navBarMode = 0; 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 = [];}
slideShow.prototype.addString = function(str){var obj = document.createElement("div"); 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'; 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 = 0; var _slideShow = this; img.onload=function(){slideShow.zoom_img(this, _slideShow.width, _slideShow.height);}
var obj = document.createElement("div"); if(linkUrl){var objA = document.createElement("a"); objA.href=linkUrl; linkUrl.target = "_blank"; objA.appendChild(img); obj.appendChild(objA);}else obj.appendChild(img); if(imgNote){var textDiv = document.createElement("div"); textDiv.style.marginTop = "6px"; js.Dom.writeHTML(textDiv, imgNote); obj.appendChild(textDiv);}
obj.style.display = 'none'; this._data[this._data.length] = obj;}
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); if(this.height > 0)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._timerId != -1){clearInterval(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();} 
slideShow.prototype.showByKey = function(key){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();} 
slideShow.prototype._createItemSelect = function(){if(this._data.length == 0)return false; if(this.navBarMode != 4&& !this.navBarNode)return false; var _sildeShow = this; if(this.navBarMode == 4){function createA(i){var objA = js.Dom.createElement("a", pDiv, 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;}
var pDiv = js.Dom.createDiv(this._container); pDiv.style.position = "absolute"; pDiv.style.right = "0px"; pDiv.style.bottom = "0px"; 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(){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.filters.blendTrans.Apply(); this._objDiv.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; 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]; this._currKey++;}
