<!-- Begin
function emailvalidate(Email){
	
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(Email))
{
return true;
}
alert("Invalid E-mail Address! Please re-enter.");
return false;
}
//  End -->

function trim(Value)
{
	
	return Value.replace(/^\s+|\s+$/g, "");
}
function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}


function Validation()
{

var usename=document.loginfrm.usename.value;
var password=document.loginfrm.password.value;
var rtn = true
if(trim(usename) == "")
{
	alert("Please Enter username");
	document.loginfrm.usename.value = "";
	document.loginfrm.usename.focus();
	rtn = false;
	return rtn;
}if(trim(password) == "")
{
	alert("Please Enter Password ");
	document.loginfrm.password.value = "";
	document.loginfrm.password.focus();
	rtn = false;
	return rtn;
}
return rtn;
}

function login_validation()
{
	username = document.login.username.value
	password = document.login.password.value
	var rtn = true
if(trim(username) == "")
{
	alert("Please Enter First Name ")
	document.login.username.value = ""
	document.login.username.focus()
	rtn = false
	return rtn
}
if(trim(password) == "")
{
	alert("Please Enter Last Name ")
	document.login.password.value = ""
	document.login.password.focus()
	rtn = false
	return rtn
}
}

function emailvalidation()
{
	var Email = trim(document.frgtpwd.Email.value)
 
	if(trim(Email) == "")
	{
		alert("Please Enter Email Address");
		document.frgtpwd.Email.value="";
		document.frgtpwd.Email.focus();
		return false;
	}else{
	if(emailvalidate(Email)==false){
		document.frgtpwd.Email.value="";
		document.frgtpwd.Email.focus();
		return false;
	}
}
}
function Validation_donate()
{
	var weight = document.donate.weight_capacity.value
	var nvalue = document.donate.nvalue.value
	var rtn = true
	if(trim(weight) == 0){
		alert("Please Enter Weight Capacity")
		document.donate.weight_capacity.value = ""
		document.donate.weight_capacity.focus()
		rtn = false
		return rtn
	}
	if(trim(weight) == ""){
		alert("Please Enter  Weight Capacity")
		document.donate.weight_capacityt.value = ""
		document.donate.weight_capacity.focus()
		rtn = false
		return rtn
	}else if(isInteger(weight) == false)
	{
		alert("Please Enter Valid Weight Capacity")
		document.donate.weight_capacity.value = ""
		document.donate.weight_capacity.focus()
		rtn = false
		return rtn
	}
	if(nvalue != "" && isInteger(nvalue) == false)
	{
		alert("Please Enter Valid Value")
		document.donate.nvalue.value=""
		document.donate.nvalue.focus()
		rtn = false
		return rtn
	}
	
  return rtn
}

// ----------------------------------javascrit validation by us-------------------->


var file_cout =1;
function addfile()
{
file_cout = file_cout + 1; 
var newtotal = file_cout;
var errorf=false;

	var b_photo=document.getElementsByName('b_photo[]');

	for(i=0;i<b_photo.length;i++)
	{
		if(b_photo[i].value=="")
		{
		errorf=true;
		break;
		}
	}
	
	if(errorf==true)
	{
		alert("Upload an Image");
		return false;
	}


var maindiv=document.getElementById('files');
var divobj=document.createElement('div');
divobj.id=newtotal;
divobj.innerHTML = "<table width='100%' border='0' align='enter' cellpadding='0' cellspacing='0'><tr><td height='27' width='37%'align='right'>Upload Photo [" + newtotal + "]:</td><td width='63%' align='left'><input type='file' name='b_photo[]' id='b_photo' /></td></tr><tr><td height='27' align='right'>Title Photo [" + newtotal + "]: </td><td align='left'><input type='text' name='p_title[]' id='p_title' /></td></tr></table>";
maindiv.appendChild(divobj);
}


var workhr_cout = 0;

