//------cpOverlay---------------------------
cpSnow = function(name){
	this.name=name;
	this.status='null';
	this.target=document.getElementById(name);
	this.count=15;
	this.bgDiv=Array();
	this.dirs=Array();
	this.speed=50;
	this.isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
	this.left=(document.documentElement.clientWidth-960)/2;
	this.width=960;

	this.create=function(){
		for(var i=0;i<this.count;i++) {
			this.bgDiv[i]=document.createElement("div");
			this.bgDiv[i].id=this.name+'_cpSnowDiv'+i;
			this.bgDiv[i].name=this.name+'_cpSnowDiv'+i;
			this.bgDiv[i].style.zIndex='103';
			if(this.isIE) {
				this.bgDiv[i].style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=crop, src=\'script/snow.png\')';
			} else {
				this.bgDiv[i].style.background='url("script/snow.png")';
			}
			this.bgDiv[i].style.display='block';
			this.bgDiv[i].style.position='absolute';
			this.bgDiv[i].style.marginBottom='-19px';
			this.bgDiv[i].style.width='19px';
			this.bgDiv[i].style.height='19px';
			this.bgDiv[i].style.top=0-(  Math.floor(Math.random()*(this.target.offsetHeight*2))  )+'px';
			//this.bgDiv[i].style.left=this.target.offsetLeft+Math.floor(Math.random()*this.target.offsetWidth)+'px';
			this.bgDiv[i].style.left=this.target.offsetLeft+this.left+Math.floor(Math.random()*this.width)+'px';
			this.target.appendChild(this.bgDiv[i]);
			this.dirs[i]=0;
		}
		var self=this;
		setTimeout(function() { self.show(); }, this.speed);
	}

	this.show=function(){
		for(var i=0;i<this.count;i++) {
			this.bgDiv[i].style.top=parseInt(this.bgDiv[i].style.top)+(  Math.floor(Math.random()*2)  )+'px';
			if( (parseInt(this.bgDiv[i].style.top))>(this.target.offsetHeight-2) ) {
				this.bgDiv[i].style.top=0-(  Math.floor(Math.random()*this.target.offsetHeight)  )+'px';
				//this.bgDiv[i].style.left=this.target.offsetLeft+Math.floor(Math.random()*this.target.offsetWidth)+'px';
				this.bgDiv[i].style.left=this.target.offsetLeft+this.left+Math.floor(Math.random()*this.width)+'px';
			}
			this.bgDiv[i].style.left=parseInt(this.bgDiv[i].style.left)+(  Math.floor(Math.random()*2)-1  )+'px';			
		}
		var self=this;
		setTimeout(function() { self.show(); }, this.speed);
	}

}

var cpSnowItem=Array();

function addCpSnow(id){
	if(cpSnowItem[id]==null) {
		cpSnowItem[id]=new cpSnow(id);
		cpSnowItem[id].create();
	} else {
		cpSnowItem[id].show();
	}
}

