function openNewWindow(address) {
	newWindow = window.open(address, "winAdmin", "width=700,height=600,innerWidth=700,innerHeight=600,toolbar=yes,personalbar=no,locationbar=no,statusbar=no,scrollbars=yes,resizable=yes");
	newWindow.focus();
}

function confirm_delete(){
    var answer=confirm("Do you want to delete the record?");
    if (answer==false)
    { 
        return false;
    }
    else 
        return true;
}

function verify_login () {
  if (document.login.uLogin.value == "") {
    alert("Please enter username!");
    document.login.uLogin.focus();
    return false;
  }
  if (document.login.uPass.value == "") {
    alert("Please enter password!");
    document.login.uPass.focus();
    return false;
  }    
}

function verify_ticket () {
  if (document.editTicket.tTitle.value == "") {
    alert(document.editTicket.tTitle.tag);
    document.editTicket.tTitle.focus();
    return false;
  }
  if (document.editTicket.tDescription.value == "") {
    alert(document.editTicket.tDescription.tag);
    document.editTicket.tDescription.focus();
    return false;
  }
  if (document.editTicket.tPriceA.value == "") {
    alert(document.editTicket.tPriceA.tag);
    document.editTicket.tPriceA.focus();
    return false;
  }
  else if (document.editTicket.tPriceA.value > "") {
  	// only allow 0-9, and decimal point be entered
	var checkOK = "0123456789.";
	var checkStr = document.editTicket.tPriceA.value;
	var allValid = true;
	var decPoints = 0;
	var allNum = "";
	for (i = 0;  i < checkStr.length;  i++) {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++) {
			if (ch == checkOK.charAt(j))
			break;
		}
		if (j == checkOK.length) {
			allValid = false;
			break;
		}
		if (ch != ".")
			allNum += ch;
	}
	if (!allValid) {
		alert(document.editTicket.tPriceA.tag);
		document.editTicket.tPriceA.focus();
		return (false);
	}
  }
  
  if (document.editTicket.tPriceB.value == "") {
    alert(document.editTicket.tPriceB.tag);
    document.editTicket.tPriceB.focus();
    return false;
  }
  else if (document.editTicket.tPriceB.value > "") {
  	// only allow 0-9, and decimal point be entered
	var checkOK = "0123456789.";
	var checkStr = document.editTicket.tPriceB.value;
	var allValid = true;
	var decPoints = 0;
	var allNum = "";
	for (i = 0;  i < checkStr.length;  i++) {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++) {
			if (ch == checkOK.charAt(j))
			break;
		}
		if (j == checkOK.length) {
			allValid = false;
			break;
		}
		if (ch != ".")
			allNum += ch;
	}
	if (!allValid) {
		alert(document.editTicket.tPriceB.tag);
		document.editTicket.tPriceB.focus();
		return (false);
	}
  }
  
  if (document.editTicket.tAircraft.value == "") {
    alert(document.editTicket.tAircraft.tag);
    document.editTicket.tAircraft.focus();
    return false;
  }

  if (document.editTicket.tSeats.value == "") {
    alert(document.editTicket.tSeats.tag);
    document.editTicket.tSeats.focus();
    return false;
  }
  else if (document.editTicket.tSeats.value > ""){
	// only allow numbers to be entered
	var checkOK = "0123456789";
	var checkStr = document.editTicket.tSeats.value;
	var allValid = true;
	var allNum = "";
	for (i = 0;  i < checkStr.length;  i++) {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++) { 
			if (ch == checkOK.charAt(j))
				break;
		}
		if (j == checkOK.length) {
			allValid = false;
			break;
		}
		if (ch != ",")
			allNum += ch;
	}
	if (!allValid) {
		alert(document.editTicket.tSeats.tag);
		document.editTicket.tSeats.focus();
		return (false);
	}
  }

  if (document.editTicket.tDepart.value == "") {
    alert(document.editTicket.tDepart.tag);
    document.editTicket.tDepart.focus();
    return false;
  }

  if (document.editTicket.tArrival.value == "") {
    alert(document.editTicket.tArrival.tag);
    document.editTicket.tArrival.focus();
    return false;
  }
  if (document.editTicket.tDepartAirport.value == "") {
    alert(document.editTicket.tDepartAirport.tag);
    document.editTicket.tDepartAirport.focus();
    return false;
  }

  if (document.editTicket.tArriveAirport.value == "") {
    alert(document.editTicket.tArriveAirport.tag);
    document.editTicket.tArriveAirport.focus();
    return false;
  }
}

function verify_agent () {
  if (document.editAgent.tAgencyID.value == "") {
    alert("Please enter agency!");
    document.editAgent.tAgencyID.focus();
    return false;
  }
  else if (document.editAgent.tAgencyID.value > ""){
	// only allow numbers to be entered
	var checkOK = "123456789";
	var checkStr = document.editAgent.tAgencyID.value;
	var allValid = true;
	var allNum = "";
	for (i = 0;  i < checkStr.length;  i++) {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++) { 
			if (ch == checkOK.charAt(j))
				break;
		}
		if (j == checkOK.length) {
			allValid = false;
			break;
		}
		if (ch != ",")
			allNum += ch;
	}
	if (!allValid) {
		alert("Please enter agencyid > 0!");
		document.editAgent.tAgencyID.focus();
		return (false);
	}
  }

  if (document.editAgent.tUsername.value == "") {
    alert("Please enter username!");
    document.editAgent.tUsername.focus();
    return false;
  }
  if (document.editAgent.tPassword.value == "") {
    alert("Please enter password!");
    document.editAgent.tPassword.focus();
    return false;
  }    
  if (document.editAgent.tPassword2.value == "") {
    alert("Please confirm password!");
    document.editAgent.tPassword2.focus();
    return false;
  }    
  if (document.editAgent.tEmail.value == "") {
    alert("Please enter password!");
    document.editAgent.tEmail.focus();
    return false;
  }    
  if (document.editAgent.tPassword.value != document.editAgent.tPassword2.value) {
    alert("The confirm password is not identical with password!");
    document.editAgent.tPassword2.focus();
    return false;
  }    
}

function verify_config () {
  if (document.config.tUsername.value == "") {
    alert(document.config.tUsername.tag);
    document.config.tUsername.focus();
    return false;
  }
  if (document.config.tPassword.value == "") {
    alert(document.config.tPassword.tag);
    document.config.tPassword.focus();
    return false;
  }
  if (document.config.tPassword2.value == "") {
    alert(document.config.tPassword2.tag);
    document.config.tPassword2.focus();
    return false;
  }
  if (document.config.tCurrencyRate.value == "") {
    alert(document.config.tCurrencyRate.tag);
    document.config.tCurrencyRate.focus();
    return false;
  }
  if (document.config.tEmail.value == "") {
    alert(document.config.tEmail.tag);
    document.config.tEmail.focus();
    return false;
  }
}
