function check_empty(qq,str)

{  

  var q = qq.value;

  var spc=0;

  for(var i=0;i<=q.length;i++)

  {

     if(q.charAt(i)==" ")  spc++;

  }

  lnm=q.length;

  if(spc==lnm)

  {  

  	alert(" "+str+" Should Not Be Blank");

	qq.value='';

	qq.focus();

  	return false;

  } 

  else

  	return true;

}

                  



function validate()

{

 var d=document.category; 

 

if (!check_empty(d.cat,"Category Name"))

return false;



}



function validateads()

{

	var d=document.ads; 

	

	if (!check_empty(d.catid,"Category Name"))

	return false; 

	

	if (!check_empty(d.subcatid,"Sub Category Name"))

	return false;

	

	if (!check_empty(d.country,"Country Name"))

	return false;

	

	if (!check_empty(d.state,"State Name"))

	return false;

	

	if (!check_empty(d.city,"City Name"))

	return false;

	

	if (!check_empty(d.addtitle,"Title Name"))

	return false;

	

	if (!check_empty(d.adddesc,"Description"))

	return false;

	

	if (!check_empty(d.email,"Email"))

	return false;

	

}





function subcatvalidate()

{

 var d=document.subcategory; 

if (!check_empty(d.subcat,"Sub Category Name"))

return false;



}



function validatedir()

{

 var d=document.dircategory; 

 

if (!check_empty(d.dircat,"Category Name"))

return false;



}





function subdircatvalidate()

{

 var d=document.subdircategory; 

if (!check_empty(d.subdircat,"Sub Category Name"))

return false;



}



function getState(path,country_Id)
	 {
	 xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		 {
			alert ("Browser does not support HTTP Request")
			return
		 }
		var strURL=path+"/states.php?country="+country_Id;
		xmlHttp.onreadystatechange=loadStates
		xmlHttp.open("GET",strURL,true)
		xmlHttp.send(null)
	}
	function loadStates() 
	{ 

					
		if (xmlHttp.readyState < 4 )
		 { 
			 document.getElementById("statediv").innerHTML='<option value="">Loading States...</option>' ;
		} 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 
			 document.getElementById("statediv").innerHTML=xmlHttp.responseText ;
		} 
	}
	// Common function for browsers
	function GetXmlHttpObject()
	{
		var xmlHttp=null;
		try {  
			xmlHttp=new XMLHttpRequest(); 
		} catch (e) {  

			try  {  

				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");  

			} catch (e)  {  

				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");  

			} 

		}

		return xmlHttp;

	}

	

	function getCity(path,state_id){



	xmlHttp=GetXmlHttpObject();

		if (xmlHttp==null)

		 {

			alert ("Browser does not support HTTP Request")

			return

		 }

	

		var strURL=path+"/city.php?state="+state_id;

		xmlHttp.onreadystatechange=cityChanged

		xmlHttp.open("GET",strURL,true)

		xmlHttp.send(null)

	}

	

	function cityChanged() 

	{ 

		if (xmlHttp.readyState < 4 )

		 { 

			 document.getElementById("cityDiv").innerHTML='<option value="">Loading Cities...</option>' ;

		} 

			 

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

		 { 

			

			 document.getElementById("cityDiv").innerHTML=xmlHttp.responseText ;

		 

		} 

		

	}

	

	function catChanged() 

	{ 

		if (xmlHttp.readyState < 4 )

		 { 

			 document.getElementById("subcatdiv").innerHTML='<option value="">Loading Sub Categories...</option>' ;

		} 

			 

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

		 { 

			

			 document.getElementById("subcatdiv").innerHTML=xmlHttp.responseText ;

		} 

		

	}

	

function postadd_valid()

	{

		d= document.postadd;

		if(d.country.value=="")

		{

		  alert("Please select country");	

		  d.country.focus();

		  return false;

		}

		

		if(d.state.value=="")

		{

		  alert("Please select state");	

		  d.state.focus();

		  return false;

		}

		if(d.city.value=="")



		{







		  alert("Please type your city name");	



		  d.city.focus();



		  return false;



		}







		var surl='http://'+window.location.host+'/';
		

		var ctry = document.postadd.country.selectedIndex;

		var xcountryVal = document.postadd.country.options[ctry].text;

		

		xcountryVal =   CheckSpace(xcountryVal);



		var s = document.postadd.state.selectedIndex;

		var xstateVal = document.postadd.state.options[s].text;

		

		xstateVal =   CheckSpace(xstateVal);







		var c = document.postadd.city.selectedIndex;







		var xcityVal = document.postadd.city.value;











		xcityVal =   CheckSpace(xcityVal);
		d.action = surl+"selectCat/"+xcountryVal+"/"+xstateVal+"/"+xcityVal+".html";

		d.submit();

    }

	

function checkcode(thecode) { 

	   http.open("GET", url + escape(thecode), true); 

	   http.onreadystatechange = handleHttpResponse; 

	   http.send(null); 

	   } 

	   

function postbytext_checkcode(thecode) { 

	   http.open("GET", url + escape(thecode), true); 

	   http.onreadystatechange = postby_handleHttpResponse; 

	   http.send(null); 

	   }   

	   

