function format_date(idt)
{
	var idate = new String;
	idate = idt;
      
        dt_array = idate.split("/");
      
        if ((dt_array[0] < 10) && (dt_array[0].length == 1))
		dt_array[0] = "0" + dt_array[0];
        
	if ((dt_array[1] < 10) && (dt_array[1].length == 1))
		dt_array[1] = "0" + dt_array[1];
           
	fdate = dt_array[2] + "/" + dt_array[1] + "/" + dt_array[0];
      
        return fdate;
}

function comp_dates(date_1, date_2)
{	
	var t=0;		  

	var rdate_1 = new String;
	rdate_1 = format_date(date_1);

	var rdate_2 = new String;
	rdate_2 = format_date(date_2);

	if (rdate_2 < rdate_1)
		t=1;
		  
	return t;		    
}

function format_date_time(idt, flag)
{
	var idtime = new String;
	idtime = idt;

	dtime_array = idtime.split(" ");
	
	fdtime = format_date(dtime_array[0]) + " " + dtime_array[1];

	if (flag == "0")
	    return fdtime;
	else if (flag == "1")
	    return format_date(dtime_array[0]);
}

function check_dates(dt1, dt2, dt3, dt4, dt5, dt6, dt7, dt8)
{
	if((comp_dates(dt1, dt2) == 1) || (comp_dates(dt3, dt4) == 1) || (comp_dates(dt5, dt6) == 1) || (comp_dates(dt7, dt8) == 1))
		window.alert("END dates must be Greater or Equal to START dates.");
	else
		document.frm1.submit();
}

function check_fields()
{
    
    if ((document.frm1.start_time.value == "") || (document.frm1.end_time.value == "") || (document.frm1.start_code.value == "") || (document.frm1.end_code.value == ""))
	window.alert("All detail fields must be filled.");
    else {
    if (document.frm1.detail_type.value == "R")
    {	
	if (format_date_time(document.frm1.start_time.value) >= format_date_time(document.frm1.end_time.value))
	    window.alert("The TO date must be Greater than the FROM date");
	else if ((format_date_time(document.frm1.start_time.value, 1) < format_date(document.frm1.reg_start.value)) || 		(format_date_time(document.frm1.end_time.value, 1) > format_date(document.frm1.reg_end.value)))
	    		window.alert("The detail dates must be in the REGISTRATION date range.");
	else if (document.frm1.start_code.value >= document.frm1.end_code.value)
	   	 window.alert("The TO student id # must be Greater than the FROM student id #.");
	else
	    document.frm1.submit();
    }
    else if (document.frm1.detail_type.value == "D")
    {	
	if (format_date_time(document.frm1.start_time.value, 0) >= format_date_time(document.frm1.end_time.value, 0))
	    window.alert("The TO date must be Greater than the FROM date");
	else if ((format_date_time(document.frm1.start_time.value, 1) < format_date(document.frm1.add_start.value)) || 		(format_date_time(document.frm1.end_time.value, 1) > format_date(document.frm1.add_end.value)))
	    		window.alert("The detail dates must be in the DROP & ADD date range.");
	else if (document.frm1.start_code.value >= document.frm1.end_code.value)
	    	window.alert("The TO student id # must be Greater than the FROM student id #.");
	else
	    document.frm1.submit();
    }
	}
}

function check_fields_sch()
{
    if ((document.frm1.start_date.value == "") || (document.frm1.end_date.value == "") || (document.frm1.start_time.value == "") 
		|| (document.frm1.end_time.value == ""))
	window.alert("All Attendance/Grading fields must be filled.");
    else if (format_date(document.frm1.start_date.value) >= format_date(document.frm1.end_date.value))
	window.alert("The END date must be Greater than the START date");
    else if (document.frm1.start_time.value >= document.frm1.end_time.value)
	window.alert("The END time must be Greater than the START time");
    else
	document.frm1.submit();
}

function ch_form_action(new_script)
{
	document.frm1.action = new_script;
	document.frm1.submit();
}

function confirm_del(path)
{
    if (confirm("Are you sure you want to delete this detail from this schedule?"))
	window.location.pathname = path;

}