function addmore()
{
var workhr_cout = workhr_cout + 1;
var newtotal = workhr_cout;
var errorf=false;

	var b_hours=document.getElementsByName('b_hours[]');

	for(i=0;i<b_hours.length;i++)
	{
		if(b_hours[i].value=="")
		{
		errorf=true;
		break;
		}
	}
	
	if(errorf==true)
	{
		alert("Enter Business Hours");
		return false;
	}
var maindiv=document.getElementById('attach');
var hourobj=document.createElement('div');
hourobj.id=newtotal;
hourobj.innerHTML = "<table width='100%' border='0' align='center' cellpadding='0' cellspacing='0'><tr><td width='37%' height='27' align='right'>Hrs From &amp; To:</td><td width='63%' align='left'><input type='text' name='b_hours[]' id='b_hours' /></td></tr><tr><td height='27' align='right'>Week Day:</td><td align='left'><label><select name='b_days[]' id='b_days'><option value='1'>Sunday</option><option value='2' selected='selected'>Monday</option><option value='3'>Tuesday</option><option value='4'>Wednesday</option><option value='5'>Thursday</option><option value='6'>Friday</option><option value='7'>Saturday</option></select></label></td></tr></table>";

maindiv.appendChild(hourobj);

}

 
function show_hide(tblid, show) {
if (tbl = document.getElementById(tblid)) {
if (null == show) show = tbl.style.display == 'none';
tbl.style.display = (show ? '' : 'none');
}
}

function validmenutitle()
{
 if(trim(document.menutitle.menu_title.value)=="" )
	{
		alert("Management Name Can't be Null");
		document.menutitle.menu_title.value= "";
		document.menutitle.menu_title.focus();
		return false;
	}
	
}


function checkvalidation()
{    
if(document.registration.utype.value=="1")
{
   	if(trim(document.registration.fname.value)=="" )
	{
		alert("First Name Can't be Null");
		document.registration.fname.value= "";
		document.registration.fname.focus();
		return false;
	}
    
   	if(trim(document.registration.lname.value)=="" )
	{
		alert("Last Name Can't be Null");
		document.registration.lname.value= "";
		document.registration.lname.focus();
		return false;
	}
}
	if(trim(document.registration.uname.value)=="" )
	{
		alert("UserName Can't be Null");
		document.registration.uname.value= "";
		document.registration.uname.focus();
		return false;
	}
        var Userlength=document.registration.uname.value;
		var userlen = Userlength.length;
		if(userlen < 6)
		{
			alert("Username must be minimum six character long");
			document.registration.uname.focus();
			return  false;
		}
		if(document.registration.utype.value=="1")
	   {
			if(trim(document.registration.fname.value)=="" )
			{
				alert("First Name Can't be Null");
				document.registration.fname.value= "";
				document.registration.fname.focus();
				return false;
			}
			if(trim(document.registration.lname.value)=="" )
			{
				alert("Last Name Can't be Null");
				document.registration.lname.value= "";
				document.registration.lname.focus();
				return false;
			}
		}
	if(trim(document.registration.upassword.value)=="")
	{
		alert("Password Can't be Null");
		document.registration.upassword.value="";
		document.registration.upassword.focus();
		return false;
	}
if(document.registration.utype.value=="1")
{	
  if(trim(document.registration.upassword.value)!= "" ) 
	{
		if(document.registration.chkStrn.value != "ok")  
		{
	  		alert("Password is to be of Level STRONG");
	  		//document.registration.upassword.value="";
			document.registration.upassword.focus();
			return false;
		}
	}
}
    
	if(trim(document.registration.upassword1.value)=="")
	{
		alert("Confirm Password Can't be Null");
		document.registration.upassword1.value="";
		document.registration.upassword1.focus();
		return false;
	}
	if(document.registration.upassword.value !=document.registration.upassword1.value  )
	{
		alert("Password and Confirm password does not match");
		document.registration.upassword1.value="";
		document.registration.upassword1.focus();
		return false;
	}
	
	if(trim(document.registration.email.value)=="" )
	{
		alert("EmailAddress Can't be Null");
		document.registration.email.value='';
		document.registration.email.focus();
		return false;
	}
	
	if(!emailvalidate(trim(document.registration.email.value)))
	{
		//alert("EmailAddress Can't be Null");
		document.registration.email.select();
		return false;
	}


   	if(trim(document.registration.cemail.value)=="" )
	{
		alert("Confirm EmailAddress Can't be Null");
		document.registration.cemail.value="";
		document.registration.email.focus();
		return false;
	}

	if(trim(document.registration.email.value) !=trim(document.registration.cemail.value) )
	{
		alert("E-Mail and Confirm E-Mail is not match");
        document.registration.cemail.value='';
		document.registration.cemail.focus();
		return false;
	}
	


		 
	/*if(isNaN(document.registration.phone.value))
	{
			alert("Please enter valid phone No");
			document.registration.phone.focus();
			return false;
	}*/
	
	
if(document.registration.utype.value=="1")
	   {
	   	
		  if(trim(document.registration.address1.value)==""  )
		{
			alert("Address1 Can't be Null");
			document.registration.address1.value="";
			document.registration.address1.focus();
			return false;
		}

		if(document.registration.state.value=="0")
		{
			alert("State Can't be Null");
			document.registration.state.focus();
			return false;
		}
		if(document.registration.city.value=="0")
		{
			alert("City Can't be Null");
			document.registration.city.focus();
			return false;
		}
		if(trim(document.registration.zipcode.value)==""  )
		{
			alert("Zipcode Can't be Null");
			document.registration.zipcode.value="";
			document.registration.zipcode.focus();
			return false;
		}
	 
		
		if(trim(document.registration.bname.value)=="" )
		{
			alert("BusinessName Can't be Null");
			document.registration.bname.focus();
			return false;
		}
		
		
		if(trim(document.registration.category1.value)=="0")
		{
			alert("Select Business Category");
			document.registration.category1.focus();
			return false;
		}
		
 
		
	}
 if(document.registration.code.value=='' || document.registration.code.value.charAt(0)==" ") {
          alert('Please enter the string from the displayed image');
          document.registration.code.value='';
          document.registration.code.focus();
          return false;
          }
          // Now the Ajax CAPTCHA validation
         /* if(!checkcode(document.registration.code.value)){          return false; } */
	return true;
	
       
}


