function update_div(divid, txt) { document.getElementById(divid).innerHTML=txt; }
function show_div(divid) { document.getElementById(divid).style.display='block'; }
function hide_div(divid) { document.getElementById(divid).style.display='none'; }
function toggle_div(divid) { if(document.getElementById(divid).style.display=='none') { show_div(divid); } else { hide_div(divid); } }
function update_img(divid, sfl) { document.getElementById(divid).src=sfl; }
function update_bkimg(divid, sfl) { document.getElementById(divid).style.backgroundImage="url("+sfl+")"; }

messageObj = new DHTML_modalMessage(); messageObj.setShadowOffset(5);
function displayMessage(url){
	messageObj.setSource(url);
	messageObj.setCssClassMessageBox(false);
	messageObj.setSize(340,180);
	messageObj.setShadowDivVisible(false);
	messageObj.display();
};
function closeMessage() { messageObj.close(); };

function GetValById(d) { v=document.getElementById(d).value; return v; }
function SetValById(d,v) { document.getElementById(d).value=v; return true; }

String.prototype.trim=function() { return this.replace(/^s*|s*$/g,''); } // var sOriginal=' text '; sTrim = sOriginal.trim();

function disStream(classval)//select stream defined function
	{
		if(classval==6 || classval==7){
			document.getElementById('streamId').style.display = 'block';
		} 
		else 
		{
			document.getElementById('streamId').style.display = 'none';
		}
	}//function end disStream()

	function login_validation() {
       		
			
		if ((document.getElementById('email1').value==null)||(document.getElementById('email1').value==''))
			{
				
				alert("Please Enter Email-ID.");
				document.getElementById('email1').focus();
				return false;
			}
			if (echeck(document.getElementById('email1').value)==false)
			{
				document.getElementById('email1').value="";
				document.getElementById('email1').focus();
				return false;
			}
		
			if ((document.getElementById('password1').value==null)||(document.getElementById('password1').value==0))
			{
				//alert("value-"+document.getElementById('exist_mail').value);
				//alert("value-"document.getElementById('email_chk').innerHTML);
				alert("Please Enter Password.");
				document.getElementById('password1').value='';
				document.getElementById('password1').focus();
				return false;
			}
			return true; 
	}	
	//Email validation
	function reguser_validation()//validation form
	   {
			//alert("HIIII");
			user_type = document.frm.user_type;
			email = document.frm.email;
			password = document.frm.password;
			user_name = document.frm.user_name;
			gender = document.frm.gender;
			class_auto_id = document.frm.class_auto_id; 
			teacher_level = document.frm.teacher_level;
		    term = document.frm.term; // Checkbox
			stream=document.frm.stream;
			
			if ((email.value==null)||(email.value==""))
			{
				alert("Please Enter Email-ID.");
				email.focus();
				return false;
			}
			if (echeck(email.value)==false)
			{
				email.focus();
				return false;
			}
			
	
			if ((password.value==null)||(password.value==0))
			{
				//alert("value-"+document.getElementById('exist_mail').value);
				//alert("value-"document.getElementById('email_chk').innerHTML);
				alert("Please Enter Password.");
				password.value='';
				password.focus();
				return false;
			}
			
			if(password.value.length<5) 	
			{
				alert("Please Enter Password. (min. 5 characters).");
				password.focus();
				return false;
			}
			
			if ((user_name.value==null)||(user_name.value==0))
			{
				alert("Please Enter Your Name.");
				user_name.value='';
				user_name.focus();
				return false;
			}
			
		  else if(user_type.value=="Student")
			{
				if ((class_auto_id.value==null)||(class_auto_id.value==""))
				{
					alert("Please Select Class.");
					class_auto_id.focus();
					return false;
				}
				
				if((class_auto_id.value==6) || (class_auto_id.value==7)) 
				{
					
					if(stream.value=='') 
					{
						alert('Please Select Stream.');
						stream.focus();
						return false; 
					}
				}

			}	// else	 
			if (isNaN(document.getElementById('contact_phone').value)) 
			{
	
				alert('Contact No. Should Be Numeric.');
				document.getElementById('contact_phone').value='';
				document.getElementById('contact_phone').focus();
				return false;
	
			}
			if(document.getElementById('contact_phone').value==0)
			{
				alert('Please Enter Contact No.');
				document.getElementById('contact_phone').value='';
				document.getElementById('contact_phone').focus();
				return false;
			}
			
			if(term.checked==false) 
			{	
				alert("Please Read And Check The Terms And Conditions.");
				term.focus();
				return false;
			}
			if(document.getElementById('term')==false) 
			{	
				alert("Please Read And Check The Terms And Conditions.");
				document.getElementById('term').focus();
				return false;
			}
	
if(document.getElementById('exist_mail'))
{
		if(document.getElementById('exist_mail').value!='')
		{
				alert('Email-Id Is Existing.');
				//email.value='';
				email.focus();
				return false;
		} 
}
		//document.frm.action="common_regis_step.php";
      // document.frm.submit();
			return true;
		/* document.frm.action="<?php echo $PHP_SELF;?>";
        document.frm.submit();
			return true; */
		}

		
	//Email validation
	function echeck(str) 
		{

			var at="@"
			var dot="."
			var lat=str.indexOf(at)
			var lstr=str.length
			var ldot=str.indexOf(dot)
			if (str.indexOf(at)==-1)
			{
			   alert("Invalid E-mail ID")
			   return false
			}

			if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
			{
			   alert("Invalid E-mail ID")
			   return false
			}

			if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
			{
			    alert("Invalid E-mail ID")
			    return false
			}

			 if (str.indexOf(at,(lat+1))!=-1){
			    alert("Invalid E-mail ID")
			    return false
			 }

			 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
			 {
			    alert("Invalid E-mail ID")
			    return false
			 }

			 if (str.indexOf(dot,(lat+2))==-1)
			 {
			    alert("Invalid E-mail ID")
			    return false
			 }
			
			 if (str.indexOf(" ")!=-1)
			 {
			    alert("Invalid E-mail ID")
			    return false
			 }
			//document.frm.submit();
			return true					
		}