function check_fields()
{
    
    if ((document.frm1.start_time.value == "") || (document.frm1.end_time.value == "") || (document.frm1.start_code.value == "") || (document.frm1.end_code.value == ""))
	window.alert("All detail fields must be filled.");
    else {
    if (document.frm1.detail_type.value == "R")
    {	
	if (format_date_time(document.frm1.start_time.value) >= format_date_time(document.frm1.end_time.value))
	    window.alert("The TO date must be Greater than the FROM date");
	else if ((format_date_time(document.frm1.start_time.value, 1) < format_date(document.frm1.reg_start.value)) || (format_date_time(document.frm1.end_time.value, 1) > format_date(document.frm1.reg_end.value)))
	    window.alert("The detail dates must be in the REGISTRATION date range.");
	else if (document.frm1.start_code.value >= document.frm1.end_code.value)
	    window.alert("The TO student id # must be Greater than the FROM student id #.");
	else
	    document.frm1.submit();
    }
    else if (document.frm1.detail_type.value == "D")
    {	
	if (format_date_time(document.frm1.start_time.value, 0) >= format_date_time(document.frm1.end_time.value, 0))
	    window.alert("The TO date must be Greater than the FROM date");
	else if ((format_date_time(document.frm1.start_time.value, 1) < format_date(document.frm1.add_start.value)) || (format_date_time(document.frm1.end_time.value, 1) > format_date(document.frm1.add_end.value)))
	    window.alert("The detail dates must be in the DROP & ADD date range.");
	else if (document.frm1.start_code.value >= document.frm1.end_code.value)
	    window.alert("The TO student id # must be Greater than the FROM student id #.");
	else
	    document.frm1.submit();
    }
	}
}
function check_valid_date(DD,MM,YYYY){
	//window.alter(DD+'/'+MM+'/'+YYYY);
	
	if (YYYY<1889)
			return 'Invalid year';
	if (MM<1 || MM>12)
			return  'Invalid month';
	if (DD<1 || DD>31)
			return  'Invalid day';
	if (MM==4  || MM==6 || MM==9 || MM==11 ) { 
			if (DD<1 || DD>30)
				return 'Invalid day';
	}
	if (MM==2) { 
		if ((YYYY%100)==0  || (YYYY%4)!=0)
			if (DD>28)
				return 'Invalid day';		
	} 
	return 'valid';

	//return 'Invalid';
}