function postbyimage_handleHttpResponse(thecode) { 

	   http.open("GET", url + escape(thecode), true); 

	   http.onreadystatechange = postby_handleHttpResponse; 

	   http.send(null); 

	   } 

function add_validate()

{

	var emailFormat = /^\w(\.?[\w-])*@\w(\.?[\w-])*\.[a-zA-Z]{2,6}(\.[a-zA-Z]{2})?$/i;

	var numericFormat=/^[\-+]?[0-9]*\.?[0-9]+$/;

	var d = document.newadd;



	if(d.addtitle.value=="")

		{

		  alert("Please Enter Add Title");	

		  d.addtitle.focus();

		  return false;

		}

			

	if(d.adddesc.value=="")

		{

		  alert("Please Enter Add Description");	

		  d.adddesc.focus();

		  return false;

		}

		

	if(d.email.value=="")

		{

		  alert("Please Enter Email");	

		  d.email.focus();

		  return false;

		}

		

		if(d.email.value.search(emailFormat) == -1)

		{	

			alert("Please Enter valid Email.");

			d.email.focus();

			return false;

	}

		

	if(d.phoneno.value=="")

		{

		  alert("Please Enter Phone Number");	

		  d.phoneno.focus();

		  return false;

		}	

		

		if(d.phoneno.value.search(numericFormat) == -1)

					{	

						alert("Please enter phone in numeric values only.");

						d.phoneno.focus();

						return false;

					}

		

	if(d.currency.value!="")

		{

			if(d.price.value==""){

			  alert("Please Enter price");	

			  d.price.focus();

			  return false;

			}

		}	

	if(d.price.value!=""){

		if(d.currency.value=="")
		{	
			alert("Please Select Currency Type");	

			  d.currency.focus();

			  return false;
		}
		
	}

		

		var btn = valButton(d.posttype);

				if (btn == null) {alert('Please select post type.');

				return false;

			}

var adverttypebtn = valButton(d.advertype);







				if (adverttypebtn == null) {alert('Please select advert type.');







				return false;







				}

	if(adverttypebtn=="Trade")







	{







		if(d.companyname.value=="")







			{







			  alert("Please Enter Trader Comapny Name");	







			  d.companyname.focus();







			  return false;







			}	







	}

		if(!d.terms.checked)

		{

			alert("Please Accept terms of use by making a post");

			return false;

		} 

		

		if(d.verif_box.value=='') { 

			alert('Please Enter verification Code'); 

			d.verif_box.value=''; 

			d.verif_box.focus(); 

			return false; 

			} 

			checkcode(d.verif_box.value); 

			return false; 

		

	}







//admin side js for country dropdown 

function getAdminState(path,country_Id)

	 {

	 xmlHttp=GetXmlHttpObject();

		if (xmlHttp==null)

		 {

			alert ("Browser does not support HTTP Request")

			return

		 }
 

		var strURL=path+"/adminstates.php?country="+country_Id;

 


		xmlHttp.onreadystatechange=stateChanged

 
		xmlHttp.open("GET",strURL,true)

		xmlHttp.send(null)

	}

	

	function stateChanged() 
	{ 

		if (xmlHttp.readyState < 4 )
		 { 
			 document.getElementById("statediv").innerHTML='<option value="">Loading States...</option>' ;
		} 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 
			 document.getElementById("statediv").innerHTML=xmlHttp.responseText ;
		} 
	}

//adminn side for city display

function getAdminCity(path,state_id){



xmlHttp=GetXmlHttpObject();

	if (xmlHttp==null)

	 {

		alert ("Browser does not support HTTP Request")

		return

	 }



	var strURL=path+"/admincity.php?state="+state_id;

	xmlHttp.onreadystatechange=cityChanged

	xmlHttp.open("GET",strURL,true)

	xmlHttp.send(null)

}







function getAdminSubCategory(path,catid){



xmlHttp=GetXmlHttpObject();

	if (xmlHttp==null)

	 {

		alert ("Browser does not support HTTP Request")

		return

	 }

	var strURL=path+"/admincat.php?cat="+catid;

	xmlHttp.onreadystatechange=catChanged

	xmlHttp.open("GET",strURL,true)

	xmlHttp.send(null)

	

	

}





