// JavaScript Document
/*
	get object
*/
function $(id) {
	return typeof(id)=="string"?document.getElementById(id):id;
}

/*
	bind func
*/
var Bind = function(object,fun){
	var args = Array.prototype.slice.call(arguments,2);
	return function(){
		return fun.apply(object,args);
	}
}

/*
	v1.1.201007271628
	2010-7-22 by fred
	
	objects class
	showtype: 1,2
	flag: false,true
	n: count nums
	imgs: data objects
	div_show: img parent
	img: img object
	div_no: No object
	t: time object
	speed: 3000
	_run: bind func
*/
function picShow(name,no,imgs) {
	this.showtype = 1;
	this.flag = false;
	this.n=0;
	this.imgs = imgs;
	this.urls;
	this.div_show = $(name);
	this.img = this.div_show.getElementsByTagName("img")[0];
	this.div_no = $(no);
	this.t;
	this.speed = 2000;
	this._run = Bind(this,this.autoRun);
}
picShow.prototype={
	/*
		bing event for special objects
	*/
	initEvent:function() {
		var obj = this;
		this.spans = this.div_no.getElementsByTagName("span");
		if(this.spans) {
			for(var i=0;i<this.spans.length;i++) {
				var span = this.spans[i];
				span.i = i;
				span.onmouseover = function() {
					this.className = "current";
				}
				span.onmouseout = function() {
					if(obj.n!=this.i) {
						this.className = "";
					}
				}
				span.onclick = function() {
					obj.n = this.i
					obj.start();
				}
			}
		}
	},
	/*
		program auto create No objects
	*/
	initNo:function() {
		var obj = this;
		var spans = [];
		if(this.imgs) {
			this.div_no.innerHTML = "";
			for(var i=0;i<this.imgs.length;i++) {
				var span = document.createElement("span");
				span.innerHTML = (i+1);
				span.i = i;
				span.onmouseover = function() {
					this.className = "current";
				}
				span.onmouseout = function() {
					if(obj.n!=this.i) {
						this.className = "";
					}
				}
				span.onclick = function() {
					obj.n = this.i
					obj.start();					
				}
				this.div_no.appendChild(span);
				spans.push(span);
			}
			this.spans = spans;
		}
	},
	/*
		show img 
	*/
	showImg:function() {
		if(document.images) {
			//var image = new Image();
			//image.src = this.imgs[this.n].src;
			//this.img.src = image.src;
			this.img.src = this.imgs[this.n].src;
		}
	},
	/*
		set No style
	*/
	setStyle:function() {
		if(this.spans) {
			var spans = this.spans;
			for(var i=0;i<spans.length;i++) {
				var span = spans[i];
				if(this.n==i) {
					span.className = "current";
				}
				else {
					span.className = "";
				}
			}
		}
	},
	/*
		show img start
	*/
	start:function() {
		if(document.all) {
			this.IEfilter(this.showtype);
		}
		else {
			this.showImg();
		}
		this.setStyle();
		a_over(this.n);
	},
	/*
		auto show img 
	*/
	autoRun:function() {
		this.flag = true;
		this.start();
		this.n++;
		if(this.n>=this.imgs.length) {
			this.n=0;
		}
		this.t = window.setTimeout(this._run,this.speed);
	},
	/*
		ie special filter
	*/
	IEfilter:function(flag) {
		if(flag==1) {
			this.div_show.style.cssText = "filter:revealTrans(duration=1,transition=20);"
			this.div_show.filters.revealTrans.Transition=Math.floor(Math.random()*20);
			this.div_show.filters.revealTrans.apply();
			this.showImg();
			this.div_show.filters.revealTrans.play();
		}
		if(flag==2) {
			this.div_show.style.cssText = "filter:blendTrans(Duration=1,transition=2);";
			this.div_show.filters.blendTrans.apply();
			this.showImg();
			this.div_show.filters.blendTrans.play();
		}
	}
}
