// JavaScript Document
	  function check_data()
	  	{
						
						var sString=document.searchform.search_bar_category.value;
						
						while (sString.substring(0,1) == ' ')
						{
						sString = sString.substring(1, sString.length);
						}
						while (sString.substring(sString.length-1, sString.length) == ' ')
						{
						sString = sString.substring(0,sString.length-1);
						}
						if(sString.length<3)
						{
							//alert("Please enter valid keyword or category");
							//return false;
						}
						// validate for blank space  ----
						l=sString.length;
						var n=0;
						//var str1=str.replace( /^\s+¦\s+$/g, "");
						//alert(str1);
						for(i=0;i<=l;++i){
						//alert("aaaaaaaaaa");
								a=sString.charAt(i);
								//alert(a);
								if(a==" "){
									n=n+1;
								}
							}
							if(n==l){
							alert("Please enter valid keyword or category");
								return false;
							}
							if(l==3 && n==2){
								alert("Please enter valid keyword or category");
								return false;
							}
						//----------------------------------
						//if((searchform.search_bar_zip.value=="e.g 92882" || searchform.search_bar_zip.value=="") && (searchform.location.value=="e.g Los Angeles" || searchform.location.value.length<3) && (searchform.search_bar_category.value!="e.g Pizza" && searchform.search_bar_category.value.length>=3))
			if(document.searchform.search_bar_category.value!="e.g Pizza" && document.searchform.search_bar_category.value!="")
				{
					
				
					 if((document.searchform.search_bar_zip.value=="e.g 92882" || document.searchform.search_bar_zip.value==""))
						{
							alert("Please enter a valid Zip code or City");
							return false;
						}
					else if((document.searchform.search_bar_zip.value!="e.g 92882" && document.searchform.search_bar_zip.value!="" ))
						{
							if(document.searchform.search_bar_zip.value=="e.g 92882")
							{
								var s = "";
							}
						else
							{
								var s=document.searchform.search_bar_zip.value;
							}
						if(document.searchform.search_bar_category.value=="")
							{
								var s3="";
							}
						else
							{
								s3=document.searchform.search_bar_category.value;
								out = "&"; // replace this
								add = "%26"; // with this
								//temp = "" + entry; // temporary holder

								while (s3.indexOf(out)>-1) {
								pos= s3.indexOf(out);
								s3 = "" + (s3.substring(0, pos) + add + 
								s3.substring((pos + out.length), s3.length));
								}
								out = " "; // replace this
								add = "+"; // with this
								//temp = "" + entry; // temporary holder

								while (s3.indexOf(out)>-1) {
								pos= s3.indexOf(out);
								s3 = "" + (s3.substring(0, pos) + add + 
								s3.substring((pos + out.length), s3.length));
								}	
								
								out = "-"; // replace this
								add = " "; // with this
								//temp = "" + entry; // temporary holder

								while (s3.indexOf(out)>-1) {
								pos= s3.indexOf(out);
								s3 = "" + (s3.substring(0, pos) + add + 
								s3.substring((pos + out.length), s3.length));
								}
								out = " "; // replace this
								add = "+"; // with this
								//temp = "" + entry; // temporary holder

								while (s3.indexOf(out)>-1) {
								pos= s3.indexOf(out);
								s3 = "" + (s3.substring(0, pos) + add + 
								s3.substring((pos + out.length), s3.length));
								}	
								
								
								out = "/"; // replace this
								add = " "; // with this
								//temp = "" + entry; // temporary holder

								while (s3.indexOf(out)>-1) {
								pos= s3.indexOf(out);
								s3 = "" + (s3.substring(0, pos) + add + 
								s3.substring((pos + out.length), s3.length));
								}
								out = " "; // replace this
								add = "+"; // with this
								//temp = "" + entry; // temporary holder

								while (s3.indexOf(out)>-1) {
								pos= s3.indexOf(out);
								s3 = "" + (s3.substring(0, pos) + add + 
								s3.substring((pos + out.length), s3.length));
								}	
								

							}
							//s3=trim(s3, "");
							//alert(s3);
							query="action=all&string="+s+"&category="+s3;
							document.location="/listings.php?"+query;
							return false;
						}
					
					else if(document.searchform.search_bar_zip.value!="e.g 92882" && document.searchform.search_bar_zip.value!="")
						{
							if(document.searchform.search_bar_zip.value=="e.g 92882")
							{
								var s = "";
							}
						else
							{
								var s=document.searchform.search_bar_zip.value;
							}
							
						if(document.searchform.search_bar_category.value=="")
							{
								var s3="";
							}
						else
							{
								s3=document.searchform.search_bar_category.value;
							}
								out = "&"; // replace this
								add = "%26"; // with this
								//temp = "" + entry; // temporary holder

								while (s3.indexOf(out)>-1) {
								pos= s3.indexOf(out);
								s3 = "" + (s3.substring(0, pos) + add + 
								s3.substring((pos + out.length), s3.length));
								
								}
								out = " "; // replace this
								add = "+"; // with this
								//temp = "" + entry; // temporary holder

								while (s3.indexOf(out)>-1) {
								pos= s3.indexOf(out);
								s3 = "" + (s3.substring(0, pos) + add + 
								s3.substring((pos + out.length), s3.length));
								}
								//s3=trim(s3, "");
								//alert(s3);
							query="action=all&string="+s1+"&string="+s+"&category="+s3;
							document.location="/listings.php?"+query;
							return false;
						}
					
				}
			if((document.searchform.search_bar_zip.value!="e.g 92882" && document.searchform.search_bar_zip.value!="") && (document.searchform.search_bar_category.value=="e.g Pizza" || document.searchform.search_bar_category.value==""))
				{
						if(document.searchform.search_bar_zip.value=="e.g 92882")
							{
								var s = "";
							}
						else
							{
								var s=document.searchform.search_bar_zip.value;
							}
						query="action=search&string="+s;
						document.location="/listings.php?"+query;
						return false;
				}
			
			
				if(document.searchform.search_bar_zip.value=="e.g 92882" || document.searchform.search_bar_zip.value=="")
					{
							alert("Please enter  zip or location");
							return false;
					}
				else if((document.searchform.search_bar_zip.value=="e.g 92882" || document.searchform.search_bar_zip.value=="") && (document.searchform.search_bar_category.value=="e.g Pizza" || document.searchform.search_bar_category.value==""))
					{
						alert("Please enter a valid zip code");
						return false;
					}
					
		}

