function addEvent(elm, evType, fn, useCapture)
{
	if (typeof useCapture == "undefined") 
	{
		useCapture = false;
	}
	
	if(elm.addEventListener)
	{
		elm.addEventListener(evType, fn, useCapture);
		return true;
	}
	else if(elm.attachEvent)
	{
		var r = elm.attachEvent('on' + evType, fn);
		EventCache.add(elm, evType, fn);
		return r;
	}
	else
	{
		elm['on' + evType] = fn;
	}
}

var EventCache = function(){
	var listEvents = [];
	return {
		listEvents : listEvents,
		add : function(node, sEventName, fHandler){
			listEvents.push(arguments);
		},
		flush : function(){
			var i, item;
			for(i = listEvents.length - 1; i >= 0; i = i - 1){
				item = listEvents[i];
				if(item[0].removeEventListener){
					item[0].removeEventListener(item[1], item[2], item[3]);
				};
				if(item[1].substring(0, 2) != "on"){
					item[1] = "on" + item[1];
				};
				if(item[0].detachEvent){
					item[0].detachEvent(item[1], item[2]);
				};
				item[0][item[1]] = null;
			};
		}
	};
}();


// Copyright © 2001 by Apple Computer, Inc., All Rights Reserved.
//
// You may incorporate this Apple sample code into your own code
// without restriction. This Apple sample code has been provided "AS IS"
// and the responsibility for its operation is yours. You may redistribute
// this code, but you are not permitted to redistribute it as
// "Apple sample code" after having made changes.

// email

function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "You didn't enter an email address.\n";
}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid email address.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "The email address contains illegal characters.\n";
       }
    }
return error;    
}


// phone number - strip out delimiters and check for 10 digits

function checkPhone (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a phone number.\n";
}

var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
    if (isNaN(parseInt(stripped))) {
       error = "The phone number contains illegal characters.";
  
    }
    if (!(stripped.length == 10)) {
	error = "The phone number is the wrong length. Make sure you included an area code.\n";
    } 
return error;
}


// password - between 6-8 chars, uppercase, lowercase, and numeral

function checkPassword (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a password.\n";
}

    var illegalChars = /[\W_]/; // allow only letters and numbers
    
    if ((strng.length < 6) || (strng.length > 8)) {
       error = "The password is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
      error = "The password contains illegal characters.\n";
    } 
    else if (!((strng.search(/(a-z)+/)) && (strng.search(/(A-Z)+/)) && (strng.search(/(0-9)+/)))) {
       error = "The password must contain at least one uppercase letter, one lowercase letter, and one numeral.\n";
    }  
return error;    
}    


// username - 4-10 chars, uc, lc, and underscore only.

function checkUsername (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a username.\n";
}


    var illegalChars = /\W/; // allow letters, numbers, and underscores
    if ((strng.length < 4) || (strng.length > 10)) {
       error = "The username is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
    error = "The username contains illegal characters.\n";
    } 
return error;
}       


// non-empty textbox

function isEmpty(obj) {
var error = "";
  if (obj.value.length == 0) {
     error = "The "+obj.title+" has not been filled in.\n"
  }
return error;	  
}

// was textbox altered

function isDifferent(strng) {
var error = ""; 
  if (strng != "Can\'t touch this!") {
     error = "You altered the inviolate text area.\n";
  }
return error;
}

// exactly one radio button is chosen

function checkRadio(checkvalue) {
var error = "";
   if (!(checkvalue)) {
       error = "Please check a radio button.\n";
    }
return error;
}

// valid selector from dropdown list

function checkDropdown(obj) {
var error = "";
    if (obj.selectedIndex == 0) {
    error = "You didn't choose an option from the "+obj.title+" list.\n";
    }    
return error;
}    

function checkBoxCheck()
{
    var inputs = document.getElementsByTagName("input");
    var i = document.getElementById("hearAbout");
    i.value = "";
    for(x=0;x<inputs.length;x++)
    {
        if(inputs[x].type == "checkbox")
        {
            if(inputs[x].checked)
            {
                i.value += inputs[x].value + ', ';
            }
        }
    }
}

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 doPreLoadImages()
{
	MM_preloadImages('http://www.efiglobal.com/images/nav_about_on.gif','http://www.efiglobal.com/images/nav_services_on.gif','http://www.efiglobal.com/images/nav_projects_on.gif','http://www.efiglobal.com/images/nav_news_on.gif','http://www.efiglobal.com/images/nav_contact_on.gif','http://www.efiglobal.com/images/nav_locations_on.gif');
}

