var browser_name = navigator.appName;


var win=null;
function NewWindow(mypage,myname,w,h,pos,infocus){
	if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}
	settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=yes,location=yes,directories=yes,status=yes,menubar=yes,toolbar=yes,resizable=yes";
	win=window.open(mypage,myname,settings);
	win.focus();
}

 /////////////////////////////////////////
 //FORMS/AUTOTAB: Auto Tab with phone numbers
 /////////////////////////////////////////
 var isNN = (navigator.appName.indexOf("Netscape")!=-1);
 function autoTab(input,len, e) {
 var keyCode = (isNN) ? e.which : e.keyCode;
 var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
 if(input.value.length >= len && !containsElement(filter,keyCode)) {
 input.value = input.value.slice(0, len);
 input.form[(getIndex(input)+1) % input.form.length].focus();
 }
 function containsElement(arr, ele) {
 var found = false, index = 0;
 while(!found && index < arr.length)
 if(arr[index] == ele)
 found = true;
 else
 index++;
 return found;
 }
 function getIndex(input) {
 var index = -1, i = 0, found = false;
 while (i < input.form.length && index == -1)
 if (input.form[i] == input)index = i;
 else i++;
 return index;
 }
 return true;
}

///////////////////////////////////////////
//NAVIGATION: rolls
///////////////////////////////////////////
/*
Author: Michele
Date: 01/24/2005 
Description: navigation rollovers
*/
if (document.images) {
	var emb1off = new Image();
	emb1off.src = "images/homeoff.gif";
	var emb2off = new Image();
	emb2off.src = "images/historyoff.gif";
	var emb3off = new Image();
	emb3off.src = "images/teamoff.gif";
	var emb4off = new Image();
	emb4off.src = "images/winesoff.gif";
	var emb5off = new Image();
	emb5off.src = "images/contactoff.gif";
	var emb6off = new Image();
	emb6off.src = "images/joinoff.gif";
	
	var emb1on = new Image();
	emb1on.src = "images/homeon.gif";
	var emb2on = new Image();
	emb2on.src = "images/historyon.gif";
	var emb3on = new Image();
	emb3on.src = "images/teamon.gif";
	var emb4on = new Image();
	emb4on.src = "images/wineson.gif";
	var emb5on = new Image();
	emb5on.src = "images/contacton.gif";	
	var emb6on = new Image();
	emb6on.src = "images/joinon.gif";

function img_act(imgName) {
	if (document.images) {
		document.images[imgName].src = eval(imgName + "on.src");
	}
}

function img_inact(imgName) {
	if (document.images) {
		document.images[imgName].src = eval(imgName + "off.src");
	}
}

}

function showDiv(layer) {
  	elem = document.getElementById(layer);
  	elem.style.display = "block";
}
function hideDiv(layer) {
  	elem = document.getElementById(layer);
  	elem.style.display = "none";
}


function ValidateForm () {
	error = false;

	error_message = "The following error(s) must be corrected before the form can be submitted:\n\n";

	f = document.theForm;


	if (f.firstname.value == '') {
		error_message = error_message + "* The 'First Name' field is blank\n";
		error = true;
	}

	if (f.lastname.value == '') {
		error_message = error_message + "* The 'Last Name' field is blank\n";
		error = true;
	}

	if (!f.ageVerification.checked) {
		error_message = error_message + "* Please check the 'Age Verification' checkbox.\n";
		error = true;
	}

	var    stateID = f.states.options[f.states.selectedIndex].value;
		
	if ((stateID == 0)) {

		error_message = error_message + "* You must select a U.S. state to continue\n";

		error = true;
	}


	// ALERT AND RETURN FALSE IF ERROR

	if (error == true) {

		alert (error_message);

		return false;
	}

	// OTHERWISE, RETURN TRUE

	return true;

}