// JavaScript Document

	  function check_data_frame()
	  	{
				
						
						
						var sString=document.searchform1.search_bar_category.value;
						
						while (sString.substring(0,1) == ' ')
						{
						sString = sString.substring(1, sString.length);
						}
						while (sString.substring(sString.length-1, sString.length) == ' ')
						{
						sString = sString.substring(0,sString.length-1);
						}
						if(sString.length<3)
						{
							//alert("Please enter valid keyword or category");
							//return false;
						}
				
			
						//if((searchform.search_bar_zip.value=="e.g 92882" || searchform.search_bar_zip.value=="") && (searchform.location.value=="e.g Los Angeles" || searchform.location.value.length<3) && (searchform.search_bar_category.value!="e.g Pizza" && searchform.search_bar_category.value.length>=3))
			if(document.searchform1.search_bar_category.value!="e.g Pizza" && document.searchform1.search_bar_category.value.length>=3)
				{
					
				
					 if((document.searchform1.search_bar_zip.value=="e.g 92882" || document.searchform1.search_bar_zip.value.length < 3))
						{
							alert("Please enter a valid Zip code or City");
							return false;
						}
					else if((document.searchform1.search_bar_zip.value!="e.g 92882" && document.searchform1.search_bar_zip.value!="" ))
						{
							if(document.searchform1.search_bar_zip.value=="e.g 92882")
							{
								var s = "";
							}
						else
							{
								var s=document.searchform1.search_bar_zip.value;
							}
						if(document.searchform1.search_bar_category.value=="")
							{
								var s3="";
							}
						else
							{
								s3=document.searchform1.search_bar_category.value;
								out = "&"; // replace this
								add = "+"; // with this
								//temp = "" + entry; // temporary holder

								while (s3.indexOf(out)>-1) {
								pos= s3.indexOf(out);
								s3 = "" + (s3.substring(0, pos) + add + 
								s3.substring((pos + out.length), s3.length));
								}
									
								out = " "; // replace this
								add = "+"; // with this
								//temp = "" + entry; // temporary holder

								while (s3.indexOf(out)>-1) {
								pos= s3.indexOf(out);
								s3 = "" + (s3.substring(0, pos) + add + 
								s3.substring((pos + out.length), s3.length));
								}

							}
							//s3=trim(s3, "");
							//alert(s3);
							query="action=all&string="+s+"&category="+s3;
							document.location="/listings.php?"+query;
							return false;
						}
					
					else if(document.searchform1.search_bar_zip.value!="e.g 92882" && document.searchform1.search_bar_zip.value!="")
						{
							if(document.searchform1.search_bar_zip.value=="e.g 92882")
							{
								var s = "";
							}
						else
							{
								var s=document.searchform1.search_bar_zip.value;
							}
							
						if(document.searchform1.search_bar_category.value=="")
							{
								var s3="";
							}
						else
							{
								s3=document.searchform1.search_bar_category.value;
							}
								out = "&"; // replace this
								add = "+"; // with this
								//temp = "" + entry; // temporary holder

								while (s3.indexOf(out)>-1) {
								pos= s3.indexOf(out);
								s3 = "" + (s3.substring(0, pos) + add + 
								s3.substring((pos + out.length), s3.length));
								
								}
								
								out = " "; // replace this
								add = "+"; // with this
								//temp = "" + entry; // temporary holder

								while (s3.indexOf(out)>-1) {
								pos= s3.indexOf(out);
								s3 = "" + (s3.substring(0, pos) + add + 
								s3.substring((pos + out.length), s3.length));
								}
							//s3=trim(s3, "");
							//alert(s3);
							query="action=all&string="+s1+"&string="+s+"&category="+s3;
							document.location="/listings.php?"+query;
							return false;
						}
					
				}
			if((document.searchform1.search_bar_zip.value!="e.g 92882" && document.searchform1.search_bar_zip.value.length>=3) && (document.searchform1.search_bar_category.value=="e.g Pizza" || document.searchform1.search_bar_category.value.length<3))
				{
						if(document.searchform1.search_bar_zip.value=="e.g 92882")
							{
								var s = "";
							}
						else
							{
								var s=document.searchform1.search_bar_zip.value;
							}
						query="action=search&string="+s;
						document.location="/listings.php?"+query;
						return false;
				}
			
			
				if(document.searchform1.search_bar_zip.value=="e.g 92882" || document.searchform1.search_bar_zip.value.length<3)
					{
							alert("Please enter  zip or location");
							return false;
					}
				else if((document.searchform1.search_bar_zip.value=="e.g 92882" || document.searchform1.search_bar_zip.value.length < 3) && (document.searchform1.search_bar_category.value=="e.g Pizza" || document.searchform1.search_bar_category.value.length<3))
					{
						alert("Please enter a valid zip code");
						return false;
					}
					
		}
