// JavaScript Document
function findPos(w,h,obj,x,y)
{
	var curleft = 0;
	var curtop = 0;
	if (window.ActiveXObject) 
	{
	var screenX = document.documentElement.offsetWidth;
  	var screenY = document.documentElement.offsetHeight;
	}
	else
	{
	var screenY = window.innerHeight;
	var screenX = window.innerWidth;
	}
	//gecko type
	if (obj.offsetParent) {
		curleft = (screen.width-450)/2;
		curtop = (screen.height-300)/2;
	}
	//ie
	if (x != null) {
		curleft = x;
		}
	if (y != null) {
		curtop = y;
		}
		
	if ((curleft+w)>screenX) {
		curleft=screenX-w-15; 
		}
	if ((curtop+h)>screenY) {
		curtop=screenY-h-15; 
		}
	return [curleft,curtop];
//	return [315, 218];
}
function createObject(w,h,title,desc,id,css) {
	
	var toolTip=document.createElement("div");
	toolTip.id=id;
	if (window.ActiveXObject) 
		{
		toolTip.setAttribute("className",css);
		}
	else {
		toolTip.setAttribute("class",css);
		}
	if (w != null) {
		toolTip.style.width=w+'px';
		}
	else {
		toolTip.style.width= '200px';
		}
	if (h != null) {
		toolTip.style.height=h+'px';
		var tipH = h-20;
		}
	else {
		toolTip.style.height= '100px';
		var tipH = 80;
		}
    toolTip.style.visibility = "hidden";
	
	
	var content = "<div style=\"height:"+tipH+"px; overflow:auto;\">"+desc+"</div>";
	content += "<a href=\"javascript:hideObject('"+id+"');\">close window</a>";
	toolTip.innerHTML=content;
	document.body.appendChild(toolTip);
}
function showObject(obj,id,x,y) {
  var divW = document.getElementById(id).offsetWidth;
  var divH = document.getElementById(id).offsetHeight;
  var coors = findPos(divW,divH,obj,x,y);
  var bx = document.getElementById(id)
  document.getElementById(id).style.left= coors[0] + 'px';
  document.getElementById(id).style.top= coors[1] + 'px';
  document.getElementById(id).style.visibility = "visible";
  document.getElementById(id).style.opacity = .8;
	document.getElementById(id).style.filter = 'alpha(opacity=' + 80 + ')';
  bx.setAttribute("className", "popupvisible"); 

}
function hideObject(id) {
  document.getElementById(id).style.visibility = "hidden";
}