function checkcode(thecode) {
//        http.open("GET", url + escape(thecode), true);
//        http.onreadystatechange = handleHttpResponse;
//        http.send(null);
        } 

function advance_validation()
{
	var h_errorf=false;
	var p_errorf=false;
	
	var b_hours=document.getElementsByName('b_hours[]');

	for(i=0;i<b_hours.length;i++)
	{
		if(b_hours[i].value=="")
		{
		h_errorf=true;
		break;
		}
	}
	
	if(h_errorf==true)
	{
		alert("Enter Business Hours");
		return false;
	}
	
	
	var b_photo=document.getElementsByName('b_photo[]');

	for(i=0;i<b_photo.length;i++)
	{
		if(b_photo[i].value=="")
		{
		p_errorf=true;
		break;
		}
	}
	
	if(p_errorf==true)
	{
		alert("Upload an Image");
		return false;
	}
	return true;
}

function business_show(bstatus)
{
	if(bstatus==0)
 	{
		document.getElementById('business_detail').style.display='none';
		document.getElementById('advance_business_detail').style.display='none';
	}
	else
	{
		document.getElementById('business_detail').style.display='block';
		document.getElementById('advance_business_detail').style.display='block';
	}
}
function custvalidation()
{
	 
	
	
	/*if(document.coupon.state.value=="0")
	{
		alert("State Can't be Null");
		document.coupon.state.focus();
		return false;
	}
	if(document.coupon.city.value=="0")
	{
		alert("City Can't be Null");
		document.coupon.city.focus();
		return false;
	}
	if(trim(document.coupon.zipcode.value)=="")
	{
		alert("Zipcode Can't be Null");
		document.coupon.zipcode.focus();
		return false;
	}*/
	if(trim(document.coupon.email.value)=="")
	{
		alert("Email Address Can't be Null");
		document.coupon.email.focus();
		return false;
	}
	if(!emailvalidate(trim(document.coupon.email.value)))
	{
		alert("EmailAddress Can't be Null");
		document.coupon.email.select();
		return false;
	}
	
	/*if(trim(document.coupon.address1.value)=="")
	{
		alert("Address1 Can't be Null");
		document.coupon.address1.focus();
		return false;
	}*/
	
}

function salesvalidation()
{
	
	if(trim(document.coupon.email.value)=="")
	{
		alert("EmailAddress Can't be Null");
		document.coupon.email.focus();
		return false;
	}
	
	if(!emailvalidate(trim(document.coupon.email.value)))
	{
		alert("EmailAddress Can't be Null");
		document.coupon.email.select();
		return false;
	}
	
	if(trim(document.coupon.address1.value)=="")
	{
		alert("Address1 Can't be Null");
		document.coupon.address1.focus();
		return false;
	}
	
}

function contactvalidation()
{
	if(trim(document.coupon.fname.value)=="")
	{
		alert("Frist Name Can't be Null");
		document.coupon.fname.focus();
		return false;
	}
	if(trim(document.coupon.bname.value)=="")
	{
		alert("Business Name Can't be Null");
		document.coupon.bname.focus();
		return false;
	}
	if(trim(document.coupon.zipcode.value)=="")
	{
		alert("Zipcode Can't be Null");
		document.coupon.zipcode.focus();
		return false;
	}
	if(trim(document.coupon.email.value)=="")
	{
		alert("Email Address Can't be Null");
		document.coupon.email.focus();
		return false;
	}
	
	if(!emailvalidate(trim(document.coupon.email.value)))
	{
		alert("Email Address Can't be Null");
		document.coupon.email.select();
		return false;
	}
	
	if(trim(document.coupon.address1.value)=="")
	{
		alert("Address1 Can't be Null");
		document.coupon.address1.focus();
		return false;
	}
	
}

