function validate_personaldetails()
{	
	if (  trim(document.myform.txtuser.value) == "" )
	{	
		alert("Please enter user id.");
		document.myform.txtuser.focus();
		return false;
	}
	if (trim(document.myform.txtuser.value) != "" )
	{	
		if (document.myform.txtuser.value.search(/[^a-zA-z0-9-._]/) > 0 )
		{	
			alert("Please provide valid userid.");
			document.myform.txtuser.focus();
			return false;
		}
	}
	
	if (  trim(document.myform.pwd.value) == "" )
	{	
		alert("Please enter password.");
		document.myform.pwd.focus();
		return false;
	}
	if (  trim(document.myform.rpwd.value) == "" )
	{	
		alert("Please enter your password again.");
		document.myform.rpwd.focus();
		return false;
	}
	if (  trim(document.myform.rpwd.value) != trim(document.myform.pwd.value) )
	{	
		alert("Both password does not match.");
		document.myform.rpwd.focus();
		return false;
	}
	
	if (  trim(document.myform.first_name.value) == "" )
	{	
		alert("Please provide first name");
		document.myform.first_name.focus();
		return false;
	}
	
	if ( trim(document.myform.last_name.value) == "" )
	{	
		alert("Please provide last name");
		document.myform.last_name.focus();
		return false;
	}
	
	if (document.myform.ccProfPersonalDetails_ddob.value=="Select")
	{
		alert("Please select day of your DOB.")
		document.myform.ccProfPersonalDetails_ddob.focus();
		return false;
	}
	if (document.myform.ccProfPersonalDetails_mdob.value=="0")
	{
		alert("Please select month of your DOB.")
		document.myform.ccProfPersonalDetails_mdob.focus();
		return false;
	}
	if (document.myform.ccProfPersonalDetails_ydob.value=="Select")
	{
		alert("Please select year of your DOB.")
		document.myform.ccProfPersonalDetails_ydob.focus();
		return false;
	}
	
	fileValue = document.myform.ccProfPersonalDetails_professionalimage.value;
	if (fileValue != "")
	{
		if (!CheckFileExt())
		{
			return false;
		}
	}
	
	if ( trim(document.myform.address1.value) == "" )
	{	
		alert("Please provide address.");
		document.myform.address1.focus();
		return false;
	}		
				
	if ( document.myform.country.selectedIndex == 0 || document.myform.country.selectedIndex == null )
	{	
		alert("Please select country.");
		document.myform.country.focus();
		return false;
	}		
				
	if(document.myform.cphone.value == "")
	{
		alert("Please provide country code.");
		document.myform.cphone.focus();
		return false;
	}
	if(document.myform.cphone.value != "")
	{
		if ( !validatePhone(document.myform.cphone.value) )
		{
			alert("Please provide valid phone number.");
			document.myform.cphone.focus();
			return false;
		}
	}
	
	if(document.myform.aphone.value == "")
	{
		alert("Please provide area code.");
		document.myform.aphone.focus();
		return false;
	}
	if(document.myform.aphone.value != "")
	{
		if ( !validatePhone(document.myform.aphone.value) )
		{
			alert("Please provide valid phone number.");
			document.myform.aphone.focus();
			return false;
		}
	}
	
	if(document.myform.pphone.value == "")
	{
		alert("Please provide phone number.");
		document.myform.pphone.focus();
		return false;
	}
	if(document.myform.pphone.value != "")
	{
		if ( !validatePhone(document.myform.pphone.value) )
		{
			alert("Please provide valid phone number.");
			document.myform.pphone.focus();
			return false;
		}
	}
	
	if ( document.myform.mobile.value != "" )
	{
		if ( !validatePhone(document.myform.mobile.value) )
		{
			alert("Please provide valid mobile number.");
			document.myform.mobile.focus();
			return false;
		}
	}	
											
	if( document.myform.Email.value == "")
	{
		alert("Please provide email address.");
		document.myform.Email.focus();
		return false;
	}
	if( document.myform.Email.value != "")
	{
		if ( document.myform.Email.value.search(/([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})/) < 0 )
		{	
			alert("Please provide valid email.");
			document.myform.Email.focus();
			return false;
		}
	}	
	
	if (document.myform.terms.checked==false)
	{
		alert("Check Terms and Conditions before proceeding");
		document.myform.terms.focus();
		return false;
	} 																	
		
	return true;
}