// creating http object to handle ajax
function getHTTPObject() {
  var xmlhttp;
 
  if(window.XMLHttpRequest){
    xmlhttp = new XMLHttpRequest();
  }
  else if (window.ActiveXObject){
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    if (!xmlhttp){
        xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    
}
  return xmlhttp;

  
}


var http = getHTTPObject(); // We create the HTTP Object
var http1 = getHTTPObject(); // We create the HTTP Object
var http2 = getHTTPObject(); // We create the HTTP Object


///
function category_show(){   // will call when someone click view all from category search page
	
	var s=document.getElementById("divAll").innerHTML;
	
	s=s.replace("<a>", '');
	s=s.replace("</a>", '');
	if(s=="View More&gt;&gt;&gt;"){
			document.getElementById("divMoreCat").style.display="block";
			document.getElementById("divAll").innerHTML="<<<View Less";
			
	}else{
			document.getElementById("divAll").innerHTML="View More>>>";
			document.getElementById("divMoreCat").style.display="none";
	}
	
}
function show_sub_category(cat_id,category_name,business_count){	// this will call when someone tick main catgory
		city=frm1.city.value;
		state=frm1.state.value;
		zip=frm1.zip.value;
		table=frm1.business_table.value;
		category_name=category_name.replace("GOMY1", "'");
		query1="cid="+cat_id+"&location="+city+"&state="+state+"&zip="+zip+"&table="+table+"&category_name="+category_name+"&business_count="+business_count;
		query2="cid="+cat_id+"&location="+city+"&state="+state+"&zip="+zip+"&table="+table;
		
		//document.getElementById("divChildCat").innerHTML="<img src='/images/loading.gif'>";
		document.getElementById("divList").className  = "op2";
		//document.getElementById("divList").innerHTML="<img src='images/loading.gif'>";
		document.getElementById("Layer1").style.display ="block";
		document.getElementById("Layer1").innerHTML="<img src='/images/loading.gif'>";
		//category_search(cat_id);  // call category narrow search function to display business business in right side
		url="/show_sub_category.php?"+query1;
		var temp=new Array();
			http.open("GET", url, true);
			http.onreadystatechange = function() {
				if (http.readyState == 4) {
				  if(http.status==200) {
			  		var results=http.responseText;
					document.getElementById("divChildCat").innerHTML = results;
					
				  } 
  				}
			};
			http.send(null);
			url2="/category_narrow_search.php?"+query2;
			var temp=new Array();
			http1.open("GET", url2, true);
			http1.onreadystatechange = function() {
				if (http1.readyState == 4) {
				  if(http1.status==200) {
					  
			  		var results=http1.responseText;
					document.getElementById("Layer1").style.display ="none";
					document.getElementById("divList").className  = "op3";
					document.getElementById("divList").innerHTML = results;
					
				  } 
  				}
			};
			http1.send(null);
			G_Maps_load();
			load();
			
			//category_search(cat_id);
}

function category_search(cat_id){
				document.getElementById("divList").className  = "op2";
				//document.getElementById("divList").innerHTML="<img src='images/loading.gif'>";
				document.getElementById("Layer1").style.display ="block";
				document.getElementById("Layer1").innerHTML="<img src='/images/loading.gif'>";
				city=frm1.city.value;
				state=frm1.state.value;
				zip=frm1.zip.value;
				table=frm1.business_table.value;
				query="cid="+cat_id+"&location="+city+"&state="+state+"&zip="+zip+"&table="+table;
				url="/category_narrow_search.php?"+query;
				var temp=new Array();
				http.open("GET", url, true);
				http.onreadystatechange = function() {
				if (http.readyState == 4) {
				  if(http.status==200) {
			  		var results=http.responseText;
					document.getElementById("Layer1").style.display ="none";
					document.getElementById("divList").className  = "op3";
					document.getElementById("divList").innerHTML = results;
					
				  } 
  				}
			};
			http.send(null);
			G_Maps_load();
			load();
		//}
		
		
}
// this function work after normal search and click any category left side
function category_search_list(cat_id,category_name,business_count){
			
				city=window.document.frm1.city.value;
		state=window.document.frm1.state.value;
		zip=window.document.frm1.zip.value;
		table=window.document.frm1.business_table.value;
		category_name=category_name.replace("GOMY1", "'");
		query1="cid="+cat_id+"&location="+city+"&state="+state+"&zip="+zip+"&table="+table+"&category_name="+category_name+"&business_count="+business_count;
		query2="cid="+cat_id+"&location="+city+"&state="+state+"&zip="+zip+"&table="+table;
		
		//document.getElementById("divChildCat").innerHTML="<img src='/images/loading.gif'>";
		document.getElementById("divList").className  = "op2";
		//document.getElementById("divList").innerHTML="<img src='images/loading.gif'>";
		document.getElementById("Layer1").style.display ="block";
		document.getElementById("Layer1").innerHTML="<img src='/images/loading.gif'>";
		//document.getElementById("floater").innerHTML="<img src='/images/loading.gif'>";
		//document.getElementById("divMap").innerHTML="Loading map.....";
		
		//category_search(cat_id);  // call category narrow search function to display business business in right side
		url="/show_sub_category.php?"+query1;
		var temp=new Array();
			http.open("GET", url, true);
			http.onreadystatechange = function() {
				if (http.readyState == 4) {
				  if(http.status==200) {
			  		var results=http.responseText;
					document.getElementById("divChildCat").innerHTML = results;
					
				  } 
  				}
			};
			http.send(null);
			url2="/list_narrow_search.php?"+query2;
			var temp=new Array();
			http1.open("GET", url2, true);
			http1.onreadystatechange = function() {
				if (http1.readyState == 4) {
				  if(http1.status==200) {
					  
			  		var results=http1.responseText;
					document.getElementById("Layer1").style.display ="none";
					document.getElementById("divList").className  = "op3";
					document.getElementById("divList").innerHTML = results;
					
				  } 
  				}
			};
			
			http1.send(null);
			G_Maps_load();
			load();
			/*url2="floating_map1.php?"+query2;
			var temp=new Array();
			http2.open("GET", url2, true);
			http2.onreadystatechange = function() {
				if (http2.readyState == 4) {
				  if(http2.status==200) {
					  
			  		var results=http2.responseText;
					//document.getElementById("Layer1").style.display ="none";
					//document.getElementById("divList").className  = "op3";
					document.getElementById("divMap").innerHTML = results;
					
				  } 
  				}
			};
			http2.send(null); */
			//category_search(cat_id);
		
}

function category_search_list_test(cat_id,category_name,business_count,category){
		city=frm1.city.value;
		state=frm1.state.value;
		zip=frm1.zip.value;
		table=frm1.business_table.value;
		query1="cid="+cat_id+"&location="+city+"&state="+state+"&zip="+zip+"&table="+table+"&category_name="+category+"&business_count="+business_count;
		query2="cid="+cat_id+"&location="+city+"&state="+state+"&zip="+zip+"&table="+table;
		
		//document.getElementById("divChildCat").innerHTML="<img src='/images/loading.gif'>";
		document.getElementById("divList").className  = "op2";
		//document.getElementById("divList").innerHTML="<img src='images/loading.gif'>";
		document.getElementById("Layer1").style.display ="block";
		document.getElementById("Layer1").innerHTML="<img src='/images/loading.gif'>";
		//category_search(cat_id);  // call category narrow search function to display business business in right side
		url="/show_sub_category.php?"+query1;
		var temp=new Array();
			http.open("GET", url, true);
			http.onreadystatechange = function() {
				if (http.readyState == 4) {
				  if(http.status==200) {
			  		var results=http.responseText;
					document.getElementById("divChildCat").innerHTML = results;
					
				  } 
  				}
			};
			http.send(null);
			url2="/list_narrow_search.php?"+query2;
			var temp=new Array();
			http1.open("GET", url2, true);
			http1.onreadystatechange = function() {
				if (http1.readyState == 4) {
				  if(http1.status==200) {
					  
			  		var results=http1.responseText;
					document.getElementById("Layer1").style.display ="none";
					document.getElementById("divList").className  = "op3";
					document.getElementById("divList").innerHTML = results;
					
				  } 
  				}
			};
			http1.send(null);
			//category_search(cat_id);
		
}


// function using to redirect payment option from payment_option.php after create new premium ad
// created on 1-march-2008 - prajosh
function redirect_page(){
	
	if(frm_payment.radio1[0].checked){
		
		if(frm_payment.radio2[0].checked){
		document.frm_payment.action="/paypal/ReviewOrder.php?a=Month";
		}else{
		document.frm_payment.action="/paypal/ReviewOrder.php?a=Year";
		}
		document.frm_payment.submit();
	}else{
		query=document.frm_payment.query.value;
		if(frm_payment.radio2[0].checked){
		document.frm_payment.action="/credit_card_details.php?a=Month&"+query;
		}else{
		document.frm_payment.action="/credit_card_details.php?a=Year&"+query;
		}
		
		document.frm_payment.submit();
	} 
}
function redirect_page_test(){
	
	if(frm_payment.radio1[0].checked){
		
		if(frm_payment.radio2[0].checked){
		document.frm_payment.action="/paypal/ReviewOrder_test.php?a=Month";
		}else{
		document.frm_payment.action="/paypal/ReviewOrder_test.php?a=Year";
		}
		document.frm_payment.submit();
	}else{
		query=document.frm_payment.query.value;
		if(frm_payment.radio2[0].checked){
		document.frm_payment.action="/credit_card_details_test.php?a=Month&"+query;
		}else{
		document.frm_payment.action="/credit_card_details_test.php?a=Year&"+query;
		}
		
		document.frm_payment.submit();
	} 
}

//-----------------------------------------------------------------------------------------------