function normal_ad_validate(){

	var emailFormat = /^\w(\.?[\w-])*@\w(\.?[\w-])*\.[a-zA-Z]{2,6}(\.[a-zA-Z]{2})?$/i;

	var numericFormat=/^[\-+]?[0-9]*\.?[0-9]+$/;

	var characterFormat=/^[a-zA-Z\xA1-\xFF]+$/;



	

	var d = document.normalAd;



	if(d.adtitle.value=="")

		{

		  alert("Please Enter Add Title");	

		  d.adtitle.focus();

		  return false;

		}



	if(d.adddesc.value=="")

		{

		  alert("Please Enter Add Description");	

		  d.adddesc.focus();

		  return false;

		}

	if(d.email.value=="")

		{

		  alert("Please Enter Email");	

		  d.email.focus();

		  return false;

		}

	if(d.email.value.search(emailFormat) == -1)

			{	

				alert("Please Enter valid Email.");

				d.email.focus();

				return false;

			}

	if(d.phoneno.value=="")

		{

		  alert("Please Enter Phone number");	

		  d.phoneno.focus();

		  return false;

		}

		if(d.phoneno.value.search(numericFormat) == -1)

					{	

						alert("Please enter phone in numeric values only.");

						d.phoneno.focus();

						return false;

					}

	if(!d.terms.checked)

		{

			alert("Please Accept terms of use by making a post");

			return false;

		} 



		if(d.verif_box.value=='') { 

			alert('Please Enter verification Code'); 

			d.verif_box.value=''; 

			d.verif_box.focus(); 

			return false; 

			} 

			normal_checkcode(d.verif_box.value); 

			return false; 

	}

	

	function normal_checkcode(thecode) { 



	   http.open("GET", url + escape(thecode), true); 



	   http.onreadystatechange = normalhandleHttpResponse; 



	   http.send(null); 



	   } 

	   

	    function register_valid()



		{

			var emailFormat = /^\w(\.?[\w-])*@\w(\.?[\w-])*\.[a-zA-Z]{2,6}(\.[a-zA-Z]{2})?$/i;

			var numericFormat=/^[\-+]?[0-9]*\.?[0-9]+$/;

//			var characterFormat=/^[a-zA-Z\xA1-\xFF]+$/;
				//var characterFormat=/^[A-Z ]+[a-zA-Z ]\*$/;	
				
				var characterFormat = /^([a-zA-Z ]+)$/;





			var d = document.register;

if(d.email.value=="")



				{



				  alert("Please Enter Email");	



				  d.email.focus();



				  return false;



				}



			if(d.email.value.search(emailFormat) == -1)



					{	



						alert("Please Enter valid Email.");



						d.email.focus();



						return false;



					}

		







/*









			if(d.uname.value=="")



				{



				  alert("Please Enter Username");	



				  d.uname.focus();



				  return false;



				}



				if(!isNaN(d.uname.value))



			{



				alert("Username Accepting Alphanumerics Only");



				d.uname.focus();



				return false;



			}









*/







				



				



				if(d.pword.value=="")



				{



				  alert("Please Enter Password");	



				  d.pword.focus();



				  return false;



				}



				



			if(d.cpword.value=="")



				{



				  alert("Please Enter Confirm Password");	



				  d.cpword.focus();



				  return false;



				}



				



				if(d.pword.value != d.cpword.value)



				{



				  alert("Confirm Password Does Not Match With Password");	



				  d.cpword.focus();



				  return false;



				}	



				



			if(d.fname.value=="")



				{



				  alert("Please Enter Add First Name");	



				  d.fname.focus();



				  return false;



				}


					if(!characterFormat.test(d.fname.value))
					{
						alert("Firstname Accepting Characters Only");
						d.fname.focus();
						
						
						
												return false;
					}

				/*if(d.fname.value.search(characterFormat) == -1)



					{	



						alert("Firstname Accepting Characters Only.");



						d.fname.focus();



						return false;



					}*/
					
					if(d.lname.value=="")



				{



				  alert("Please Enter Add Last Name");	



				  d.lname.focus();



				  return false;



				}

				if(d.lname.value.search(characterFormat) == -1)



					{	



						alert("Lastname Accepting Characters Only.");



						d.lname.focus();



						return false;



					}


				


if(d.phone.value=="")

		{

		  alert("Please Enter Phone Number");	

		  d.phone.focus();

		  return false;

		}	

		

		if(d.phone.value.search(numericFormat) == -1)

					{	

						alert("Please enter phone in numeric values only.");

						d.phone.focus();

						return false;

					}

					



				//	var btn = valButton(d.agriment);



					//	if (btn == null) {alert('Please Select SADC Trader user agreement.');



						//return false;
						//alert(document.register.agriment.checked);
						if(!document.register.agriment.checked){alert("Please check the terms and conditions");
return false; } 



					//}



					



					



					if(d.verif_box.value=='') { 



						alert('Please Enter verification Code'); 



						d.verif_box.value=''; 



						d.verif_box.focus(); 



						return false; 



					} 



					register_checkcode(d.verif_box.value); 



					return false;



				



		  			



	}







	

	function valButton(btn) {







    var cnt = -1;







    for (var i=btn.length-1; i > -1; i--) {

        if (btn[i].checked) {cnt = i; i = -1;}

    }

    if (cnt > -1) return btn[cnt].value;

    else return null;

}



 function checkavailable_email(path,email)
      {

	  var emailFormat = /^\w(\.?[\w-])*@\w(\.?[\w-])*\.[a-zA-Z]{2,6}(\.[a-zA-Z]{2})?$/i;

		  if(email.search(emailFormat) == 0){
		    var d=document.register;
//			var user_type = valButton(d.usr_type);
			xmlHttp=GetXmlHttpObject()
			if (xmlHttp==null)
			 {
				alert ("Browser does not support HTTP Request")
				return

			 }
			var url=path+"/includes/email_available.php";
			url=url+"?email="+email;	
			xmlHttp.onreadystatechange=function(){ 

			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			 { 
				var resp=xmlHttp.responseText;
				if(resp=='allow')
				{
					document.getElementById('emailudiv').innerHTML='<span  style="color:#009933;font-weight:bold;">Email is Available</span>';	

					document.register.hid_allow_email.value='allow';

				}		

				else 

				{

					document.getElementById('emailudiv').innerHTML='<span class="txt-red">Email Already Exists</span>';	

					document.register.hid_allow_email.value='notallow';

					



				}

			  } 

			 }

			xmlHttp.open("GET",url,true)

			xmlHttp.send(null)

		  }

   

   }

   

    function checkavailable_uname(path,uname)

      {

		    var d=document.register;

		    var user_type = valButton(d.usr_type);

            if(isNaN(uname))

				{

			xmlHttp=GetXmlHttpObject()

			if (xmlHttp==null)

			 {

				alert ("Browser does not support HTTP Request")

				return

			 }

			var url=path+"/includes/uname_available.php";

			url=url+"?uname="+uname+"&usertype="+user_type;	

			xmlHttp.onreadystatechange=function(){ 

			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

			 { 

				var unameresp=xmlHttp.responseText;

				if(unameresp=='allow')

				{

					document.getElementById('unamediv').innerHTML='<span  style="color:#009933;font-weight:bold;">Username is Available</span>';	

					document.register.hid_allow_uname.value='allow';

				}		

				else 

				{

					document.getElementById('unamediv').innerHTML='<span class="txt-red">Username Already Exists</span>';	

					document.register.hid_allow_uname.value='notallow';

					



				}

			  } 

			 }

			xmlHttp.open("GET",url,true)

			xmlHttp.send(null)

				}

   }

   

