// JavaScript Document<script language="javascript">
<!--

/********************
 CUSTOM POPUP WINDOW
********************/

// Copyright 1999 - 2002 by Ray Stott, Pop-up Windows Script ver 2.0
// OK to use if this copyright is included
// Script is available at http://www.crays.com/jsc          

var popWin = null    // use this when referring to pop-up window
var winCount = 0
var winName = "popWin"

function openPopWin(winURL, winWidth, winHeight, winFeatures, winLeft, winTop){
  var d_winLeft = 20  // default, pixels from screen left to window left
  var d_winTop = 20   // default, pixels from screen top to window top
  winName = "popWin" + winCount++ //unique name for each pop-up window
  
  closePopWin()           // close any previously opened pop-up window
  
  if (openPopWin.arguments.length >= 4)  // any additional features? 
    winFeatures = "," + winFeatures
  else 
    winFeatures = "" 
  if (openPopWin.arguments.length == 6)  // location specified
    winFeatures += getLocation(winWidth, winHeight, winLeft, winTop)
  else
    winFeatures += getLocation(winWidth, winHeight, d_winLeft, d_winTop)
  popWin = window.open(winURL, winName, "width=" + winWidth 
           + ",height=" + winHeight + winFeatures)
}

function closePopWin(){    // close pop-up window if it is open 
  if (navigator.appName != "Microsoft Internet Explorer" 
      || parseInt(navigator.appVersion) >=4) //do not close if early IE
    if(popWin != null) if(!popWin.closed) popWin.close() 
}
function getLocation(winWidth, winHeight, winLeft, winTop){
  return ""
}



function thtipwin(winURL){

  winName = "popWin" + winCount++ //unique name for each pop-up window

  closePopWin() // close any previously opened pop-up window

  popWin = window.open(winURL, winName, 'height =400 , width =500,  scrollbars = yes, toolbar = yes, menubar = yes, resizable = yes')
  popWin.moveTo(20,20);
}

function printable(winURL){

  winName = "popWin" + winCount++ //unique name for each pop-up window

  closePopWin() // close any previously opened pop-up window

  popWin = window.open(winURL, winName, 'height =550 , width =700,  scrollbars = yes, toolbar = yes, menubar = yes, resizable = yes')
  popWin.moveTo(20,20);
}


function sitemap(winURL){

  winName = "popWin" + winCount++ //unique name for each pop-up window

  closePopWin() // close any previously opened pop-up window

  popWin = window.open(winURL, winName, 'height =300 , width =275,  scrollbars = yes, toolbar = no, menubar = no, resizable = no')
  popWin.moveTo(0,0);
}

function OpenPlugin(winURL){

  winName = "popWin" + winCount++ //unique name for each pop-up window

  closePopWin() // close any previously opened pop-up window

  popWin = window.open(winURL, winName, 'height =250 , width =600,  scrollbars = yes, toolbar = no, menubar = no, resizable = no')
  popWin.moveTo(0,0);
}

/********************
 POPUP WINDOW
********************/

function miniwinpopup(url,winHeight,winWidth)
{ 
    var winOpen;
    winOpen = window.open(url,'winOpen','height = '+winHeight+', width = '+winWidth+',  scrollbars = yes, toolbar = no, menubar = yes, resizable = yes'); 
    winOpen.moveTo(0,0);
    winOpen.focus();
}

/********************
 JUMP TO URL 
********************/
 
function preview(siteNav){ // Jump to url when navigation main dropdown item is selected
	durl=(siteNav.menu.options[siteNav.menu.selectedIndex].value);
	location.href=durl;
}

/////////////////////////////////////////////////////////////////////////////////////

//	validation functions and tools

/////////////////////////////////////////////////////////////////////////////////////

