/****************************************************/
function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }

/***************************************************/
function findAbsoluteX(objSource) {
	var lngX = 0;
							
	if (document.getElementById || document.all)
	{
		while (objSource.offsetParent)
		{
			lngX += objSource.offsetLeft;
			objSource = objSource.offsetParent;
		}
	}
	else if (document.layers)
		lngX += objSource.x;
								
	return lngX;
}

/******************************************************************************/
function findAbsoluteY(objSource)
{

//alert(objSource.top);

	var lngY = 0;
	if (document.getElementById || document.all)
	{
		while (objSource.offsetParent)
		{
			lngY += objSource.offsetTop;
			objSource = objSource.offsetParent;
		}
	}
	else if (document.layers)
		lngY += objSource.y;
	return lngY;
}
/***************************************************************************************************/
function displayPopup(strParent,strPopupName,strPosition) {

    var objToolTip;
    var objParent;
    var intLeft;
    var intTop;
				
	//strParent = the id of the <TD> tag for this menu item
	//strPopupName = the name of the menu to display
	//strPosition = the position relative to the parent tage that you would 
	//				like the pop up to appear at. Possible values are:
	//				left	- popup will appear to the left
	//				right	- popup will appear to the right
	//				above	- popup will appear above
	//				below	- popup will appear below
			
	//Get current element for positioning purposes
	if (document.getElementById) {

		//get the parent tag object	
		objParent = document.getElementById(strParent);
		intLeft = findPosX(objParent);
		intTop = findPosY(objParent);

		//Get the popup object
		objToolTip = document.getElementById(strPopupName);
					
		//Hide the popup. This is a toggle.
		if (objToolTip.style.display == "inline") {
			hidePopup(strPopupName);
        }
        else
        {
         
			objToolTip.style.position = "absolute";            
            objToolTip.style.display = "inline";
               
            var intOffset = 5;
            
            if (strPosition=="") {strPosition="below"}
            
            if (strPosition == "above") {
                intOffset = 0 - (intOffset + objToolTip.clientHeight);
            } else if (strPosition == "below") {
                intOffset = 5 + objParent.offsetHeight;
            }
            
            
			//position the popup appropriately
            intTop = parseInt(intTop + intOffset);
            if (intTop < 5)
                intTop = 5;

            if (intLeft < 20)
                intLeft = 20;
                
            objToolTip.style.top = intTop;
            objToolTip.style.left = intLeft;
        }
    }
}

//******************************************************************************
function hidePopup(strName) {

	if (document.getElementById(strName)) {   
		document.getElementById(strName).style.display = "none";
    }
}

//******************************************************************************
function catchKeyDown(btnName, event)
{
	var btn = document.getElementById(btnName);
	if (document.all)
	{
		if (event.keyCode == 13)
		{
		event.returnValue=false;
		event.cancel = true;
		btn.click();
		}
	}
	else if (document.getElementById)
	{
		if (event.which == 13)
		{
		event.returnValue=false;
		event.cancel = true;
		btn.click();
		}
	}
	else if(document.layers)
	{
		if(event.which == 13)
		{
		event.returnValue=false;
		event.cancel = true;
		btn.click();
		}
	}
}	
/****************************************************/
function setOpacity(item,value) {
	item.style.opacity = value/10;
	item.style.filter = 'alpha(opacity=' + value*10 + ')';
}
/****************************************************/
function centerMe2 (Item,intHeight,intWidth) {
	//var Item
	var winl = 0
	var wint = 0
	
	//Item = document.getElementById(ItemName);   
	
	var scrollY = parseInt(document.body.scrollTop);
	var scrollX = parseInt(document.body.scrollLeft);
	
	if (Item!=null) {
		if (intHeight==0 && intWidth==0 ) {
			winl = (document.body.offsetWidth-Item.offsetWidth)/2;
			wint = (document.body.offsetHeight-Item.offsetHeight)/2;
		} else {
			winl = (document.body.offsetWidth-intWidth)/2;
			wint = (document.body.offsetHeight-intHeight)/2;
		}
		
		Item.style.top = wint + scrollY;
		Item.style.left = winl + scrollX;
	}
}

/****************************************************/
function SetLayerPosition(Item) {
	var elem = Item;    
	var scrollX = parseInt(document.body.scrollLeft);
	var scrollY = parseInt(document.body.scrollTop);
	elem.style.left = (window.screen.availWidth/2 + scrollX) + "px";
	elem.style.top = (document.body.offsetWidth-Item.offsetWidth)/2 + "px";
	elem = null;
}	

/****************************************************/
function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }
   


/****************************************************/
function hideModalPopup(strDialogId) 
{
	var objPanel = document.getElementById(strDialogId);
	if (objPanel!=null) {
		objPanel.style.position = "relative";            
		objPanel.style.display = "none";
		objPanel.style.zIndex = 1;
	}
				
	//get rid of panel behind price frame
	var objFrame = document.getElementById("backdropframe");
	if (objFrame!=null) {
		document.body.removeChild(objFrame);
	}

	//Remove backdrop div
	var objBackdrop = document.getElementById("backdrop");
	if (objBackdrop!=null) {
		document.body.removeChild(objBackdrop);
	}
	return false;	
}	