function LTrim(inStr) {
	if (inStr.length == 0)  {
	    return (inStr);
	}
	i = 0 ;
	while ( (inStr.charAt(i) == " ") && (i<= inStr.length) ){
		i++;
	}
	return (inStr.substring(i,inStr.length));
}

	function RTrim(inStr) {
		if (inStr.length == 0)  {
			return (inStr)
		}
		i = (inStr.length -1)
		while ( (inStr.charAt(i) == " ") && (i >= 0) ){
			i--
		}
		return (inStr.substring(0,i+1))
	}

	function AllTrim(inStr) {
		if (inStr.length == 0)  {
			return (inStr)
		}
		return RTrim(LTrim(inStr))
	}

	function Validate(theForm){
		theForm.txtKey.value = AllTrim(theForm.txtKey.value)
		if(theForm.txtKey.value == ""){
			alert("Please enter keywords and resubmit the search.")
			theForm.txtKey.focus()
			return (false)
		}
		return (true)
	}

function replace(string,text,by) {

    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);
    
    newstr = newstr 
    return newstr;
}

function jsOpenSmall(page) {
OpenWin = this.open(page, "window", "scrollbars=yes,resizable=yes,width=550,height=350");
}
function jsOpen(page) {
OpenWin = this.open(page, "window", "scrollbars=yes,resizable=yes,width=780,height=500");
}
function jsOpenNav(page){
OpenWin = this.open(page,"window","toolbar,scrollbars=yes,resizable=yes,width=780,height=500");
}
function jsOpenNavMenuBar(page){
OpenWin = this.open(page,"window","menubar=yes,toolbar,scrollbars=yes,resizable=yes,width=780,height=500");
}


function formHandler(){
	var URL = document.DropMenuForm.MenuSelections.options[document.DropMenuForm.MenuSelections.selectedIndex].value; 
	window.location.href = URL;
}
 
function formHandler2(){
	var URL = document.DropMenuForm2.MenuSelections.options[document.DropMenuForm2.MenuSelections.selectedIndex].value; 
	window.location.href = URL;
} 
function formHandler3(){
	var URL = document.DropMenuForm3.MenuSelections.options[document.DropMenuForm3.MenuSelections.selectedIndex].value; 
	window.location.href = URL;
	return (true)
}

function formHandler4(){
	var URL = document.DropMenuForm4.MenuSelections.options[document.DropMenuForm4.MenuSelections.selectedIndex].value; 
	window.location.href = URL;
}

function formHandler5(){
	window.location.href = document.DropMenuForm5.MenuSelections.options[document.DropMenuForm5.MenuSelections.selectedIndex].value;
} 
function formHandler6(){
	var URL = document.DropMenuForm6.MenuSelections.options[document.DropMenuForm6.MenuSelections.selectedIndex].value;
	window.location.href = URL;
} 
function formHandler7(){
	var URL = document.DropMenuForm7.MenuSelections.options[document.DropMenuForm7.MenuSelections.selectedIndex].value;
	window.location.href = URL;
}
function formHandler8(){
	var URL = document.DropMenuForm8.MenuSelections.options[document.DropMenuForm8.MenuSelections.selectedIndex].value;
	window.location.href = URL;
}
function formHandler9(){
	var URL = document.DropMenuForm9.MenuSelections.options[document.DropMenuForm9.MenuSelections.selectedIndex].value;
	window.location.href = URL;
} 


function jsOpenwindow(page) {
	OpenWin = this.open(page, "Products / Services", "scrollbars=yes,resizable=yes,width=800");
}

function Start(page) {
	document.FormSubmit.intproductID.value = ""
	document.FormSubmit.Products.value = ""
	OpenWin = this.open(page, "CtrlWindow", "width=600,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes");
}

