var objectFloat = null;
var max_height;
var max_width;
var speed;
var cur_top;
var cur_left;
var objectHeight;
var objectWidth;

var top_diection;
var left_diection;
var intervalId;

function setFloatObject(obj, maxHeight, maxWidth, s, top, left, td, ld, oh, ow){
	objectFloat = obj;
	//objectHeight = $(objectFloat).height();
	//objectWidth = $(objectFloat).width()
	objectHeight = oh;
	objectWidth = ow;
	max_height = maxHeight - objectHeight;
	max_width = maxWidth - objectWidth;
	speed = s;
	cur_top = top;
	cur_left = left;
	top_diection = td;
	left_diection = ld;
	$(objectFloat).css("top", cur_top);
	$(objectFloat).css("left", cur_left);
}

function startFloat(){
	intervalId = setInterval ("move()", speed);
	$(objectFloat).css("display", "");
}

function stopFloat(){
	clearInterval(intervalId);
}

function move(){
	if(top_diection == 0){
		if(cur_top+1 >= max_height){
			top_diection = 1;
			cur_top--;
		}
		else{
			cur_top++;
		}
	}
	else{
		if(cur_top-1 <= 0){
			top_diection = 0;
			cur_top++;
		}
		else{
			cur_top--;
		}
	}
	
	if(left_diection == 0){
		if(cur_left+1 >= max_width){
			left_diection = 1;
			cur_left--;
		}
		else{
			cur_left++;
		}
	}
	else{
		if(cur_left-1 <= 0){
			left_diection = 0;
			cur_left++;
		}
		else{
			cur_left--;
		}
	}
	$(objectFloat).css("top", cur_top);
	$(objectFloat).css("left", cur_left);
}



