
var imgStart = 10;
var hasLooped = 0;

		//holds all images
	var	imgArray = ['icon1.png', 'icon9.png', 'icon10.png', 'icon6.png', 'icon5.png', 'icon7.png', 'icon4.png', 'icon8.png', 'icon2.png', 'icon3.png']; 
	var imgUp = [38, 28, 12, 34, 45, 30, 11, 20, 40, 62];

		//IE gets a separate alias-friendly set of images
		if (navigator.userAgent.indexOf('MSIE') !=-1)
		{
		imgArray = ['1.gif', '9.gif', '10.gif', '6.gif', '5.gif', '7.gif', '4.gif', '8.gif', '2.gif', '3.gif']; 
		}

var SmokeEffect = {
	
	imgLocation: "", //url to image here
	smokeWidth: 80, //standard width
	smokeHeight: 45, //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.animate1('" + id + "')", 2000);
	},
	
	animate1: function(id) {


		//increase imgStart
		imgStart--;
		if (imgStart == -1){ 
			hasLooped = 1;
		}

		if (hasLooped < 1){

	
		//alert(imgStart);

		//create the smoke cloud
		var puff = document.createElement("IMG");
		$(puff).attr("src", 'http://www.formatdynamics.com/animation/' + imgArray[imgStart]);
		$(puff).attr("alt", "puff");
		$(puff).attr("class", "puff");

		//create a temp id for the cloud so we can delete it later on
	//	tempId = "puff" + imgStart;
		$(puff).attr("id", "puff" + imgStart);
		
		//append the icon to the body
		$('#homepage').append($(puff));		

		var objPos = $('#' + id).offset();
		
		var firstLeft = (((SmokeEffect.smokeWidth + 5) + ((imgStart * 58))));
//		var firstLeft = 644;
//		var firstUp = (10 + ((Math.random() * 60)));
		var firstUp = imgUp[imgStart];
//		var secondLeft = (150 + firstLeft);

		//do smoke animation
		$(puff).css({
			top: firstUp + "px",
			left: firstLeft + "px",
			width: SmokeEffect.smokeWidth + "px",
			height: SmokeEffect.smokeHeight + "px",
			zIndex: 25,
			opacity: 0
		}); 

		$(puff).animate({
			width: SmokeEffect.smokeWidth + "px",
			height: SmokeEffect.smokeHeight + "px",

			opacity: 1
		}, 2000, 'linear', { //speed (lower = faster)

		}); 	
	}

		//create timeout and run the animation again
	var time = 50; //how long it takes icons to appear (lower is slower)
		
	setTimeout("SmokeEffect.animate1('" + id + "')", time);
		
		//remove the old one
//	setTimeout("$('#" + tempId + "').remove()", 75000); //time removes how long sign stays on screen

	}

}

