var ABOUT={};
ABOUT.slideShow=function(){
	this.picArr = ['IMG_0020.jpg', 'IMG_0091.jpg', 'IMG_0107.jpg', 'IMG_0119.jpg', 'IMG_0136.jpg'];
	//this.colArr = ['#30ec9a', '#861374', '#d56e8b', '#26c0bb', '#bca01c', '#1f8565', '#c3561b', '#ffffff'];
	this.root = document.getElementById('bg');
	//this.ac = document.getElementById('aboutContent');
	this.imgs = this.root.childNodes;
	this.action = null;
	this.counter=0;
	this.swapEven=0;
	this.swapEven2=1;
	this.dir='next';
	this.status=true;
}
ABOUT.slideShow.prototype={
	init:function(){
		this.imgs[0].firstChild.src = path+'co/asset/pic/store/white.gif';
		$(this.imgs[0]).setOpacity(100);
		this.imgs[1].firstChild.src = path+'co/asset/pic/store/white.gif';
		$(this.imgs[1]).setOpacity(1);
		this.loadPic(this.counter);
	},
	change:function(dir){
		window.clearTimeout(this.action);
		if(this.dir=='prev')
			if(this.counter>0)
				this.counter--;
			else
				this.counter=this.picArr.length-1;
		else
			if(this.counter<this.picArr.length-1)
				this.counter++;
			else
				this.counter=0;

		this.loadPic(this.counter);
	},
	start:function(){
		this.change(this.counter);
	},
	toggle:function(loc){
		
		if (this.status) {
			this.status = false;
			if (loc != '') {
				loc.className = "active";
				loc.innerHTML = 'play';
				loc.parentNode.className = 'playPlayer';
			}
			window.clearTimeout(this.action);
		}else{
			this.status = true;
			this.start();
			if (loc != '') {
				loc.className = "";
				loc.innerHTML = 'stop';
				loc.parentNode.className = 'stopPlayer';
			}
		}
	},
	prev:function(){
		this.dir='prev';
		this.status=false;
		this.change(this.counter);
	},
	next:function(){
		this.dir='next';
		this.status=false;
		this.change(this.counter);
	},
	loadPic:function(nr){
		var thisObj = this;
		this.swapEven = this.swapEven==0?this.swapEven=1:this.swapEven=0;
		this.swapEven2 = this.swapEven2==0?this.swapEven2=1:this.swapEven2=0;
		var image = new Image();
		image.onload=function(){

			var fn1 =function(){
				document.getElementById('content').style.display = 'block';
				startHeight = document.getElementById('content').offsetHeight;
					rs.chSize();
					
				if(thisObj.status)
					thisObj.action = window.setTimeout(fn, 4000);
			};
			/*if(typeof thisObj.t3=='undefined' && typeof thisObj.t1!='undefined'){
				thisObj.t3 = morph(thisObj.ac).setStyles([['opacity','0']]).start('', '70', '');
				thisObj.t3.toggle();
			}*/
			
			if(typeof thisObj.t1=='undefined')
				thisObj.t1 = morph(thisObj.imgs[0]).setStyles([['opacity','0']]).start('', '1', '');
			thisObj.t1.toggle();
			
			thisObj.imgs[thisObj.swapEven].firstChild.src = this.src;
			if(typeof thisObj.t2=='undefined')
				thisObj.t2 = morph(thisObj.imgs[1]).setStyles([['opacity','100']]).start(fn1, '1', fn1);
				
			thisObj.t2.toggle();
			
			var fn = function(){
				thisObj.change();
			}
		}
		image.src = path+'co/asset/pic/store/'+this.picArr[nr];
	}
}
