// JavaScript Document
function validation()
{
	//if($_POST['firstName']=="" or $_POST['lastName']=="" or $_POST['address1']=="" or $_POST['address2']=="" or $_POST['city']=="" or $_POST['zip']=="" or $_POST['country']=="0" or $_POST['phone']=="" or $_POST['email']=="" or $_POST['username']=="" or $_POST['password']=="")


		//if(document.getElementById('s_accType').checked==true)
		//{
			//alert('standard');
				if(document.getElementById('firstname').value=='')
				{
					alert("Please fill all the fields marked with (*)");
					return false;
				}
				if(document.getElementById('lastname').value=='')
				{
					alert("Please fill all the fields marked with (*)");
					return false;
				}
				if(document.getElementById('txtdate').value=='')
				{
					alert("Please fill all the fields marked with (*)");
					return false;
				}
				if(document.getElementById('address1').value=='')
				{
					alert("Please fill all the fields marked with (*)");
					return false;
				}
				/*if(document.getElementById('address2').value=='')
				{
					alert("Please fill all the fields marked with (*)");
					return false;
				}*/
				if(document.getElementById('city').value=='')
				{
					alert("Please fill all the fields marked with (*)");
					return false;
				}
				if(document.getElementById('zip').value=='')
				{
					alert("Please fill all the fields marked with (*)");
					return false;
				}
/*				if(isNaN(document.getElementById('zip').value))
				{
					alert("Character is not allowded in the zip code");
					document.getElementById('zip').select();
					return false;
				}
*/				if(document.getElementById('country').value==0)
				{
					alert("Please fill all the fields marked with (*)");
					return false;
				}
				if(document.getElementById('phone').value=='')
				{
					alert("Please fill all the fields marked with (*)");
					return false;
				}
				if(isNaN(document.getElementById('phone').value))
				{
					alert("Character is not allowded in the phone number");
					document.getElementById('phone').select();
					return false;
				}
				if(isNaN(document.getElementById('fax').value))
				{
					alert("Character is not allowded in the fax number");
					document.getElementById('fax').select();
					return false;
				}
				if(document.getElementById('email').value=='')
				{
					alert("Please fill all the fields marked with (*)");
					return false;
				}
				
				
			var emailFilter = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/; 
			if(!document.getElementById('email').value.match(emailFilter))
			{	 
				
					alert("Please Enter valid Business Email Id! !\n");
					document.getElementById('email').select();
					return false;
			}
				
							
				if(document.getElementById('username').value=='')
				{
					alert("Please fill all the fields marked with (*)");
					return false;
				}
				if(document.getElementById('password').value=='')
				{
					alert("Please fill all the fields marked with (*)");
					return false;
				}
				
				
			if(document.getElementById('b_accType').checked==true)
			{
				if(document.getElementById('businessName').value=='')
				{
					alert("Please fill all the fields marked with (*)");
					return false;
				}
				if(document.getElementById('businessDesc').value=='')
				{
					alert("Please fill all the fields marked with (*)");
					return false;
				}
				if(document.getElementById('catid').value==0)
				{
					alert("Please fill all the fields marked with (*)");
					return false;
				}
						
			}
	
	
//alert("dfdf register");

return true;
//document.frmregister.firstname.value
//return true;
}

function addbusi_validation()
{
				if(document.getElementById('businessName').value=='')
				{
					alert("Please fill all the fields marked with (*)");
					return false;
				}
				if(document.getElementById('businessDesc').value=='')
				{
					alert("Please fill all the fields marked with (*)");
					return false;
				}
				if(document.getElementById('catid').value==0)
				{
					alert("Please fill all the fields marked with (*)");
					return false;
				}
				if(document.getElementById('address1').value=='')
				{
					alert("Please fill all the fields marked with (*)");
					return false;
				}
/*				if(document.getElementById('address2').value=='')
				{
					alert("Please fill all the fields marked with (*)");
					return false;
				}
*/				if(document.getElementById('city').value=='')
				{
					alert("Please fill all the fields marked with (*)");
					return false;
				}
				if(document.getElementById('zip').value=='')
				{
					alert("Please fill all the fields marked with (*)");
					return false;
				}
				if(isNaN(document.getElementById('zip').value))
				{
					alert("Character is not allowded in the zip code");
					document.getElementById('zip').select();
					return false;
				}
				if(document.getElementById('country').value==0)
				{
					alert("Please fill all the fields marked with (*)");
					return false;
				}
				if(document.getElementById('phone').value=='')
				{
					alert("Please fill all the fields marked with (*)");
					return false;
				}
				if(isNaN(document.getElementById('phone').value))
				{
					alert("Character is not allowded in the phone number");
					document.getElementById('phone').select();
					return false;
				}
				if(document.getElementById('email').value=='')
				{
					alert("Please fill all the fields marked with (*)");
					return false;
				}
				
				
			var emailFilter = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/; 
			if(!document.getElementById('email').value.match(emailFilter))
			{	 
				
					alert("Please Enter valid Business Email Id! !\n");
					document.getElementById('email').select();
					return false;
			}
	return true;
}

