jQuery(function( $ ){
	$("#bl_logo").makeBob({distance: 10, speed: 4650});
	//by default, the scroll is only done vertically ('y'), change it to both.
	$.scrollTo.defaults.axis = 'xy'; 			

	
	//TOC, shows how to scroll the whole window
	$('.scroll').click(function(){//$.scrollTo works EXACTLY the same way, but scrolls the whole screen
		var params = this.rel;
		params = params.split(',');
		//alert(params[0]);
		var top_value = params[0];
		var left_value = params[1];
		var speed = params[2];
		speed = parseFloat(speed);
		//alert(params);
		if(this.name != ''){
			$.scrollTo({ top:top_value, left:left_value }, speed, {easing:this.name});
		}else{
			$.scrollTo({ top:top_value, left:left_value }, speed);
		}
		return false;
	});
	
	cloudspace=new Array();
	x = 1;
	$('.cloud').each(function(){
		cloudspace[x]=new Array();
		var left = $("#" + this.id).attr("offsetLeft");
		var width = $("#" + this.id).attr("offsetWidth");
		cloudspace[x]['w']=width;
		cloudspace[x]['p']=left;
		x++;
	});
	setInterval('TJPfloat();',50);
});
	




function TJPmovecloud(cid,pos) {
	if(pos > stagespace && window.paused>0 ) {
		return;
	}
	if(pos+cloudspace[cid]['w']>stagespace) {
		document.getElementById('cloud'+cid).style.width=stagespace-pos+'px';
	} else {
		document.getElementById('cloud'+cid).style.width=cloudspace[cid]['w']+'px';
	}
	document.getElementById('cloud'+cid).style.left=pos+'px';
}

function TJPfloat() {
	for(i=1;i<cloudspace.length;i++) {
		if(cloudspace[i]['p'] >= stagespace){
			cloudspace[i]['p']=-cloudspace[i]['w'];
		}else if(cloudspace[i]['p'] <= -cloudspace[i]['w']){
			cloudspace[i]['p']=stagespace;
		}
		cloudspace[i]['p']-=1+cloudspace[i]['w']/200;
		TJPmovecloud(i,cloudspace[i]['p']);
	}
}