function register_checkcode(thecode) { 



	   http.open("GET", url + escape(thecode), true); 



	   http.onreadystatechange = registerhandleHttpResponse; 



	   http.send(null); 



	   }

	   function adcontact_checkcode(thecode) { 



	   http.open("GET", url + escape(thecode), true); 



	   http.onreadystatechange = adcontacthandleHttpResponse; 



	   http.send(null); 



	   }

	   

	    function login_valid()

		   {

			   var f = document.login;







			   var emailFormat = /^\w(\.?[\w-])*@\w(\.?[\w-])*\.[a-zA-Z]{2,6}(\.[a-zA-Z]{2})?$/i;







				var characterFormat=/^[a-zA-Z\xA1-\xFF]+$/;



			if(f.email.value=="")







			{







			  alert("Please Enter Email");	



				  f.email.focus();



				  return false;



				}



			if(f.email.value.search(emailFormat) == -1)







					{	







						alert("Please Enter valid Email.");







						f.email.focus();







						return false;







					}

			 /*  if(f.uname.value=="")

				   {

					   alert("Please Enter Username");

					   f.uname.focus();

					   return false;

				   }*/

			   if(f.pword.value=="")

				   {

					   alert("Please Enter Password");

					   f.pword.focus();

					   return false;

				   }

		

			   }

 function adcontact_valid()

	   {

		

		var emailFormat = /^\w(\.?[\w-])*@\w(\.?[\w-])*\.[a-zA-Z]{2,6}(\.[a-zA-Z]{2})?$/i;

		var form = document.adcontact;

	   

		   if(form.email.value=="")

			   {

				   alert("Please Enter email");

				   form.email.focus();

				   return false;

			   }

			   

		   if(form.email.value.search(emailFormat) == -1)

			{	

				alert("Please Enter valid Email.");

				form.email.focus();

				return false;

			}

			

			 if(form.message.value=="")

			   {

				   alert("Please Enter Message");

				   form.message.focus();

				   return false;

			   }

			

			if(form.verif_box.value=='') { 

				alert('Please Enter verification Code'); 

				form.verif_box.value=''; 

				form.verif_box.focus(); 

				return false; 

			} 

			adcontact_checkcode(form.verif_box.value); 

			return false;

			

		   

		   }

		   

		   

	function getsubcatjs(path,cat_id)

	 {

	 xmlHttp=GetXmlHttpObject();

		if (xmlHttp==null)

		 {

			alert ("Browser does not support HTTP Request")

			return

		 }

	

		var strURL=path+"/subcatjs.php?cat="+cat_id;

		xmlHttp.onreadystatechange=subcatChanged

		xmlHttp.open("GET",strURL,true)

		xmlHttp.send(null)

	}



	function subcatChanged() 

	{ 

	 

		

		if (xmlHttp.readyState < 4 )

		 { 

			 document.getElementById("subcatdiv").innerHTML='<option value="">Loading Categories...</option>' ;

		} 

			 

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

		 { 

			

			 document.getElementById("subcatdiv").innerHTML=xmlHttp.responseText ;

		 

		} 

		

	}

	

	function search_valid(xcountryPath,categoryPath)

		{

			var form = document.search_form;

	          if(form.search_word.value==''){

			  alert("Please Enter Search word");

			  form.search_word.focus();

			  return false;

			  }		

			  

	   // var surl='http://'+window.location.host+'/sadc/';



//		form.action = surl+"search/clf/"+form.search_word.value+"/"+xcountryName+".html";



  //if(categoryPath=="")

  //	{

  	//	url = surl+"search/"+xcountryPath+"/clf/"+RemoveSpace(form.search_word.value)+".html";

//		form.submit();

	//	return true;

	



	//  }

	 /// else{











//



	  	//	url = surl+"search/"+xcountryPath+"/clf/"+RemoveSpace(form.search_word.value)+"/"+categoryPath+".html";

			//form.submit();

		//	return true;

		//  }

		  

		// location.href=url;

		 //return false;

	}

		