function trimLeft(s) {
	var whitespaces = " \t\n\r";
	for(n = 0; n < s.length; n++) { if (whitespaces.indexOf(s.charAt(n)) == -1) return (n > 0) ? s.substring(n, s.length) : s; }
	return("");
}
function trimRight(s){
	var whitespaces = " \t\n\r";
	for(n = s.length - 1; n  > -1; n--) { if (whitespaces.indexOf(s.charAt(n)) == -1) return (n < (s.length - 1)) ? s.substring(0, n+1) : s; }
	return("");
}
function trim(s) {
        return ((s == null) ? "" : trimRight(trimLeft(s))); 
}
function isBlank(field, strBodyHeader) {
	strTrimmed = trim(field.value);
	if (strTrimmed.length > 0) return false;
	//
	alert("\"" + strBodyHeader + "\" is required. Please type a value.");
	///field.class="noticer";
	///field.value=strBodyHeader + " is required";
	///field.value="";
	field.focus();
	return true;
}

function isNumber(field, strBodyHeader) {
	strTrimmed = trim(field.value);
	if (!isNaN(field.value))	return false;
	
	//
	alert("\"" + strBodyHeader + "\" must be a number. Please try again.");
	field.focus();
	field.select();
	return true;

}


function isNumberLength(field, strBodyHeader, nlength) {
	strTrimmed = trim(field.value);
	if (strTrimmed.length >= nlength){
		return false;
	}
	else
	{
	//
	alert("\"" + strBodyHeader + "\" must be a number of at least " + nlength + " digits. Please try again.");
	field.select();
	field.focus();
	
	return true;
}
}


function isEmail(field, strBodyHeader) {
	var strMsg = ""; var chAt  = '@'; var chDot = '.'; var chSpace = ' '; var strEmailAddr = trim(field.value);
	if (strEmailAddr.length == 0) return true;
	if (strEmailAddr.indexOf(chSpace) == -1) {
		var iFirstAtPos = strEmailAddr.indexOf(chAt);
		var iLastAtPos = strEmailAddr.lastIndexOf(chAt);
		if (iFirstAtPos > 0 && iFirstAtPos < (strEmailAddr.length - 1) && iFirstAtPos == iLastAtPos) {
			// look for '.' there must be at least one char between '@' and '.'
			var iDotPos = strEmailAddr.indexOf(chDot, iFirstAtPos + 1);
			if (iDotPos > (iFirstAtPos + 1) && iDotPos < (strEmailAddr.length - 1)) return true;
		}
	}
	alert("Please type a valid Email Address.");
	//alert("Please type in a valid Email Address for field \"" + strBodyHeader + "\"");
	field.focus();
	return false;
}
function isChecked(field, strBodyHeader, nLength) {
	for(i = 0; i < nLength; i++) { if (field.checked) return true;}
	//else
	//{
		alert("\"" + strBodyHeader + "\" is a required field. Please select a choice.");
	//if (nLength > 0)
//		field[0].focus();
	return false;
	//}
}
function isSelected(field, strBodyHeader) {
	for(i=0; i < field.length; i++) { 
	if (field[i].selected && (trim(field[i].value).length > 0)) return true; }
	alert("\"" + strBodyHeader + "\" is a required field. Please select a choice.");
	//field.text=strBodyHeader + "\" is required";
	field.focus();
	return false;
}

function clDelConfirm(varHref, varDescptn){
var val1="Do you reeally want to delete this "+varDescptn;
var val2="";
val2=confirm(val1);
return val2;
}

