
function checkform() {	
  if(isEmpty(document.getElementById("username"),'User Name','userError'))
  {
      return false;
  }
  if(!isEmail(document.getElementById("username"),'userError'))
	{
	  return false;
	}

  if(isEmpty(document.getElementById("password"),'Password','passError'))
  {
      return false;
  }
  document.getElementById("logins").disabled = true;
  getLoginResponse(document.getElementById("username").value, document.getElementById("password").value, document.getElementById("logintype").value);
  return false;
  
 
}



function getLoginResponse(username,password, usertype) { 
	sUserType = usertype;
	new Ajax.Updater('ajaxFeedback',base_url+'/login/index/'+usertype, {postBody: 'username='+username+'&password='+password+'&user_type='+usertype, onComplete:showAlert});
	return false;
}



function showAlert(response){
	
	var retMsg = response.responseText;	
	
	if(retMsg == "success"){        
      	document.getElementById("logins").disabled = false;
	if(sUserType == 'coach')
		parent.document.location.href=base_url+'/coach_myprofile';
	else if(sUserType == 'student')
		parent.document.location.href=base_url+'/student_myprofile';
      }
      else {
      		document.getElementById("logins").disabled = false;
      		alert(retMsg);
      }
}




function checkform_fp() {	
 	var emlid= document.getElementById('email_id').value;
  
  getLoginResponse(document.getElementById("username").value, document.getElementById("password").value, document.getElementById("logintype").value);
  return false;
  
 
}



function chkform_fp() {
	var emlid= document.getElementById('email_id').value;
	var usertype= document.getElementById('user_type').value;
	new Ajax.Updater('ajaxFeedback',base_url+'/login/forgot_password', {postBody: 'email_id='+emlid+'&user_type='+usertype, onComplete:showAlert_fp});
	return false;
}

function showAlert_fp(response){
	
	var retMsg = response.responseText;
	if(retMsg == "success"){        
      	document.getElementById("email_id").value = "";
      	alert("Password has been successfully send");
      	parent.document.location.href=base_url;//+'search/home';
      }
      else {      		
      		alert(retMsg);     		
      }
}



function checkFPform() {
	document.getElementById("userError").innerHTML = "";
	document.getElementById("passError").innerHTML = "";
	if(isEmpty(document.getElementById("femail"),'Email Id','userError'))
	{
	  return false;
	}
	else if(!isEmail(document.getElementById("femail"),'userError'))
	{
	  return false;
	}
  /* if(isEmpty(document.getElementById("password"),'Key','passError'))
	{
	  return false;
	}*/
   return true;
}



