var total1 = 0;	
var popup_window = null;
function ltrim (s) {
	return s.replace(/^\s*/, "");
}

function rtrim (s) {
	return s.replace(/\s*$/, "");
}

function trim (s) {
	return rtrim(ltrim(s));
}

function total(x){
	if (x == 1){
		total1 = total1 + 1;
		this.document.sender.TotalScore.value = total1;
	}else{
		total1 = total1 + 0;
	}
}

function password() {
         popup_window = window.open('password.html', 'GolfShow',
         'width=450,height=200,resizable=1');
}

function goForit() {
  var location;
  var password;
  password=this.document.testform.inputbox.value
  if (password =="80034"){
	location="golfshow.asp";
   } else {
	location="index.html";
   }		
  fetch(location)
  theKeeper=window.close()
}

function fetch(location) {
  var root;
  if (opener.closed) {
    root=window.open('','theKeepersGopher','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=no');
    root.location.href = location;
  } else {
    opener.location.href = location;
  }
}

function ltrim (s) {
	return s.replace(/^\s*/, "");
}

function rtrim (s) {
	return s.replace(/\s*$/, "");
}

function trim (s) {
	return rtrim(ltrim(s));
}

function validateForm() {
	var allQuestionsAnswered = true;
	var messageString = "Sorry, we cannot accept your entry until the following sections are completed:\n\n";
	var messageString2 = "Thank you, your registration form has been submitted!";

	/**************  CORE SECTION ******************/
	
	if (trim(document.forms.coreform.txtQ1.value) == "") {
		messageString = messageString + "- An answer to question # 1\n";
		allQuestionsAnswered = false;
	}
	if (trim(document.forms.coreform.txtQ2.value) == "") {
		messageString = messageString + "- An answer to question # 2\n";
		allQuestionsAnswered = false;
	}
	if (trim(document.forms.coreform.txtQ3.value) == "") {
		messageString = messageString + "- An answer to question # 3\n";
		allQuestionsAnswered = false;
	}
	if (trim(document.forms.coreform.txtQ4.value) == "") {
		messageString = messageString + "- An answer to question # 4\n";
		allQuestionsAnswered = false;
	}
	if (trim(document.forms.coreform.txtName.value) == "") {
		messageString = messageString + "- Your Full Name\n";
		allQuestionsAnswered = false;
	}
	if (trim(document.forms.coreform.txtPhone.value) == "") {
		messageString = messageString + "- Your Phone Number\n";
		allQuestionsAnswered = false;
	}
	if (trim(document.forms.coreform.txtEmail.value) == "") {
		messageString = messageString + "- Your Email Address\n";
		allQuestionsAnswered = false;
	}

	if (allQuestionsAnswered) {
		alert(messageString2);
		document.forms.coreform.submit();
	}
	else {
		alert(messageString);
	}
}