/*var  va1='User name ... ';
var  va2='Password ... ';
  document.form.textfield.value=va1;  
    document.form.textfield2.value=va2;  */
  
  function nvcalld()
  {
  if( document.form.textfield.value=='')
  {
    document.form.textfield.value=va1;
	}
  }

  
  function calld()
  {
   if( document.form.textfield.value==va1)
  {
    document.form.textfield.value='';
  }
  }
  
  
  
  /*function valdt()
  {
  if((document.form.textfield.value=='') || (document.form.textfield.value==va1))
  {
  alert('Your Name is required');
 // document.form.textfield2.focus();
  return false;
  }
 else
  {
 // return true;
  //}
  if((document.form.textfield2.value=='') || (document.form.textfield2.value==va2))
  {
  alert('Your Email Address is required');
 // document.form.textfield2.focus();
  return false;
  }
  else
  {
  return true;
  }
  }
  }


function valdt2()
  {
  if((document.form.textfield.value=='') || (document.form.textfield.value==va1))
  {
  alert('Your Name is required');
 // document.form.textfield2.focus();
  return false;
  }
 else
  {
 // return true;
  //}
  if((document.form.textfield2.value=='') || (document.form.textfield2.value==va2))
  {
  alert('Your Email Address is required');
 // document.form.textfield2.focus();
  return false;
  }
  else
  {
  return true;
  }
  }
  }*/
  

function validation1()
{
var textfield=document.formfdbk.textfield;
var textfield3=document.formfdbk.textfield3;
var textfield2=document.formfdbk.textfield2;
var textfield4=document.formfdbk.textfield4;
//textfield2

if(isBlank(textfield, "Name"))
{
 return false;
 }
 else
 {
 if(isBlank(textfield3, "Telephone"))
{
 return false;
 }
else{
if(isBlank(textfield2, "Email Address"))
{
 return false;
 }
else{
	if(!isEmail(textfield2, ""))
{
 return false;
 }
else{
if(isBlank(textfield4, "Message"))
{
 return false;
 }
else{
//err_code="";
return true;
}
}
}
}
}
}


function validations()
{
var textfield=document.formfdbk.textfield;
var textfield3=document.formfdbk.textfield3;
var textfield2=document.formfdbk.textfield2;
var textfield4=document.formfdbk.textfield4;
//textfield2

if(isBlank(textfield, "Name"))
{
 return false;
 }
 else
 {
 if(isBlank(textfield3, "Telephone"))
{
 return false;
 }
else{
if(isBlank(textfield2, "Email Address"))
{
 return false;
 }
else{
	if(!isEmail(textfield2, ""))
{
 return false;
 }
else{
if(isBlank(textfield4, "Message"))
{
 return false;
 }
else{
//err_code="";
return true;
}
}
}
}
}
}

function vaolc(){
var textfield=document.form.textfield2;
var textfield3=document.form.username;
var textfieldp=document.form.password;
var textfieldcp=document.form.password2;
var textfield2=document.form.email;
var textfield4=document.form.password2;
//textfield2

if(isBlank(textfield, "Name"))
{
 return false;
 }
 else
 {
 if(isBlank(textfield3, "ID"))
{
 return false;
 }
else{
	 if(isBlank(textfieldp, "Password"))
{
 return false;
 }
else{
if(isBlank(textfield4, "Confirm Password"))
{
 return false;
 }
else{
	if(textfieldp.value!=textfieldcp.value){
		alert("Password and Confirmed Password are different. Please ensure that they are the same.");
		textfieldp.focus();
		 return false;
	}
	else
	{
if(isBlank(textfield2, "Email Address"))
{
 return false;
 }
else{
	if(!isEmail(textfield2, ""))
{
 return false;
 }
else{

//err_code="";
return true;
}
}
}
}
}
}
}
}


function finalSubit(){
document.form.submitted.value=1;
}

function nextForm(){
document.form.txtTDo.value="next";	
}
function previousForm(){
document.form.txtTDo.value="previous";	
}
function goNext(){
	nextForm();
	//document.form.txtTDo.value="next";	
document.form.gopntxt.value="p";
//window.location="applyn2.php";
}
function goToProfile(){
window.location="profile.php";
}
function goPrev(){
	previousForm();
document.form.gopntxt.value="p";
//window.location="profile.php";
}
function goPrevious(){
	previousForm();
document.form.gopntxt.value="p";
//window.location="profile.php";
}
function goPrevious1(){
	previousForm();
document.form.gopntxt.value="p";
//window.location="applyn1.php";
}
function goPrevious2(){
	previousForm();
document.form.gopntxt.value="p";
//window.location="applyn2.php";
}
function goPrevious3(){
document.form.gopntxt.value="p";
previousForm();
//window.location="applyn3.php";
}