function check_app_fields()
{       //window.alert((document.frm1.DD.value+document.frm1.MM.value+document.frm1.YYYY.value));
	//window.alert(check_valid_date(document.frm1.DD.value,document.frm1.MM.value,document.frm1.YYYY.value));


	
	
    check_date=check_valid_date(document.frm1.DD.value,document.frm1.MM.value,document.frm1.YYYY.value);
    
   
    document.frm1.APP_DOB.value=document.frm1.DD.value+"/"+document.frm1.MM.value+"/"+document.frm1.YYYY.value;
    if (document.frm1.APP_LASTNAME.value =="") {
    	window.alert("(*) Required field is missing"+":  Surname");
    	return;
    }
    if (document.frm1.APP_FIRSTNAME.value =="") {
    	window.alert("(*) Required field is missing"+":  First name");
    	return;
    }
    
	if (document.frm1.APP_FATHERNAME.value =="" ) {
		window.alert("(*) Required field is missing"+":  Middle Name");
    	return;
    }
    if (document.frm1.DD.value =="" || document.frm1.MM.value =="" ||document.frm1.YYYY.value =="") {
    	window.alert("(*) Required field is missing"+":  Date of Birth");
    	return;
    }
     
    if (check_date!='valid' ) {
	window.alert(check_date);
  	return check_date;
    }

    
    if (document.frm1.APP_TEL1.value =="" && document.frm1.APP_TEL2.value =="") {
    	window.alert("(*) Required field is missing"+":  Telephone 1 or 2");
    	return;
    }
    if (document.frm1.APP_EMAIL.value =="") {
    	window.alert("(*) Required field is missing"+":  email");
    	return;
    }
    if  (document.frm1.NATIONALITY.options[document.frm1.NATIONALITY.selectedIndex].text =="") {
    	window.alert("(*) Required field is missing"+":  Nationality");
    	return;
    }
    	
    if (document.frm1.NATIONALITY.options[document.frm1.NATIONALITY.selectedIndex].text =="NIGERIAN") {
    		if  (document.frm1.STATE.options[document.frm1.STATE.selectedIndex].text =="" ) {
    			window.alert("(*) Required field is missing"+":  State");
    			return;	
    		}
    		if (document.frm1.LGA.options[document.frm1.LGA.selectedIndex].text =="") {
    			window.alert("(*) Required field is missing"+":  LGA");
    			return;	
    		}
    }
    
		
    if (document.frm1.basisadmission.options[document.frm1.basisadmission.selectedIndex].text =="UME") {
    		if ( document.frm1.MAJOR.options[document.frm1.MAJOR.selectedIndex].text =="") {
    			window.alert("(*) Required field is missing"+":  First or Second choice of course");
    			return;	
    		}
    		
    		
    }



    if ( document.frm1.APP_EXAMNUMBER.value =="") {
    			window.alert("(*) Required field is missing"+document.frm1.examname.value);
    			return;	
    		}
    
    if (document.frm1.TRANSFERTEMPLATE1.options[document.frm1.TRANSFERTEMPLATE1.selectedIndex].text =="" ){
    	window.alert("(*) Required field is missing"+":  First sitting - Exam");
    			return;	
	}
	if (document.frm1.MONTH1.options[document.frm1.MONTH1.selectedIndex].text==''
    	|| document.frm1.APPDT_YEAR1.value==''){
		window.alert("(*) Required field is missing"+":  First sitting -  Month / Year of Exam");
		return;
	}
	if (document.frm1.APPDT_CANDIDATE1.value=='') {
    	window.alert("(*) Required field is missing:  First sitting - Candidate's Number");
    	return;
    }
    
    if 	((document.frm1.SCE1.options[document.frm1.SCE1.selectedIndex].text!='') && (document.frm1.GRADESEXAM1.options[document.frm1.GRADESEXAM1.selectedIndex].text=='')) {
	window.alert("(*) Required field is missing:  First sitting - Grade 1");	
	return;
    }		
    if 	((document.frm1.SCE2.options[document.frm1.SCE2.selectedIndex].text!='') && (document.frm1.GRADESEXAM2.options[document.frm1.GRADESEXAM2.selectedIndex].text=='')) {
	window.alert("(*) Required field is missing:  First sitting - Grade 2");	
	return;
    }	
    	
    if 	((document.frm1.SCE3.options[document.frm1.SCE3.selectedIndex].text!='') && (document.frm1.GRADESEXAM3.options[document.frm1.GRADESEXAM3.selectedIndex].text=='')) {
	window.alert("(*) Required field is missing:  First sitting - Grade 3");	
	return;
    }	
    if 	((document.frm1.SCE4.options[document.frm1.SCE4.selectedIndex].text!='') && (document.frm1.GRADESEXAM4.options[document.frm1.GRADESEXAM4.selectedIndex].text=='')) {
	window.alert("(*) Required field is missing:  First sitting - Grade 4");	
	return;
    }	
    if ((document.frm1.SCE5.options[document.frm1.SCE5.selectedIndex].text!='') && (document.frm1.GRADESEXAM5.options[document.frm1.GRADESEXAM5.selectedIndex].text=='')) {
	window.alert("(*) Required field is missing:  First sitting - Grade 5");	
	return;
    }	
    if 	((document.frm1.SCE6.options[document.frm1.SCE6.selectedIndex].text!='') && (document.frm1.GRADESEXAM6.options[document.frm1.GRADESEXAM6.selectedIndex].text=='')) {
	window.alert("(*) Required field is missing:  First sitting - Grade 6");	
	return;
    }	
    if 	((document.frm1.SCE7.options[document.frm1.SCE7.selectedIndex].text!='') && (document.frm1.GRADESEXAM7.options[document.frm1.GRADESEXAM7.selectedIndex].text=='')) {
	window.alert("(*) Required field is missing:  First sitting - Grade 7");	
	return;
    }	
    if 	((document.frm1.SCE8.options[document.frm1.SCE8.selectedIndex].text!='') && (document.frm1.GRADESEXAM8.options[document.frm1.GRADESEXAM8.selectedIndex].text=='')) {
	window.alert("(*) Required field is missing:  First sitting - Grade 8");	
	return;
    }	
    if 	((document.frm1.SCE9.options[document.frm1.SCE9.selectedIndex].text!='') && (document.frm1.GRADESEXAM9.options[document.frm1.GRADESEXAM9.selectedIndex].text=='')) {
	window.alert("(*) Required field is missing:  First sitting - Grade 9");	
	return;
    }	
    if 	((document.frm1.SCE10.options[document.frm1.SCE10.selectedIndex].text!='') && (document.frm1.GRADESEXAM10.options[document.frm1.GRADESEXAM10.selectedIndex].text=='')) {
	window.alert("(*) Required field is missing:  First sitting - Grade 10");	
	return;
    }	



    if 	((document.frm1.SCE1.options[document.frm1.SCE1.selectedIndex].text=='') && (document.frm1.GRADESEXAM1.options[document.frm1.GRADESEXAM1.selectedIndex].text!='')) {
	window.alert("(*) Required field is missing:  First sitting - Subject 1");	
	return;
    }		
    if 	((document.frm1.SCE2.options[document.frm1.SCE2.selectedIndex].text=='') && (document.frm1.GRADESEXAM2.options[document.frm1.GRADESEXAM2.selectedIndex].text!='')) {
	window.alert("(*) Required field is missing:  First sitting - Subject 2");	
	return;
    }	
    	
    if 	((document.frm1.SCE3.options[document.frm1.SCE3.selectedIndex].text=='') && (document.frm1.GRADESEXAM3.options[document.frm1.GRADESEXAM3.selectedIndex].text!='')) {
	window.alert("(*) Required field is missing:  First sitting - Subject 3");	
	return;
    }	
    if 	((document.frm1.SCE4.options[document.frm1.SCE4.selectedIndex].text=='') && (document.frm1.GRADESEXAM4.options[document.frm1.GRADESEXAM4.selectedIndex].text!='')) {
	window.alert("(*) Required field is missing:  First sitting - Subject 4");	
	return;
    }	
    if  ((document.frm1.SCE5.options[document.frm1.SCE5.selectedIndex].text=='') && (document.frm1.GRADESEXAM5.options[document.frm1.GRADESEXAM5.selectedIndex].text!='')) {
	window.alert("(*) Required field is missing:  First sitting - Subject 5");	
	return;
    }	
    if 	((document.frm1.SCE6.options[document.frm1.SCE6.selectedIndex].text=='') && (document.frm1.GRADESEXAM6.options[document.frm1.GRADESEXAM6.selectedIndex].text!='')) {
	window.alert("(*) Required field is missing:  First sitting - Subject 6");	
	return;
    }	
    if 	((document.frm1.SCE7.options[document.frm1.SCE7.selectedIndex].text=='') && (document.frm1.GRADESEXAM7.options[document.frm1.GRADESEXAM7.selectedIndex].text!='')) {
	window.alert("(*) Required field is missing:  First sitting - Subject 7");	
	return;
    }	
    if 	((document.frm1.SCE8.options[document.frm1.SCE8.selectedIndex].text=='') && (document.frm1.GRADESEXAM8.options[document.frm1.GRADESEXAM8.selectedIndex].text!='')) {
	window.alert("(*) Required field is missing:  First sitting - Subject 8");	
	return;
    }	
    if 	((document.frm1.SCE9.options[document.frm1.SCE9.selectedIndex].text=='') && (document.frm1.GRADESEXAM9.options[document.frm1.GRADESEXAM9.selectedIndex].text!='')) {
	window.alert("(*) Required field is missing:  First sitting - Subjecte 9");	
	return;
    }	
    if 	((document.frm1.SCE10.options[document.frm1.SCE10.selectedIndex].text=='') && (document.frm1.GRADESEXAM10.options[document.frm1.GRADESEXAM10.selectedIndex].text!='')) {
	window.alert("(*) Required field is missing:  First sitting - Subject 10");	
	return;
    }	


     crs1number=0;
    
    if (document.frm1.SCE1.options[document.frm1.SCE1.selectedIndex].text !="" && document.frm1.GRADESEXAM1.options[document.frm1.GRADESEXAM1.selectedIndex].text !="")
    	crs1number++;
    if (document.frm1.SCE2.options[document.frm1.SCE2.selectedIndex].text !=""  && document.frm1.GRADESEXAM2.options[document.frm1.GRADESEXAM2.selectedIndex].text !="")
    	crs1number++;
    if (document.frm1.SCE3.options[document.frm1.SCE3.selectedIndex].text !=""  && document.frm1.GRADESEXAM3.options[document.frm1.GRADESEXAM3.selectedIndex].text !="")
    	crs1number++;
    if (document.frm1.SCE4.options[document.frm1.SCE4.selectedIndex].text !=""  && document.frm1.GRADESEXAM4.options[document.frm1.GRADESEXAM4.selectedIndex].text !="")
    	crs1number++;
    if (document.frm1.SCE5.options[document.frm1.SCE5.selectedIndex].text !=""  && document.frm1.GRADESEXAM5.options[document.frm1.GRADESEXAM5.selectedIndex].text !="")
    	crs1number++;
    if (document.frm1.SCE6.options[document.frm1.SCE6.selectedIndex].text !=""  && document.frm1.GRADESEXAM6.options[document.frm1.GRADESEXAM6.selectedIndex].text !="")
    	crs1number++;
    if (document.frm1.SCE7.options[document.frm1.SCE7.selectedIndex].text !=""  && document.frm1.GRADESEXAM7.options[document.frm1.GRADESEXAM7.selectedIndex].text !="")
    	crs1number++;
    if (document.frm1.SCE8.options[document.frm1.SCE8.selectedIndex].text !=""  && document.frm1.GRADESEXAM8.options[document.frm1.GRADESEXAM8.selectedIndex].text !="")
    	crs1number++;
    if (document.frm1.SCE9.options[document.frm1.SCE9.selectedIndex].text !=""  && document.frm1.GRADESEXAM9.options[document.frm1.GRADESEXAM9.selectedIndex].text !="")
    	crs1number++;
    if (document.frm1.SCE10.options[document.frm1.SCE10.selectedIndex].text !=""  && document.frm1.GRADESEXAM10.options[document.frm1.GRADESEXAM10.selectedIndex].text !="")
    	crs1number++;	
    
    if (crs1number<5) { 
    	window.alert ('The minimum number of Subjects and Grades allowed are 5 for the First sitting:'+document.frm1.TRANSFERTEMPLATE1.options[document.frm1.TRANSFERTEMPLATE1.selectedIndex].text+' exam. Currently selected:'+crs1number);
	
return;
    }


   if ((document.frm1.TRANSFERTEMPLATE2.options[document.frm1.TRANSFERTEMPLATE2.selectedIndex].text!='') ||
	(document.frm1.MONTH2.options[document.frm1.MONTH2.selectedIndex].text!='') ||
        ( document.frm1.APPDT_YEAR2.value!='')	||
	(document.frm1.APPDT_CANDIDATE2.value!='') ){


   if (document.frm1.TRANSFERTEMPLATE2.options[document.frm1.TRANSFERTEMPLATE2.selectedIndex].text =='' ){
    	window.alert("(*) Required field is missing"+":  Second sitting - Exam");
    			return;	
	}
	if (document.frm1.MONTH2.options[document.frm1.MONTH2.selectedIndex].text==''
    	|| document.frm1.APPDT_YEAR2.value==''){
		window.alert("(*) Required field is missing"+":  Second sitting -  Month / Year of Exam");
		return;
	}
	if (document.frm1.APPDT_CANDIDATE2.value=='') {
    	window.alert("(*) Required field is missing:  Second sitting - Candidate's Number");
    	return;
    }



     







    if 	((document.frm1.SCE11.options[document.frm1.SCE11.selectedIndex].text!='') && (document.frm1.GRADESEXAM11.options[document.frm1.GRADESEXAM11.selectedIndex].text=='')) {
	window.alert("(*) Required field is missing:  Second sitting - Grade 1");	
	return;
    }		
    if 	((document.frm1.SCE12.options[document.frm1.SCE12.selectedIndex].text!='') && (document.frm1.GRADESEXAM12.options[document.frm1.GRADESEXAM12.selectedIndex].text=='')) {
	window.alert("(*) Required field is missing:  Second sitting - Grade 2");	
	return;
    }	
    	
    if 	((document.frm1.SCE13.options[document.frm1.SCE13.selectedIndex].text!='') && (document.frm1.GRADESEXAM13.options[document.frm1.GRADESEXAM13.selectedIndex].text=='')) {
	window.alert("(*) Required field is missing:  Second sitting - Grade 3");	
	return;
    }	
    if 	((document.frm1.SCE14.options[document.frm1.SCE14.selectedIndex].text!='') && (document.frm1.GRADESEXAM14.options[document.frm1.GRADESEXAM14.selectedIndex].text=='')) {
	window.alert("(*) Required field is missing:  Second sitting - Grade 4");	
	return;
    }	
    if ((document.frm1.SCE15.options[document.frm1.SCE15.selectedIndex].text!='') && (document.frm1.GRADESEXAM15.options[document.frm1.GRADESEXAM15.selectedIndex].text=='')) {
	window.alert("(*) Required field is missing:  Second sitting - Grade 5");	
	return;
    }	
    if 	((document.frm1.SCE16.options[document.frm1.SCE16.selectedIndex].text!='') && (document.frm1.GRADESEXAM16.options[document.frm1.GRADESEXAM16.selectedIndex].text=='')) {
	window.alert("(*) Required field is missing:  Second sitting - Grade 6");	
	return;
    }	
    if 	((document.frm1.SCE17.options[document.frm1.SCE17.selectedIndex].text!='') && (document.frm1.GRADESEXAM17.options[document.frm1.GRADESEXAM17.selectedIndex].text=='')) {
	window.alert("(*) Required field is missing:  Second sitting - Grade 7");	
	return;
    }	
    if 	((document.frm1.SCE18.options[document.frm1.SCE18.selectedIndex].text!='') && (document.frm1.GRADESEXAM18.options[document.frm1.GRADESEXAM18.selectedIndex].text=='')) {
	window.alert("(*) Required field is missing:  Second sitting - Grade 8");	
	return;
    }	
    if 	((document.frm1.SCE19.options[document.frm1.SCE19.selectedIndex].text!='') && (document.frm1.GRADESEXAM19.options[document.frm1.GRADESEXAM19.selectedIndex].text=='')) {
	window.alert("(*) Required field is missing:  Second sitting - Grade 9");	
	return;
    }	
    if 	((document.frm1.SCE20.options[document.frm1.SCE20.selectedIndex].text!='') && (document.frm1.GRADESEXAM20.options[document.frm1.GRADESEXAM20.selectedIndex].text=='')) {
	window.alert("(*) Required field is missing:  Second sitting - Grade 10");	
	return;
    }	



    if 	((document.frm1.SCE11.options[document.frm1.SCE11.selectedIndex].text=='') && (document.frm1.GRADESEXAM11.options[document.frm1.GRADESEXAM11.selectedIndex].text!='')) {
	window.alert("(*) Required field is missing:  Second sitting - Subject 1");	
	return;
    }		
    if 	((document.frm1.SCE12.options[document.frm1.SCE12.selectedIndex].text=='') && (document.frm1.GRADESEXAM12.options[document.frm1.GRADESEXAM12.selectedIndex].text!='')) {
	window.alert("(*) Required field is missing:  Second sitting - Subject 2");	
	return;
    }	
    	
    if 	((document.frm1.SCE13.options[document.frm1.SCE13.selectedIndex].text=='') && (document.frm1.GRADESEXAM13.options[document.frm1.GRADESEXAM13.selectedIndex].text!='')) {
	window.alert("(*) Required field is missing:  Second sitting - Subject 3");	
	return;
    }	
    if 	((document.frm1.SCE14.options[document.frm1.SCE14.selectedIndex].text=='') && (document.frm1.GRADESEXAM14.options[document.frm1.GRADESEXAM14.selectedIndex].text!='')) {
	window.alert("(*) Required field is missing:  Second sitting - Subject 4");	
	return;
    }	
    if  ((document.frm1.SCE15.options[document.frm1.SCE15.selectedIndex].text=='') && (document.frm1.GRADESEXAM15.options[document.frm1.GRADESEXAM15.selectedIndex].text!='')) {
	window.alert("(*) Required field is missing:  Second sitting - Subject 5");	
	return;
    }	
    if 	((document.frm1.SCE16.options[document.frm1.SCE16.selectedIndex].text=='') && (document.frm1.GRADESEXAM16.options[document.frm1.GRADESEXAM16.selectedIndex].text!='')) {
	window.alert("(*) Required field is missing:  Second sitting - Subject 6");	
	return;
    }	
    if 	((document.frm1.SCE17.options[document.frm1.SCE17.selectedIndex].text=='') && (document.frm1.GRADESEXAM17.options[document.frm1.GRADESEXAM17.selectedIndex].text!='')) {
	window.alert("(*) Required field is missing:  Second sitting - Subject 7");	
	return;
    }	
    if 	((document.frm1.SCE18.options[document.frm1.SCE18.selectedIndex].text=='') && (document.frm1.GRADESEXAM18.options[document.frm1.GRADESEXAM18.selectedIndex].text!='')) {
	window.alert("(*) Required field is missing:  Second sitting - Subject 8");	
	return;
    }	
    if 	((document.frm1.SCE19.options[document.frm1.SCE19.selectedIndex].text=='') && (document.frm1.GRADESEXAM19.options[document.frm1.GRADESEXAM19.selectedIndex].text!='')) {
	window.alert("(*) Required field is missing:  Second sitting - Subjecte 9");	
	return;
    }	
    if 	((document.frm1.SCE20.options[document.frm1.SCE20.selectedIndex].text=='') && (document.frm1.GRADESEXAM20.options[document.frm1.GRADESEXAM20.selectedIndex].text!='')) {
	window.alert("(*) Required field is missing:  Second sitting - Subject 10");	
	return;
    }	





















    
     crs2number=0;
    
    if (document.frm1.SCE11.options[document.frm1.SCE11.selectedIndex].text !="" && document.frm1.GRADESEXAM11.options[document.frm1.GRADESEXAM11.selectedIndex].text !="")
    	crs2number++;
    if (document.frm1.SCE12.options[document.frm1.SCE12.selectedIndex].text !=""  && document.frm1.GRADESEXAM12.options[document.frm1.GRADESEXAM12.selectedIndex].text !="")
    	crs2number++;
    if (document.frm1.SCE13.options[document.frm1.SCE13.selectedIndex].text !=""  && document.frm1.GRADESEXAM13.options[document.frm1.GRADESEXAM13.selectedIndex].text !="")
    	crs2number++;
    if (document.frm1.SCE14.options[document.frm1.SCE14.selectedIndex].text !=""  && document.frm1.GRADESEXAM14.options[document.frm1.GRADESEXAM14.selectedIndex].text !="")
    	crs2number++;
    if (document.frm1.SCE15.options[document.frm1.SCE15.selectedIndex].text !=""  && document.frm1.GRADESEXAM15.options[document.frm1.GRADESEXAM15.selectedIndex].text !="")
    	crs2number++;
    if (document.frm1.SCE16.options[document.frm1.SCE16.selectedIndex].text !=""  && document.frm1.GRADESEXAM16.options[document.frm1.GRADESEXAM16.selectedIndex].text !="")
    	crs2number++;
    if (document.frm1.SCE17.options[document.frm1.SCE17.selectedIndex].text !=""  && document.frm1.GRADESEXAM17.options[document.frm1.GRADESEXAM17.selectedIndex].text !="")
    	crs2number++;
    if (document.frm1.SCE18.options[document.frm1.SCE18.selectedIndex].text !=""  && document.frm1.GRADESEXAM18.options[document.frm1.GRADESEXAM18.selectedIndex].text !="")
    	crs2number++;
    if (document.frm1.SCE19.options[document.frm1.SCE19.selectedIndex].text !=""  && document.frm1.GRADESEXAM19.options[document.frm1.GRADESEXAM19.selectedIndex].text !="")
    	crs2number++;
    if (document.frm1.SCE20.options[document.frm1.SCE20.selectedIndex].text !=""  && document.frm1.GRADESEXAM20.options[document.frm1.GRADESEXAM20.selectedIndex].text !="")
    	crs2number++;	
    
    if (crs2number<5) { 
    	window.alert ('The minimum number of Subjects and Grades allowed are 5 for the Second sitting:'+document.frm1.TRANSFERTEMPLATE2.options[document.frm1.TRANSFERTEMPLATE2.selectedIndex].text+' exam. Currently selected:'+crs2number);
	
return;
    }

}




    document.frm1.submit(); 
}










