//Added by Meghabarna on 10/07/09 to copy from permanenet address to current address if it is same
function copyAdd()
{  
document.frmsignup.curr.value =document.frmsignup.perm.value;
}
//Added by Meghabarna on 10/07/09 to clear when uncheck
function clerAddd()
{
	document.frmsignup.curr.value = "";
}
//Added by Meghabarna on 01/06/09 to show the terms and conditions
function displayTerms()
{
var term = document.getElementById("termCond");
term.style.display = 'none';       
}

//Added by Meghabarna on 30/05/09 to hide a row
function displayRow()
{	
var row = document.getElementById("studentinfo");
row.style.display = 'none';
}
//Added by Meghabarna on 03/06/09 to display the div tag
function displayDiv()
{	
var usr = document.getElementById("studentinfo");
usr.style.display = '';
}

//Added by Meghabarna on 25/05/09
//Function for disabling checkbox 
function valCheckbo()
{
	// for values if (frmregistration.level.value == "Conversation - Distance Learning" || frmregistration.level.value == "Level 4 - Distance Learning" || frmregistration.level.value == "Student Special Online Program")
	if (regi.level.selectedIndex == 1 || regi.level.selectedIndex == 2 || regi.level.selectedIndex == 4 || regi.level.selectedIndex == 9)
	{
		//Student Special Online Program
		document.regi.demo.disabled=false 
   }
	else
	{
		// alert(frmregistration.level.value);
	document.regi.demo.disabled=true
	document.regi.demo.checked=false
	}
}
//Added by Meghabaran 26/05/09
//Function for disabling checkbox in the form load
function disCheckbo()
{
	if(regi.level.selectedIndex == 0)
	document.regi.demo.disabled=true   
	else
	document.regi.demo.disabled=false 
     	
}


//Function for Registration Report page
function fnchregreport(){

	var jsregfrom = document.getElementById("regfrom").value;

	//alert(jsregfrom)

	var jsregto = document.getElementById("regto").value;

	var jstoday = document.getElementById("hdtoday").value;



	var arrfrom = jsregfrom.split('-');

	var arrto = jsregto.split('-');



	var todaydate =new Date(jstoday);

	//Date(

	var fromdate = new Date(arrfrom[2] +","+ arrfrom[1] +","+ arrfrom[0])

	var todate = new Date(arrto[2] +","+ arrto[1] +","+ arrto[0])

	//alert(todaydate)

	//alert(fromdate)

	if(jsregfrom !="" && jsregto == ""){

		alert('Notification: To date is conditional mandatory')

		return false;

	}

	if(jsregto !="" && jsregfrom == ""){

		alert('Notification: From date is conditional mandatory')

		return false;

	}

	if(fromdate > todaydate ){

		alert('Notification: From Date should not greater than Current Date')

		return false;

	} if (todate > todaydate){

		alert('Notification: To Date should not greater than Current Date')

		return false;

	}

	if(fromdate > todate ){

		alert('Notification: From Date should not greater To Date')

		return false;

	}

		

}



//Function for Changepassword page

function fnchchangepass(){

	var jscurrpass = document.getElementById("currpassword");

	var jsnewpass = document.getElementById("newpassword");

	var jsretypenewpass = document.getElementById("retypenewpass");

	if(isEmpty(jscurrpass.value)){

        alert('Notification: Current Password is mandatory.');

        jscurrpass.focus();

        return false;

    }

	if(isEmpty(jsnewpass.value)){

        alert('Notification: New Password is mandatory.');

        jsnewpass.focus();

        return false;

    }

	if(isEmpty(jsretypenewpass.value)){

        alert('Notification: Re-enter New Password is mandatory.');

        jsretypenewpass.focus();

        return false;

    }

	if(jsnewpass.value != jsretypenewpass.value){

        alert('Notification: New Password and Re-enter New Password does not match.');

        jsnewpass.focus();

        jsnewpass.select();

        return false;		

	}	

	

}



