function registercheck(){
    var pwd=document.userRegisterForm.pwd;

    var cpwd=document.userRegisterForm.cpwd;

    var name=document.userRegisterForm.username;

    var email=document.userRegisterForm.email;

    var phone=document.userRegisterForm.mobile;  

    var add=document.userRegisterForm.address;
      if (checkEmail(email,'Enter the valid email address'))

      {

      return;

      }

      else if(isEmpty(pwd,'Enter the password'))

      {

      return;

      

      }

      else if(isEmpty(cpwd,'Enter the confirm password')){

      return;      

      }

      else if(document.userRegisterForm.pwd.value!=document.userRegisterForm.cpwd.value)

      {

      alert("Confirm password is not matched with Password ");

      

      return;

      }

       else if(isEmpty(name,'Enter the name!..'))

      {

      

      return;

      }

      else if(isEmpty(email,'Enter the valid email address'))

      {

      return;

      }

     

       else if(isEmpty(phone,'Enter the Mobile no.'))

      {

      return;

     }

      

   

   /*  else if(checkNumber(phone))

     {

         return;

     }*/

      else if(isEmpty(add,'Enter the Address'))

      {

      return;

      }

      

      

                  

      else{

      document.userRegisterForm.submit();

      }

  }

  

   function logincheck(){ 

       

    var answer = confirm("Please Login & post ads ?")

	if (answer){

    // var url="ajax_process.php?type=login&cid="+id;   

     $.get(url, function(data){ 

    

     if(fromwhere=="page")

       window.location.href=path+"admin_addproducts.php";

     else

       window.location.href=path+"admin_addproducts.php";

  });

	}

}

function deletelist(id,path,fromwhere){



  var answer = confirm("Want to Delete ads?")

	if (answer){

     var url="ajax_process.php?type=delads&aid="+id;         

     $.get(url, function(data){

     if(fromwhere=="maincat")

       window.location.href=path+"myaccount.html";

     else

       window.location.href=path+"myaccount.html?subcat="+fromwhere;

  });

	}

}function getcity(id,city,path){

    

    

      var url="ajax_process.php?type=selected&cid="+id+"&selcity="+city;

      alert("Your are selected " +city);

      $.get(url,function(data){    

       window.location.href=path;

    });   



} function selectlocality(){ 
     var id=document.getElementById('state').value ;
	   if (id){
     var url="ajax_process.php?type=locality&pid="+id;
     $.get(url, function(data){
      $("#status").html(data);
  });
	}
 }function selectRegisterlocality(){ 
     var id=document.getElementById('state').value ;
	   if (id){
     var url="ajax_process.php?type=registerlocality&pid="+id;
     $.get(url, function(data){
      $("#status").html(data);
  });
	}
 }  
 function selectcategory(){

   var id=document.getElementById('category').value;

   if(id){

   var url="ajax_process.php?type=category&cid="+id;

  

    $.get(url,function(data){

    

     $("#cat").html(data);

     });

    

}

   

   }function changepasscheck(){



    var pwd=document.changepwdForm.pwd;

    var cpwd=document.changepwdForm.cpwd;

    var name=document.changepwdForm.name;

     

     if(isEmpty(pwd,'Enter the password'))

      {

      return;

      

      }

      else if(isEmpty(cpwd,'Enter the confirm password')){

      return;      

      }

      else if(document.changepwdForm.pwd.value!=document.changepwdForm.cpwd.value)

      {

      alert("Confirm password is not matched with Password ");

      

      return;

      }   

      else{

      document.changepwdForm.submit();

      }

  }



  function validateRetailerForm(form)

{



var product=document.retailerRegisterForm.product;

var des=document.retailerRegisterForm.des;

var category=document.retailerRegisterForm.categories;

var location=document.retailerRegisterForm.locality;

var form=document.getElementById('action').value;

var ret=true;



if(isEmpty(product,"Product Name is Empty"))

return false;

/*else if(isEmpty(des,"Description is Empty"))

return false;*/

else if(isEmpty(category,"Please Select Category"))

return false;

else if(isEmpty(location,"Please Select a loction"))

return false;



if(form=='login')

{

var loginemail=document.retailerRegisterForm.loginemail;

var pwd=document.retailerRegisterForm.pwd.pwd;

if(checkEmail(loginemail,"Please Give Valid Email address"))

return false;

}

else if(form=='registration')

{

var email=document.retailerRegisterForm.email;

var pwd=document.retailerRegisterForm.newpassword;

var shopname=document.retailerRegisterForm.shopname;

var name=document.retailerRegisterForm.name;

var contact_person=document.retailerRegisterForm.contact_person;

var addres=document.retailerRegisterForm.addres; 

var mobile=document.retailerRegisterForm.mobile;

var phone=document.retailerRegisterForm.phone;

var website=document.retailerRegisterForm.website;



if(checkEmail(email,"Email is not valid"))

return false;



//else if(isEmpty(pwd,"Please Fill Password"))

//return false;

else if(isEmpty(pwd,"Please Fill Password"))

return false;



else if(isEmpty(shopname,"Please Fill Shop Name"))

return false;


else if(isEmpty(name,"Please Fill  Name"))

return false;




else if(isEmpty(contact_person,"Please Fill Contact Name"))

return false;







else if(isEmpty(addres,"Please Fill Shop Address"))

return false;



else if(isEmpty(mobile,"Please Fill up Mobile"))

return false;

else if(isEmpty(phone,"Please Fill Phone No"))

return fasle;

}



}

 function Addproductcheck()

