function doPopup(layer,obj) {
    HidAll();
	  if (!document.getElementsByTagName) return false; 
	  var helpTextDiv = layer;
  	  if(helpTextDiv.style.display == "block"){
			helpTextDiv.style.display = 'none';
	}else{
		/* display popup */
		helpTextDiv.style.zIndex = '10';
		helpTextDiv.style.display = 'block';
		helpTextDiv.style.position = 'absolute';
		//helpTextDiv.style.right = right;
		var coors = findPos(obj);
		//alert(coors[0]+ " : " + coors[1]);
		coors[0] -= helpTextDiv.offsetWidth;
		coors[1] += 20;
		helpTextDiv.style.top = coors[1] + 'px';
		if (coors[0] < 0 ) coors[0] = 20;
		helpTextDiv.style.left = 200 + 'px';
		helpTextDiv.focus();
	} 
	 
}

function doPopupMiddle(layer,obj) {
    HidAll();
	  if (!document.getElementsByTagName) return false; 
	  var helpTextDiv = layer;
  	  if(helpTextDiv.style.display == "block"){
			helpTextDiv.style.display = 'none';
	}else{
		/* display popup */
		helpTextDiv.style.zIndex = '10';
		helpTextDiv.style.display = 'block';
		helpTextDiv.style.position = 'absolute';
		//helpTextDiv.style.right = right;
		var coors = findPos(obj);
		//alert(coors[0]+ " : " + coors[1]);
		coors[0] -= helpTextDiv.offsetWidth;
		coors[1] -= (helpTextDiv.offsetHeight/2);
		helpTextDiv.style.top = coors[1] + 'px';
        helpTextDiv.style.left = '250px';
		helpTextDiv.focus();
	} 
	 
}


function closePopups(layer){
		ThisPopup = document.getElementById(layer);						
		if(ThisPopup.style.display == "block"){
			ThisPopup.style.display = 'none';
		}
}

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };



function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function findPos(obj)
{
	
	var curleft = curtop = 0;
	
	if (obj.offsetParent) {
	
	    var s = obj.id +"_" + obj.offsetLeft+" - ";
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
			s+= obj.tagName+"_" + obj.id+ ":"+obj.offsetLeft+" - ";
			
		}
		s = s+ "------>" + curleft;
		//document.write(s);
	}
	return [curleft,curtop];
}

function HidAll() {
var layers = document.getElementsByTagName("div");
for (var i=0;i<layers.length;i++) {
if(layers[i].className == "popup_item")
    layers[i].style.display = "none";
}
// repeat for select and textarea if needed
}

         