//Modified by Rajagopal dated 09/09/2008
//Function for Student Home page
function fnchhome(thisform){
	myOption = -1;
	coursecount = document.getElementsByName('course')
	var jsterms = document.getElementById('terms');
	var jspaymethod = document.getElementsByName('paymethod');
	var jsencrypt = document.getElementsByName('encrypted');
	var jsreturn;
	var jsselpayment;
	var jscourseid;
	for (i=(coursecount.length-1); i > -1; i--) {
		if (coursecount[i].checked) {
			myOption = i; 
			jscourseid = coursecount[i].value; 
			i = -1;
		}
	}
	if (myOption == -1) {
		alert("Notification: You must select a Course");
		return false;
	}
	for(i=0;i<jspaymethod.length;i++){
		if(jspaymethod[i].checked) {
			jsreturn = true;
			jsselpayment = jspaymethod[i].value
		}
	}
	if(!jsreturn){
		alert("Notification: You must select Payment Method");
		return false;
	}
	if(!(jsterms.checked)){
        alert('Notification: Agree the Terms and Conditions are Mandatory');
        jsterms.focus();
        return false;
    }
	if(jscourseid == 1 ){
		document.getElementsByName('encrypted')[0].value = document.getElementById('prd1encr').value;
	} else if(jscourseid == 2){
		document.getElementsByName('encrypted')[0].value = document.getElementById('prd2encr').value;	
	}else if(jscourseid == 3){
		document.getElementsByName('encrypted')[0].value = document.getElementById('prd3encr').value;	
	}
	if(jsselpayment == "paypal"){
		document.frmpayment.action = "https://www.sandbox.paypal.com/cgi-bin/webscr"
	} 
}

//Function for Forgetpassword page

function fnchforgetpass(){

	var jsuserid = document.getElementById('userid');

 	var jsforgquestion = document.getElementById('forgquestion');

    var jsforgans= document.getElementById('forgans');

    

	if(isEmpty(jsuserid.value)){

        alert('Notification: User Id is mandatory');

        jsuserid.focus();

        return false;

    }		

    if(isEmpty(jsforgquestion.value)){

        alert('Notification: Security Question is mandatory');

        jsforgquestion.focus();

        return false;

    }		

    if(isEmpty(jsforgans.value)){

        alert('Notification: Answer is mandatory');

        jsforgans.focus();

        return false;

    }

}

//Function for Login page

function fnchlogin(frmname){

	var jsuserid = document.getElementById('userid');

 	var jspassword = document.getElementById('password');

 	

    if(isEmpty(jsuserid.value)){

        alert('Notification: User Id is mandatory.');

        jsuserid.focus();

        return false;

    }

    if(isEmpty(jspassword.value)){

        alert('Notification: Password is mandatory.');

        jspassword.focus();

        return false;

    }		

}

// Function for Signup page

