
/**** vars ****/
var browser=navigator.appName;
var autoanimate;
var hoveranimate = 1;
var direction = "+";
var all_clouds = 'div.cloud_9, div.cloud_7, div.cloud_2, div.cloud_4, div.cloud_8, div.cloud_5, div.cloud_11, div.cloud_10, div.cloud_12, div.cloud_1';

/**** window load - has to be window load due to safari & needing to manipulate css ****/
$(window).load(function(){
/*ie hates this moving clouds - so turning it off til find out why..*/
	if(browser != "Microsoft Internet Explorer"){
		/*click link to move clouds */
		$('.animate_clouds').click(function(){
			animate_clouds(direction, 1, 0);
			if(direction == "+"){
				direction = "-";
			}else {
				direction = "+";
			}
			return false;
		});
		/*click link to stop clouds*/
		$('.stop_clouds').click(function(){
			clearTimeout(autoanimate);
			$('div.floating_cloud').stop();
			return false;
		});
		/*if you hover on a cloud they move*/
		if(hoveranimate == 1){
			$(all_clouds).hover(function(){
				animate_clouds(direction, 1, '#'+this.id);
				if(direction == "+"){
					direction = "-";
				}else {
					direction = "+";
				}
			},
			function(){
				clearTimeout(autoanimate);
				$('div.floating_cloud').stop();
			}
			);
		}		
	
	}

});




function animate_clouds(symbol, loop, id){
	if(id != 0){
		divs = id;
	}else{
		divs = all_clouds;
	}	
	$(divs).each(function(){
		amount_left = 1 + (Math.random());
		amount_top = 2 + (Math.random());
		if(symbol == "+"){
			$(this).animate({"left": "+="+amount_left+"%", "top": "+="+amount_top+"px"}, 4000);
		}else{
			$(this).animate({"left": "-="+amount_left+"%", "top": "-="+amount_top+"px"},4000);			
		}		
	});
	if(symbol == "+" && loop == 1){
		autoanimate = setTimeout("animate_clouds('-')", 4200);
	}else if(loop == 1){
		autoanimate = setTimeout("animate_clouds('+')", 4200);
	}
	
}
