var user_location;
var rand_num;
var restaurant_list = [
	"A&amp;W",
	"Applebee's",
	"Arby's",
	"Bakers Square",
	"Boston Market",
	"Buffalo Wild Wings",
	"Burger King",
	"California Pizza Kitchen",
	"Cheeseburger in Paradise",
	"The Cheesecake Factory",
	"Chili's",
	"Chipotle Mexican Grill",
	"Coldstone",
	"Country Donuts",
	"Culver's",
	"Dairy Queen",
	"Denny's",
	"Dog N Suds",
	"Fuddruckers",
	"Georgio's",
	"Giordano's",
	"Golden Corral",
	"Hooters",
	"IHOP",
	"KFC",
	"Lone Star Steakhouse",
	"Long John Silver's",
	"Lou Malnati's",
	"Maggiano's Little Italy",
	"Max &amp; Erma's",
	"McDonald's",
	"Moretti's",
	"Nick's Pizza &amp; Pub",
	"Olive Garden",
	"On the Border",
	"Papa John's",
	"Pizza Hut",
	"PizzAmore",
	"Portillo's",
	"Potbelly",
	"Quiznos",
	"Red Robin",
	"Ruby Tuesday",
	"Sonic",
	"Spaghetti Warehouse",
	"Steak 'n Shake",
	"Subway",
	"Taco Bell",
	"Texas Roadhouse",
	"TGI Friday's",
	"Wendy's"
]

var restaurant_links = [
	"http://www.awrestaurants.com",
	"http://www.applebees.com",
	"http://www.arbys.com",
	"http://www.bakerssquarerestaurants.com",
	"http://www.bostonmarket.com",
	"http://www.buffalowildwings.com",
	"http://www.bk.com",
	"http://www.cpk.com",
	"http://www.cheeseburgerinparadise.com",
	"http://www.cheesecakefactory.com",
	"http://www.chilis.com",
	"http://www.chipotle.com",
	"http://www.coldstonecreamery.com",
	"http://www.countrydonuts.net",
	"http://www.culvers.com",
	"http://www.dairyqueen.com",
	"http://www.dennys.com",
	"http://www.dognsuds.org",
	"http://www.fuddruckers.com",
	"http://www.georgiospizza.com",
	"http://www.giordanos.com",
	"http://www.goldencorral.net",
	"http://www.hooters.com",
	"http://www.ihop.com",
	"http://www.kfc.com",
	"http://www.lonestarsteakhouse.com",
	"http://www.ljsilvers.com",
	"http://www.loumalnatis.com",
	"http://www.maggianos.com",
	"http://www.maxandermas.com",
	"http://www.mcdonalds.com",
	"http://www.morettischicago.com",
	"http://www.nickspizzapub.com",
	"http://www.olivegarden.com",
	"http://www.ontheborder.com",
	"http://www.papajohns.com",
	"http://www.pizzahut.com",
	"http://www.pizzamorepizza.com",
	"http://www.portillos.com",
	"http://www.potbelly.com",
	"http://www.quiznos.com",
	"http://www.redrobin.com",
	"http://www.rubytuesday.com",
	"http://www.sonicdrivein.com",
	"http://www.meatballs.com",
	"http://www.steakandshake.com",
	"http://www.subway.com",
	"http://www.tacobell.com",
	"http://www.texasroadhouse.com",
	"http://www.tgifridays.com",
	"http://www.wendys.com"
]

function random_restaurant() {
	document.getElementById('address').style.display = "none";
	rand_num = Math.floor(Math.random()*restaurant_list.length);
	document.getElementById('restaurant').innerHTML = restaurant_list[rand_num];
	document.getElementById('website').innerHTML = '<a href="'+restaurant_links[rand_num]+'">Visit the website<\/a>';
}

function find_restaurant() {
	document.getElementById('address').style.display = "none";
	user_location = document.getElementById('user_location').value;
	if(user_location != "") {
		window.location = "http://maps.google.com/maps?q=" + restaurant_list[rand_num].replace(/&amp;/, "%26") + "+near+" + user_location;
	} else {
		window.location = "http://maps.google.com/maps?q=" + restaurant_list[rand_num].replace(/&amp;/, "%26");
	}
}

function find_restaurant2(restaurant) {
	user_location = document.getElementById('address').value;
	if(user_location != "") {
		window.location = "http://maps.google.com/maps?q=" + restaurant.replace(/&amp;/, "%26") + "+near+" + user_location;
	} else {
		window.location = "http://maps.google.com/maps?q=" + restaurant.replace(/&amp;/, "%26");
	}
}

function show_address() {
	if (document.getElementById('address').style.display != "block") {
		document.getElementById('address').style.display = "block";
		document.getElementById('user_location').focus();
	} else {
		find_restaurant();
	}
}