window.onload = initForm;

function initForm(){
	document.getElementById("school").selectedIndex =0;
    document.getElementById("group").selectedIndex = 0;
    document.getElementById("school").onchange = direct;

	document.getElementById("gbt").onclick = direct;
}
function direct() 
{
	var sch = document.getElementById("school").value;
	var grp = document.getElementById("group").value;
	var PLOGIN = 0; // Primary Login Screen
	if ((sch == 0) ||( grp == 0)){
		alert ("Please select your Group / Your School ");
	}else {
		//School with email domain for staff and students

//Staff and students having emails

		var sc_mail = new Array(10);
		
		sc_mail[1] =  "1";//
		sc_mail[2] =  "6";//
		sc_mail[3] =  "8";//
		sc_mail[4] =  "11";//
		sc_mail[5] =  "12";//
		sc_mail[7] =  "14";//
		sc_mail[6] = "17";//
		sc_mail[8] =  "18";//
		sc_mail[9] =  "19";//
		sc_mail[10] = "21";//

   //Staff having emails.== no email student
         
            var sc =  new Array(10);
                      sc[1] = "2";//
                      sc[2] = "3";//
                      sc[3] = "4";//
                      sc[5] = "5";//
            
                      sc[8] = "20";//

// Students having emails == no email staff
           var sc2 = new Array(10);
								
                          sc2[1] = "7";//
                          sc2[2] = "9";//
                          sc2[3] = "15";//
			sc2[4] =  "13";//
					
                         

//Parents (STUDENTS WHO ARE NOT PROVIDED WITH  SCHOOL EMAIL ADDRESS)

            var sc3 = new Array(8);
			     		sc3[1]  = "2";
				 		sc3[2] = "3";
				 		sc3[3] = "4";
				 		sc3[4] =  "5";
				 		sc3[5] = "16";
				 		sc3[7] = "20";
				                sc3[7] = "22";


		
//Staff and students have email address

	  for (var i = 1; i <= 10; i++) { 
	     //alert (sc_mail[i]);
	    if (sch == sc_mail[i]) {
			 
			   PLOGIN = 1;
			   		   
			   break;
		}
	  }
	 
   //Staff have email address

             for (var k = 1; k <= 10; k++) { 

	    if (sch == sc[k]) {
			  if (grp == 3) {
			        PLOGIN = 2;      
			  }
			   break;
		}
	  }  
	  
  //Only Students have email address 
                      for (var j = 1; j <= 10; j++) { 

	    if (sch == sc2[j]) {
			if (grp == 1)  {
			   PLOGIN = 3;
			}
			   break;
		}
	  }  


//Parents  whose kids are not provided with school email address
	       for (var l = 1; l <= 8; l++) {
			     if (sch == sc3[l]) {
					 if (grp == 2) {

						   PLOGIN = 4; 
					 }

					 break;
				 }

		   }
		   if ((grp == 2) && (PLOGIN != 4) )  {
			      PLOGIN = 1;
		   }
		

if (PLOGIN == 2)   {
	   //Staff Please change the path to the required files  (PRIMARY LOGIN SYSTEM)    STAFF
        window.location = "http://www.cyberfriendly.com.au/index.php/registration/sign_up_staff/";
}


if (PLOGIN == 3)  {
	    // Student Please change the path to the required file  (PRIMARY LOGIN SYSTEM)  STUDENT
       window.location = "http://www.cyberfriendly.com.au/index.php/registration/sign_up_stud/";
}



     
	  if (PLOGIN == 1) {
		    // Student Please change the path to the required file  (PRIMARY LOGIN SYSTEM)
			   if (grp == 1)  {
				   window.location = "http://www.cyberfriendly.com.au/index.php/registration/sign_up_stud/";
				
			   }
			 // Parents  Please change the path to the required files  (PRIMARY LOGIN SYSTEM)
			   if (grp == 2) {
				    window.location = "http://www.cyberfriendly.com.au/index.php/registration/parents/";
				
			   }
			 //Staff Please change the path to the required files  (PRIMARY LOGIN SYSTEM)
			  if (grp == 3) {
				  window.location = "http://www.cyberfriendly.com.au/index.php/registration/sign_up_staff/";
				
			  }
			
	  }
	 if (((PLOGIN != 1) && (PLOGIN != 2) && (PLOGIN !=3)) || (PLOGIN == 4)) {  
		  //Please change the path to the secondary Login Screen
		  window.location = "http://www.cyberfriendly.com.au/index.php/registration/sign_up_other/";
	  }
	   

	}
	
	
}

