<!--
function sf(){document.f.q.focus();}
function e(x){x =escape(x).replace(/\+/g,"%2b");return x;}
function c(p){if(document.f.q.value.length)location.href=p+'&q='+e(document.f.q.value);else location.href=p; return false;}
// -->


// Sets focus on the Google search box //
// The second number in the "onLoad" command in the body tag
// determines the form's focus. Counting starts with '0'
<!-- Begin
function putFocus(formInst, elementInst) {
	if (document.forms.length > 0) {
	document.forms[formInst].elements[elementInst].focus();
	}
}
//  End -->


// Drop-down navigation //
function openDir( form ) { 
var newIndex = form.fieldname.selectedIndex; 
if ( newIndex == 0 ) { 
	alert( "Please select your ID" ); 
} else { 
cururl = form.fieldname.options[ newIndex ].value; 
window.location.assign( cururl ); 
	} 
}


// "only 1 open at a time" popup function //
function openPop(url,width,height,addloptions){
	var xspot=Math.round((scrnwidth/2)-(width/2));
	var yspot=Math.round((scrnheight/2)-(height/2)-30);
	features = "height="+height+",width="+width+",top="+yspot+",screenY="+yspot+",left="+xspot+",screenX="+xspot;
	if (addloptions && addloptions!="") { features += ","+addloptions; }
	if (!popupWin || popupWin.closed){
		popupWin = window.open(url, '', features);
	}
	else {
		window.popupWin.close();
		popupWin = window.open(url, '', features);
	}
}


// Opens pop-up to specific window size //
var popUp;
function openPopUp(url, wd, ht) {
	var features = "resizable,width=" + wd + ",height=" + ht;
	if (!popUp || popUp.closed) {
		popUp = window.open(url, "", features);
	} else {
		popUp.close();
		popUp = window.open(url, "", features);
	}
}


// FIELD validation functions
function showMessage(msg,fld) {
	alert(msg);fld.focus();return;
}

function validEmail(fld) {
	if(fld.value.search(/^\w+((-\w+)|(\.\w+)|(\+\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9][A-Za-z0-9]+$/) == -1) {
		showMessage("Please enter a valid email address.",fld);return false; }
	return true;
}

// FORM validation function
function validateContact(fm) {
	if(fm.Visitor.value=="") { showMessage("Please enter your name.",fm.Visitor);return false; }
	if(!validEmail(fm.Email)) { return false; }
	// now submit the form
	return true; 
}


// Builds random, complete image tag for home page
var imgqty=3;  // Set this to QTY of available images. Image filenames are zero-indexed (1st one is 0).
var rndm=Math.round(Math.random() * (imgqty-1));
var imgstr='<img src="images/hp_' + rndm + '.jpg" width="750" height="300" border="0" alt="">';


// thumbnail - photo swap //
function switchMainPhoto(photoidnum) {
	if(document.getElementById) {
		document.getElementById("mainphoto").src = "images/"+photoidnum+".jpg";
	}
}