function change_pword_valid()

{         

		  var form = document.chpword;

		  if (!check_empty(form.oldpword,"Old Password"))

				return false; 

		  if (!check_empty(form.npword,"New Password"))

					return false; 

		  if (!check_empty(form.ncpword,"New Confirm Password"))

						return false; 			

					

			if(form.npword.value != form.ncpword.value){

			alert("Confirm Password Does Not Match With Newpassword");

			form.ncpword.focus();

			return false;

			}

		}

		

	function delrecord(id)

		{ 

		

			var surl='http://'+window.location.host+'/';

			if(confirm('Do You Want to Delete the Record?'))

			{

				document.manageAd.action='manage_ads.php?id='+id;

				document.manageAd.action = surl+"delAd/manageAds/"+id+".html";

				document.manageAd.submit();

				

			}



		}	

		

		function delsponrecord(id)

		{ 

		

			var surl='http://'+window.location.host+'/';

			if(confirm('Do You Want to Delete the Record?'))

			{

				document.sponmanageAd.action = surl+"delSponAd/sponmanageAds/"+id+".html";

				document.sponmanageAd.submit();

				

			}



		}	

		

		function deladword(id)

		{ 

		

			var surl='http://'+window.location.host+'/';

			if(confirm('Do You Want to Delete the Record?'))

			{

				document.manageAdword.action = surl+"deladword/manageAdword/"+id+".html";

				document.manageAdword.submit();

				

			}



		}	



	function OpenMore(divName)

			{

				document.getElementById(divName).style.display='block';

			

			}

	function postbytext_valid()

	{

		var regUrl = /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/;

	

		 var d=document.sponbytext;

			 if(d.title.value=='') { 

				alert('Please Enter Sponsor Ad Title'); 

				d.title.focus(); 

				return false; 

				} 

		 if(d.addesc.value=='') { 

				alert('Please Enter Sponsor Ad Description'); 

				d.addesc.focus(); 

				return false; 

				} 

		 if(d.adurl.value=='') { 

				alert('Please Enter Sponsor Ad Url (http://www.google.com)'); 

				d.adurl.focus(); 

				return false; 

				} 

		

			if(d.adurl.value.search(regUrl) == -1){

					alert("Please Enter valid Website url (http://www.google.com).");

					d.adurl.focus();

					return false;

			}

			

			

			var btn = valButton(d.addtype);

				if (btn == null) {alert('Please select payment option.');

				return false;

			}

			

			if(d.verif_box.value=='') { 

				alert('Please Enter verification Code'); 

				d.verif_box.value=''; 

				d.verif_box.focus(); 

				return false; 

				} 

				postbytext_checkcode(d.verif_box.value); 

				return false; 

			}

			

	function postbyimage_valid()

	{

		//var emailFormat = /^\w(\.?[\w-])*@\w(\.?[\w-])*\.[a-zA-Z]{2,6}(\.[a-zA-Z]{2})?$/i;

		var regUrl = /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/;

	 	var d=document.sponbyimage;

		 if(d.title.value=='') { 

			alert('Please Enter Sponsor Ad Title'); 

			d.title.focus(); 

			return false; 

			} 

		/*if(d.email.value=='') { 

			alert('Please Enter Email Address'); 

			d.email.focus(); 

			return false; 

			} 

			

		if(d.email.value.search(emailFormat) == -1)

			{	

				alert("Please Enter valid Email.");

				d.email.focus();

				return false;

			}*/

			

	 if(d.adurl.value=='') { 

			alert('Please Enter Sponsor Ad Url (http://www.google.com)'); 

			d.adurl.focus(); 

			return false; 

			} 

	

	  	if(d.adurl.value.search(regUrl) == -1){

				alert("Please Enter valid Website url (http://www.google.com).");

				d.adurl.focus();

				return false;

		}

		

		var btn = valButton(d.addtype);

				if (btn == null) {alert('Please select payment option.');

				return false;

			}

		

		if(d.verif_box.value=='') { 

			alert('Please Enter verification Code'); 

			d.verif_box.value=''; 

			d.verif_box.focus(); 

			return false; 

			} 

			postbyimage_checkcode(d.verif_box.value); 

			return false; 

     	}	





function forgot_valid()

{

	var emailFormat = /^\w(\.?[\w-])*@\w(\.?[\w-])*\.[a-zA-Z]{2,6}(\.[a-zA-Z]{2})?$/i;

	var d = document.forgotpword;

	

	if(d.email.value=='') { 

			alert('Please Enter Email Address'); 

			d.email.focus(); 

			return false; 

			} 

			

		if(d.email.value.search(emailFormat) == -1)

			{	

				alert("Please Enter valid Email.");

				d.email.focus();

				return false;

			}

			return true;

			

	}

	

<!-- Start : Adword Validation -->