function confirm_app_fields() {  
	document.frm1.action='i_application.php?type=RED';  
	document.frm1.submit(); 
}

function return_app_fields() {  
	document.frm1.action ='application.php?type=RED';
	document.frm1.submit(); 
}





















function check_state_lga() {
	if (document.frm1.NATIONALITY.options[document.frm1.NATIONALITY.selectedIndex].text=='NIGERIAN') {
		document.frm1.LGA.disabled=false;
		document.frm1.STATE.disabled=false;
	} else {
		document.frm1.STATE.selectedIndex=0;
		document.frm1.LGA.selectedIndex=0;
		//document.frm1.STATE.options[document.frm1.STATE.selectedIndex].text='';
		//document.frm1.LGA.options[document.frm1.LGA.selectedIndex].text='';
		document.frm1.LGA.disabled=true;
		document.frm1.STATE.disabled=true;
		
		
	}
}

function check_lga() {
	//windows.alert("test");
	if (document.frm1.STATE.options[document.frm1.STATE.selectedIndex].text!='') {
		document.frm1.LGA.disabled=false;
		document.frm1.action ='application.php?type=RED';
		document.frm1.submit();

	} else {
                document.frm1.LGA.selectedIndex=0;
		//document.frm1.LGA.options[document.frm1.LGA.selectedIndex].text='';
		document.frm1.LGA.disabled=true;
	}
}