function validateform(aform){	 
	return validateformCustomMessage(aform, "Answers are required for the following questions:" );
}		
	
	
function validateformCustomMessage( aform, errorHeader) {
	var msg = "";
	var msgTemp = "";
	var isChecked = 0;
	var appendMessage
	var temp = "";
	var country = "";
	var flag = 0;
	
		for ( i = 0; i < aform.elements.length; i++) {

			field = aform.elements[i];
			
			if (field.name == "07 Country_req"){	
				country = field.value;	
			}
			if (field.type == "checkbox") {
				isChecked = 0;

				var reqIndex = field.name.indexOf( "_req", 0)
				if (  reqIndex > 0 ){
					var temp = aform.elements[i];

					var tempName  = temp.name.substring(0,temp.name.indexOf( "@", 0));
					var fieldName = field.name.substring(0,field.name.indexOf( "@", 0));

					if (tempName == ""){ tempName = field.name; }
					if (fieldName == ""){ fieldName = field.name; }


					while (tempName == fieldName){

						if (field.checked){
							isChecked = 1;
						}
						i = i + 1;
						field = aform.elements[i];
						fieldName = field.name.substring(0,field.name.indexOf( "@", 0));
						if (fieldName == ""){ fieldName = field.name; }


					}

					if (isChecked == 0){
						msg += tempName.substring(2, reqIndex) + "\n";
					}
					if (field.type == "checkbox") {
						i = i - 1;
					}				
				}

			}
			
			if (field.type == "radio") {
				if (temp == "")
					temp = field.name;
				var reqIndex = field.name.indexOf( "_req", 0)
				if (  reqIndex > 0 ){
					if (! field.checked){
						if (isChecked == 0)
						{
							if (msgTemp == "")
								msgTemp = field.name.substring(2, reqIndex) + "\n";
							isChecked == 0;
						}
						}else{
							isChecked = 1;
							msgTemp = "";
						}
				}

			}

			if ((field.type == "text" ) || (field.type == "textarea") || (field.type == "select") || (field.type == "select-one")){
				if (temp != "" && msgTemp != "")
				{
					msg += msgTemp;
					temp = "";
					msgTemp = "";
				}
				var reqIndex = field.name.indexOf( "_req", 0)


				switch(field.name){
				
					case("09 State_req"):
						if (country == "United States"){
							if (field.value == ""){
								msg += field.name.substring(2, reqIndex) + "\n";
							}
						}
						break;
					
					case("10 Province_req"):
						if (country == "Canada"){
							if (field.value == ""){
								msg += field.name.substring(2, reqIndex) + "\n";
							}
						}
						break;
						
					case("config_phone_area"):
						if (! isValidUSPhoneNumber(aform.config_phone_area.value,aform.config_phone_prefix.value, aform.config_phone_suffix.value)){
							msg += "enter a valid phone number \n";
						}else{
							aform.phone.value = "(" + aform.config_phone_area.value + ") " + aform.config_phone_prefix.value + "-" + aform.config_phone_suffix.value;
						}
						break;
					
					default:
						if (  reqIndex > 0 ){
							if (field.value == "")
								msg += field.name.substring(2, reqIndex) + "\n";
						}						
					
				}

			}
		}
        		
	if (msg != ""){
		msg = errorHeader + "\n\n" + msg;
		alert(msg)
		return false
	} else {
		return true;
	}
}




	

var msgWindow; 

function show(term, arg) {
       if (navigator.appName != 'Netscape'){
               if (typeof(msgWindow) == 'object'){
                     if (msgWindow.closed != true){
                         msgWindow.close();
                         }
                      }
                      else{
                         msgWindow=window.open('','displayWindow','menubar=no,toolbar=no,scrollbars=yes,width=200,height=200');
                         if (msgWindow.closed != true){
                              msgWindow.close();
                              }
                      }
                  if (msgWindow.closed == true ){
                       msgWindow=window.open('','displayWindow','menubar=no,toolbar=no,scrollbars=yes,width=200,height=200');
                       if (msgWindow.closed != true){
                               msgWindow.document.open();
                               msgWindow.document.write('<' + 'HEAD><TITLE' + '>' + term + '</' + 'TITLE></' +'HEAD>');
                               msgWindow.document.bgColor='#FFFFE0';
                               msgWindow.document.fgColor='#0000FF';
                               msgWindow.document.write(arg);
                               msgWindow.document.close();
                               }
                       }
                   return true;
                   }
       if (navigator.appName == 'Netscape'){
               if (typeof(msgWindow) == 'object'){ 
                   if (msgWindow.name == 'displayWindow'){
                       msgWindow.close();
                       }
                   }
               msgWindow=window.open("","displayWindow","menubar=no,toolbar=no,scrollbars=yes,width=200,height=200");
               msgWindow.document.open();
               msgWindow.document.write('<' + 'HEAD><TITLE' + '>' + term + '</' + 'TITLE></' +'HEAD>');
               msgWindow.document.bgColor="#FFFFE0" ;
               msgWindow.document.fgColor="#0000FF";
               msgWindow.document.write(arg);
               msgWindow.document.close();
               return true;
               }
               }