function adword_checkcode(thecode) { 

	   http.open("GET", url + escape(thecode), true); 

	   http.onreadystatechange = adword_handleHttpResponse; 

	   http.send(null); 

	   }  	

	   

function adword_valid()

	{

			d = document.adword;

			var regUrl = /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/;

			

		 

			if (!check_empty(d.adword,"Ad word"))

			return false; 	

	

			if (!check_empty(d.title,"Ad word Title"))

			return false; 	

			if (!check_empty(d.bidprice,"Bid Price"))

			return false;

			

			if (!check_empty(d.adwordesc,"Ad word Description"))

			return false; 	

			

			if (!check_empty(d.adurl,"Ad word Url(http://www.google.com)"))

			return false; 	



			if(d.adurl.value.search(regUrl) == -1){

					alert("Please Enter valid Website url (http://www.google.com).");

					d.adurl.focus();

					return false;

			}

			

			

			

			if (!check_empty(d.verif_box,"Verification Code"))

			return false;



				adword_checkcode(d.verif_box.value); 

				return false; 

	}

<!-- End : adword  Validation -->

	<!-- Start : Get sub categories --->









function getalertsubcat(path,cat_id)

	 {

	 xmlHttp=GetXmlHttpObject();

		if (xmlHttp==null)

		 {

			alert ("Browser does not support HTTP Request")

			return

		 }

	

		var strURL=path+"/alertsubcat.php?cat="+cat_id;

		xmlHttp.onreadystatechange=searsubcatChanged

		xmlHttp.open("GET",strURL,true)

		xmlHttp.send(null)

	}





function getsubcat(path,cat_id)

	 {

	 xmlHttp=GetXmlHttpObject();

		if (xmlHttp==null)

		 {

			alert ("Browser does not support HTTP Request")

			return

		 }

	

		var strURL=path+"/searchsubcat.php?cat="+cat_id;

		xmlHttp.onreadystatechange=searsubcatChanged

		xmlHttp.open("GET",strURL,true)

		xmlHttp.send(null)

	}



	function searsubcatChanged() 

	{ 

	 

		

		if (xmlHttp.readyState < 4 )

		 { 

			 document.getElementById("searchsubcatdiv").innerHTML='<option value="">Loading Categories...</option>' ;

		} 

			 

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

		 { 

			

			 document.getElementById("searchsubcatdiv").innerHTML=xmlHttp.responseText ;

		 

		} 

		

	}



<!-- End : Get subcategories -->

<!-- Start : Get search cities -->



function getsearchCity(path,state_id){



	xmlHttp=GetXmlHttpObject();

		if (xmlHttp==null)

		 {

			alert ("Browser does not support HTTP Request")

			return

		 }

	

		var strURL=path+"/searchcity.php?state="+state_id;

		xmlHttp.onreadystatechange=searchcityChanged

		xmlHttp.open("GET",strURL,true)

		xmlHttp.send(null)

	}

	

	function searchcityChanged() 

	{ 

		if (xmlHttp.readyState < 4 )

		 { 

			 document.getElementById("searchcityDiv").innerHTML='<option value="">Loading Cities...</option>' ;

		} 

			 

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

		 { 

			

			 document.getElementById("searchcityDiv").innerHTML=xmlHttp.responseText ;

		 

		} 

		

	}



function CheckSpace(str)

    {

        var strSrc = str;

        //here we need to give the string/char that we need to replace from source string

        //in my case it is space for I gave a space between two forward slashes as var spaceFix = / /gi;

        //if you want to replace for example all "a" then it should be written as var spaceFix = /a/gi;

        var spaceFix = / /gi;

        var strDest = strSrc.replace(spaceFix,"-");

         

        return strDest;

    }

<!-- remove spaces -->







	function RemoveSpace(str)

    {







        var strSrc = str;







        //here we need to give the string/char that we need to replace from source string







        //in my case it is space for I gave a space between two forward slashes as var spaceFix = / /gi;







        //if you want to replace for example all "a" then it should be written as var spaceFix = /a/gi;







        var spaceFix = / /gi;

        var strDest = strSrc.replace(spaceFix,"");









        return strDest;







    }

<!-- remove spaces -->









	

<!-- Start : Get search cities -->

<!-- Start  : add a post populate  city-->	

function citypopulate(path,city)

	{

		var country_id = document.postadd.country.value;

		xmlHttp=GetXmlHttpObject();

		if (xmlHttp==null)

		 {

			alert ("Browser does not support HTTP Request")

			return

		 }

			var strURL=path+"/populateothercity.php?countryid="+country_id+"&cityname="+city;

			xmlHttp.onreadystatechange=populatecityDropdown

			xmlHttp.open("GET",strURL,true)

			xmlHttp.send(null)

	}

<!-- End : add a post populate  city-->	

	

<!-- Start :Advanced Search city populate  -->



function advcitypopulate(country_id,path,city)

	{

		xmlHttp=GetXmlHttpObject();

		if (xmlHttp==null)

		 {

			alert ("Browser does not support HTTP Request")

			return

		 }

			var strURL=path+"/populateothercity.php?countryid="+country_id+"&cityname="+city;

			xmlHttp.onreadystatechange=populatecityDropdown

			xmlHttp.open("GET",strURL,true)

			xmlHttp.send(null)

	}	