function fnchsignup(frmname){
	

	//var jsuserid = document.getElementById('userid');   
	
	var jsuserid=document.frmsignup.userid;

 	var jsusername = document.getElementById('username');

 	//var jspassword = document.getElementById('password');
 	
 	var jspassword=document.frmsignup.password;
 	
 	var jsreentepass = document.getElementById('reenterpassword');

 	var jsemail= document.getElementById('email');


 	var jsforgquestion = document.getElementById('forgquestion');

 	var jsforgans = document.getElementById('forgans');

	var jsjcprimaryfrom = document.getElementById('jcprimaryfrom')

	var jsjcprimaryto = document.getElementById('jcprimaryto')

	var jsjlptprimaryfrom = document.getElementById('jlptprimaryfrom')

	var jsjlptprimaryto = document.getElementById('jlptprimaryto')

	

	var jsjcsecondaryfrom = document.getElementById('jcsecondaryfrom')

	var jsjcsecondaryto = document.getElementById('jcsecondaryto')

	var jsjlptsecondaryfrom = document.getElementById('jlptsecondaryfrom')

	var jsjlptsecondaryto = document.getElementById('jlptsecondaryto')
	
	var jdob = document.getElementById('dob');
	
	var jqual = document.getElementById('qual');
	var jprior = document.getElementById('prior');
	var jprof = document.getElementById('prof');
	var jperm = document.getElementById('perm');
	var jcurr = document.getElementById('curr');
	var jcont = document.getElementById('cont');
	var jnecss = document.getElementById('necss');
	var agreec = document.getElementById('agreeCh');
	
	//alert(!isEmpty(jsjcsecondaryto.value))
	
// Code Modified By Rajagopal dated 09/09/2008 Starts Here			
 	if(isEmpty(jsuserid.value)){
        alert('Notification: User Id is mandatory.');
        jsuserid.focus();
        return false;
    } else if(!isAlphaNumeric(jsuserid.value)){
		alert('Notification: User Id should not contain special character and space.');
        jsuserid.focus();
        return false;
	}
	
	if(jsuserid.value == "" ){
        alert('Notification: User Id should not have space.');
        jsuserid.focus();
        return false;		
	}
    if(isEmpty(jsusername.value)){
        alert('Notification: User Name is mandatory.');
        jsusername.focus();
        return false;
    }
	if(jsuserid.value == jsusername.value)
	{
        alert('Notification: User id and Usernsme should not be same');
        jsuserid.focus();
		jsuserid.select();
       return false;		

	}	
	if(isEmpty(jspassword.value)){
        alert('Notification: Password is mandatory.');
        jspassword.focus();
        return false;
    }
	if(jspassword.value.length < 6){
        alert('Notification: Password must be atleast 6 character.');
        jspassword.focus();
        return false;
    }
// Code Modified By Rajagopal dated 09/09/2008 End Here
	if(isEmpty(jsreentepass.value)){

        alert('Notification: Re-enter Password is mandatory.');

        jsreentepass.focus();

        return false;

    }

	if(jspassword.value != jsreentepass.value){

        alert('Notification: Password and Re-enter Password does not match.');

        jspassword.focus();

        jspassword.select();

        return false;		

	}
	

    if(isEmpty(jsemail.value)){

        alert('Notification: Email  is mandatory');

        jsemail.focus();

        return false;

    } else if(!isEMail(jsemail.value)){

        alert('Notification: Invalid Email Address');

        jsemail.focus();

        jsemail.select();

        return false;        

    }

    if(isEmpty(jsforgquestion.value)){

        alert('Notification: Security Question is mandatory.');

        jsforgquestion.focus();

        return false;

    }

    if(isEmpty(jsforgans.value)){

        alert('Notification: Answer is mandatory.');

        jsforgans.focus();

        return false;

    }

	// function validations for the special online program
 

    if(document.getElementById('studentinfo').style.display=='')
	 {	
	 if(isEmpty(jdob.value)){

        alert('Notification: Date of Birth is mandatory.');

        jdob.focus();

        return false;
    }
	
	if(isEmpty(jqual.value)){

        alert('Notification: Qualification is mandatory.');

        jqual.focus();

        return false;

    }
	
	 if(isEmpty(jprior.value)){

        alert('Notification: Prior Japanese Knowledge is mandatory.');

        jprior.focus();

        return false;

    }
	 if(isEmpty(jprof.value)){

        alert('Notification: Profession is mandatory.');

        jprof.focus();

        return false;

    }
	
	 if(isEmpty(jperm.value)){

        alert('Notification: Residence Permanent Address is mandatory.');

        jperm.focus();

        return false;

    }
	 if(isEmpty(jcurr.value)){

        alert('Notification: Residence Current Address is mandatory.');

        jcurr.focus();

        return false;

    }
	 if(isEmpty(jcont.value)){

        alert('Notification: Contact No. is mandatory.');

        jcont.focus();

        return false;

    }
	
		  if(!isEmpty(jcont.value))
	  {
        if(!IsPhoneNo(jcont.value))
		{
        alert('Notification: Invalid Contact Number.');

        jcont.focus();

        jcont.select();

        return false;    
        }
    } 

	 if(isEmpty(jnecss.value)){

        alert('Notification: Necessity to learn Japanese Language is mandatory.');

        jnecss.focus();

        return false;

    }  
	 }

	

     if(document.getElementById("jcvl")!=null)
     {
    	 if((!document.getElementById("jcvl").checked) && (!isOneCheck("frmsignup","selectcourse[]")))
    	 {
    		 alert('Notification: Course is mandatory.');

    		 return false;	

    	 }
     }
	 else  if(document.getElementById("jcvlnative")!=null)
     {
    	 if((!document.getElementById("jcvlnative").checked) && (!isOneCheck("frmsignup","selectcourse[]")))
    	 {
    		 alert('Notification: Course is mandatory.');

    		 return false;	
    	 }
     }
     else{

    	 if(!isOneCheck("frmsignup","selectcourse[]")){

    		 alert('Notification: Course is mandatory1.');

    		 return false;	

    	 }
    	 
     }
	

	/*if(!document.getElementById("jcvl").checked && !isOneCheck("frmsignup","selectcourse[]"))	
	{
		alert('Notification: Course is mandatory.');

		return false;	

	}*/

	if(document.getElementById("japanconver").checked){

		if(!isOneCheck("frmsignup","jcdays[]")){

		alert('Notification: Available days is mandatory.');

		return false;	

		}

		if(isEmpty(jsjcprimaryfrom.value) || isEmpty(jsjcprimaryto.value)){

			alert('Notification: Primary Hour is mandatory.');

			return false;

		}

		if(Number(jsjcprimaryfrom.value)+1 >= Number(jsjcprimaryto.value) ){

			alert('Notification: Invalid Primary Hour. TO should be 1 Hour greater than From');

			return false

		}

		if((!isEmpty(jsjcsecondaryfrom.value)) || (!isEmpty(jsjcsecondaryto.value))){	

				if((!isEmpty(jsjcsecondaryfrom.value)) && (isEmpty(jsjcsecondaryto.value))){

					alert('Notification: Invalid Secondary Hours.');

					return false;	

				} else if((isEmpty(jsjcsecondaryfrom.value)) && (!isEmpty(jsjcsecondaryto.value))){

					alert('Notification: Invalid Secondary Hours.');

					return false;	

				} else if(Number(jsjcsecondaryfrom.value)+1 >= Number(jsjcsecondaryto.value) ){

					alert('Notification: Invalid Secondary Hour. TO should be 1 Hour greater than From');

					return false

				}

		}	

	}

	if(document.getElementById("jlptlevel").checked){

		if(!isOneCheck("frmsignup","jlptdays[]")){

		alert('Notification: Available days is mandatory.');

		return false;	

		}

		if(isEmpty(jsjlptprimaryfrom.value) || isEmpty(jsjlptprimaryto.value)){

			alert('Notification: Primary Hour is mandatory.');

			return false;

		}

		if(Number(jsjlptprimaryfrom.value)+1 >= Number(jsjlptprimaryto.value) ){

			alert('Notification: Invalid  Primary Hour. TO should be 1 Hour greater than From');

			return false

		}

		if((!isEmpty(jsjlptsecondaryfrom.value)) || (!isEmpty(jsjlptsecondaryto.value))){	

				if((!isEmpty(jsjlptsecondaryfrom.value)) && (isEmpty(jsjlptsecondaryto.value))){

					alert('Notification: Invalid Secondary Hours.');

					return false;	

				} else if((isEmpty(jsjlptsecondaryfrom.value)) && (!isEmpty(jsjlptsecondaryto.value))){

					alert('Notification: Invalid Secondary Hours.');

					return false;	

				} else if(Number(jsjlptsecondaryfrom.value)+1 >= Number(jsjlptsecondaryto.value) ){

					alert('Notification: Invalid Secondary Hour. TO should be 1 Hour greater than From');

					return false

				}

		}		
		
	}		
	
	 if(document.getElementById('termCond').style.display=='')
	 {	
	 if(document.frmsignup.agreeCh.checked==false)
	 {
        alert('Notification: Accept the terms and condtions to signup.');
        agreec.focus();
        return false;
    }
	 } 


	

}