function validworkinghrs()
{
	if(trim(document.working_hrs.day.value)=="0")
	{
		alert("Day Can't be Null");
		document.working_hrs.day.focus();
		return false;
	}
	if(trim(document.working_hrs.time.value)=="")
	{
		alert("Time Can't be Null");
		document.working_hrs.time.focus();
		return false;
	}
		
}


function passwordvalidation() {

	with(document.password)
	{
		if(opassword.value == '')
		{
			alert("Enter Old Password");
			opassword.focus();
			return  false;
		}

		if(upassword.value == '')
		{
			alert("Enter New Password");
			upassword.focus();
			return  false;
		}
		
	
 if(trim(upassword.value)!= "" ) 
	{
		if(chkStrn.value != "ok")  
		{
	  		alert("Please enter strong password");
			upassword.focus();
			return false;
		}
	}
		
	
		if(cpassword.value == '')
		{
			alert("Enter Confirm Password");
			cpassword.focus();
			return  false;
		}
	
		if(upassword.value != cpassword.value)
		{
			alert("Confirm password should be same as new password");
			cpassword.focus();
			return false;
		}

	}
	return true;
}

function validpicture()
{
	if(trim(document.image.photo.value)=="")
	{
		alert("Photo Can't be Null");
		document.image.photo.focus();
		return false;
	}
	if(trim(document.image.title.value)=="")
	{
		alert("Title Can't be Null");
		document.image.title.focus();
		return false;
	}
		
}

function validtitle()
{
	if(trim(document.imgtitle.title.value)=="")
	{
		alert("Title Can't be Null");
		document.imgtitle.title.focus();
		return false;
	}
	return true;	
}

function chknum()
   {
      key2=window.event.keyCode;
		  if((key2 <48)||(key2>57))
	{
	   var num1=String.fromCharCode(key2); 
	   alert("'" + num1 + "'is not numeric!");
	   return false;
	}
}	

			
function validcoupon()
{
	

	if(trim(document.coupon.coupon_code.value)=="")
	{
		alert("Coupon Code Can't be Null");
		document.coupon.coupon_code.focus();
		return false;
	}
	if(trim(document.coupon.title.value)=="")
	{
		alert("Coupon Title Can't be Null");
		document.coupon.title.focus();
		return false;
	}
	if(document.coupon.start_date.value=="")
	{
		alert("Available Date Can't be Null");
		document.coupon.start_date.focus();
		return false;
	}
	
	if(document.coupon.expiry_date.value=="")
	{
		alert("Expiry Date Can't be Null");
		document.coupon.expiry_date.focus();
		return false;
	}

/*	if(document.coupon.start_date.value>document.coupon.expiry_date.value)
	{
		alert("Expiry Date should not be less than available date ");
		document.coupon.expiry_date.focus();
		return false;
	}
	if(document.coupon.amount.value=="" || document.coupon.amount.value.charAt(0)==" ")
	{
		alert("Amount Can't be Null");
		document.coupon.amount.focus();
		return false;
	}*/
	
	 
}


function validmenu()
{
	
	if(trim(document.menu.food_name.value)=="" )
	{
		alert("Name Can't be Null");
		document.menu.food_name.focus();
		return false;
	}
/*	if( trim(document.menu.amount.value)=="" )
	{
		alert("Amount Can't be Null");
		document.menu.amount.focus();
		return false;
	}
	
	if(isNaN(document.menu.amount.value))
	{
			alert("Please enter valid amount");
			document.menu.amount.focus();
			return false;
	}*/
	
	if(trim(document.menu.description.value)=="" )
	{
		alert("Description Can't be Null");
		document.menu.description.focus();
		return false;
	}
	
	
	if(document.menu.photo.value=="")
	{
		alert("Photo Can't be Null");
		document.menu.photo.focus();
		return false;
	}
	
	
}