<!-- End :Advanced Search city populate  -->

	

function populatecityDropdown() 

	{ 

		if (xmlHttp.readyState < 4 )

		 { 

			 document.getElementById("cityDiv").innerHTML='<option value="">Loading Cities...</option>' ;

		} 

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

		 { 

			 document.getElementById("cityDiv").innerHTML=xmlHttp.responseText ;

		} 

	}

<!-- End : Get search cities -->



function CountLeft(field, count, max) {

if (field.value.length > max){

alert("it is allowing upto "+max+"characters");

	field.value = field.value.substring(0, max);

}

else{

	count.value = max - field.value.length;

}

}

function advertypefields(type)







{







	if(type=="trader"){







		document.getElementById('adverttypefield').style.display='block';	







	}else if(type=="private"){







		document.getElementById('adverttypefield').style.display='none';	







		}

}









<!--- Start : saving ad function -->

function savead(path,adid)







{







		xmlHttp=GetXmlHttpObject();







		if (xmlHttp==null)







		 {







			alert ("Browser does not support HTTP Request")







			return







		 }







		var strURL=path+"/save_ads.php?path="+path+"&adid="+adid;

			xmlHttp.onreadystatechange=function() {







				  displaySavedstaus(adid);







			  };

			xmlHttp.open("GET",strURL,true)







			xmlHttp.send(null)







			







	}	









function displaySavedstaus(adid) 







	{ 







		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")







			 { 







				 document.getElementById(adid).innerHTML=xmlHttp.responseText ;







			} 







	}







<!--- Start : saving ad function -->

<!--- Start : saving ad function -->

function saveaddetail(path,adid)







{







		xmlHttp=GetXmlHttpObject();







		if (xmlHttp==null)







		 {







			alert ("Browser does not support HTTP Request")







			return







		 }







		var strURL=path+"/save_ads_detail.php?path="+path+"&adid="+adid;







			xmlHttp.onreadystatechange=function() {







				  displaySavedstausdetail(adid);







			  };

			xmlHttp.open("GET",strURL,true)







			xmlHttp.send(null)







			







	}	









function displaySavedstausdetail(adid) 







	{ 







		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")







			 { 







				 document.getElementById(adid).innerHTML=xmlHttp.responseText ;







			} 







	}







<!--- Start : saving ad function -->









<!--- Start : removing  ad function -->

function savermad(path,adid)







{







		xmlHttp=GetXmlHttpObject();







		if (xmlHttp==null)







		 {







			alert ("Browser does not support HTTP Request")







			return







		 }







		var strURL=path+"/saverm_ads.php?path="+path+"&adid="+adid;







			xmlHttp.onreadystatechange=function() {







				  displayRemovedstaus(adid);







			  };

			xmlHttp.open("GET",strURL,true)







			xmlHttp.send(null)







			







	}	









function displayRemovedstaus(adid) 







	{ 







		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")







			 { 







				 document.getElementById(adid).innerHTML=xmlHttp.responseText ;







			} 







	}







	







	







	function savermaddetail(path,adid)







		{







				xmlHttp=GetXmlHttpObject();







				if (xmlHttp==null)







				 {







					alert ("Browser does not support HTTP Request")







					return







				 }







				var strURL=path+"/saverm_ads_detail.php?path="+path+"&adid="+adid;







					xmlHttp.onreadystatechange=function() {







						  displayRemovedstausdetail(adid);







					  };







		







					xmlHttp.open("GET",strURL,true)







					xmlHttp.send(null)







					







			}	









function displayRemovedstausdetail(adid) 







	{ 







		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")







			 { 







				 document.getElementById(adid).innerHTML=xmlHttp.responseText ;







			} 







	}







<!--- Start : saving ad function -->

<!-- Start : Share Ad form validations -->







function sharead()



	{



		var emailFormat = /^\w(\.?[\w-])*@\w(\.?[\w-])*\.[a-zA-Z]{2,6}(\.[a-zA-Z]{2})?$/i;

		var d = document.sharethisad;

		

			if(d.fromname.value=="")

			{

				alert("Please Enter Your Name");

				d.fromname.focus();

				return false;

			}



		if(d.femail.value=="")

			{

				alert("Please Enter Your Email");

				d.femail.focus();

				return false;

			}

		

	if(d.femail.value.search(emailFormat) == -1)

		{	

			alert("Please Enter valid Email.");

			d.femail.focus();

			return false;

		}







	if(d.toname.value=="")

			{

				alert("Please Enter Friend Name");

				d.toname.focus();

				return false;

			}

	if(d.tomail.value=="")

			{

				alert("Please Enter Your Friend Email");

				d.tomail.focus();

				return false;

			}



	if(d.tomail.value.search(emailFormat) == -1)

		{	

			alert("Please Enter valid Email.");

			d.tomail.focus();

			return false;

		}

	}

<!-- End : Share Ad form validations -->









<!-- Start : Contact Form display on view detyail page -->







function contact_display(){







document.getElementById('contact').style.display='block';	







}







function overlayclose(subobj){







document.getElementById(subobj).style.display="none";







}







