function ImgRollOverUp(sBtnName) {
	//alert(sBtnName)
	var sFullBtnName = 'btn' + sBtnName + '_down.png'
	var oImage = eval('document.' + sBtnName + '.src')
	var sImagePath = '/IPA/Images/' + sFullBtnName
	//alert(oImage)
	oImage = sImagePath
	//alert(oImage)
	//document.CompInfoImg.src='/IPA/Images/btnCompanyInfo_On.gif'
}
function detectBrowser(isNetscape) {
  if (parseInt(navigator.appVersion) >= 4) {
    if (navigator.appName == "Netscape") {
      isNetscape = true;
    }
  }
  return isNetscape;
}

function tr(text, find, repl) {
  //Finds and Replaces given character with given character and returns the value into the variable.
  var newtext = ""

  count = 0;  
  while (count < text.length) {
    if (text.charAt(count) == find) {
      newtext += repl;
    } else {
      newtext += text.charAt(count);
    }
    count++;  
  }
  return newtext
}

function ValidateEntry(ControlObject, ControlName, MaxLength, Type)
{
  var oControl = ControlObject;
  var sTemp, sMsg;

  // First check to see if a value is present.
  oControl.value = trim(oControl.value);
  //alert(oControl.value)
  if (oControl.value == "" || oControl.value == "0") {
    if (Type == "combo")
      sMsg = "Please select a " + ControlName + " from the pulldown list.";
    else
      sMsg = "Please make an entry for " + ControlName + ".";
    return sMsg;
  }

  // Validate non-combo entries
  if (Type != "combo") {
    // Check for valid characters
    sTemp = isValidText(oControl.value, Type);
    if (sTemp != 'true') {
      sMsg = ControlName + " is limited to " + Type + " characters.  " +
             "Please do not use the character '" + sTemp + "'.";
      return sMsg;
    }

    // Check that maximum length has not been exceeded
    if (oControl.value.length > MaxLength) {
      sMsg = ControlName + " is limited to " + MaxLength + " characters."
      return sMsg;
    }
  }

  return 'true';
}

function ValidateMinLength (ControlObject, ControlNameString, MinLength){
  var oControlObject = ControlObject;
  var sControlValue = oControlObject.value;
  var ilen = sControlValue.length;
  if (ilen < MinLength) {
	var sMsgText = ControlNameString + ' must be at least ' + MinLength + ' characters long.';
	return sMsgText;
  }
 return 'true';
}

function isValidText(myText, type) {
  //type = 'numeric' or 'alphanumeric' all lowercase only.
  //Checks each character in a string againts the characters in the validCharacters string. 
  //If any of the characters in the passed string do not match one of the characters in the 
  //validCharacters string, the function returns the invalid character.  Else it returns a string ‘true’.
  //I'm using this to ensure that characters do not try to send any  values such as the ‘&’ that 
  //will cause sql to err.

  var validCharacters;
  var count;
  var count2;
  var isValidChar;
  if (type == 'numeric') {
    validCharacters = ',.1234567890';
  } else if (type == 'alphanumeric') {
    validCharacters = ' ,.1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$%*@()-!{}[]:;<>?/' + String.fromCharCode(10, 13);
  } else if (type == 'alphanumericplus') {
    validCharacters = " ,.1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$%*@()'_-!{}[]:;<>?/" + String.fromCharCode(10, 13);
  } else if (type == '-numeric') {
	validCharacters = '-,.1234567890';
  } else {
    alert('Invalid type:  syntax = \"isValidText(myText, type)\" where myText \n is the passed string variable and type is \'numeric\' or \'alphanumeric\'.');
    return 'false'
  }
  
  myText = myText.toString();
  count = 0;
  while (count < myText.length) {        
    isValidChar = false;  
    count2 = 0;
    while (count2 < validCharacters.length) {
      if (myText.charAt(count) == validCharacters.charAt(count2)) {
        isValidChar = true;
      }
      count2++;
    }
    if (isValidChar == false) {
	  return myText.charAt(count)
	}  
    count++;
  }
  return 'true'
}

function trim(StringValue) {
	var tempstring;
	while (StringValue.substring(StringValue.length, StringValue.length) == ' ') { 
		tempstring = StringValue.substr( 0, (StringValue.length - 1));
		StringValue = tempstring;
	}	
	while (StringValue.substring(0, 1) == ' ') { 
		tempstring = StringValue.substring(1, StringValue.length);
		StringValue = tempstring;		
	}
	return StringValue;
}

function lifetimer(dDate){            
        today = new Date()          
        BirthDay = new Date(dDate)         
        timeold = (today.getTime() - BirthDay.getTime());         
        sectimeold = timeold / 1000;         
        secondsold = Math.floor(sectimeold);         
        msPerDay = 24 * 60 * 60 * 1000 ;         
        timeold = (today.getTime() - BirthDay.getTime());         
        e_daysold = timeold / msPerDay;         
        daysold = Math.floor(e_daysold);                
        timerID = setTimeout("lifetimer()",1000) 
  return daysold  
}     

function moveTo(obj, x, y) {
  obj = eval('document.' + obj);
  obj.left = x;
  obj.top = y;
}

function round2(myNumber) {
	count = 0;
	PPos = 0;
	AfterPeriod = '';
	myNumber = myNumber.toString();
	count = myNumber.indexOf('.') + 1;
	if (count > 0) {
	    BeforePeriod = myNumber.substring(0, (count -1));
		while (count < myNumber.length && AfterPeriod.length < 3) {
			AfterPeriod += (myNumber.charAt(count)).toString();
			count++;
		}		
		if (AfterPeriod.length > 2) {
			if (AfterPeriod.charAt(2).valueOf() > 4) {				
				AfterPeriod = AfterPeriod.substring(0, 2).valueOf()				
				AfterPeriod++;
				if (AfterPeriod.valueOf() > 99) { 
					BeforePeriod++; 
					AfterPeriod = 0;
				}
				AfterPeriod = AfterPeriod.toString();				
			} else {
				AfterPeriod = (AfterPeriod.substring(0,2).valueOf()).toString();	
			}
		}
		while (AfterPeriod.length < 2) {
			AfterPeriod = AfterPeriod + '0';
		}	
		myNumber = (BeforePeriod + '.' + AfterPeriod).toString();
	}
	return myNumber;
} 

function ObjectRef (sObjName, sControlName) {
	var ObjectReference;
	if (NN==true){
		ObjectReference = 'document.div' + sObjName + '.document.frm' + sObjName + '.' + sControlName;
	}else{
		ObjectReference = 'document.frm' + sObjName + '.' + sControlName;
	
	}
 return eval(ObjectReference)
}