function validmenuedit()
{
	
	if( trim(document.menu.food_name.value) =="" )
	{
		alert("Name Code Can't be Null");
		document.menu.food_name.focus();
		return false;
	}
/*	if(document.menu.amount.value=="" || document.menu.amount.value.charAt(0)==" ")
	{
		alert("Amount Can't be Null");
		document.menu.amount.focus();
		return false;
	}*/
	if(trim(document.menu.description.value)==""  )
	{
		alert("Description Can't be Null");
		document.menu.description.focus();
		return false;
	}
		
}

function validbusiness()
{
	
	if(trim(document.business.business_name.value)=="")
	{
		alert("Business Name Can't be Null");
		document.business.business_name.focus();
		return false;
	}
	if(trim(document.business.user_name.value)=="")
	{
		alert("User Name Can't be Null");
		document.business.user_name.focus();
		return false;
	}
	if(trim(document.business.upassword.value)=="")
	{
		alert("Password Can't be Null");
		document.business.upassword.focus();
		return false;
	}
		
}

function validcustomer()
{
	
	if(document.customer.user_name.value=="")
	{
		alert("User Name Can't be Null");
		document.customer.user_name.focus();
		return false;
	}
	if(document.customer.upassword.value=="")
	{
		alert("Password Can't be Null");
		document.customer.upassword.focus();
		return false;
	}
		
}
function chknum(value)
   {
      key2=window.event.keyCode;
		  if((key2 <48)||(key2>57))
	{
	   var num1=String.fromCharCode(key2); 
	   alert("'" + num1 + "'is not numeric!");
	   return false;
	}
}	

function chkchar()
	   {   key1=window.event.keyCode;
      if (((key1 < 65) || (key1 > 90))&&((key1<97) || (key1>122))) 
	      {
		       var ch = String.fromCharCode(key1);
		    	alert( "'" + ch + "' is not character!");
			    return false;
        } 
		  return true;
    	}
    	
    	
    	
    	
 function checkbussale()
{
	try{

if(document.salesfrm.state.value=="0")
	{
		alert("State Can't be Null");
		document.salesfrm.state.focus();
		return false;
	}

if(document.salesfrm.city.value=="0")
	{
		alert("City Can't be Null");
		document.salesfrm.city.focus();
		return false;
	}


        if(document.salesfrm.category1.value=="0")
		{
			alert("Select Business Category1");
			document.salesfrm.category1.focus();
			return false;
		}
		 

 	/*	if(document.salesfrm.category2.length>1)
			{
				if(document.salesfrm.category2.value=="0")
				{
					alert("Select Business Category2");
					document.salesfrm.category2.focus();
					return false;
				}
			}
				*/
	
		if(document.salesfrm.payment.value=="")
		{
			alert("Select Payment option");
			document.salesfrm.payment.focus();
			return false;
		}
		}catch(e){
			}
	return true;

} 

///////validation for the system admin contact form/////////////

 
 
    function checksystemadmin()
     {

		if(trim(document.systemadmin.subject.value)=="0")
		 	 {
				alert("Select a Subject");
				document.systemadmin.subject.focus();
				return false;
		  	 }
	   if(trim(document.systemadmin.description.value)=="")
		 	{
				alert("Description Can't be Null");
				document.systemadmin.description.focus();
				return false;
		 	}
		 	return true;
     } 
    	
    	//////////////////////////// directpaymet///////////////////
    	
    	
    	
    	
    	
function directbusienss()
{
	try{
		
	
if(trim(document.directpayment.bname.value)=="" )
		{
			alert("BusinessName Can't be Null");
			document.directpayment.bname.focus();
			return false;
		}
				
if(trim(document.directpayment.email.value)=="" )
	{
		alert("EmailAddress Can't be Null");
		document.directpayment.email.value='';
		document.directpayment.email.focus();
		return false;
	}
	
	if(!emailvalidate(trim(document.directpayment.email.value)))
	{
		//alert("EmailAddress Can't be Null");
		document.directpayment.email.select();
		return false;
	}
		

if(document.directpayment.state.value=="0")
	{
		alert("State Can't be Null");
		document.directpayment.state.focus();
		return false;
	}

if(document.directpayment.city.value=="0")
	{
		alert("City Can't be Null");
		document.salesfrm.city.focus();
		return false;
	}


        if(document.directpayment.category1.value=="0")
		{
			alert("Select Business Category1");
			document.directpayment.category1.focus();
			return false;
		}
		 

 	/*	if(document.salesfrm.category2.length>1)
			{
				if(document.salesfrm.category2.value=="0")
				{
					alert("Select Business Category2");
					document.salesfrm.category2.focus();
					return false;
				}
			}
				*/
	 
		}catch(e){
			}
	return true;

} 