function check_handicaps() {
	if (document.frm1.APP_HANDICAPS.options[document.frm1.APP_HANDICAPS.selectedIndex].text=='OTHER')
		document.frm1.APP_HANDICAPSOTHER.disabled=false;
		
	 else {
		document.frm1.APP_HANDICAPSOTHER.value='';
		document.frm1.APP_HANDICAPSOTHER.disabled=true;
	}
}
function enable_handicaps() {
	document.frm1.APP_HANDICAPS.disabled=false;
	if (document.frm1.APP_HANDICAPS.options[document.frm1.APP_HANDICAPS.selectedIndex].text=='OTHER')
		document.frm1.APP_HANDICAPSOTHER.disabled=false;
	
}

function  disable_handicaps() {
	document.frm1.APP_HANDICAPSOTHER.value='';
	document.frm1.APP_HANDICAPS.disabled=true;
	document.frm1.APP_HANDICAPSOTHER.disabled=true;
}


function major_check(){
   //$link="./registration.php?student_form=".$user."&log_me=".$log_me;
  // window.open('application.php?APP_FIRSTNAME='+document.frm1.APP_FIRSTNAME.value);
	//test='application.php?type=RED';
	//window.alert(test);
	document.frm1.action ='application.php?type=RED';
	document.frm1.placementest_row.value=0;
	document.frm1.submit();
	
}
	

