function showBox(e,boxId, position){
//position:
//default
// 1 2 3
// 4 - 5
// 6 7 8
//9 - automaticaly top or bottom depending on screen witdh/height
//10- automaticaly left or right depending on screen witdh/height
//default is y - auto; x under mouse
if (!e) var e = window.event;
 var box = $(boxId);
	if(box.style.display=='none'){			
			var clickedObj= e.srcElement;
			if(!e.srcElement){
				var clickedObj = e.target;
				while(clickedObj.nodeType != clickedObj.ELEMENT_NODE){
					clickedObj = clickedObj.parentNode;
				}
			}			
			var baseClickedObj = clickedObj;  
			
			var yPos=clickedObj.offsetTop+clickedObj.offsetHeight;
			var xPos=clickedObj.offsetLeft+clickedObj.offsetWidth;
			while(clickedObj.offsetParent!=null){
				clickedObj=clickedObj.offsetParent;
				yPos+=clickedObj.offsetTop;
				xPos+=clickedObj.offsetLeft;
			}			
			box.style.display="block";	
			if(position==11){
				xPos=e.layerX-5;
				yPos=e.layerY+15;
			}else if(position==1){
				xPos=xPos-box.offsetWidth - baseClickedObj.offsetWidth;
				yPos=yPos-box.offsetHeight - baseClickedObj.offsetHeight;				
			}else if(position==2){
				xPos-=baseClickedObj.offsetWidth;
				yPos=yPos-box.offsetHeight - baseClickedObj.offsetHeight;				
			}else if(position==3){
				yPos=yPos-box.offsetHeight - baseClickedObj.offsetHeight;	
			}else if(position==4){
				xPos=xPos-box.offsetWidth - baseClickedObj.offsetWidth;
				yPos=yPos - baseClickedObj.offsetHeight;	
			}else if(position ==5){				
				yPos=yPos - baseClickedObj.offsetHeight;	
			}else if(position ==6){
				xPos=xPos-box.offsetWidth - baseClickedObj.offsetWidth;				
			}else if(position ==7){
				xPos=xPos- baseClickedObj.offsetWidth;				
			}else if(position ==8){
				//default	posx posy	
			}else if(position ==9){				
				if(yPos+box.offsetHeight>TotalHeightOfThePage()){
					yPos=yPos-box.offsetHeight - baseClickedObj.offsetHeight;			
				}								
				xPos=xPos-baseClickedObj.offsetWidth;								
			}else if(position ==10){				
				yPos-=box.offsetHeight;				
				if(xPos+box.offsetWidth>TotalWidthOfThePage()){
					xPos=xPos-box.offsetWidth - baseClickedObj.offsetWidth;				
				}
			}else{
				if(yClickCoordinate(e)+box.offsetHeight>TotalHeightOfThePage()){			
					yPos-=box.offsetHeight;
				} else {
					yPos-=10;
				}
				if(xClickCoordinate(e)+box.offsetWidth>TotalWidthOfThePage()){
					xPos=xClickCoordinate(e)-box.offsetWidth - baseClickedObj.offsetWidth;				
				} else {
					xPos=xClickCoordinate(e);			   
				}
			}			
			//box.style.top=yPos-3;
			if (!isNaN(yPos)) box.style.top=yPos+"px";
			if (!isNaN(xPos)) box.style.left=xPos+"px";						
 } 
}
function makeVisible(boxId){
var box =$(boxId);
box.style.display='block'
}
function hideBox(boxId){
 var box = $(boxId);
 box.style.display='none';
}
function TotalHeightOfThePage(){
var totalHeightOfThePage;
var test1 = document.body.scrollHeight;
var test2 = document.body.offsetHeight;
if (test1 > test2) // all but Explorer Mac
{
	totalHeightOfThePage = document.body.scrollHeight;
}
else // Explorer Mac; would also work in Explorer 6 Strict, Mozilla and Safari
{
	totalHeightOfThePage = document.body.offsetHeight;
}
return totalHeightOfThePage;
}

function TotalWidthOfThePage(){
var totalWidthOfThePage;
var test1 = document.body.scrollWidth;
var test2 = document.body.offsetWidth;
if (test1 > test2)
{
	totalWidthOfThePage = document.body.scrollWidth;
}
else 
{
	totalWidthOfThePage = document.body.offsetWidth;
}
return totalWidthOfThePage;
}
function yClickCoordinate(e){
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY)
	{	
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY)
	{
		if (document.documentElement && !document.documentElement.scrollTop){
			posy = e.clientY;
		}
		// IE6 +4.01 but no scrolling going on
		else if (document.documentElement && document.documentElement.scrollTop){
			posy = e.clientY + document.documentElement.scrollTop;
		}
		// IE6 +4.01 and user has scrolled
		else if (document.body && document.body.scrollTop){
			posy = e.clientY + document.body.scrollHeight;
		}
		//alert(document.body.scrollHeight);
		
	}
	return posy;
}

function xClickCoordinate(e){
	var posx = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY)
	{	
		posx = e.pageX;
	}
	else if (e.clientX || e.clientY)
	{
		if (document.documentElement && !document.documentElement.scrollLeft){
			posx = e.clientX;
		}		
		else if (document.documentElement && document.documentElement.scrollLeft){
			posx = e.clientX + document.documentElement.scrollLeft;
		}		
		else if (document.body && document.body.scrollTop){
			posx = e.clientX + document.body.scrollWidth;
		}	
	}
	return posx;
}