function SearchCategory(){
	var searchcat = jQuery("#searchcat").val();
		jQuery.ajax({
	    	type: "POST",
	    	url: "http://www.yellowpages.com.my/e-dining/ajax.php",
	    	data: "pageaction=searchcat&searchcat="+searchcat,
	    	success: function(responseText, responseStatus) {	
				jQuery("#searchresult").html(responseText);       
		    } 
		}); 
} 
function AddCategory(code, catname){
	var selectedcategory = jQuery("#listcategory").val();
	var countcat = (selectedcategory.length - selectedcategory.replace(new RegExp('__',"g"), '').length) / 2;
	if(selectedcategory.indexOf(code)<0){
		if(countcat<5){
			if(jQuery("#selectedcat").html()==''){
				var newselected = "- "+catname;	
			}else{
				var newselected = jQuery("#selectedcat").html()+"<br/>- "+catname;	
			}				
			jQuery("#selectedcat").html(newselected);	
			var oldcat = jQuery("#listcategory").val()+'__'+code;
			jQuery("#listcategory").val(oldcat);
		}else{
			alert('You have select 5 category.');
		}
	}else{
		alert('You have select same category.');		
	}
}
$(function() {
	jQuery("#listcategory").val('');
	
	jQuery(".agreepolicy").click(function(e){
		
		var agreepolicy = $('#agreepolicy:checked').val();
		if(agreepolicy=='Yes'){
			var userip = jQuery('#userip').val();
			var uniquepolicy = jQuery('#uniquepolicy').val();
			jQuery.ajax({
		    	type: "POST",
		    	url: "ajax.php",
		    	data: "pageaction=checkpolicy&userip="+userip+"&uniquepolicy="+uniquepolicy,
		    	success: function(responseText, responseStatus) {
			    } 
			});
		} 
	});
});
