function checkBrowser(){	
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
	return this
}
	bw=new checkBrowser()

function menuMouseOver(elem){
	if (!elem.style) return;
//	alert(elem.class);
	if (elem.style.backgroundColor != "#C59C00") {
		elem.style.backgroundColor = "#C59C00";
	}
}
function menuMouseOut(elem){
	if (!elem.style) return;
	//alert(elem.class);
		if (elem.style.backgroundColor != "#C59C00") {
		elem.style.backgroundColor = "#ECEAD9";		
	}
}

//Shows the div
function show(div,nest){
	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0; 
	obj.display=''
}
//Hides the div
function hide(div,nest){
	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0; 
	obj.display='none'
}
//With nested layers for netscape, this function hides the layer if it's visible and visa versa
function showHide(div,objArray,nest){
	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0; 
	if(obj.display=='') obj.display='none';
	else obj.display='';
	for(i=0;i<objArray.length;i++)
		if(objArray[i])
			if(objArray[i] != div)
				hide(objArray[i]);
}
// Example: obj = findObj("image1");
function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}

	// LAST UPDATED 04/16/2004
	
	//http://www.breakingpar.com/bkp/home.nsf/Doc!OpenNavigator&87256B14007C5C6A87256AFB0013C722
	function trim(inputString)
	{
	   // Removes leading and trailing spaces from the passed string. Also removes
	   // consecutive spaces and replaces it with one space. If something besides
	   // a string is passed in (null, custom object, etc.) then return the input.
	   if (typeof inputString != "string") { return inputString; }
	   var retValue = inputString;
	   var ch = retValue.substring(0, 1);
	   while (ch == " ") { // Check for spaces at the beginning of the string
		  retValue = retValue.substring(1, retValue.length);
		  ch = retValue.substring(0, 1);
	   }
	   ch = retValue.substring(retValue.length-1, retValue.length);
	   while (ch == " ") { // Check for spaces at the end of the string
		  retValue = retValue.substring(0, retValue.length-1);
		  ch = retValue.substring(retValue.length-1, retValue.length);
	   }
	   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
		  retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
	   }
	   return retValue; // Return the trimmed string back to the user
	} // End the "trim" function
	
	// http://www.breakingpar.com/bkp/home.nsf/Doc!OpenNavigator&D3A3ACA9908EBBCB87256D420073A729&Remote
	// by Matt Holthe
	function isValidDateString(dateStr)		
	{
		var reg = /^\d{2}\/\d{2}\/\d{4}$/
		if (reg.test(dateStr) == false) { return false; }
		var parts = dateStr.split("/");
		var dt = new Date(parseFloat(parts[2]), parseFloat(parts[0]-1), parseFloat(parts[1]), 0, 0, 0, 0);
		if (parseFloat(parts[1]) != dt.getDate()) { return false; }
		if (parseFloat(parts[0])-1 != dt.getMonth()) { return false; }
		return true;
	} // End isValidDateString function
	
	// Function validates MM/DD/YYYY format
	function validDateFormat(obj)		
	{
		var strDate = obj.value;
		var blnTrigger = true;		
		var reg = /^\d{2}\/\d{2}\/\d{4}$/
		if (strDate.length > 0) {
			var blnTrigger = isValidDateString(strDate);
			if (blnTrigger == false) {
				alert('Date invalid format (MM/DD/YYYY)');
			}
		}
	} // End validDateFormat function
	
	// Function validates MM/DD/YYYY format
	function validDateFormatFR(obj)		
	{
		var strDate = obj.value;
		var blnTrigger = true;		
		var reg = /^\d{2}\/\d{2}\/\d{4}$/
		if (strDate.length > 0) {
			var blnTrigger = isValidDateString(strDate);
			if (blnTrigger == false) {
				alert('Date - format non valide (mm/jj/aaaa)');
			}
		}
	} // End validDateFormatFR function	
	
	//Original Source: http://www.cs.tut.fi/~jkorpela/forms/file.html
	// FILE UPLOAD FORM - MP3 FORMAT
	function isMP3Format(ext)
	{
		ext = ext.substring(ext.length-3,ext.length);
	  	ext = ext.toLowerCase();
		if(ext != "mp3") { return false; }
		else { return true; }
	}

	//Original Source: http://www.cs.tut.fi/~jkorpela/forms/file.html	
	// FILE UPLOAD FORM - MP3 FORMAT	
	function isMPEGFormat(ext)
	{
		ext = ext.substring(ext.length-4,ext.length);
	  	ext = ext.toLowerCase();
//		if((ext != ".mpg") && (ext != "mpeg") && (ext != ".mov")){ return false; }
		if(ext != ".swf") { return false; }
		else { return true; }
	}
	
	function isImageFormat(ext)
	{
		ext = ext.substring(ext.length-4,ext.length);
	  	ext = ext.toLowerCase();
		if((ext != ".jpg") && (ext != "jpeg") && (ext != ".gif") && (ext != ".bmp")){ return false; }
		else { return true; }
	}
				
	function isJPEGFormat(ext)
	{
		ext = ext.substring(ext.length-4,ext.length);
	  	ext = ext.toLowerCase();
		if((ext != ".jpg") && (ext != "jpeg")){ return false; }
		else { return true; }
	}
	
	function isBannerFormat(ext)
	{
		ext = ext.substring(ext.length-4,ext.length);
	  	ext = ext.toLowerCase();
		if((ext != ".jpg") && (ext != "jpeg") && (ext != ".gif") && (ext != ".bmp") && (ext != ".swf")){ return false; }
		else { return true; }
	}	
	
	// Contains http://
	function isHttpPrefixed(http)
	{
		http = http.substring(0,7);
	  	http = http.toLowerCase();
		if(http != 'http://') { return false; }
		else { return true; }
	}	
	
	// http://www.pbdr.com/vbtips/asp/JavaNumberValid.htm
    // check for valid numeric strings	
	function isNumeric(strString)
   	{
		var strValidChars = "0123456789.-";
		var strChar;
	
		if (strString.length == 0) return false;
	
		//  test strString consists of valid characters listed above
		for (i=-1;i<strString.length;i++)
		{
			strChar = strString.charAt(i);
			if (strValidChars.indexOf(strChar) == -1) return false;
		}
		return true;
   	}
   	
   	 // check for valid integer strings	
	function isInteger(strString)
   	{
		var strValidChars = "0123456789";
		var strChar;
	
		if (strString.length == 0) return false;
	
		//  test strString consists of valid characters listed above
		for (i=-1;i<strString.length;i++)
		{
			strChar = strString.charAt(i);
			if (strValidChars.indexOf(strChar) == -1) return false;
		}
		return true;
   	}
   	
   	
   	// Function to validate whether an object value is a number
	function validNumber(obj)
   	{
		var strNumber = obj.value;
		var blnIsNumber = true;
		blnIsNumber = isNumeric(strNumber);
		
		if (blnIsNumber == false)
			alert('Must be numeric value (no commas)');
   	} // End validNumber function
	
	// Function: Validate email address
	function isValidEmail( emailAddress )
	{
    	var re = /^[a-zA-Z][\w'\.-]*['a-zA-Z0-9\_]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/
    	return re.test(emailAddress);
    	
	} // End isValidEmail function
	
	// Validate Postal Code
	function isValidPostalCode(strPCode)
	{
    	//take out the space from between the 2 pieces of postal code if it is there
		strPCode = strPCode.replace(/\s/g,"");
		var objPattern1 = /^[A-Z]\d+[A-Z]\d+[A-Z]\d+$/;
		return objPattern1.test(strPCode);
	}
	
	// Validate Province
	function isValidProvince(sender, args)
	{
    	var provinceID = args.Value;
    	var City = document.forms[0].txtFirmCity.value;
    	var pCode = document.forms[0].txtFirmPCode.value;
		if(City.length > 0 || pCode.length > 0){
			if(provinceID==14) {
				args.IsValid = false;
				return;
			}
		}
		
		args.IsValid = true;
		
	}
	
	// Function to restrict the number of characters allowed in a text box.
	function isMaxLength(obj, mlength){
		if (obj.value.length>mlength) {
			obj.value=obj.value.substring(0,mlength);
			alert('Maximum number of characters allowed in this field is ' + mlength + '!');
		}
	}
	
	function isMaxLengthFR(obj, mlength){
		if (obj.value.length>mlength) {
			obj.value=obj.value.substring(0,mlength);
			alert('Le nombre maximal de caractères dans ce champ est ' + mlength + '!');
		}
	}
	
	// Function to ensure a text box has the correct number of characters.
	function validLength(obj, mlength){
		if (obj.value.length < mlength) {
			alert(mlength + ' characters required!');
		}
	} // end validLength function
	
	function validLengthFR(obj, mlength){
		if (obj.value.length < mlength) {
			alert(mlength + ' caractères sont exigés.');
		}
	}
	
	// Function to ensure a text box 3 digits (used for phone number validation)
	function isValid3Digits(sender, args){
		var strNumber = args.Value;
		if (strNumber.length < 3)
		{
			args.IsValid = false;
			return;
		}
		
		args.IsValid = true;
	} // end isValid3Digits function
	
	// Function to ensure a text box 4 digits (used for phone number validation)
	function isValid4Digits(sender, args){
		var strNumber = args.Value;
		if (strNumber.length < 4)
		{
			args.IsValid = false;
			return;
		}
		
		args.IsValid = true;
	} // end isValid4Digits function
	
	// Function to set field to zero if it has no value
	function setFieldToZero( objectID ) {
		var strValue = document.getElementById(objectID).value;
		if( !isNumeric( strValue ) ){
			document.getElementById(objectID).value = "0";
		}		
	}
	
	// rounds number to X decimal places, defaults to 2
	function formatDecimal(number, X)
	{
		X = (!X ? 2 : X);
		return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
	}

	//  End -->	