<!-- End : Contact Form display on view detyail page -->

<!-- Start : Report This ad -->







function reportad(path,adid){







	xmlHttp=GetXmlHttpObject();







		if (xmlHttp==null)







		 {







			alert ("Browser does not support HTTP Request")







			return







		 }







		var strURL=path+"/report_ad.php?path="+path+"&adid="+adid;







			xmlHttp.onreadystatechange=msgreportAd;







			xmlHttp.open("GET",strURL,true)







			xmlHttp.send(null)







	}







	







	function msgreportAd() 







		{ 







			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")







				 { 







				   alert(xmlHttp.responseText);







				} 







		}

<!-- End : Report This ad -->

<!-- Start : Email subscription -->







function subscribe()







	{







		var emailFormat = /^\w(\.?[\w-])*@\w(\.?[\w-])*\.[a-zA-Z]{2,6}(\.[a-zA-Z]{2})?$/i;







		var d = document.emailalert; 







		







		if(d.email.value==""){







			alert("Please Enter Email");







			d.email.focus();







			return false;







			}







	if(d.email.value.search(emailFormat) == -1)







		{	







			alert("Please Enter valid Email.");







			d.email.focus();







			return false;







		}		







	}







<!-- Start : Email subscription -->

<!-- Start : Display more categories -->







function displayMorecat()

{

	document.getElementById('moresubcategories').style.display='block';	

}

<!-- End : Display more categories -->

<!-- Start : search save valid-->







function save_search_valid()







	{







		var emailFormat = /^\w(\.?[\w-])*@\w(\.?[\w-])*\.[a-zA-Z]{2,6}(\.[a-zA-Z]{2})?$/i;







		if(document.search_save_form.search_save_title.value==""){







			alert("Please Enter Search Criteria Name");







			document.search_save_form.search_save_title.focus();







			return false;







			}







		if(document.search_save_form.email.value==""){







			alert("Please Enter Your Login Email");







			document.search_save_form.email.focus();







			return false;







			}







			







	if(document.search_save_form.email.value.search(emailFormat) == -1)







		{	







			alert("Please Enter valid Email.");







			document.search_save_form.email.focus();







			return false;







		}		

	}







<!-- End : search save valid-->



function OpenMoreCategories(){

document.getElementById('morecategories').style.display="block";

}



function OpenMoreSubCategories(){

document.getElementById('more_sub_categories').style.display="block";

}



function changelocation(path,countryid){

	var surl=path;

	var ctry = document.logoform.country.selectedIndex;

	var xcountryVal = document.logoform.country.options[ctry].text;

if(xcountryVal=="Select Country"){

		document.logoform.action = surl+"/location/sadc-Region.html";

	}else{

	document.logoform.action = surl+"/location/"+CheckSpace(xcountryVal)+".html";

}

	document.logoform.submit();



	}
	
function backtomainmap(path)
	{
	 xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		 {
			alert ("Browser does not support HTTP Request")
			return
		 }
		var strURL=path+"/backtomap.php?path="+path;
		xmlHttp.onreadystatechange=mainmapshow
		xmlHttp.open("GET",strURL,true)
		xmlHttp.send(null)
	}
	function mainmapshow() 
	{ 
		if (xmlHttp.readyState < 4 )
		 { 
			//document.getElementById("mainmapDiv").innerHTML='<option value="">'+preloaderload()+'</option>' ;
			document.getElementById("mainmapDiv").innerHTML='<option value="">Loading Map............</option>' ;
		} 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 
		 document.getElementById('backtomap').style.display='none';
			document.getElementById("mainmapDiv").innerHTML=xmlHttp.responseText ;
			//document.getElementById("mainmapDiv").innerHTML="document.map.src='http://localhost/sadc/map/map.jpg" ;		
			} 
	}	
	
	function preloaderload()
		 {
			 var ld=(document.all);
			  var ns4=document.layers;
			 var ns6=document.getElementById&&!document.all;
			 var ie4=document.all;
			  if (ns4)
				ld=document.loading;
			 else if (ns6)
				ld=document.getElementById("loading").style;
			 else if (ie4)
				ld=document.all.loading.style;
			if(ns4){ld.visibility="hidden";}
			else if (ns6||ie4) ld.display="none";
		 }
		 
 function selectCntry()
 {
	 alert("choose country from dropdown menu or map");
	 document.logoform.country.focus();
	 return false;
	 }
	 
function getOnlineSubCategory(path,catid){
	xmlHttp=GetXmlHttpObject();
	
		if (xmlHttp==null)
	
		 {
	
			alert ("Browser does not support HTTP Request")
	
			return
	
		 }
	
		var strURL=path+"/onlineSubCate.php?cat="+catid;
		xmlHttp.onreadystatechange=onlineDirChanged
	
		xmlHttp.open("GET",strURL,true)
	
		xmlHttp.send(null)
}
	 
function onlineDirChanged() 
	{ 
		if (xmlHttp.readyState < 4 )
		 { 
			 document.getElementById("subcatdiv").innerHTML='<option value="">Loading Online Sub Directories...</option>' ;
		} 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 
			 document.getElementById("subcatdiv").innerHTML=xmlHttp.responseText ;
		} 
	} 
