﻿// JScript 文件
//<div id="div_objectPhotos" style="filter:progid:DXImageTransform.Microsoft.RandomDissolve(); width:240px;height:140px;">
//var oPhotos = new objectPhotos(document.getElementById("div_objectPhotos"));
//判断是否是IE
var agt=navigator.userAgent.toLowerCase();
var ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1) && (agt.indexOf("omniweb") == -1));
function objectPhotos(object){
    this.object = object;
	this.nowDiv = null;
	this.object.style.position = "relative";
	this.id = 0;
	this.auto = true;
	
	this.arrDiv = new Array();
	var allDiv = object.getElementsByTagName("div");
	for (var i=0; i<allDiv.length; i++){
		if (allDiv[i].className == "div_photos"){
			this.arrDiv.push(allDiv[i]);	
		}
	}
	
	for (var i=0; i<this.arrDiv.length; i++){
		this.arrDiv[i].style.position = "absolute";
		if (i == 0){
			this.nowDiv = this.arrDiv[0];
			this.nowDiv.style.visibility = "visible";
		}else{
			this.arrDiv[i].style.visibility = "hidden";
		}
	}
	var othis = this;
	setInterval (function (){
		if(othis.auto){
		    with (othis.object) {
			    if (ie) filters[0].Apply();
			    othis.nowDiv.style.visibility = "hidden";
			    othis.id++;
			    othis.testID();
			    othis.arrDiv[othis.id].style.visibility = "visible";
			    othis.nowDiv = othis.arrDiv[othis.id];
			    if (ie) filters[0].play();
		    }
		}
	},5000);
}
objectPhotos.prototype.testID = function(){
	if (this.id >= this.arrDiv.length){
		this.id = 0;	
	}
}
objectPhotos.prototype.go = function(id){
    this.auto = false;
	if (ie) this.object.filters[0].Apply();
	this.nowDiv.style.visibility = "hidden";
	this.arrDiv[id].style.visibility = "visible";
	this.nowDiv = this.arrDiv[id];
	if (ie) this.object.filters[0].play();
}


