// lazy shortcut

d=document;

// set up rollovers

sections = new Array("developments","profile","services","team","contact");
for (x=0;x<=sections.length-1;x++){
setup = sections[x]+'on = new Image();'+sections[x]+'on.src = "resources/img/nav/'+sections[x]+'_on.gif";'+sections[x]+'off = new Image();'+sections[x]+'off.src = "resources/img/nav/'+sections[x]+'_off.gif";';
eval(setup);
}

// rollover 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");}}

// status bar set

window.status=d.title;

// window popper

function popwin(url,width,height){
window.open(url,'popup','width='+width+',height='+height+',location=0,address=0,scrollbars=0,status=0,noresize');
}

// subscription checker

function checksubscribe(which){	
	var errmsg = "";	
	if (which.email.value == "" || !isEmailAddr(which.email.value) || which.email.value.length < 3){
	   	errmsg = errmsg + "· The Email field does not appear to be filled out correctly.\n";
	 	}
	if (errmsg!=""){
		alert(errmsg);
		return false;
	}else{
		return true;		
	}
}

// Contact Form Checker

function checkcontact(which){	

	var errmsg = "";	
	
	if (which["name"].value==""){errmsg = errmsg + "· The Name field does not appear to be filled out correctly.\n";}
	if (which.email.value == "" || !isEmailAddr(which.email.value) || which.email.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;
	}
	

}

// email format checker

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;
}