function chk_login(form)
{
	var error=false;
	var emailFilter = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/; 
	var regex=/^[0-9A-Za-z]+$/;
  	var err="Following Feild(s) id Required / Incorrect.\n\n";

	if(form.uname.value=="")
	{
			var err=err+"Please Enter User Name \n";
			form.uname.focus();
			error=true;
	}
	if(form.password.value=="")
	{
		var err=err+"Please Enter Password\n";
	
		if(error == false)
			form.password.focus();
			
		error=true;
	}
	
	if(error==true)
	{
			alert(err);
			return false;
	}
	else
		return true;
}

function forgetpassword()
{
	if(document.getElementById('useremail').value=='')
				{
					alert("Enter the email id");
					document.getElementById('useremail').focus();
					return false;
				}
				
				
			var emailFilter = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/; 
			if(!document.getElementById('useremail').value.match(emailFilter))
			{	 
				
					alert("Please Enter valid Business Email Id! !\n");
					document.getElementById('useremail').select();
					return false;
			}
}

function addpost()
{
	
//	if($_POST['txtsubject']=="" or $_POST['txtDesc']=="" or $_POST['catid']=="0") {
	

		if(document.getElementById('txtsubject').value=='')
		{
			alert("Please fill all the required fields");
			return false;
		}
		if(document.getElementById('txtDesc').value=='')
		{
			alert("Please fill all the required fields");
			return false;
		}
		if(document.getElementById('catid').value==0)
		{
			alert("Please fill all the required fields");
			return false;
		}
		
		 checkaddpost();
		 
		// return true;
}


function passwordvalidation()
{
if(document.frmpwd.txtold.value=="")
{
alert("Old Password can't be blank")
document.frmpwd.txtold.focus();
return false;
}

if(document.frmpwd.txtnew.value=="")
{
alert("New Password can't be blank")
document.frmpwd.txtnew.focus();
return false;
}

if(document.frmpwd.txtconfirm.value=="")
{
alert("Confirm Password can't be blank")
document.frmpwd.txtconfirm.focus();
return false;
}
if(document.frmpwd.txtnew.value!=document.frmpwd.txtconfirm.value)
{
alert("New and Confirm Password must be same")
document.frmpwd.txtnew.focus();
return false;
}
return true;
}


function mobilevalidation()
{
	if(isNaN(document.getElementById('mobile1').value))
	{
		alert('Character is not allowded');
		document.getElementById('mobile1').select();
		return false;
	}
	if(isNaN(document.getElementById('mobile2').value))
	{
		alert('Character is not allowded');
		document.getElementById('mobile2').select();
		return false;
	}
	if(isNaN(document.getElementById('mobile3').value))
	{
		alert('Character is not allowded');
		document.getElementById('mobile3').select();
		return false;
	}
	
	return true;
}

function confirmdeletealert()
{
	var check=confirm('Are u sure want to delete this Alert');
	
	if(check==true)
		return true
	else
		return false;
}

//add reply page

 function chk_form(form)
 {
		var a=document.getElementById('txtDesc').value;
		var b=document.getElementById('txtcost').value;
		var numExp = /^[0-9]+$/;
		var error=false;
		var err="Following Field(s) is Required / Incorrect.\n\n";
	if(a=="")
	{
	     err= err +	"Description is required.\n";
			
			error=true;
	
	}
		if(b=="")
		{
			if(error==true)
			{
					err= err +	"Cost is required.\n";
			}
			else
			{
					err= err +	"Cost is required.\n";
			}
			error=true;
		}
		else
		{
			if(!numExp.test(b))
			{
				if(error==true)
			{
					err= err +	"please enter number in cost.\n";
			}
			else
			{
					err= err +	"please enter number in cost";
			}
			error=true;
				}
			}
		
		if(error==true)
		{
			alert(err);
			return false;
		}
		else
		{		
			return true;
		}
 }