// Function for Registration page

function fnchregistration(){

    var jscname = document.getElementById('cname');

    var jscountry = document.getElementById('country');

    var jsstate = document.getElementById('state');

    var jszip = document.getElementById('zipcode');

    var jsphone = document.getElementById('phone');

    var jsemail = document.getElementById('email');

    var jsoccu = document.getElementById('occu');

    var jscomments = document.getElementById('comments');

    var jsvolpages = document.getElementById('volpages');

    var jsimgchk = document.getElementById('imgchk');
	
	
    if(isEmpty(jscname.value)){

        alert('Notification: Name is mandatory.');

        jscname.focus();

        return false;

    }

    if(isEmpty(jscountry.value)){

        alert('Notification: Country is mandatory.');

        jscountry.focus();

        return false;

    }

    if(jscountry.value == "United States" ){

        if(isEmpty(jsstate.value)){

            alert('Notification: State is conditional mandatory.');

            jsstate.focus();

            return false;

        }

    }

    if(isEmpty(jszip.value)){

        alert('Notification: Zip is mandatory.');

        jszip.focus();

        return false;

    }

    if(!(isNumber(jszip.value))){

        alert('Notification: Invalid Zip code');

        jszip.focus();

        return false;

    }    

    if(isEmpty(jsphone.value)){

        alert('Notification: Telephone is mandatory.');

        jsphone.focus();

        return false;

    }

    if(!isEmpty(jsphone.value)){

        if(!IsPhoneNo(jsphone.value)){

        alert('Notification: Invalid Telephone Number');

        jsphone.focus();

        jsphone.select();

        return false;    

        }

    } 

    if(isEmpty(jsemail.value)){

        alert('Notification: Email Address is mandatory');

        jsemail.focus();

        return false;

    }else if(!isEMail(jsemail.value)){

        alert('Notification: Invalid Email Address');

        jsemail.focus();

        jsemail.select();

        return false;        

    }

    if(isEmpty(jsoccu.value)){

        alert('Notification: Occupation is mandatory');

        jsoccu.focus();

        return false;

    } 

    if(isEmpty(jscomments.value)){

        alert('Notification: Queries/Comments is mandatory.');

        jscomments.focus();

        return false;

    }

      

    if(isEmpty(jsimgchk.value)){

        alert('Notification: Image verfication is mandatory.');

        jsimgchk.focus();

        return false;

    }	       

}

