
var menuWaitTime = 1000;
var hideSubMenuTimeOut = 0;
var menuOn = 0;
//var lastToggleField;
var lastToggleHash = {};

//Filter out any "Enter" key 
//document.onkeypress = kH;
//----------------------------------------------------------------------------------------------------------------------------
function kH(e) {
var pK = e ? e.which : window.event.keyCode;
return pK != 13;
}

if (document.layers) document.captureEvents(Event.KEYPRESS);


//----------------------------------------------------------------------------------------------------------------------------
function confirmDelete(myText){

  if (myText == null ) {
    return confirm("You are about to delete this item.\nThis cannot be undone.\n\n Do you want to proceed?");
  } else {
   return confirm(myText+ "\nThis cannot be undone.\n\n Do you want to proceed?");   
  }

}
//----------------------------------------------------------------------------------------------------------------------------

<!--//

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->

//----------------------------------------------------------------------------------------------------------------------------
function isUndefined(a) {
    return typeof a == 'undefined';
} 

//----------------------------------------------------------------------------------------------------------------------------
function showProps(thing,returnString) {

    props = new Array();
    var counter = 0;
    var mytext = "";

    for (prop in thing) { 
      counter++;
      mytext= "property: " + prop + "value: " + thing[prop]+ "\n";
      props[counter] = mytext;
    }

    counter=0;   
    maxRowsDisplayed=10;

    while (counter <=10000 && counter<props.length) {
      if ((props.length-counter) >= maxRowsDisplayed) {
        rowsToDisplay = maxRowsDisplayed;
      } else {
        rowsToDisplay = props.length-counter;
      }
      for(i=1;i<=rowsToDisplay;i++) {
        mytext+=props[counter];   
        counter++;
      }
      if (returnString == 0)  {
       alert(mytext) ;     
       mytext ="";      
      }
    } 
   
    if (returnString)  {
      return mytext;
    } else {
      alert(mytext);
    };
    
}

//----------------------------------------------------------------------------------------------------------------------------
function rollOffMenu (menuObj) {
  alert("RollOff");
  menuOn = 0;
  setTimeout('hideMenu(\'' + menuObj + '\');', menuWaitTime);
}
//----------------------------------------------------------------------------------------------------------------------------
function rollOnMenu (menuObj) {
  alert("RollOn");
  menuOn = 1;
 
}

//----------------------------------------------------------------------------------------------------------------------------
function hideMenu (docObj) {
  alert("hiding menu("+ !menuOn+")");
  menuTable = document.getElementById("subMenu");
  menuTable.style.display = 'none';
  if (!menuOn) { docObj.style.display = 'none'; }
}


//----------------------------------------------------------------------------------------------------------------------------
function round_decimals(original_number, decimals) {
    var result1 = original_number * Math.pow(10, decimals)
    var result2 = Math.round(result1)
    var result3 = result2 / Math.pow(10, decimals)
    return pad_with_zeros(result3, decimals)
}
//----------------------------------------------------------------------------------------------------------------------------
function pad_with_zeros(rounded_value, decimal_places) {

    // Convert the number to a string
    var value_string = rounded_value.toString()
    
    // Locate the decimal point
    var decimal_location = value_string.indexOf(".")

    // Is there a decimal point?
    if (decimal_location == -1) {
        
        // If no, then all decimal places will be padded with 0s
        decimal_part_length = 0
        
        // If decimal_places is greater than zero, tack on a decimal point
        value_string += decimal_places > 0 ? "." : ""
    }
    else {

        // If yes, then only the extra decimal places will be padded with 0s
        decimal_part_length = value_string.length - decimal_location - 1
    }
    
    // Calculate the number of decimal places that need to be padded with 0s
    var pad_total = decimal_places - decimal_part_length
    
    if (pad_total > 0) {
        
        // Pad the string with 0s
        for (var counter = 1; counter <= pad_total; counter++) 
            value_string += "0"
        }
    return value_string
}

//----------------------------------------------------------------------------------------------------------------------------
function toggleField (oField, type, hideIfVisible) {
  
  //param hideIfVisible - if oField is already visible, hide it.
  var hideCurrent = true;
  if (!isUndefined(hideIfVisible) && (hideIfVisible==true || hideIfVisible ==false)) {hideCurrent=hideIfVisible} ;

  
  
  var lastToggleField = lastToggleHash[type];
 
 
  
  if (lastToggleField && lastToggleField!=oField) {
    lastToggleField.style.display='none';
  }

  lastToggleHash[type]=oField;

  
  if (oField.style.display == 'none') {
    oField.style.display='block';
  } else if (hideCurrent) {
    oField.style.display='none';
  }
}

//----------------------------------------------------------------------------------------------------------------------------
function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}
function replace(fullString,text,by) {
// Replaces text with by in string
    var strLength = fullString.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return fullString;

    var i = fullString.indexOf(text);
    if ((!i) && (text != fullString.substring(0,txtLength))) return fullString;
    if (i == -1) return fullString;

    var newstr = fullString.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(fullString.substring(i+txtLength,strLength),text,by);

    return newstr;
}

//----------------------------------------------------------------------------------------------------------------------------
// JavaScript Document
/*
// ///////////////////////////
// isdefined v1.0
// 
// Check if a javascript variable has been defined.
// 
// Author : Jehiah Czebotar
// Website: http://www.jehiah.com
// Usage  : alert(isdefined('myvar'));
// ///////////////////////////*/

function isDefined( variable)
{
    return (typeof(window[variable]) == "undefined")?  false: true;
}



//----------------------------------------------------------------------------------------------------------------------------
  function IsNumeric(sText)
  {
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

   //zero-length fields do not qualify
   if (sText.length == 0)  IsNumber = false;
   
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }

 //----------------------------------------------------------------------------------------------------------------------------
  function changeClass (myObj,className) {
     if (myObj.className != "readOnly") {
       myObj.className =  className;
     }  
  }
  
 