﻿var ARRAY_DELIMITER = "&&";
var blnDebugMode = true;
var sEmptyField = "EmptyField";

function Trim(s) 
{
  while (s.substring(0,1) == ' ') 
  {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') 
  {
    s = s.substring(0,s.length-1);
  }
  return s;
}


/*********************************
 porpuse: Format
 inputs : 
 return:  
 comments:
**********************************/
function Format(total,decimals)
{
	 total = new String(total)
	 
	  while(total.search(",") != -1) 
		total = total.replace(",","") 
		
      var num = parseFloat(total);
      
      num = Math.abs(num) 
     
      // First section sets non-number value to zero
          if (!(num = parseFloat(num)))
               num = "0.00";
      // Second section sets two decimal place format
          var Pad = "";
          num = "" + Math.floor(num * Math.pow(10,decimals + 1) + 5);
          // Pad if less than 0.10
          if(num.length < decimals+1) 
          {
               for(Count = num.length; Count <= decimals; Count++)
                    Pad += "0";
          }
          num = Pad + num;
         
     // Parse into final string
          num = num.substring(0,num.length - decimals - 1) + 
               "." + num.substring(num.length - decimals -1, num.length -1);
     // If less than 1 then add 0 to the left of the decimal
          if((num == "") || (parseFloat(num) < 1))
               num = "0" + num;
     // Final section returns formatted number
		
		num = SetNumberComma(num)
		if (eval(total) < 0)
		{
			num = "-" + num;
		}
		
          return num;
}

function RemoveCommas(sNumber)
{	
	var num;
	while(sNumber.search(",") != -1) 
		sNumber = sNumber.replace(",","") 
	num = parseFloat(sNumber);
   // num = Math.abs(num) ;
    return num;
}
/*********************************
 porpuse: SetNumberComma
 inputs : 
 return:  
 comments:
**********************************/
function SetNumberComma(val)
{
	val = new String(val)
	
	var pos = val.indexOf(".",0);
	var decimalVal = val.substring(pos) 
	val = val.substring(0,pos) 
	
	// remove "," from string	
	
	while(val.search(",") != -1) 
		val = val.replace(",","") 
	
	

	if (val.length > 3)
	{
		var formatVal = ""
		lengthNum = val.length
		j=1
		for (var i=0; i < lengthNum ; i++){
			
			formatVal = formatVal + val.substr(val.length-1,1)
			val = val.substr(0,val.length-1)
			if ((j==3)&& (i != lengthNum-1)) 
			{
				j = 1
				formatVal = formatVal + ","	
			}
			else
			{
				j=j+1
			}
		}
		val = formatVal;
		formatVal = "";
		lengthNum = val.length
		for (var i=0; i < lengthNum ; i++)
		{
			formatVal = formatVal + val.substr(val.length-1,1)
			val = val.substr(0,val.length-1)
		}
	}
	else
	{
		formatVal = val
	}			
	
	return formatVal + decimalVal;
}

function GetInNumericFormat(sValue,DigitsAfterDot)
{
	if (sValue != "")
	{
		if (IsNumber(sValue))
		{
			var Val = Format(sValue,DigitsAfterDot);
			return Val;
		}		
	}
	else
		return "0.00";		
}

function SetFormat(oElement,DigitsAfterDot)
{
	if (!IsNull(oElement.value))
	{
		if (IsNumber(oElement.value))
		{
			var Val = Format(oElement.value,DigitsAfterDot);
			oElement.value = Val;
		}		
	}		
	
	return true;
}

/*******************************************************
 porpuse: return array which keep the document data
 inputs : document
 return:  
 comments:
*******************************************************/
function BuildFormArrayData(objDocument,iMaxField)
{
	var arrData = new Array(iMaxField);
	var strData = "";
	
	//Reset all array to emply fields
	for(i=0;i<arrData.length;i++)
		arrData[i] = sEmptyField;
	
	
	if(browser.isIE)
	{
		if(objDocument == document.all)
		{
			for(ItemIndex = 0; ItemIndex < objDocument.length; ItemIndex++)
			{	 	
				ind = objDocument[ItemIndex].getAttribute("FIELD_ENUM");
				
				if (objDocument[ItemIndex].getAttribute("ParticipantInSave") != "0" && IsNumber(ind))
				{
					if ((objDocument[ItemIndex].tagName.toLowerCase() == "input") || (objDocument[ItemIndex].tagName.toLowerCase() == "select") || (objDocument[ItemIndex].tagName.toLowerCase() == "textarea"))
					{
						if (objDocument[ItemIndex].type.toLowerCase() == "checkbox" || objDocument[ItemIndex].type.toLowerCase() == "radio")
						{					
							if (objDocument[ItemIndex].checked)
								arrData[ind] = 1;
							else
								arrData[ind] = "0";
						}
						else if(objDocument[ItemIndex].tagName.toLowerCase() == "select")
						{	
							if (objDocument[ItemIndex].selectedIndex == -1)
								arrData[ind] = "";
							else if ((objDocument[ItemIndex].value == 0) && (objDocument[ItemIndex].options[objDocument[ItemIndex].selectedIndex].innerText == ""))
								arrData[ind] = "";
							else
								arrData[ind] = objDocument[ItemIndex].value;
						}
						else if (objDocument[ItemIndex].type.toLowerCase() == "text" ||
								 objDocument[ItemIndex].type.toLowerCase() == "hidden" ||
								 objDocument[ItemIndex].type.toLowerCase() == "password")
						{
							arrData[ind] = objDocument[ItemIndex].value;
						}
						else if(objDocument[ItemIndex].tagName.toLowerCase() == "textarea")
						{	
							arrData[ind] = objDocument[ItemIndex].innerText;
						}
					}
					else if  (objDocument[ItemIndex].tagName.toLowerCase() == "label")
					{
						if (objDocument[ItemIndex].getAttribute("ParticipantInSave") != "0" && IsNumber(ind))
							arrData[ind] = objDocument[ItemIndex].innerText;
					}
				}
			}
		}
	}
	else
	{
		BuildRecoursiveData(objDocument,arrData);
	}
		
	
	return arrData;
}

function BuildRecoursiveData(objDocument,arrData)
{
	for (var i=0; i < objDocument.childNodes.length ; i++)
	{
		var oNode = objDocument.childNodes[i];
		
		if(oNode.tagName == null)
		{
			continue;
		}
		
		if(oNode.childNodes.length > 0)
		{
			BuildRecoursiveData(oNode,arrData);
		}	
		
		if ((oNode.tagName.toLowerCase() == "input") || (oNode.tagName.toLowerCase() == "select") || (oNode.tagName.toLowerCase() == "textarea"))
		{
			ind = oNode.getAttribute("FIELD_ENUM");
			
			if (IsNumber(ind))
			{
				if (oNode.type.toLowerCase() == "checkbox" || oNode.type.toLowerCase() == "radio")
				{					
					if (oNode.checked)
						arrData[ind] = 1;
					else
						arrData[ind] = "0";
				}
				else if(oNode.tagName.toLowerCase() == "select")
				{	
					if (oNode.selectedIndex == -1)
						arrData[ind] = "";
					else if ((oNode.value == 0) && (oNode.options[oNode.selectedIndex].innerText == ""))
						arrData[ind] = "";
					else
					{
						if(oNode.value == 0)
							arrData[ind] = "";
						else	
							arrData[ind] = oNode.value;
					}
				}
				else if (oNode.type.toLowerCase() == "text" ||
							oNode.type.toLowerCase() == "hidden" ||
							oNode.type.toLowerCase() == "password")
				{
					arrData[ind] = oNode.value;
				}
				else if(oNode.tagName.toLowerCase() == "textarea")
				{	
					arrData[ind] = oNode.value;
				}
			}	
		}
		else if  (oNode.tagName.toLowerCase() == "label")
		{
			ind = oNode.getAttribute("FIELD_ENUM");
			
			if (IsNumber(ind))
				arrData[ind] = oNode.value;
		}
	}
}

function DisplayData(val)
{
	if ((IsNull(val)) || (val == 0))
	{
		return " ";
	}
	else
	{
		return val;
	}
}

/*******************************************************
 porpuse: Errors handling msg
 inputs : the DebugMode
 return:  
 comments:
*******************************************************/

function DebugErrorDetails(strHTML,blndebugMode)
{
	if (blndebugMode) 
	{	
		var w = window.open ("","error_window","width=500,height=300,toolbar=no,location=no,directories=no,status=no,menubar=no")
		w.document.write("<HTML>");
		w.document.write("<BODY>");
		w.document.write("<CENTER>");
		w.document.write("<H2>Remote Scripting Call Returned the following:</H2>");
		w.document.write("<TABLE border=1 cellpadding=10 bgcolor=#dddddd><TR><TD>");
		w.document.write(strHTML)
		w.document.write("</TD></TR></TABLE>");
		w.document.write("<FORM id=form1 name=form1><INPUT type=button value=\" OK \" onclick=self.close()></FORM>");
		w.document.write("</CENTER>");
		w.document.write("</BODY>");
		w.document.write("</HTML>");
	}
	else
	{
		alert("אירעה שגיאה")
	}
}

/*******************************************************
 porpuse: Errors handling - run time error
 inputs : the rs object
 return:  
 comments:
*******************************************************/
function RSErrorFunction(retObj)
{
	if (retObj.status != 0) 
	{
		DebugErrorDetails(retObj.data,blnDebugMode)
		return false;
	}	
}

/*******************************************************
 porpuse: open the calander window
 inputs : 
 return:  the date
 comments:
*******************************************************/
function OpenCal(Control,SelectedDate)
{
	var retval=null;
	
	retval = top.window.showModalDialog(VIRTUAL_DIRECTORY +"Fnd/Calendar/calendar_main.aspx?SelectedDate="+SelectedDate,window,
										"center:yes;dialogWidth:215px;dialogHeight:205px;status:no")
	if (retval != null) 
	{
		Control.value = retval 									
	}	
	return retval;
}

/*******************************************************
 porpuse: return a select attributes in HTML format
 inputs : select id
 return:  select attributes in HTML format
 comments:
*******************************************************/
function GetExistSelectAttributes(objDocument,SelectID)
{
	/*var _emptyTags = {
	"IMG":   true,
	"BR":    true,
	"INPUT": true,
	"META":  true,
	"LINK":  true,
	"PARAM": true,
	"HR":    true
	};

	HTMLElement.prototype.__defineGetter__("outerHTML", function () {
	var attrs = this.attributes;
	var str = "<" + this.tagName;
	for (var i = 0; i < attrs.length; i++)
		str += " " + attrs[i].name + "=\"" + attrs[i].value + "\"";

	if (_emptyTags[this.tagName])
		return str + ">";

	return str + ">" + this.innerHTML + "</" + this.tagName + ">";});*/

		// get the select HTML	
		
		
		
	
		if(browser.isIE)
			var strSelect = eval("objDocument.all." + SelectID +".outerHTML");
		else
		{
	
			var str = "<select id=" + SelectID  + ">" + objDocument.getElementById(SelectID).innerHTML + "</select>";
			var strSelect = str;
			
		}
		
		//alert(strSelect);
	
		
		//var strSelect = eval("objDocument.getElementById(" + SelectID +").outerHTML");
		
		//alert(strSelect);
		
		// search the end of the select attributes
		var pos	 = strSelect.search('>'); 
		// get the select attributes
		strSelect = strSelect.substring(0,pos+1)
		
		return(strSelect)
}

function GetExistSelectAttributesWithAttributes(objDocument,SelectID,sTagAttributes)
{
	/*var _emptyTags = {
	"IMG":   true,
	"BR":    true,
	"INPUT": true,
	"META":  true,
	"LINK":  true,
	"PARAM": true,
	"HR":    true
	};

	HTMLElement.prototype.__defineGetter__("outerHTML", function () {
	var attrs = this.attributes;
	var str = "<" + this.tagName;
	for (var i = 0; i < attrs.length; i++)
		str += " " + attrs[i].name + "=\"" + attrs[i].value + "\"";

	if (_emptyTags[this.tagName])
		return str + ">";

	return str + ">" + this.innerHTML + "</" + this.tagName + ">";});*/

		// get the select HTML	
		
		
	
		if(browser.isIE)
			var strSelect = eval("objDocument.all." + SelectID +".outerHTML");
		else
		{
			
			var str = "<select " + sTagAttributes + " id=" + SelectID  + ">" + objDocument.getElementById(SelectID).innerHTML + "</select>";
			var strSelect = str;
			
		}
	
	
		
		//var strSelect = eval("objDocument.getElementById(" + SelectID +").outerHTML");
		
		//alert(strSelect);
		
		// search the end of the select attributes
		var pos	 = strSelect.search('>'); 
		// get the select attributes
		strSelect = strSelect.substring(0,pos+1)
		
		return(strSelect)
}

 

/*******************************************************
 porpuse: change the select outerHTML 
 inputs : 
 return:  
 comments:
*******************************************************/
function ChangeOuterHTML(arrObj)
{
	SelectName = arrObj[0];
	SelectedItem = arrObj[1];
	objDocument = arrObj[2];
	

	
	if(browser.isIE)
	{
		eval("objDocument.all." + SelectName + ".outerHTML = arrObj[3]")
		eval("objDocument.all." + SelectName + ".value = SelectedItem")	
	}
	else
	{
		// Get the select parent object !
		var obj = objDocument.getElementById(SelectName).parentNode;
		obj.innerHTML = arrObj[3] ;
		
		objDocument.getElementById(SelectName).value = SelectedItem;
		
	}
	
	try 
	{
		strBuffer = document.getElementById("divDetails").innerHTML;
	}
	catch(e)
	{
		
	}
	
}
/*******************************************************
 porpuse: get the current date
 inputs : 
 return:  
 comments:
*******************************************************/
function GetDate()
{
	var dDate
	var strDate
	var day
	var month

	dDate = new Date();  
	
	day  = dDate.getDate();
	if ((day > 0) && (day < 10))
		day = "0" + day;
	
	month  = dDate.getMonth ()+ 1;
	if ((month > 0) && (month < 10))
		month = "0" + month;
	
	sDate = day + "/"
	sDate += month + "/"                         
	sDate += dDate.getYear ()                 
	return(sDate);

}


/*******************************************************
 porpuse: add option to select list
 inputs : 1. select value
		  2. select text
		  3. SelectName
 return:  
 comments:
*******************************************************/
function addSelectOption(Val,Desc,SelectName)
{
	// add an option to cboOfferID
	var oOption;
	oOption = document.createElement("OPTION");
	oOption.value=Val;
	oOption.text=Desc;
	eval("document.all." + SelectName + ".add(oOption)");
	eval("document.all." + SelectName + ".value = " + Val);
}

/*******************************************************
 porpuse: change option in existing select lise
 inputs : 1. select value
		  2. select text
		  3. SelectName
 return:  
 comments:
*******************************************************/
function UpdateSelectOption(Desc,SelectName)
{
	var index; 
	//index = document.all." + SelectName + ".selectedIndex
	eval("index = document.all." + SelectName + ".selectedIndex");
	eval("document.all." + SelectName + "[" + index + "].text = " + 'Desc');
}

/*******************************************************
 porpuse: remove the selected option in existing select lise
 inputs : 
 return:  
 comments:
*******************************************************/
function RemoveSelectOption(val,SelectName)
{	
	var found = false;
	var i=0;
	var pos;
	var optVal;
	
	eval("var len = document.all." + SelectName + ".options.length");
	while ((!found) && (i < len))
	{
		optVal = eval("document.all." + SelectName + "[i].value");
		pos = optVal.search('@');
		if (pos != -1)
		{
			optVal = optVal.substr(0,pos);
		}	
		if (optVal == val)
		{
			found = true;
			eval("document.all." + SelectName + ".remove(" + i + ")");
			eval("document.all." + SelectName + ".value = ''");
			
		}
		i = i + 1;
	}		
}	

/***********************************************
 porpuse: perform the main action when the enter key pressed
 inputs :
 return:
 comments:
***********************************************/
function OnEnterKeyPress(e,FunctionName) 
{
	
   if (e.keyCode == 13)
   {
	   if (document.activeElement.type)
	   {
			if (document.activeElement.type.toLowerCase() != "button")
			{
				if (document.activeElement.type.toLowerCase() != "textarea")
				{
					e.returnValue = false ;
					eval(FunctionName + "()");
				}
				else
				{
					//window.event.returnValue = false 
				}	
			}	
	   }
	   else
	   {
		    eval(FunctionName + "()");
	   }	
						    						
   }   
   
}

/*******************************************************
 porpuse: check if the number is integer
 inputs : 
 return:  
 comments:
*******************************************************/
function IsIntegerNum(num)
{
	
	// get the number of the integer digits 
	var int = num.lastIndexOf('.');
	if (int != -1)
	{
		// get the full num length
		var fulllength = num.length;

		if (fulllength - int > 1)
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	return true;	
}

/*************************************************************************************
 porpuse: reset the SELECT object values
 inputs : 
 return:  SELECT object name
 comments:
**************************************************************************************/
function ResetCombo(objName)
{
	eval("document.all." + objName + ".options.length=1;");
	eval("document.all." + objName + ".options.options[0].value = '';");
	eval("document.all." + objName + ".options.options[0].text = '';");
}	
		
/*************************************************************************************
 porpuse: return the left value after removing the @ sign from the select value
 inputs : 
 return:  
 comments:
**************************************************************************************/
function GetLeftVal(val)
{
	var pos = val.search('@');
	if (pos != -1)
	{
		return val.substr(0,pos);
	}
	else
	{
		return "";
	}	
}

/*********************************************************************************************************
 porpuse: return the right  value after removing the @ sign from the select value
 inputs : 
 return:  
 comments:
**********************************************************************************************************/
function GetRightVal(val)
{
	var pos = val.search('@');
	if (pos != -1)
	{
		return val.substr(pos+1,val.length);
	}
	else
	{
		return "";
	}	
}
/**************************************************************
 porpuse: selecting item in select list 
 inputs : 1. an element to select
		  2. an object to search in	
 return:  
***************************************************************/
function SelectVal(val,objSelect)
{
	eval("var len = document.all." + objSelect + ".options.length");
	var found = false;
	var i=0;
	var pos;
	var optVal;
	while ((!found) && (i < len))
	{
		optVal = eval("document.all." + objSelect + "[i].value");
		pos = optVal.search('@');
		if (pos != -1)
		{
			optVal = optVal.substr(0,pos);
			if (optVal == val)
			{
				found = true;
				eval ("document.all." + objSelect + ".value = document.all." + objSelect + "[i].value");
			}
		}
		i = i + 1;
	}		
}

// check time
function Date_validateTIME1(fieldVal)
{
	var timePat = /^(\d{1,2})(:)(\d{2})(\2(\d{1,2}))?$/;
	var matchArray = fieldVal.match(timePat);
	if (matchArray == null)
		return false;
	hour = matchArray[1];
	minute = matchArray[3];
	second = matchArray[4];

	if (second=="") 
		second = null;
	if (hour < 0  || hour > 23)
	    return false;
	if (minute<0 || minute > 59) 
	  return false;
	if (second != null && (second < 0 || second > 59)) 
	  return false;

	return true;
}

// change the date format to mm/dd/yyyy
function Date_ToDate(sDate)
{
	var arr;
	sDate=sDate.toString();
	arr = sDate.split("/");
	if (arr.length !=1)
		// date
		var sDate= new Date (arr[1]+ '/' + arr[0] + '/' +arr[2]);
	else{
		arr = sDate.split(":");
		if(arr.length==2)
		{
			arr[2]=0; //set seconds
			arr[3]=0; // set miliseconds
		}
		if(arr.length==3)
			arr[3]=0; // set miliseconds
		
		var sDate= new Date ();
		sDate.setHours(arr[0]); 
		sDate.setMinutes(arr[1]); 
		sDate.setSeconds(arr[2]); 
		sDate.setMilliseconds(arr[3]);		
	}
	return sDate;
}

// return the datee diff
function Date_Diff(Interval,sDate1,sDate2)
{
	var value = Date_ToDate(sDate1)-Date_ToDate(sDate2);
	
	if (Interval=="d") // days
		value=value/86400000;
	else if (Interval=="m") // months
		value=value/86400000/30;
	else if (Interval=="y") // year
		value=value/86400000/365;
	else if (Interval=="s") // seconds
		value=value/1000;
	else if (Interval=="n") // minutes
		value=value/60000;
	else if (Interval=="h") // hours
		value=value/3600000;
	else 
		value=0;			
		
	value=Math.round(value-0.5); 
	return value;
}

function Date_Add(Interval,Num,sDate)
{
	var value = Date_ToDate(sDate);
	if (Interval=="d")
		value.setDate(value.getDate()+Num);
	else if (Interval=="m")
		value.setMonth(value.getMonth()+Num);
	else if (Interval=="y")
		value.setFullYear(value.getFullYear()+Num);
	else 
		value;					
	return value.getDateString();
}

function getDateString()
{
   var dateStr;
   if (this.getDate() < 10)
      dateStr = "0";
   dateStr += this.getDate() + "/";
   if (this.getMonth() < 9)
      dateStr += "0";
   dateStr +=  (this.getMonth() + 1)+ "/";
   dateStr += "" + this.getFullYear();
   return dateStr;
}

function FormatNum1(val)
{
	val = new String(val);
	
	// remove "," from string	
	while(val.search(",") != -1) 
		val = val.replace(",",""); 
	
	if (val.length > 3)
	{
		var formatVal = "";
		lengthNum = val.length;
		j=1;
		for (var i=0; i < lengthNum ; i++)
		{
			
			formatVal = formatVal + val.substr(val.length-1,1)
			val = val.substr(0,val.length-1);
			if ((j==3)&& (i != lengthNum-1)) 
			{
				j = 1;
				formatVal = formatVal + ",";	
			}
			else
			{
				j=j+1;
			}
		}
		val = formatVal;
		formatVal = "";
		lengthNum = val.length
		for (var i=0; i < lengthNum ; i++)
		{
			formatVal = formatVal + val.substr(val.length-1,1);
			val = val.substr(0,val.length-1);
		}
	}
	else
	{
		formatVal = val;
	}			
	
	return formatVal;
}	

function SetToZeroIfEmpty(val)
{

	if (val == "")
	{
		return 0;
	}
	else
	{
		return val;
	}
}

function SetToIntegerNumber(val,objName)
{
	if (IsNumber(val)) 
	{
		var IntegerValue = "";
	
		if (val != "") 
		{
			IntegerValue =  Math.round(val);
		}	
		eval("document.all." + objName + ".value = IntegerValue");
	}
	else
	{
		return "";
	}
}

function FormatNum(val,obj)
{		
	val = new String(val);	
	
	var check = val.indexOf(',');	
	while (check != -1)
	{		      
		var val = val.replace(',','');				
		check = val.indexOf(',');
	}
	
	var minus = 0;
	if (val.substr(0,1) == '-')
	{
		val = val.substr(1,val.length)
		minus = 1
	}
	
	if (val.length > 3){
				
		var formatVal = '';
		lengthNum = val.length;
		var lengthBeforeDot = 0;
		var lengthAfterDot = 0;
		
		if (val.indexOf('.') > 2)
		{
			lengthAfterDot = lengthNum - val.indexOf('.');
			for (var i=0; i < lengthAfterDot; i++)
			{
				formatVal = formatVal + val.substr(val.length-1,1);
				val = val.substr(0,val.length-1);
			}
		}
		else if (val.indexOf('.') != -1)
		{
			if (minus == 1)
			{
				val = '-' + val;
			}
			obj.value = val;
			return val;
		}		
		
		lengthBeforeDot = lengthNum - lengthAfterDot;		
		
		j=1;
		for (var i=0; i < lengthBeforeDot ; i++)
		{
			formatVal = formatVal + val.substr(val.length-1,1);
			val = val.substr(0,val.length-1);
			if ((j==3)&& (i != lengthBeforeDot-1)) 
			{
				j = 1;
				formatVal = formatVal + ',';
			}
			else
			{
				j=j+1;
			}
		}
		val = formatVal;
		formatVal = '';
		lengthNum = val.length;
		for (var i=0; i < lengthNum ; i++)
		{
			formatVal = formatVal + val.substr(val.length-1,1);
			val = val.substr(0,val.length-1);
		}
	}
	else
	{
		formatVal = val;
	}
	if (minus == 1)
	{
		formatVal = '-' + formatVal;
	}
	
	obj.value = formatVal;
	return formatVal;	
}

function TrimString(sInString)
{
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}

function HideElements(elmID,overDiv)
{
	if(ie)
	{
		for( i = 0; i < document.all.tags( elmID ).length; i++ )
		{
			obj = document.all.tags( elmID )[i];
			if( !obj || !obj.offsetParent )
			{
				continue;
			}
			
			// Find the element's offsetTop and offsetLeft relative to the BODY tag
			objLeft   = obj.offsetLeft;
			objTop    = obj.offsetTop;
			objParent = obj.offsetParent;
			while( objParent.tagName.toUpperCase() != "BODY" )
			{
				objLeft  += objParent.offsetLeft;
				objTop   += objParent.offsetTop;
				objParent = objParent.offsetParent;
			}
			
			objHeight = obj.offsetHeight;
			objWidth = obj.offsetWidth;
			if(( overDiv.offsetLeft + overDiv.offsetWidth ) <= objLeft );
			else if(( overDiv.offsetTop + overDiv.offsetHeight ) <= objTop );
			else if( overDiv.offsetTop >= ( objTop + objHeight ));
			else if( overDiv.offsetLeft >= ( objLeft + objWidth ));
			else
			{
				obj.style.visibility = "hidden";
			}
		}
	}
}

/*unhides <select> and <applet> objects (for IE only)*/
function ShowElements(elmID)
{
	if( ie )
	{
		for( i = 0; i < document.all.tags( elmID ).length; i++ )
		{
			obj = document.all.tags( elmID )[i];
			if( !obj || !obj.offsetParent )
			{
				continue;
			}
			obj.style.visibility = "";
		}
	}
}
