// lazy shortcut

d=document;

// set up rollovers

if (d.images) {	
	sections = new Array("home","services","edge","results","resources","about","contact");
	for (x=0;x<=sections.length;x++){
	var setup = sections[x]+'on = new Image();'+sections[x]+'on.src = "images/global/nav/'+sections[x]+'_on.gif";'+sections[x]+'off = new Image();'+sections[x]+'off.src = "images/global/nav/'+sections[x]+'_off.gif";'
	eval(setup)
	}
}

// roll functions

function on(which){if (d.images){document[which].src = eval(which + "on.src");}}
function off(which){if (d.images){document[which].src = eval(which + "off.src");}}

// window opener

function popwin(url,name,width,height){
var t=(screen.height-height)/2;
var l=(screen.width-width)/2;
window.open(url,name,'width='+width+',height='+height+',top='+t+',left='+l+',location=0,status=0,scrollbars=0,toolbar=0,resizeable=no,noresize');
}

// newsletter elements

function checknewsletter(which){	
	var errmsg = "";	
	if ((which.email_address.value == "")||(!isEmailAddr(which.email_address.value))||(which.email_address.value.length < 3)){
    errmsg = errmsg + "· The Email field does not appear to be filled out correctly.\n";
  	}	
	if (errmsg!=""){
		errmsg="The following errors were found:\n\n"+errmsg+"\nPlease fix these errors and try again.";
		alert(errmsg);
		return false;
	}else{
		return true;
	}
}

// free market analysis elements

function checkfma(which){	
	var errmsg = "";	
	if (which.contact_name.value==""){errmsg = errmsg + "· The Contact Name field does not appear to be filled out correctly.\n";}
	if (which.company_name.value==""){errmsg = errmsg + "· The Company Name field does not appear to be filled out correctly.\n";}
	if (which.city.value==""){errmsg = errmsg + "· The City field does not appear to be filled out correctly.\n";}
	if (which.state.value==""){errmsg = errmsg + "· The State field does not appear to be filled out correctly.\n";}
	if ((which.email_address.value == "")||(!isEmailAddr(which.email_address.value))||(which.email_address.value.length < 3)){
    errmsg = errmsg + "· The Email field does not appear to be filled out correctly.\n";
  	}	
	if (errmsg!=""){
		errmsg="The following errors were found:\n\n"+errmsg+"\nPlease fix these errors and try again.";
		alert(errmsg);
		return false;
	}else{
		return true;
	}
}

// global email

function isEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}