////////////////////////////////////////
// Common (all pages) 
////////////////////////////////////////

hdrt=new Image(); hdrt.src="images/header-right.gif";
hdrt_=new Image(); hdrt_.src="images/header-right_.gif";

function policy(which) {
var page = "p_"+which+".html";
var viewpolicy = window.open(page,"","width=400,height=300,resizable=no,toolbar=no,location=no,directories=no,status=no,menubar=no,titlebar=no,scrollbars=yes");
}

////////////////////////////////////////
// Catering (menu application)
////////////////////////////////////////

elimit=0;
slimit=0;
alimit=0;

function setsize(mysize) {
	if(mysize==0) { elimit=2; slimit=1; alimit=0; }	
	if(mysize==1) { elimit=2; slimit=2; alimit=1; }	
	if(mysize==2) { elimit=3; slimit=3; alimit=2; }	
	if(mysize==3) { elimit=4; slimit=4; alimit=3; }	
var message=
"You've selected party size "+mysize+". This includes the following:<br>"+
elimit+" entrees, "+slimit+" sides, and "+alimit+" addons."
;
	document.getElementById('partysize').innerHTML=message;
	document.caterthis.reset();
}

function checkme(box) {
var total=0;
if(box.name=="entree") {
for(var i=0; i < document.caterthis.entree.length; i++) {
	if(document.caterthis.entree[i].checked) { total=total+1; }
	if(total > elimit) {
		alert("Choose different party size to add more entrees.");
		box.checked = false;
		return false;
		} } }
if(box.name=="side") {
for(var i=0; i < document.caterthis.side.length; i++) {
	if(document.caterthis.side[i].checked) { total=total+1; }
	if(total > slimit) {
		alert("Choose different party size to add more sides.");
		box.checked = false;
		return false;
		} } }
if(box.name=="addon") {
for(var i=0; i < document.caterthis.addon.length; i++) {
	if(document.caterthis.addon[i].checked) { total=total+1; }
	if(total > alimit) {
		alert("Choose different party size to add another addon.");
		box.checked = false;
		return false;
		} } }
}

////////////////////////////////////////
// Contact (form validation)
////////////////////////////////////////

function validate_required(field,alerttxt) {
with (field) {
	if (value==null||value=="") {alert(alerttxt);return false;}
	else {return true}
	}
}

function validate_email(field,alerttxt) {
with (field) {
	apos=value.indexOf("@");
	dotpos=value.lastIndexOf(".");
	if (apos<1||dotpos-apos<2) {alert(alerttxt);return false;}
		else {return true;}
	}
}

function validate_form(thisform) {
with (thisform) {
if (validate_required(fullname,"Please include your full name.")==false)
	{fullname.focus();return false;}
if (email.value!="") { if (validate_email(email,"Please make sure your email address is valid.")==false)
	{email.focus();return false;} }
if (validate_required(comments,"Please include your comments.")==false)
	{comments.focus();return false;}
	}
}

////////////////////////////////////////
// Employee Portal
////////////////////////////////////////

function yousure(){
    msg = "Are you sure you wish to make these changes?";
    return confirm(msg);
    }