//if (!navigator.geolocation) window.location.href = "/";

function getLocation() {
	navigator.geolocation.getCurrentPosition(showLocation, showError, {enableHighAccuracy:true,maximumAge:600000});
}
 
function showError(error) {
	alert("Sorry. :-( Error " + error.code + ": " + error.message);
}
 
function showLocation(position) {
	var curry = position.coords.latitude;
	var currx = position.coords.longitude;
	getRestaurantList(curry,currx,0);
}
			

			
function ajaxIt(submitUrl){
	var xmlHttpReq = false;      
	if (window.XMLHttpRequest) {
		xmlHttpReq = new XMLHttpRequest();
		xmlHttpReq.overrideMimeType('text/xml');
	} else if (window.ActiveXObject) {
		xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}		
    xmlHttpReq.open('POST', submitUrl, true);
    xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlHttpReq.send(submitUrl);
    var text = "";
    xmlHttpReq.onreadystatechange = function() {
	    if (xmlHttpReq.readyState == 4) {
   	    	text = xmlHttpReq.responseText;
		    getSpots(text);
		}
	}
}
			

function getSpots(text) {
	if(text=="0"){
		document.getElementById('places').innerHTML = "<li><span class=\"nomatch\">Searching...</span></li>";
		var meal = document.getElementById('meal').value;
		var location = document.getElementById('location').value;
		var wildcard = document.getElementById('wildcard').value;
		var submitUrl = "http://www.onlyeathere.com/ajax.php?meal=" + meal + "&location=" + location + "&wildcard=" + wildcard;
		ajaxIt(submitUrl);
	} else {
		document.getElementById('places').innerHTML = text;
	}
}

function showSearch(){
alert('a');
	if(document.getElementById('content').style.display=='block'){
		document.getElementById('content').style.display='none';
		document.getElementById('search').style.display='block';
	} else {
		document.getElementById('content').style.display='block';
		document.getElementById('search').style.display='none';
	
	}
}