//Show days Checkbox

function enabledays(flag,checkname){

	var jsjcprimaryfrom = document.getElementById('jcprimaryfrom')

	var jsjcprimaryto = document.getElementById('jcprimaryto')

	var jsjlptprimaryfrom = document.getElementById('jlptprimaryfrom')

	var jsjlptprimaryto = document.getElementById('jlptprimaryto')

	

	var jsjcsecondaryfrom = document.getElementById('jcsecondaryfrom')

	var jsjcsecondaryto = document.getElementById('jcsecondaryto')

	var jsjlptsecondaryfrom = document.getElementById('jlptsecondaryfrom')

	var jsjlptsecondaryto = document.getElementById('jlptsecondaryto')

	

	var jsjcremarks = document.getElementById('jcremarks')

	var jsjlptremarks = document.getElementById('jlptremarks')

	if(flag == "true"){

		for(counter=0; counter <document.getElementsByName(checkname).length; counter ++){

		document.getElementsByName(checkname)[counter].disabled=false;	

		}

		if(checkname == "jcdays[]"){

			jsjcprimaryfrom.disabled = false;

			jsjcprimaryto.disabled = false;

			jsjcsecondaryfrom.disabled = false;

			jsjcsecondaryto.disabled = false;

			jsjcremarks.disabled = false;

		}

		if(checkname == "jlptdays[]"){

			jsjlptprimaryfrom.disabled = false;

			jsjlptprimaryto.disabled = false;

			jsjlptsecondaryfrom.disabled = false;

			jsjlptsecondaryto.disabled = false;

			jsjlptremarks.disabled = false;				

		}		

    }

    else {

		for(counter=0; counter <document.getElementsByName(checkname).length; counter ++){

		document.getElementsByName(checkname)[counter].disabled=true;	

		document.getElementsByName(checkname)[counter].checked=false;	

		}

		if(checkname == "jcdays[]"){

			jsjcprimaryfrom.disabled = true;

			jsjcprimaryto.disabled = true;

			jsjcsecondaryfrom.disabled = true;

			jsjcsecondaryto.disabled = true;

			jsjcremarks.disabled = true;

		}

		if(checkname == "jlptdays[]"){

			jsjlptprimaryfrom.disabled = true;

			jsjlptprimaryto.disabled = true;

			jsjlptsecondaryfrom.disabled = true;

			jsjlptsecondaryto.disabled = true;				

			jsjlptremarks.disabled = true;				

		}		

		

    }



}



//Show Hours dropdonw

function showHours(flag,day){

    if(flag == "true"){

        document.getElementById(day).disabled = false;

    }

    else {

    document.getElementById(day).disabled = true;

    document.getElementById(day).selectedIndex = ""

    }

    

}


//Modified by Meghabarna on 27/05/09 for 2 conditions on checkbox
//Reset form values  

function resetvalue()
{
   if(confirm("Notification : All values will be reset. Please confirm?"))
	 { 
        document.forms[0].reset()
		document.regi.demo.disabled=false 
	  }   
}

function resetvalue1()
{
	 if(confirm("Notification : All values will be reset. Please confirm?"))
	 { 
        document.forms[0].reset()
		document.regi.demo.disabled=true 
	  }   
}

     
//Country Onchange

function showstate(country){

    if(country == "United States"){

        document.getElementById("state").disabled = false;

    } else {

        document.getElementById("state").disabled = true;
   

    }

}


