
function doSearch() {
	category = document.getElementById('sf_category_id').value;	
	citystate = document.getElementById('sf_citystate').value;
	tmpArr = citystate.split(',');
	city = jQuery.trim(tmpArr[0]);
	state = jQuery.trim(tmpArr[1]);
	if(category!='' && tmpArr.length==2) location.href="/"+category+"/"+state+"/"+city;
	else if(category=='' &&  tmpArr.length==2) location.href="/"+state+"/"+city;
	else if(category!='' &&  tmpArr.length!=2) location.href="/"+category; 
	else alert("Please enter a category and/or city");
}

var categories_timer;

$(document).ready(function() {


	$('#sf_category').mouseover(function() {$('#sf_categories').fadeTo('fast',1);});
	$('#sf_category').mouseout(function() {$('#sf_categories').hide();});
	$('#sf_categories').mouseover(function() {$('#sf_categories').show();});
	$('#sf_categories').mouseout(function() {$('#sf_categories').hide();});
});

function setsfCategory(val,text) {
	document.getElementById('sf_category_id').value=val;
	document.getElementById('sf_category').innerHTML=text;
	$('#sf_categories').hide();
}

//function to support legacy code
function makeRequest(theurl) {
	$.ajax({
	  url: theurl,
	  cache:false,
	  success: function(data) {
	    processResults(data);
	  }
	});
}

function copyToClipboard(s)
{
	if( window.clipboardData && clipboardData.setData )
	{
		clipboardData.setData("Text", s);
	}
	else
	{
		// You have to sign the code to enable this or allow the action in about:config by changing user_pref("signed.applets.codebase_principal_support", true);
		netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');

		var clip = Components.classes['@mozilla.org/widget/clipboard;[[[[1]]]]'].createInstance(Components.interfaces.nsIClipboard);
	   if (!clip) return;
	   
	   // create a transferable
	   var trans = Components.classes['@mozilla.org/widget/transferable;[[[[1]]]]'].createInstance(Components.interfaces.nsITransferable);
	   if (!trans) return;
	   
	   // specify the data we wish to handle. Plaintext in this case.
	   trans.addDataFlavor('text/unicode');
	   
	   // To get the data from the transferable we need two new objects
	   var str = new Object();
	   var len = new Object();
	   
	   var str = Components.classes["@mozilla.org/supports-string;[[[[1]]]]"].createInstance(Components.interfaces.nsISupportsString);
	   
	   var copytext=meintext;
	   
	   str.data=copytext;
	   
	   trans.setTransferData("text/unicode",str,copytext.length*[[[[2]]]]);
	   
	   var clipid=Components.interfaces.nsIClipboard;
	   
	   if (!clip) return false;
	   
	   clip.setData(trans,null,clipid.kGlobalClipboard);	   
	}
}

function bumpStats(access_type,client_id,category_id,city_id,state_id) {
	theurl = "/ajax/bumpStats.php?access_type="+access_type+"&client_id="+client_id+"&category_id="+category_id+"&city_id="+city_id+"&state_id="+state_id;
	
	$.ajax({
	  url: theurl,
	  success: function(data) {
	   //nothing
	  }
	});
}	
