var IE = document.all?true:false;
var tempX = 0;
var tempY = 0;
var box_id_ = '';
var deg_ ='';
var table_id = '';
var table_width_ = '';
var table_height_ = '';
var error_ = 0;
var id_interval;
var last_id = 1;

if (IE){
	var aprox_width = 30;
	var aprox_height = 30;
} 
else {
	var aprox_width = 10;
	var aprox_height = 10;	
}

function getMouseXY(e) {
	if (IE) { 
		tempX = event.clientX + document.body.scrollLeft;
		tempY = event.clientY + document.body.scrollTop;		
	}
	else {  
		tempX = e.pageX;
		tempY = e.pageY;		
	} 
}	

function set_error(val){
	error_ = val;	
	box_id_.style.left = tempX - table_width_ - aprox_width - 50;
	box_id_.style.top = tempY - table_height_ - aprox_height - 50;	
}

function off_me(){
	if (error_ == 0){
		box_id_.style.left = 0;
		box_id_.style.top = 0;
		box_id_.style.visibility = "hidden";				
		box_id_ = '';
		table_id = '';
		table_width_ = '';
		table_height_ = '';
		window.clearInterval(id_interval); 
	}
}

function display_box(id,type){		
	if (!IE) calculate(id);
	if (type == 1) window.clearInterval(id_interval);
	else {
		last_id = id;
		id_interval = window.setInterval(off_me,10);
	}
}

function calculate(id){
	if (box_id_ == '' || (box_id_ != '' && box_id_ != id)) 	{
		box_id_ = document.getElementById("box_"+id);		
		box_id_.style.visibility = "visible";
		if (last_id != id && document.getElementById("box_"+last_id)) document.getElementById("box_"+last_id).style.visibility = 'hidden';
		table_width_  = '';
		table_height_ = '';
	}
	if (table_id == '')	table_id_ = document.getElementById("table_"+id);		
	if (table_width_ == '' ) {
		table_width_ = table_id_.scrollWidth;
		table_height_ = table_id_.scrollHeight;
	}
}

function show_box(id,event){			
	if (IE) calculate(id);
	getMouseXY(event);	
	box_id_.style.left = tempX - table_width_ - aprox_width;
	box_id_.style.top = tempY - table_height_ - aprox_height;
}