// JavaScript Document


function newWindow(page){
  popWindow=window.open(page,"popWindow","status=1,scrollbars=1,resizable=1,width=580,height=430")
 popWindow.focus()
}

var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=1,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}



// Flip it on!
function roll(imgName) {
	if (document.images) { document[imgName].src = "i/menu/" + imgName + "-on.gif" }
}
// Flip it off!
function out(imgName) {
	if (document.images)  {	document[imgName].src = "i/menu/" + imgName + ".gif" }
}
// Flip it on!
function roll(imgName) {
	if (document.images) { document[imgName].src = "i/menu/" + imgName + "-on.jpg" }
}
// Flip it off!
function out(imgName) {
	if (document.images)  {	document[imgName].src = "i/menu/" + imgName + ".jpg" }
}




//use the following var to remember an image's original src value
//the imageRoll function will constantly update this value, allowing the imageOut function to use its current value
var imageSourceValue = '';
function imageRoll(imageObject)
{
	//store the current src value
	imageSourceValue = imageObject.src;
	//grab the directory from the src attribute
	var folderIndex = imageObject.src.lastIndexOf("/");
	var theDirectory = imageObject.src.substring(0,folderIndex+1);//returns the DIR in the form http://domain.com/folder
	//test for image file type, jpg v. gif
	var theFileType = imageObject.src.substring(imageObject.src.length-3);//grab the last 3 characters, they represent the file type

	imageObject.src=theDirectory+imageObject.name+'-on.'+theFileType;
}
function imageOut(imageObject)
{
	//retrieve the original image src attribute
	imageObject.src = imageSourceValue;
}


function emailCheck()
{
	//test for required fields
	
	var re = new RegExp("^[A-Za-z0-9_-]+[A-Za-z0-9_\.\-]*[A-Za-z0-9_-]+@[A-Za-z0-9_-]+[A-Za-z0-9\.-]*\\.[a-zA-Z]{2,4}$","i");
	
	if(!re.test(document.form1.email.value))
	{
		alert("Your email address is invalid.");
	}
	else if(document.form1.firstname.value == ""){alert("Please enter your first name.");}
	else if(document.form1.lastname.value == ""){alert("Please enter your last name.");}
	else if(document.form1.address1.value == ""){alert("Please enter your street address.");}
	else if(document.form1.city.value == ""){alert("Please enter your city.");}
	else if(document.form1.state.value == ""){alert("Please enter your state.");}
	else if(document.form1.zip.value == ""){alert("Please enter your zip code.");}
	else if(document.form1.homephone.value == ""){alert("Please enter phone number.");}
	
	else{document.form1.submit();}

}