function validateLogin()
{
	var isValid = true;	
	isFieldFocusSet = false;
	if(isEmptyValue("email")){xAlert('Please enter email','user_email'); isValid=false;}	
	else {xAlert('','user_email');}	
	if(!emailCheck("email")){xAlert('Please enter valid email ','user_email');
	  	document.getElementById("email").focus();
	  	isValid=false;}	
	else {xAlert('','user_email');}	
	if(isEmptyValue("password")){xAlert('Please enter password','user_password'); isValid=false;}	
	else {xAlert('','user_password');}
	
	if(isValid)
	{
		xDisableElement("loginBtn","WWIButtonDisable");
	}		
	return isValid;	
}


function forgotpassword(url)
{
	var isValid = true;	
	isFieldFocusSet = false;
	if(isEmptyValue("email")){xAlert('Please enter email','user_email'); isValid=false;}	
	else {xAlert('','user_email');}	
	if(!emailCheck("email")){xAlert('Please enter valid email ','user_email');
	  	document.getElementById("email").focus();
	  	isValid=false;}	
	else {xAlert('','user_email');}	
	if(isValid){
		window.location = url+"?user.email="+document.getElementById("email").value;	
		}
	return isValid;	
}


function validateEditPartner(){	
	var isValid = true;	
	isFieldFocusSet = false;
	if(isEmptyValue("firstName")){xAlert('Please enter firstName','user_firstName'); isValid=false;}	
	else {xAlert('','user_firstName');}	
	if(isEmptyValue("middleName")){xAlert('Please enter middleName','user_middleName'); isValid=false;}	
	else {xAlert('','user_middleName');}	
	if(isEmptyValue("lastName")){xAlert('Please enter lastName','user_lastName'); isValid=false;}	
	else {xAlert('','user_lastName');}		
	if(isEmptyValue("organisation")){xAlert('Please enter organisation','user_organisation'); isValid=false;}	
	else {xAlert('','user_organisation');}	
	if(isEmptyValue("phoneNumber")){xAlert('Please enter phoneNumber','user_phoneNumber'); isValid=false;}	
	else if(checkInternationalPhone(document.getElementById("phoneNumber").value)==false){
		xAlert('Please enter the valid phone number','user_phoneNumber');
		isValid=false;
	}						
	else {xAlert('','user_phoneNumber');}						
	return isValid;	
}
function cancelEditPartner(){
	window.location = "http://"+serverName+":"+serverPort+contextPath+"/partner/profile.action";
	
}
function cancelEditClient(){
	window.location = "http://"+serverName+":"+serverPort+contextPath+"/client/profile.action";
	
}
function cancelPartnerResources()
{
	window.location = "http://"+serverName+":"+serverPort+contextPath+"/partner/myResources.action";
}
function cancelClientResources()
{
	window.location = "http://"+serverName+":"+serverPort+contextPath+"/client/myResources.action";
}
function validateResetPassword()
{
	var isValid = true;	
	isFieldFocusSet = false;
	if(isEmptyValue("password")){xAlert('Please enter current password','password_Div'); isValid=false;}	
	else {xAlert('','password_Div');}	
	if(isEmptyValue("newPassword")){xAlert('Please enter new password','newPassword_Div'); isValid=false;}	
	else if((document.getElementById("newPassword").value).length<6){xAlert('Password should be atleast 6 characters','newPassword_Div'); isValid=false;}
	else {xAlert('','newPassword_Div');}
	if(document.getElementById("newPassword").value!=document.getElementById("confirmpassword").value){
		xAlert('Please enter same value in new password and confirm password.','confirmPassword_Div');
		isValid=false;
	}
	return isValid;	
}
function saveAndAdd(){
	if(validateLead()){
		document.forms[0].action="saveAndCreateLead.action";
		document.forms[0].submit();
	}
}
function validateLead()
{
	var isValid = true;	
	isFieldFocusSet = false;
	if(isEmptyValue("firstname")){xAlert('Please enter first name','leads_firstname'); isValid=false;}	
	else {xAlert('','leads_firstname');}	
	if(isEmptyValue("lastName")){xAlert('Please enter last name','leads_lastName'); isValid=false;}	
	else {xAlert('','leads_lastName');}		
	if(isEmptyValue("jobTitle")){xAlert('Please enter job title','leads_jobTitle'); isValid=false;}	
	else {xAlert('','leads_jobTitle');}	
	if(isEmptyValue("phoneNumber")){xAlert('Please enter phone number','leads_phoneNumber'); isValid=false;}	
	else if(checkInternationalPhone(document.getElementById("phoneNumber").value)==false){
		xAlert('Please enter the valid phone number','leads_phoneNumber');
		isValid=false;
	}						
	else {xAlert('','leads_phoneNumber');}	
	if(isEmptyValue("email")){xAlert('Please enter email','leads_email'); isValid=false;}	
	else {xAlert('','leads_email');}						
	if(!emailCheck("email")){xAlert('Please enter valid email ','leads_email');
	  	document.getElementById("email").focus();
	  	isValid=false;}	
	else {xAlert('','leads_email');}	
	if(isEmptyValue("leadSource")){xAlert('Please enter lead source','leads_leadSource'); isValid=false;}	
	else {xAlert('','leads_leadSource');}	
	if(isEmptyValue("company")){xAlert('Please enter company','leads_company'); isValid=false;}	
	else {xAlert('','leads_company');}		
	if(isEmptyValue("industry")){xAlert('Please enter industry','leads_industry'); isValid=false;}	
	else {xAlert('','leads_industry');}	
	if(isEmptyValue("street")){xAlert('Please enter street','leads_street'); isValid=false;}	
	else {xAlert('','leads_street');}	
	if(isEmptyValue("city")){xAlert('Please enter city','leads_city'); isValid=false;}	
	else {xAlert('','leads_city');}						
	if(isEmptyValue("state")){xAlert('Please enter state/province','leads_state'); isValid=false;}	
	else {xAlert('','leads_state');}	
	if(isEmptyValue("zip")){xAlert('Please enter zip/postal code','leads_zip'); isValid=false;}	
	else {xAlert('','leads_zip');}						
	return isValid;	
}
function validateCreateResource(mode){	

	var isValid = true;	
	isFieldFocusSet = false;
	if(isEmptyValue("title")){xAlert('Please enter title','resource_title'); isValid=false;}	
	else {xAlert('','resource_title');}	
	if(isEmptyValue("descripton")){xAlert('Please enter descripton','resource_descripton'); isValid=false;}	
	else {xAlert('','resource_descripton');}
	if(mode.trim()=='add'){
		if(isEmptyValue("upload")){xAlert('Please select the file to upload ','resource_upload'); isValid=false;}	
		else {xAlert('','resource_upload');}	
	}			
	return isValid;	
}

function cancelLeadPartner(){
	window.location = "http://"+serverName+":"+serverPort+contextPath+"/partner/listLeads.action";
	
}
function saveAndAddMyResource(){
	if(validateCreateResource('add')){
		document.forms[0].action="saveAndCreateMyResource.action";
		document.forms[0].submit();
	}
}
function restrictText(event,value,errorDiv){
	key = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	if(key==8 || key == 46 || key == 37){
		if(trim(value).length<=999)
			xAlert('',errorDiv);
		return true;
	}
	if(value.length>999){
		xAlert('Should not exceed 1000 characters',errorDiv);
		return false;
	}else{
		xAlert('',errorDiv);
		return true;
	}
}
function validateContactUs(){
	var isValid = true;	
	isFieldFocusSet = false;
	if(isEmptyValue("subject")){xAlert('Please enter subject','contactUs_subject'); isValid=false;}	
	else {xAlert('','contactUs_subject');}	
	if(isEmptyValue("message")){xAlert('Please enter message','contactUs_message'); isValid=false;}	
	else {xAlert('','contactUs_message');}
	return isValid;
}