

var isNN = (navigator.appName.indexOf("Netscape")!=-1);
if(isNN) document.captureEvents(Event.KEYPRESS);

//autoTab(this,3,event,1);
function autoTab(input,len, e, selectit) {
	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();
		if (selectit==1) input.form[(getIndex(input)+1) % input.form.length].select();
	}

	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;
}

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;
}

function valContact(theForm) {
  if (theForm.ContactName.value == "" )
  {
    alert("Please enter your Name.");
    theForm.ContactName.focus();
    return (false);
  }

  if (theForm.ContactEmail.value == "" || !isEmailAddr(theForm.ContactEmail.value))
  {
    alert("Please enter a valid Email Address.");
    theForm.ContactEmail.focus();
    return (false);
  }

  if (theForm.ContactSubject.value == "" )
  {
    alert("Please enter a Subject.");
    theForm.ContactSubject.focus();
    return (false);
  }

  if (theForm.ContactMessage.value == "" )
  {
    alert("Please enter a Message.");
    theForm.ContactMessage.focus();
    return (false);
  }

  return (true);
}

function valRequest(theForm)
{

  if (theForm.eventdate.value == "" )
  {
    alert("Please enter the date of your event.");
    theForm.eventdate.focus();
    return (false);
  }

  if (theForm.q0.value == "" )
  {
    alert("Please enter a name for the Guest of Honor.");
    theForm.q0.focus();
    return (false);
  }

  if (theForm.q1.value == "" )
  {
    alert("Please enter the Party Coordinator's Name.");
    theForm.q1.focus();
    return (false);
  }

  	if (theForm.q3a.value == "" )
	{
		alert("Please enter the Coordinator's Phone Number.");
		theForm.q3a.focus();
		return (false);
	}

   	if (theForm.q3b.value == "" )
	{
		alert("Please enter the Coordinator's Phone Number.");
		theForm.q3b.focus();
		return (false);
	}
  	if (theForm.q3c.value == "" )
	{
		alert("Please enter the Coordinator's Phone Number.");
		theForm.q3c.focus();
		return (false);
	}
 
  
  if (theForm.q4.value == "" || !isEmailAddr(theForm.Email.value))
  {
    alert("Please enter the Coordinator's valid Email Address.");
    theForm.q4.focus();
    return (false);
  }  
  



	if (theForm.o1.value == "" )
  {
    alert("Please enter the arrival time.");
    theForm.o1.focus();
    return (false);
  }
 	if (theForm.Guests.value == "" )
  {
    alert("Please enter the number of guests.");
    theForm.Guests.focus();
    return (false);
  }  
/*  
  	if (theForm.o0.value == "" )
  {
    alert("Please enter the type of party.");
    theForm.arrival_time.focus();
    return (false);
  }
*/
  return (true);

}


function val2Request(theForm)
{

  if (theForm.eventdate.value == "" )
  {
    alert("Please enter the date of your event.");
    theForm.eventdate.focus();
    return (false);
  }

  if (theForm.q0.value == "" )
  {
    alert("Please enter business name.");
    theForm.q0.focus();
    return (false);
  }

  if (theForm.q1.value == "" )
  {
    alert("Please enter the Party Coordinator's Name.");
    theForm.q1.focus();
    return (false);
  }

  	if (theForm.q3a.value == "" )
	{
		alert("Please enter the Coordinator's Phone Number.");
		theForm.q3a.focus();
		return (false);
	}

   	if (theForm.q3b.value == "" )
	{
		alert("Please enter the Coordinator's Phone Number.");
		theForm.q3b.focus();
		return (false);
	}
  	if (theForm.q3c.value == "" )
	{
		alert("Please enter the Coordinator's Phone Number.");
		theForm.q3c.focus();
		return (false);
	}
 
  
  if (theForm.q4.value == "" || !isEmailAddr(theForm.Email.value))
  {
    alert("Please enter the Coordinator's valid Email Address.");
    theForm.q4.focus();
    return (false);
  }  
  



	if (theForm.o1.value == "" )
  {
    alert("Please enter the arrival time.");
    theForm.o1.focus();
    return (false);
  }
 	if (theForm.Guests.value == "" )
  {
    alert("Please enter the number of guests.");
    theForm.Guests.focus();
    return (false);
  }  
  return (true);

}