function hide() {
       if (typeof(msgWindow) == 'object'){ 
               if (navigator.appName == 'Netscape'){
                   if (msgWindow.name == 'displayWindow'){
                       msgWindow.close();
                       }
                   }
               if (navigator.appName != 'Netscape'){
                   if (msgWindow.closed != true){
                       msgWindow.close();
                       }
                   }
               }        }




//Ecomp Javascript for submission

function eCompSubmit() {
	submitUrl = "http://www.ecomponline.com/cobrand/";
	if (document.eCompForm.strEcompType.value == "") {

		alert("You must select a company name or symbol to continue.");
	} else {

		if (document.eCompForm.strEcompType.value == "Name"){
			OpenWin = this.open( submitUrl+"cobrand.asp?cobrand_id=4&compname="+document.eCompForm.strEcomp.value, "window", "scrollbars=yes,resizable=yes,width=780,height=500");
		} else if (document.eCompForm.strEcompType.value == "Symbol") {
			OpenWin = this.open(submitUrl+"cobrand.asp?cobrand_id=4&symbol="+document.eCompForm.strEcomp.value, "window", "scrollbars=yes,resizable=yes,width=780,height=500");
		}
	}
	return false;
	
}

//Focus Form javascript with cookies

	var expires = new Date();
	expires.setTime (expires.getTime() + 24 * 60 * 60 * 180 * 1000);
	var expiryDate = expires.toGMTString();

	function checkForumCookies(URL,referer) {
	
	var beginURL = "http:";
	var checkBeginURL = URL.substring(0,5);
	var fullURL = "http://www.aon.com" +  URL + "";
	
	
			if (GetCookieName("ForumCookie") == null){
				setCookie('ForumCookie','Active')
				window.open("http://www.aon.com/about/contactus/focus_form_2.jsp?referer=" + referer + "","test","width=650,height=600,status=no,");
				if (beginURL == checkBeginURL){
					location.href = URL;
				}else{
					location.href = fullURL;
				}
			} else {
				if (beginURL == checkBeginURL){
					location.href = URL;
				}else{
					location.href = fullURL;
				}
			}
			return "";
	}

	function setCookie(name,value){
		document.cookie = name + "=" + value + "; expires=" + expiryDate;
	}

	function getCookieVal(offset){
		var endstr = document.cookie.indexOf (";", offset);
		if (endstr == -1)
			endstr = document.cookie.length;
		return unescape(document.cookie.substring(offset,endstr));
	}

	function GetCookieName (name){
		var cookieName =  name + "=";
		var alen = cookieName.length;
		var cookieLength = document.cookie.length;
		var i = 0;
		while (i < cookieLength){
			var j = i + alen;
			if (document.cookie.substring(i,j) == cookieName)
				return getCookieVal (j);
			i = document.cookie.indexOf() + 1;
			if (i == 0) break;
		}
		return null;
	}
//End Cookie functions


function isValidPostalcode(postalcode) {

   if (postalcode.search) {
      postalcode = removeSpaces(postalcode);      
      if (postalcode.length == 6 && postalcode.search(/^[a-zA-Z]\d[a-zA-Z]\d[a-zA-Z]\d$/) != -1) return true;
      else if (postalcode.length == 7 && postalcode.search(/^[a-zA-Z]\d[a-zA-Z]-\d[a-zA-Z]\d$/) != -1) return true;
      else alert("Please enter a proper postal code");
   }
   return true;
}

// Remove all spaces from a string
function removeSpaces(string) {
   var newString = '';
   for (var i = 0; i < string.length; i++) {
      if (string.charAt(i) != ' ') newString += string.charAt(i);
   }
   return newString;
}



var reEmail = /^.+\@.+\..+$/

function isEmail (s)

{
       if (! reEmail.test(s)){
       		alert("Please enter a proper email address");
       }

}




function isValidUSPhoneNumber(areaCode, prefixNumber, suffixNumber) {

   if (areaCode.length != 3 || !isNumeric(areaCode) || prefixNumber.length != 3 || !isNumeric(prefixNumber) || suffixNumber.length != 4 || !isNumeric(suffixNumber)){   	
   	return false;
   }else{
   	return true;
   }
}


// Check that a string contains only numbers
function isNumeric(string, ignoreWhiteSpace) {
   if (string.search) {
      if ((ignoreWhiteSpace && string.search(/[^\d\s]/) != -1) || (!ignoreWhiteSpace && string.search(/\D/) != -1)) return false;
   }
   return true;
}







































































