var SmokeEffect = {
	
	imgLocation: "", //url to image here
	smokeWidth: 80, //standard width
	smokeHeight: 145, //standard height
	
	//don't touch this:
	smokePos: new Array(),
		
	makeEffect: function(id, posX, posY) {
		//set position from the "parent"
		SmokeEffect.smokePos[id] = new Array();
		SmokeEffect.smokePos[id]['x'] = posX;
		SmokeEffect.smokePos[id]['y'] = posY;
		
		//set a random time to start puffing
		var time = (Math.floor(Math.random()*3001));
		//setTimeout("SmokeEffect.animate('" + id + "')", time);
	},
	
	animate: function(id) {

		//create the smoke cloud
		var puff = document.createElement("IMG");
		$w8x(puff).attr("src", SmokeEffect.imgLocation);
		$w8x(puff).attr("alt", "cms system W8X");
		$w8x(puff).attr("class", "imgLogoW8x");
		$w8x(puff).click(function () {
			window.open('http://w8x.ru','_blank')
		    });
		//create a temp id for the cloud so we can delete it later on
		var tempId = "puff" + Math.floor(Math.random()*1001);
		$w8x(puff).attr("id", tempId);
		
		//append the cloud to the body
		$w8x(document.body).append($w8x(puff));
		
		var objPos = $w8x('#' + id).offset();
		
		//do smoke animation
		$w8x(puff).css({
			top: (objPos['top'] + SmokeEffect.smokePos[id]['y']) + "px",
			left: (objPos['left'] + SmokeEffect.smokePos[id]['x']) + "px",
			zIndex: 25,
			opacity: 0.4
		});
		$w8x(puff).animate({
			width: SmokeEffect.smokeWidth + "px",
			height: SmokeEffect.smokeHeight + "px",
			marginLeft:  (SmokeEffect.smokeWidth * 2.5) + "px",
			marginTop: "-" + (SmokeEffect.smokeHeight /2.5) + "px",
			opacity: 0.9
		},{
			duration: 3500
		});
		
		//create timeout and run the animation again
		var time = 1000// + (Math.floor(Math.random()*4501));
		
		//setTimeout("SmokeEffect.animate('" + id + "')", time);
		
		//remove the old one
		//setTimeout("$w8x('#" + tempId + "').remove()", 4000);
		
	}
}