{

var product=document.productForm.product;

var des=document.productForm.des;

var category=document.productForm.categories;

var location=document.productForm.locality;



 if(isEmpty(category,"Please Select Category"))

return false;

else if(isEmpty(location,"Please Select a loction"))

return false;

if(isEmpty(product,"Product Name is Empty"))

return false;

/*else if(isEmpty(des,"Description is Empty"))

return false;*/

document.productForm.submit();

}



  function regtype(type) {

  

  var gettype=type;

  

  if(gettype=='login')

    {

    document.getElementById('action').value="login";

    return validateRetailerForm('login');

    }

  else if (gettype=='registration')  

    {

    document.getElementById('action').value="registration";

    return validateRetailerForm('registration');

    }

    

  //document.retailerRegisterForm.submit();   

 }

 function checkEmails(emails, message) {

	

	emailarr=emails.split(",")

		for(i=0;i<emailarr.length;i++)

    {

    emailarr[i]=trim(emailarr[i]);

    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(emailarr[i]))

		{

    _isValid = false;

		}else{

		_isValid = true;

		alert(message);

		

	 }

	}

	

	return _isValid;

}



function isNumber(formElement,message)

{

formElement.value=trim(formElement.value);

if(isNaN(formElement.value))

{

alert(message);

return true;

}



return false;

}

 

 function validateReferFriend()

 {

 

var name=document.referFriendForm.name;

var email=document.referFriendForm.email;

var mobile=document.referFriendForm.mobile;

var emails=document.referFriendForm.emails; 

var msg=document.referFriendForm.message;

 if(isEmpty(name,"Your Name Please"))

 {

 return false;

 }

 else if(checkEmail(email,"InValid Email address"))

 {

 return false;

 }

 else if(isNumber(mobile,"Invalid Mobile number"))

 {

 return false;

 }

 else if(checkEmails(emails.value,"Invalid Email Addresses"))

 {

 return false

 }

 return true;

 }

 

 function validateFeedBackForm()

 {

 

var name=document.feedBackForm.name;

var email=document.feedBackForm.email;

var msg=document.feedBackForm.comments;

 

 if(isEmpty(name,"Your Name Please"))

 {

 return false;

 }

 else if(checkEmail(email,"InValid Email address"))

 {

 return false;

 }

 else if(isEmpty(msg,"No Comments Found"))

 {

 return false

 }

 return true;



}





















  

/*

//form=registerphone()  

var digits = "0123456789";

// non-digit characters which are allowed in phone numbers

var phoneNumberDelimiters = "()- ";

// characters which are allowed in international phone numbers



var validWorldPhoneChars = phoneNumberDelimiters + "+";

// Minimum no of digits in an international phone no.

var minDigitsInIPhoneNumber = 10;



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 trim(s)

{   var i;

    var returnString = "";

    // Search through string's characters one by one.

    // If character is not a whitespace, append to returnString.

    for (i = 0; i < s.length; i++)

    {   

        // Check that current character isn't whitespace.

        var c = s.charAt(i);

        if (c != " ") returnString += c;

    }

    return returnString;

}

function stripCharsInBag(s, bag)

{   var i;

    var returnString = "";

    // Search through string's characters one by one.

    // If character is not in bag, append to returnString.

    for (i = 0; i < s.length; i++)

    {   

        // Check that current character isn't whitespace.

        var c = s.charAt(i);

        if (bag.indexOf(c) == -1) returnString += c;

    }

    return returnString;

}



function checkInternationalPhone(strPhone){

var bracket=3

strPhone=trim(strPhone)

if(strPhone.indexOf("+")>1) return false

if(strPhone.indexOf("-")!=-1)bracket=bracket+1

if(strPhone.indexOf("(")!=-1 && strPhone.indexOf("(")>bracket)return false

var brchr=strPhone.indexOf("(")

if(strPhone.indexOf("(")!=-1 && strPhone.charAt(brchr+2)!=")")return false

if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false

s=stripCharsInBag(strPhone,validWorldPhoneChars);

return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);

}

function registerphone(){

	var Phone=document.register.phone

	if ((Phone.value==null)||(Phone.value=="")){

		alert("Please Enter your Phone Number")

		Phone.focus()

		return false

	}

	if (checkInternationalPhone(Phone.value)==false){

		alert("Please Enter a Valid Phone Number")

		Phone.value=""

		Phone.focus()

		return false

	}

	return true

 }*/



  

  