function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function search_OnClick(MainSearch){

   objField    = document.getElementById(MainSearch);

   objOrigText = document.getElementById("OrigSearchText");

   if (trim(objField.value) == trim(objOrigText.value)) {

      objField.value = "";

   }

   return;

}



function search_OnBlur(MainSearch){

   objField    = document.getElementById(MainSearch);

   objOrigText = document.getElementById("OrigSearchText");



   if (trim(objField.value) == "") {

      objField.value = objOrigText.value;

   }

   return;

}


// Common javascript


function changeLocation(){
 var openSiteInNewWindow = false;
 var value = document.getElementById("cars").value;

	if (value == "") {
	   return false;
	}
	if (value == "#") {
	   return false;
	}
	if (value.indexOf('hayresourcesdirect.haygroup') > 1) openSiteInNewWindow = true;
	if (value.indexOf('haypaynet') > 1) openSiteInNewWindow = true;
	if (value.indexOf('haygrouppaynet') > 1) openSiteInNewWindow = true;
	if (value.indexOf('icm.haygroup') > 1) openSiteInNewWindow = true;

    if (openSiteInNewWindow == true) {
    	wndChild = window.open(value, "NewWindow", "width=800,height=600,top=20,left=20,toolbar=no,scrollbars=yes,resizable=yes");
	    wndChild.focus();
    	return false;
    }
    else {
    	window.location.href = value;
	    return false;
	}
	return false;
}


// There are three arguments being passed into this array
// "theName", "theLinkName" is the username (or the portion of the email address prior to the @)
// "theDomain", "theLinkDomain" is the domain (or the portion of the email address after the @)
// "theExtras" are items such as "?subject=blah". Can be blank if you don't want to use this feature
// "theLink" is the text for the link. For example "Contact Us".  Can be blank if you don't want to use this feature
function encodeEmail(theName, theExtras, theDomain, theLinkName, theLinkDomain) {
	var theEmail  = theName + "@" + theDomain;

	if ((theExtras == "") && (theLinkName == "")) {
		myEmail = theEmail;
		myLink  = theEmail;
	}

	if ((theLinkName == "") && (theExtras != "")) {
		myLink  = theEmail;
		myEmail = theEmail + theExtras;
	}

	if ((theLinkName != "") && (theExtras != "")) {
		myLink  = theLinkName;
		myEmail = theEmail + theExtras;
	}

	if ((theLinkName != "") && (theExtras == "")) {
		myLink  = theLinkName;
		myEmail = theEmail;
	}

	if (theLinkDomain != "") {
		myLink  = myLink + "@" + theLinkDomain;
	}


	// If the email isn't suppose to be a mailto link, then we don't make it one
	if (theName == "") {
		document.write(myLink);
	} else {
		document.write('<a href=mailto:' + myEmail + '>' + myLink + '</a>');
	}
}

function search_OnClick(sFieldName){
   objField    = document.getElementById(sFieldName);
   objOrigText = document.getElementById("OrigSearchText");
   if (trim(objField.value) == trim(objOrigText.value)) {
      objField.value = "";
   }
   return;
}

function search_OnBlur(sFieldName){
   objField    = document.getElementById(sFieldName);
   objOrigText = document.getElementById("OrigSearchText");

   if (trim(objField.value) == "") {
      objField.value = objOrigText.value;
   }
   return;
}

// 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.
function trim(inputString) {
   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
} // Ends the "trim" function


// Homepage javascript


  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

   document.cookie = "ResolutionWidth=" + screen.width + "; path=/";
   document.cookie = "ResolutionHeight=" + screen.height + "; path=/";
   document.cookie = "BrowserWidth=" + myWidth + "; path=/";
   document.cookie = "BrowserHeight=" + myHeight + "; path=/";

//Function added for TL 2009
//START Function used for Home Page Scripted Questions
function switch1(div) {
var option=['1','2','3','4'];
for(var i=0; i<option.length; i++) {
if (document.getElementById(option[i])) {
obj=document.getElementById(option[i]);
obj.style.display=(option[i]==div)? "block" : "none";
}
}
}

window.onload=function () {switch1('');}
//END Function used for Home Page Scripted Questions

    function addToFavorites() { 
        sURLaddress = window.location.toString()
          if (window.external) { 
            window.external.AddFavorite(sURLaddress,document.title) 
        } else { 
            alert("Sorry! Your browser doesn't support this function."); 
        } 
    }     