function check_basisofadmission() {
	/*if (document.frm1.basisadmission.options[document.frm1.basisadmission.selectedIndex].text=='UME') {
		document.frm1.MAJOR.disabled=false;
		//document.frm1.APP_EXAMNUMBER.disabled=false;
		document.frm1.examname.value='*Registration Number';
		document.getElementById('abc').innerHTML='*Registration Number';
		
	} else if (document.frm1.basisadmission.options[document.frm1.basisadmission.selectedIndex].text=='Direct Entry') {
		document.frm1.MAJOR.disabled=true;
		//document.frm1.APP_EXAMNUMBER.disabled=true;
		document.frm1.examname.value='*Registration Number';
		document.getElementById('abc').innerHTML='*Registration Number';
	} else if (document.frm1.basisadmission.options[document.frm1.basisadmission.selectedIndex].text=='Pre-Degree') {
		document.frm1.MAJOR.disabled=true;
		//document.frm1.APP_EXAMNUMBER.disabled=true;
		document.frm1.examname.value='*Number';
		document.getElementById('abc').innerHTML='*Number';
	}		
	*/
	document.frm1.action ='application.php?type=RED';
	document.frm1.submit(); 
	
}

function init_placement(j) {
	window.alert(j.value);
	//=document.frm1.course[j-1].value
	//window.alert(document.frm1.course[j-1].value);
	//window.document.savedate['my_arry_score_'+ index ].value;
	//document.frm1.PLACEMENTTEST[i].value=document.frm1.course[j-1].value;
	//document.frm1.savedate['.PLACEMENTTEST[i].value=document.frm1.course[j-1].value;
	
}

function check_group() {
		document.frm1.action ='application.php?type=RED';
		document.frm1.submit();

}