function goNext1(){
	nextForm();
document.form.gopntxt.value="p";
//window.location="applyn1.php";
}
function goNext2(){
	nextForm();
document.form.gopntxt.value="p";
//window.location="applyn2.php";
}
function goNext3(){
	nextForm();
document.form.gopntxt.value="p";

//window.location="applyn3.php";
}
function goNext4(){
	nextForm();
document.form.gopntxt.value="p";
//window.location="applyn4.php";
}

function goCont(){
	nextForm();
document.form.gopntxt.value="p";
window.location="login.php";
}


function valacc1(){
	var v0=document.form1.textfield;
	var v1=document.form1.textfield2;
	var v2=document.form1.textfield43;
	var v2a1=document.form1.select6;
	var v2a2=document.form1.select5;
	var v2a3=document.form1.select4;
	var v3=document.form1.textfield44;
	var v4=document.form1.textfield45;
	var v5=document.form1.textfield46;
	var v6=document.form1.textfield47;
	var v7=document.form1.textfield48;
	var v8=document.form1.textfield8;
	var v9=document.form1.textfield9;
	var v10=document.form1.textfield11;
	
	var v11=document.form1.textfield7;
	var v13=document.form1.textfield8;

if(isBlank(v0, "Surname")){
	v0.focus();
	return false;
}
else
{
	if(isBlank(v1, "First Name(s)")){
	v1.focus();
	return false;
}
else

{
	if(isBlank(v2a3, "Date of Birth (Day) ")){
	v2a3.focus();
	return false;
}
else
{
	if(isBlank(v2a2, "Date of Birth (Month) ")){
	v2a2.focus();
	return false;
}
else
{
	if(isBlank(v2a1, "Date of Birth (Year) ")){
	v2a1.focus();
	return false;
}

else
{
	if(isBlank(v2, "Contact Address ")){
	v2.focus();
	return false;
}
else
{
		if(isBlank(v3, "Tel No. ")){
	v3.focus();
	return false;
}
else
{
		if(isNumber(v3, "Tel No. ")){
	//v3.focus();
	return false;
}
// isNumberLength(field, strBodyHeader, nlength) {
else
{
			if(isNumberLength(v3, "Tel No. ", 5)){
	//v3.focus();
	return false;
}
else
{
		if(isBlank(v4, "Name of Parent / Guardian ")){
	v4.focus();
	return false;
}
else
{
		if(isBlank(v5, "Relationship to student ")){
	v5.focus();
	return false;
}
else
{
		if(isBlank(v6, "Mother's Name ")){
	v6.focus();
	return false;
}
else
{
		if(isBlank(v7, "Father's Name ")){
	v7.focus();
	return false;
}
else
{
	if(isBlank(v11, "Residential Tel. No. of Parent / Guardian ")){
	v11.focus();
	return false;
}
else
{
					if(isNumber(v11, "Residential Tel. No. of Parent / Guardian ")){
	//v3.focus();
	return false;
}
else
{
// isNumberLength(field, strBodyHeader, nlength) {

			if(isNumberLength(v11, "Residential Tel. No. of Parent / Guardian ", 5)){
	//v3.focus();
	return false;

	}
	else
	{
			if(isBlank(v8, "Cell No. of Parent / Guardian ")){
	v8.focus();
	return false;
}
else
{
			if(isNumber(v8, "Cell No. of Parent / Guardian ")){
	//v3.focus();
	return false;
}
// isNumberLength(field, strBodyHeader, nlength) {
else
{
			if(isNumberLength(v8, "Cell No. of Parent / Guardian ", 5)){
	//v3.focus();
	return false;
}
else
{
			if(isBlank(v9, "Email Address of Parent / Guardian ")){
	v9.focus();
	return false;
}
else
{
			if(!isEmail(v9, "Email Address of Parent / Guardian ")){
	v9.focus();
	return false;
}
else
{
			if(isBlank(v10, "Name of Parent / Guardian / Sponsor ")){
	v10.focus();
	return false;
}
else
{
	return true;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}

function valacc2shs(){
	var v1=document.form1.textfield2;
	var v2=document.form1.textfield3;
	var v2a1=document.form1.select6;
	var v2a2=document.form1.select5;
	var v2a3=document.form1.select4;
	var v2b1=document.form1.select1;
	var v2b2=document.form1.select2;
	var v2b3=document.form1.select3;
	var v3=document.form1.textfield4;

if(isBlank(v1, "Last Senior High School Attended")){
	v1.focus();
	return false;
}
else
{
	if(isBlank(v2, "Address of Last Senior High School Attended")){
	v2.focus();
	return false;
}
else

{
	if(isBlank(v2a3, "Begining Date (Day) ")){
	v2a3.focus();
	return false;
}
else
{
	if(isBlank(v2a2, "Begining Date (Month) ")){
	v2a2.focus();
	return false;
}
else
{
	if(isBlank(v2a1, "Begining Date (Year) ")){
	v2a1.focus();
	return false;
}
else
{
	if(isBlank(v2b1, "Ending Date (Day) ")){
	v2b1.focus();
	return false;
}
else
{
	if(isBlank(v2b2, "Ending Date (Month) ")){
	v2b2.focus();
	return false;
}
else
{
	if(isBlank(v2b3, "Ending Date (Year) ")){
	v2b3.focus();
	return false;
}
else
{
	if(isBlank(v3, "Form/Sec/Grade completed ")){
	v3.focus();
	return false;
}
else
{
	
	return true;
}
}
}
}
}
}
}
}
}
}


function valacc2other(){
	var v1=document.form1.textfield2;
	var v2=document.form1.textfield3;
	var v2a1=document.form1.select6;
	var v2a2=document.form1.select5;
	var v2a3=document.form1.select4;
	var v2b1=document.form1.select1;
	var v2b2=document.form1.select2;
	var v2b3=document.form1.select3;
	var v3=document.form1.textfield4;

if(isBlank(v1, "Name of Last School Attended")){
	v1.focus();
	return false;
}
else
{
	if(isBlank(v2, "Address of Last School Attended")){
	v2.focus();
	return false;
}
else

{
	if(isBlank(v2a3, "Begining Date (Day) ")){
	v2a3.focus();
	return false;
}
else
{
	if(isBlank(v2a2, "Begining Date (Month) ")){
	v2a2.focus();
	return false;
}
else
{
	if(isBlank(v2a1, "Begining Date (Year) ")){
	v2a1.focus();
	return false;
}
else
{
	if(isBlank(v2b1, "Ending Date (Day) ")){
	v2b1.focus();
	return false;
}
else
{
	if(isBlank(v2b2, "Ending Date (Month) ")){
	v2b2.focus();
	return false;
}
else
{
	if(isBlank(v2b3, "Ending Date (Year) ")){
	v2b3.focus();
	return false;
}
else
{
	if(isBlank(v3, "Class completed ")){
	v3.focus();
	return false;
}
else
{
	
	return true;
}
}
}
}
}
}
}
}
}
}


function valacc3(){
	var v1=document.form1.checkbox;
	var v2=document.form1.textfield4;
	var v3=document.form1.checkbox2;

if(!isChecked(v1, "Confirmation of Undertaking", 1)){
	v1.focus();
	return false;
}
else
{
	if(isBlank(v2, "Name of Guardian")){
	v2.focus();
	return false;
}
else
{
	if(!isChecked(v3, "Confirmation by Guardian", 1)){
	v3.focus();
	return false;
}
else
{
	return true;
}
}
}
}



function valos(){
	var v0=document.form1.textfield;
	var v1=document.form1.textfield2;
	var v2=document.form1.textfield43;
	var v2a1=document.form1.select6;
	var v2a2=document.form1.select5;
	var v2a3=document.form1.select4;
	var v3=document.form1.textfield44;
	var v4=document.form1.textfield45;
	var v5=document.form1.textfield46;
	var v6=document.form1.textfield47;
	var v7=document.form1.textfield48;
	var v8=document.form1.textfield8;
	var v9=document.form1.textfield9;
	var v10=document.form1.textfield11;
	
	var v11=document.form1.textfield7;
	var v13=document.form1.textfield8;

if(isBlank(v0, "Surname")){
	v0.focus();
	return false;
}
else
{
	if(isBlank(v1, "First Name(s)")){
	v1.focus();
	return false;
}
else

{
	if(isBlank(v2a3, "Date of Birth (Day) ")){
	v2a3.focus();
	return false;
}
else
{
	if(isBlank(v2a2, "Date of Birth (Month) ")){
	v2a2.focus();
	return false;
}
else
{
	if(isBlank(v2a1, "Date of Birth (Year) ")){
	v2a1.focus();
	return false;
}

else
{

	if(isBlank(v11, "Residential Tel. No. ")){
	v11.focus();
	return false;
}
else
{
	if(isNumber(v11, "Residential Tel. No. ")){
	//v3.focus();
	return false;
}
else
{
// isNumberLength(field, strBodyHeader, nlength) {

	if(isNumberLength(v11, "Residential Tel. No. ", 5)){
	//v3.focus();
	return false;
	}
	else
	{
	if(isBlank(v8, "Cell No. ")){
	v8.focus();
	return false;
}
else
{
	if(isNumber(v8, "Cell No. ")){
	//v3.focus();
	return false;
}
// isNumberLength(field, strBodyHeader, nlength) {
else
{
	if(isNumberLength(v8, "Cell No. ", 5)){
	//v3.focus();
	return false;
}
else
{
	if(isBlank(v9, "Email Address ")){
	v9.focus();
	return false;
}
else
{
	if(!isEmail(v9, "Email Address ")){
	v9.focus();
	return false;
}
else
{
	return true;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
/*}
}
}
}
}
}
}
}
}*/


function valregister(){
	var v1=document.form.textfield;
	var v2=document.form.username;
	var v3=document.form.password;
	var v4=document.form.password2;
	var v5=document.form.tel;
	var v6=document.form.city;
	//var v7=document.form.email;

if(isBlank(v1, "Name")){
	v1.focus();
	return false;
}
else
{
	
	if(isBlank(v2, "Email")){
	v2.focus();
	return false;
}
else
{
	if(!isEmail(v2, "Email")){
	v2.focus();
	return false;
}
else
{
	if(isBlank(v3, "Password")){
	v3.focus();
	return false;
}
else
{
	if(isBlank(v4, "Confirm password")){
	v4.focus();
	return false;
}
else
{
	if(v3.value != v4.value){
	alert("Password and Confirmed Password are different. Please make sure they are the same")
	v4.focus();
	return false;
}
else
{
	if(isBlank(v5, "Telephone")){
	v5.focus();
	return false;
}
else
{
	if(isBlank(v6, "City")){
	v6.focus();
	return false;
}
else
{
	return true;
}
}
}
}
}
}
}
}
}


function vallogin(var1, var2){
	var v1=document.form.username;
	var v2=document.form.password;

if(isBlank(v1, var1)){
	v1.focus();
	return false;
}
else
{
	if(isBlank(v2, var2)){
	v2.focus();
	return false;
}
else
{
	return true;
}
}
}


function valrecovery(){
	var v1=document.form3.textfield4;
	//var v2=document.form.password;
alert("OK");
if(isBlank(v1, "Email Address ")){
	v1.focus();
	return false;
}
else
{
	if(!isEmail(v1, "Email Address ")){
	v1.focus();
	v1.select();
	return false;
}
else
{
	return true;
}
}
}

//-->