function mmLoadMenus() {
  if (window.mm_menu_0731102932_0) return;
  window.mm_menu_0731102932_0 = new Menu("root",209,18,"Arial, Helvetica, sans-serif",11,"#FFFFFF","#FFFFFF","#993333","#666666","left","middle",5,0,600,-5,7,true,true,true,0,true,true);
  mm_menu_0731102932_0.addMenuItem("Company&nbsp;Overview","location='http://www.efiglobal.com/efi_global_about/about_efi_overview.shtml'");
  mm_menu_0731102932_0.addMenuItem("Executive&nbsp;Team","location='http://www.efiglobal.com/efi_global_about/about_efi_executiveteam.shtml'");
  mm_menu_0731102932_0.addMenuItem("Mission&nbsp;and&nbsp;Values","location='http://www.efiglobal.com/efi_global_about/about_efi_mission_statement.shtml'");
  mm_menu_0731102932_0.addMenuItem("Why&nbsp;EFI&nbsp;Global","location='http://www.efiglobal.com/efi_global_about/about_efi_why_efi_global.shtml'");
  mm_menu_0731102932_0.addMenuItem("Clients&nbsp;and&nbsp;Markets&nbsp;Served","location='http://www.efiglobal.com/efi_global_about/about_efi_clients_markets.shtml'");
  mm_menu_0731102932_0.addMenuItem("Industry Affiliations","location='http://www.efiglobal.com/efi_global_about/about_efi_industry_affiliations.shtml'");
  mm_menu_0731102932_0.addMenuItem("Careers","location='http://www.efiglobal.com/efi_global_about/about_efi_culture.shtml'");
  mm_menu_0731102932_0.addMenuItem("Locations","location='http://www.efiglobal.com/efi_global_locations/index_locations.shtml'");
   mm_menu_0731102932_0.hideOnMouseOut=true;
   mm_menu_0731102932_0.bgColor='#FFFFFF';
   mm_menu_0731102932_0.menuBorder=1;
   mm_menu_0731102932_0.menuLiteBgColor='#FFFFFF';
   mm_menu_0731102932_0.menuBorderBgColor='#FFFFFF';


  window.mm_menu_0731172236_0 = new Menu("root",233,18,"Arial, Helvetica, sans-serif",11,"#FFFFFF","#FFFFFF","#993333","#666666","left","middle",5,0,1000,-5,7,true,true,true,0,true,true);
  mm_menu_0731172236_0.addMenuItem("Engineering","location='http://www.efiglobal.com/efi_global_services/services_engineering.shtml'");
  mm_menu_0731172236_0.addMenuItem("Fire&nbsp;Investigations","location='http://www.efiglobal.com/efi_global_services/services_fire_investigations.shtml'");
  mm_menu_0731172236_0.addMenuItem("Environmental&nbsp;Services","location='http://www.efiglobal.com/efi_global_services/services_environmental.shtml'");
  mm_menu_0731172236_0.addMenuItem("Specialty&nbsp;and&nbsp;Consulting&nbsp;Services","location='http://www.efiglobal.com/efi_global_services/services_specialty_consulting.shtml'");
  mm_menu_0731172236_0.addMenuItem("Catastrophe&nbsp;Response&nbsp;Team","location='http://www.efiglobal.com/efi_global_services/services_catastrophe_response_team.shtml'");
  mm_menu_0731172236_0.addMenuItem("Projects","location='http://www.efiglobal.com/efi_global_projects/index_projects.shtml'");
  mm_menu_0731172236_0.addMenuItem("GSA&nbsp;Advantage","location='http://www.efiglobal.com/efi_global_services/services_gsa.shtml'");
  mm_menu_0731172236_0.addMenuItem("Request&nbsp;for&nbsp;Services","location='http://www.efiglobal.com/efi_global_contact/contact_request_services.shtml'");
   mm_menu_0731172236_0.hideOnMouseOut=true;
   mm_menu_0731172236_0.bgColor='#FFFFFF';
   mm_menu_0731172236_0.menuBorder=1;
   mm_menu_0731172236_0.menuLiteBgColor='#FFFFFF';
   mm_menu_0731172236_0.menuBorderBgColor='#FFFFFF';
   
  window.mm_menu_0906164731_0 = new Menu("root",200,18,"Arial, Helvetica, sans-serif",11,"#FFFFFF","#FFFFFF","#993333","#666666","left","middle",5,0,1000,-5,7,true,true,true,0,true,true);
  mm_menu_0906164731_0.addMenuItem("Engineering","location='http://www.efiglobal.com/efi_global_projects/projects_engineering.shtml'");
  mm_menu_0906164731_0.addMenuItem("Fire Investigations","location='http://www.efiglobal.com/efi_global_projects/projects_fire_investigations.shtml'");
  mm_menu_0906164731_0.addMenuItem("Environmental","location='http://www.efiglobal.com/efi_global_projects/projects_environmental.shtml'");
  mm_menu_0906164731_0.addMenuItem("Catastrophe","location='http://www.efiglobal.com/efi_global_projects/projects_catastrophe.shtml'");  
  mm_menu_0906164731_0.addMenuItem("Specialty and Consulting Services","location='http://www.efiglobal.com/efi_global_projects/projects_specialty_consulting.shtml'");
   mm_menu_0906164731_0.hideOnMouseOut=true;
   mm_menu_0906164731_0.bgColor='#FFFFFF';
   mm_menu_0906164731_0.menuBorder=1;
   mm_menu_0906164731_0.menuLiteBgColor='#FFFFFF';
   mm_menu_0906164731_0.menuBorderBgColor='#FFFFFF';   

  window.mm_menu_0801094813_0 = new Menu("root",148,18,"Arial, Helvetica, sans-serif",11,"#FFFFFF","#FFFFFF","#993333","#666666","left","middle",5,0,1000,-5,7,true,true,true,0,true,true);
  mm_menu_0801094813_0.addMenuItem("Press&nbsp;Releases","location='http://www.efiglobal.com/efi_global_news_events/news_events_press_releases.shtml'");
  mm_menu_0801094813_0.addMenuItem("Articles","location='http://www.efiglobal.com/efi_global_news_events/news_events_articles.shtml'");
  mm_menu_0801094813_0.addMenuItem("Events","location='http://www.efiglobal.com/efi_global_news_events/news_events_events.shtml'");
   mm_menu_0801094813_0.hideOnMouseOut=true;
   mm_menu_0801094813_0.bgColor='#FFFFFF';
   mm_menu_0801094813_0.menuBorder=1;
   mm_menu_0801094813_0.menuLiteBgColor='#FFFFFF';
   mm_menu_0801094813_0.menuBorderBgColor='#FFFFFF';

  window.mm_menu_0801094859_0 = new Menu("root",156,18,"Arial, Helvetica, sans-serif",11,"#FFFFFF","#FFFFFF","#993333","#666666","left","middle",5,0,200,-5,7,true,true,true,0,true,true);
  mm_menu_0801094859_0.addMenuItem("General&nbsp;Inquiry","location='http://www.efiglobal.com/efi_global_contact/contact_efi_general_inquiry.shtml'");
  mm_menu_0801094859_0.addMenuItem("Request&nbsp;for&nbsp;Services","location='http://www.efiglobal.com/efi_global_contact/contact_request_services.shtml'");
  mm_menu_0801094859_0.addMenuItem("Client&nbsp;Feedback","location='http://www.efiglobal.com/efi_global_contact/index_client_feedback.shtml'");
  mm_menu_0801094859_0.addMenuItem("Careers","location='http://www.efiglobal.com/efi_global_about/about_efi_culture.shtml'");
   mm_menu_0801094859_0.hideOnMouseOut=true;
   mm_menu_0801094859_0.bgColor='#FFFFFF';
   mm_menu_0801094859_0.menuBorder=1;
   mm_menu_0801094859_0.menuLiteBgColor='#FFFFFF';
   mm_menu_0801094859_0.menuBorderBgColor='#FFFFFF';

mm_menu_0801094859_0.writeMenus();
}

