connect(window,"onload", function(){

	var username=getObjectFromID("username");
	var password=getObjectFromID("password");
	var loginButton=getObjectFromID("loginButton");	
	
	username.disabled=false;
	password.disabled=false;
	loginButton.disabled=false;
	

	var sqlbttn=getObjectFromID("moreinfoButton");
	
	if(sqlbttn){
		var sqlDivs = new Array();
		sqlDivs[sqlDivs.length]=getObjectFromID("moreinfo");
	
		var sqlLinks = new Array();
		sqlLinks[sqlLinks.length]=sqlbttn;
	
		var sqlAccordion = new fx.Accordion(sqlLinks, sqlDivs, {opacity: true, duration:250});
	}

	username.focus();		
})

function validate_required(field,alerttxt)
{
with (field)
  {
  if (value==null||value=="")
    {
    	alert(alerttxt);return false;
    }
  else
    {
   		 return true;
    }
  }
}

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
		 }

 		 return true					
	}

function validate_form(thisform)
{
with (thisform)
  {  
	if (validate_required(dispname,"Please mention your Name.\n")==false)
		 { dispname.focus(); return false;}
	else if (validate_required(compname,"Please mention your Company name.\n")==false)
		 { compname.focus(); return false;}
	else if (validate_required(emailid,"Please enter your Email Address.\n")==false)
		 { emailid.focus(); return false;} 
	else if(echeck(thisform.emailid.value)==false) 	{  return false; }
	else if (validate_required(mobilenumber,"We are missing your mobile number.\n")==false)
		 { mobilenumber.focus(); return false;}
	else if (validate_required(recaptcha_response_field,"Please enter the Security Code shown in Image Box.\n")==false)
		 { recaptcha_response_field.focus(); return false;}
	else if(!thisform.terms.checked) { alert('You Must agree Our Terms & Conditions.'); return false; }
  }
}

function validate_login(thisform)
{
with (thisform)
  {  
	if (validate_required(username,"Please mention your Login ID.\n")==false)
		 { username.focus(); return false;}
 
	else if (validate_required(password,"Please enter the Login Password.\n")==false)
		 { password.focus(); return false;}
  }
}