function CheckUserExist()
{
	var page;
	if ( trim(document.myform.ccProfPersonalDetails_txtuser.value) != "" )
	{
		if (document.myform.ccProfPersonalDetails_txtuser.value.search(/[^a-zA-z0-9-._]/) > 0 )
		{	
			alert("Please provide valid userid.");
			document.myform.ccProfPersonalDetails_txtuser.focus();
			return false;
		}
		else
		{
			page = "/CheckAvailable.aspx?user_id=" + document.myform.ccProfPersonalDetails_txtuser.value + "&logintype=professional";							
			window.open(page,'','toolbars=0,width=400,height=150,scrollbars=yes,top=0,left=0,dependent=1,resizable=0,')
		}
	}
	else
	{
		alert("Provide user name to be checked.")
		document.myform.ccProfPersonalDetails_txtuser.value = "";
		document.myform.ccProfPersonalDetails_txtuser.focus();
	}
}

extArray = new Array(".jpg",".gif",".bmp");

function CheckFileExt()
{
	allowSubmit = false;
	fileValue = document.myform.ccProfPersonalDetails_professionalimage.value;
			
	while (fileValue.indexOf("\\") != -1)
	
	fileValue = fileValue.slice(fileValue.indexOf("\\") + 1);
	ext = fileValue.slice(fileValue.indexOf(".")).toLowerCase();
	
	for (var i = 0; i < extArray.length; i++)
	{
		if (extArray[i] == ext) 
		{ 
			allowSubmit = true; 
			break; 
		}
	}
	
	if (allowSubmit)
	{
		return true;
	}
	else
	{
		alert("Please only upload files that end in types:  " 
		+ (extArray.join("  ")) + "\nPlease select a new "
		+ "file to upload and submit again.");
		return false;
	}
}

function validate_educationdetail()
{
	if (trim(document.myform.school_name.value) == "" )
	{
		alert("Please contect school name.");						
		document.myform.school_name.focus();						
		return false;
	}					
	if( document.myform.grad_degree.value == "")
	{
		alert("Please provide graduation degree");
		document.myform.grad_degree.focus();
		return false;
	}					
	if(document.myform.grad_college.value == "")
	{
		alert("Please provide college");
		document.myform.grad_college.focus();
		return false;
	}
	
	return true;				
}

function validatePhone( phoneVal )
{
	if ( phoneVal == "" )
			return false;			
	
	if ( phoneVal.search(/[^0-9\-\s]/) > -1 )
		return false;
	return true;
}

function validate_profdetails()
{				
	if (  trim(document.myform.present_employer.value) == "" )
	{	
		alert("Please provide present employer");
		document.myform.present_employer.focus();
		return false;
	}					
	if ( trim(document.myform.designation.value) == "" )
	{	
		alert("Please provide designation");
		document.myform.designation.focus();
		return false;
	}
	if ( trim(document.myform.duration.value) == "" )
	{	
		alert("Please provide duration");	
		document.myform.duration.focus();											
		return false;
	}
	if ( trim(document.myform.profile.value) == "" )
	{	
		alert("Please provide profile.");
		document.myform.profile.focus();
		return false;
	}
	if ( trim(document.myform.profile.value) != "" )
	{							
		if ( document.myform.profile.value.length > 500 )
		{
			alert("Maximum 500 can be allowed.");
			document.myform.profile.focus();
			return false;
		}						
	} 
	
	if ( trim(document.myform.previous_profile.value) != "" )
	{	
		if ( document.myform.previous_profile.value.length > 500 )
		{
			alert("Maximum 500 can be allowed.");
			document.myform.previous_profile.focus();
			return false;
		}
	} 
	
	return true;
}

function chkTerms()
{
	if (document.myform.terms.checked==false)
	{
		alert("Check Terms and Conditions before proceeding");
		document.myform.terms.focus();
		return false;
	} 	 	
	return true;
}