function doSearch(e)
{
	var sc = document.getElementById('addEvent').value;
	var url = 'http://172.16.5.44/search?q='+sc+'&btnG=Search+EFI+Global%2C+Inc.&sort=date%3AD%3AL%3Ad1&output=xml_no_dtd&oe=UTF-8&ie=UTF-8&client=default_frontend&proxystylesheet=default_frontend&site=Public';
	window.location = url;
}
function clearSearch(e)
{
		var el = window.event ? window.event.srcElement : e ? e.target : null;
		if(el.value == 'Search')
		{
				el.value = '';

		}

}

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_findObj(n, d) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); 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 checkWholeForm(e) {
    checkBoxCheck();
    var why = "";
    why += isEmpty(document.getElementById("Company"));
    why += isEmpty(document.getElementById("FirstName"));
    why += isEmpty(document.getElementById("LastName"));
    why += isEmpty(document.getElementById("City"));
    why += checkDropdown(document.getElementById("State"));
    why += isEmpty(document.getElementById("ZipCode"));
    why += isEmpty(document.getElementById("Country"));
    why += isEmpty(document.getElementById("AreaCode"));
    why += isEmpty(document.getElementById("Phone"));
    why += isEmpty(document.getElementById("Email"));
    why += checkDropdown(document.getElementById("service_type"));
    why += isEmpty(document.getElementById("lossZip"));
    why += isEmpty(document.getElementById("hearAbout"));
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}

function installListerners()
{
	//addEvent(window,"resize",resizewin);
	
	var el = document.getElementById('ctilist')
	if(el != null)
	{
			addEvent(el, "click", ctilist);
	}
	
	var searchBox = document.getElementsByName('textfield')[0];
	if(searchBox != null)
	{
		addEvent(searchBox,"focus",clearSearch, false);
	}
	
	var sb = document.getElementById('searchbutton');
	if(sb != null)
	{
		addEvent(sb, 'click', doSearch);
	}
	
	var el1 = document.getElementById("General_Inquiry");
	if(el1 != null)
	{
	    addEvent(el1, 'submit', checkWholeForm);
	}
}

addEvent(window,"load",doPreLoadImages);
addEvent(window,"load",installListerners);
addEvent(window,'unload',EventCache.flush);