function emptyvalidation(entered, alertbox)
{
with (entered)
{
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}


function nonevalidation(entered, alertbox)
{
with (entered)
{
if (value=="none")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function Length_TextField_Validator()
{
// Check the length of the value of the element named text_name
// from the form named form_name if it's < 3 and > 10 characters
// display a message asking for different input
if (form.keyword.value.length < 3)
{
// Build alert box message showing how many characters entered
mesg = "You have entered " + form.keyword.value.length + " character(s)\n"
mesg = mesg + "Valid entries are at least 3 characters in length.\n"
mesg = mesg + "Please verify your input and submit again."
alert(mesg);
// Place the cursor on the field for revision
form.keyword.focus();
// return false to stop further processing
return (false);
}
// If text_name is not null continue processing
return (true);
}

function searchVal(form) {
	with (form) {

	if (emptyvalidation(keyword,"Please Enter a Search word")==false) {keyword.focus(); return false;};
this.form.submit();
}
}

function staffvalidation(form) {
	with (form) {
	if (emptyvalidation(sc_username,"Please enter your USERNAME")==false) {sc_username.focus(); return false;};
	if (emptyvalidation(sc_password,"Please enter your PASSWORD")==false) {sc_password.focus(); return false;};
	
this.form.submit();
}
}

function formvalidation(form) {
	with (form) {
	if (emptyvalidation(em_name,"Please Enter Your Name")==false) {em_name.focus(); return false;};
	if (emptyvalidation(em_email,"Please Enter An Email Address")==false) {em_email.focus(); return false;};
	if (emptyvalidation(em_comments,"Please Specify Your Comments")==false) {em_comments.focus(); return false;};
this.form.submit();
}
}

function go()
{
	box = document.forms[0].country;
	destination = box.options[box.selectedIndex].value;
	theurl = "misc.php?page_id=93&country="+destination;
	if (destination) location.href = theurl;
}
function go3()
{
	box = document.forms[0].country;
	destination = box.options[box.selectedIndex].value;
	theurl = "reservations.php?page_id=104&country="+destination;
	if (destination) location.href = theurl;
}

function goCC()
{
this.form.submit();
}


function validate_nums(string) {
    if (!string) return false;
    var nums = "0123456789";
    for (var n = 0; n < string.length; n++) {
       if (nums.indexOf(string.charAt(n)) == -1)
          return false;
    }
    return true;
}  
function validate_letters(string) {
    if (!string) return false;
    string=string.toUpperCase(); 
    var chars = "QWERTYUIOPASDFGHJKLZXCVBNM";
    for (var m = 0; m < string.length; m++) {
       if (chars.indexOf(string.charAt(m)) == -1)
          return false;
    }
    return true;
}

function isValidNumber(field)
	{
	var valid = "0123456789"
	var ok="yes";
	var temp;
	for (var i=0; i<field.value.length; i++)
		{ 
		temp = "" + field.value.substring(i,i+1);
		if (valid.indexOf(temp) == -1) ok = "no";
		}
		if (ok == "no")
			{ 
			alert ("Invalid entry!\n\nOnly numbers are allowed!\n\nExample: 123456");
			field.focus(); 
			field.select();
			}
	}

function validate(form)
	{
		var submitform = true;
		var manfields = "Some errors occurred when submitting the page.  Please fix them and try again:\n_________________________________________________________\n\n";
		var form = document.form;
		var valid = "0123456789"
		var ok="yes";
		var temp;
		if (form.FirstName.value == '')
			{
			submitform = false;
			manfields += "First Name is mandatory.\n";
			}
		if (form.LastName.value == '')
			{
			submitform = false;
			manfields += "Last Name is mandatory.\n";
			}
		if (form.Age.value == '')
			{
			submitform = false;
			manfields += "Age is mandatory.\n";
			}
		if (form.AbilityCode[0].selected)
			{
			submitform = false;
			manfields += "Ability Level is mandatory.\n";
			}
		if (form.Rental[0].checked)
			{
			if (form.Height.value == '')
				{
				submitform = false;
				manfields += "Height is mandatory when renting.\n";
				}
			if (form.Weight.value == '')
				{
				submitform = false;
				manfields += "Weight is mandatory when renting.\n";
				}
			if (form.ShoeSize.value == '')
				{
				submitform = false;
				manfields += "Shoe Size is mandatory when renting.\n";
				}
			// Validation for a shoe size type.
			var CheckboxProceed = 0;
			for (i=0; i<=1; i++)
				{
				if (form.ShoeSizeType[i].checked)
					{
					CheckboxProceed = 1;
					break;
					}
				}
			if (CheckboxProceed == 0)
				{
				submitform = false;
				manfields += "Shoe Size Type (child or adult) is mandatory when renting.\n";
				}
			}
		if(submitform == false)
			{
			alert(manfields);
			return false;
			}
	}


function formvalidation(form) {
	with (form) {
	if (emptyvalidation(keyword,"Please Enter a Search word")==false) {keyword.focus(); return false;};

this.form.submit();
}
}


function openSesame(theURL) {
		leftPos = (screen.width / 2) - 200;
	topPos = (screen.height / 2) - 150;
  window.open(theURL,'vid','width=400,height=300,left='+leftPos+',top='+topPos+',innerHeight=0,innerWidth=0,outerHeight=0,outerWidth=0,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0');
}
function openJoe()
{	
	leftPos = (screen.width / 2) - 200;
	topPos = (screen.height / 2) - 150;
	newwin = window.open('joe.php','joe','width=400,height=300,left='+leftPos+',top='+topPos+',innerHeight=0,innerWidth=0,outerHeight=0,outerWidth=0,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0');
}


function paylogin_validation(form) {
	with (form) {
	if (emptyvalidation(conf_num,"Please Enter Your Confirmation Number")==false) {conf_num.focus(); return false;};
	if (emptyvalidation(password,"Please Enter a Password")==false) {password.focus(); return false;};
	
this.form.submit();
}
}


function IsEmailValid(FormName,ElemName)
{
var EmailOk  = true
var Temp     = document.forms[FormName].elements[ElemName]
var AtSym    = Temp.value.indexOf('@')
var Period   = Temp.value.lastIndexOf('.')
var Space    = Temp.value.indexOf(' ')
var Length   = Temp.value.length - 1   

if ((AtSym < 1) ||                    
    (Period <= AtSym+1) ||            
    (Period == Length ) ||          
    (Space  != -1))                  
   {  
      EmailOk = false
      alert("Please enter a valid e-mail address!");
      Temp.value="";
      Temp.focus()
   }
return EmailOk
}


function waiverfname_response(){

document.form.f_name.value = "";
document.form.f_name.focus();
alert('Letters Only Please');

}
function waiverlname_response(){

document.form.l_name.value = "";
document.form.l_name.focus();
alert('Letters Only Please');
}

function appfname_response(){

document.form.fname.value = "";
document.form.fname.focus();
alert('Letters Only Without Spaces Please');

}
function applname_response(){

document.form.lname.value = "";
document.form.lname.focus();
alert('Letters Only Without Spaces Please');
}

function brofname_response(){

document.form.f_name.value = "";
document.form.f_name.focus();
alert('Letters Only Without Spaces Please');

}
function brolname_response(){

document.form.l_name.value = "";
document.form.l_name.focus();
alert('Letters Only Without Spaces Please');
}

function openPagePrint(page_id) {	
	leftPos = (screen.width / 2) - 360;
	topPos = (screen.height / 2) - 270;
	newwin = window.open('print_page.php?page_id='+page_id+'','PrintPage','width=720,height=540,left='+leftPos+',top='+topPos+',innerHeight=0,innerWidth=0,outerHeight=0,outerWidth=0,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=1');
}



function trimAll(sString)
{
while (sString.substring(0,1) == ' ')
{
sString = sString.substring(1, sString.length);
}
while (sString.substring(sString.length-1, sString.length) == ' ')
{
sString = sString.substring(0,sString.length-1);
}
return sString;
}