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 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 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 go2()
{
	box = document.forms[0].country;
	destination = box.options[box.selectedIndex].value;
	theurl = "competitors.php?page_id=23&mycountry="+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 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 formvalidation(form) {
	with (form) {
	if (emptyvalidation(name,"Please Enter Your Name")==false) {name.focus(); return false;};
	if (emptyvalidation(email,"Please Enter An Email Address")==false) {email.focus(); return false;};
	if (emptyvalidation(comments,"Please Specify Your Comments")==false) {comments.focus(); return false;};
this.form.submit();
}
}


function regvalidation(form) {
	with (form) {
	if (emptyvalidation(competitor_fname,"Please Enter Your First Name")==false) {competitor_fname.focus(); return false;};
	if (emptyvalidation(competitor_lname,"Please Enter Your Last Name")==false) {competitor_lname.focus(); return false;};
	if (emptyvalidation(competitor_age,"Please Enter Your AGE")==false) {competitor_age.focus(); return false;};
	if (emptyvalidation(competitor_email,"Please Enter An Email Address")==false) {competitor_email.focus(); return false;};
	if (emptyvalidation(competitor_country,"Please Specify Your Country")==false) {competitor_country.focus(); return false;};
	if (emptyvalidation(PaymentMadeby,"Please Specify The Name of the Person Making This Payment")==false) {PaymentMadeby.focus(); return false;};
	if (emptyvalidation(NameofCardholder,"Please Enter the Cardholder's Name")==false) {NameofCardholder.focus(); return false;};
	if (emptyvalidation(CCNumber,"Please Enter a valid Credit Card Number")==false) {CCNumber.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 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 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 openEmailPage(id) {	
	leftPos = (screen.width / 2) - 270;
	topPos = (screen.height / 2) - 250;
	newwin = window.open('email_competitor.php?c='+id+'','emailComp','width=540,height=500,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=0');
}
function validate_CCNumber(string) {
    if (!string) return false;
    var hoink=string.length;
    if(hoink<16) 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 NameofCardholder_response(){
alert('Letters Only Please ');
document.form.NameofCardholder.value = "";
document.form.NameofCardholder.focus();
}
function PaymentMadeby_response(){
alert('Letters Only Please ');
document.form.PaymentMadeby.value = "";
document.form.PaymentMadeby.focus();
} 

function CCNumber_response(){
alert('Please enter a valid Credit Card Number ');
document.form.CCNumber.value = "";
document.form.CCNumber.focus();
}

