	var types=new Array(36);
	types[1] ='Barbeque';
	types[3] ='Burgers';
	types[4] ='Cajun/Creole';
	types[5] ='Chinese';
	types[7] ='Delis';
	types[8] ='Diners';
	types[9] ='French';
	types[10] ='German';
	types[11] ='Greek/Mediterranian';
	types[12] ='HotDogs';
	types[13] ='Fast Food';
	types[14] ='Indian/Pakistani';
	types[15] ='Italian';
	types[16] ='Japanese';
	types[17] ='Korean';
	types[18] ='Latin American';
	types[19] ='Mexican';
	types[20] ='Middle Eastern';
	types[21] ='American - New';
	types[22] ='Pizza';
	types[23] ='Sandwiches';
	types[24] ='Seafood';
	types[25] ='Steak';
	types[26] ='Sushi';
	types[27] ='Thai';
	types[28] ='American - Traditional';
	types[30] ='Vegetarian';
	types[31] ='Russian';
	types[32] ='Cafe';
	types[33] ='Salads';
	types[34] ='Southern';
	types[35] ='Soul';
	//not in list
	types[36] ='Bar';

	var loadingMessage; 
	var hght;
	var howhigh;
	var monkey;
	var map;
	var lunches = [];
	var infoWinsCode = [];
	var dots = [];

	var tackB = new GIcon(); 
	tackB.iconSize = new GSize(12, 20);
	tackB.shadowSize = new GSize(22, 20);
	tackB.iconAnchor = new GPoint(6, 20);
	tackB.infoWindowAnchor = new GPoint(5, 1);
	tackB.image = '/images/mm_20_blue.png';
	tackB.shadow = '/images/mm_20_shadow.png';
	
	var tackY = new GIcon(); 
	tackY.iconSize = new GSize(12, 20);
	tackY.shadowSize = new GSize(22, 20);
	tackY.iconAnchor = new GPoint(6, 20);
	tackY.infoWindowAnchor = new GPoint(5, 1);
	tackY.image = '/images/mm_20_yellow.png';
	tackY.shadow = '/images/mm_20_shadow.png';
	
	var iconImageY= '/images/mm_20_yellow.png';
	var iconImageB= '/images/mm_20_blue.png';

	var icons = [];
	icons["0"] = tackB;
	icons["1"] = tackY;
	
	var marker;	
	var markers;


function lunchMe(id) {
	if (GBrowserIsCompatible()) {
 
		map = new GMap2(document.getElementById("map"));
		map.addControl(new GLargeMapControl());
		map.setCenter(new GLatLng(41.882438, -87.629056), 16);

		loadingMessage=(new HtmlControl("<div class='loadsplash'><h1>Gimme a few seconds to load</h1><br><img src='/images/ajax_marker_load.gif' alt='Map loading...'/><br><h2>(It'll be worth it)</h2></div>'"));
		//map.addControl(loadingMessage, new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(312,246)));
		map.addControl(loadingMessage, new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(212,246)));
		
		letThereBeDots(id);

		howhigh = document.documentElement.clientHeight;
		document.getElementById("map").style.height = howhigh + "px";
		document.getElementById("building").style.height = (howhigh - 290) + "px";

		map.checkResize();

		window.addEventListener("resize", function() {
			howhigh = document.documentElement.clientHeight;
			document.getElementById("map").style.height = howhigh + "px";
			document.getElementById("building").style.height = (howhigh - 290)+ "px";
			map.checkResize();
		}, false);
    }
	else {
		alert("Sorry, your browser is not compatible with Google Maps. Try Firefox.");
	}
	
}









function letThereBeDots(id) {
	GDownloadUrl("phpsqlajax_genxml.php?id=" + id, function(data, responseCode) {

		if(responseCode == 200) {
  
			var xml = GXml.parse(data);
			var markers = xml.documentElement.getElementsByTagName("marker");
			var listDv = document.getElementById("lunchList");
			listDv.innerHTML = "";
  
			infoWinsCode.clear();
			lunches.clear();
			dots.clear();

			listDv.innerHTML += '<ul>';

			for (var i = 0; i < markers.length; i++) {
//* gloabal PK for POST since i index is recrete every time**/
				var name = markers[i].getAttribute("name");
				var address = markers[i].getAttribute("addr");
				var phone ="";
				 phone = markers[i].getAttribute("phone");
				var url="";
				 url = markers[i].getAttribute("url");
				//var type = markers[i].getAttribute("type");
				var tp_cd1="";
				var tp_cd2="";
				var tp_cd3="";
				
				 tp_cd1 = markers[i].getAttribute("tp_cd1");
				 tp_cd2 = markers[i].getAttribute("tp_cd2");
				 tp_cd3 = markers[i].getAttribute("tp_cd3");
				var yelp = markers[i].getAttribute("y_url");
				 rating="";
				var rating = markers[i].getAttribute("rate");
				var photo_url="";
				 photo_url = markers[i].getAttribute("y_pic_url");
				//var menu_url = markers[i].getAttribute("menu_url");
				//var the_word = markers[i].getAttribute("the_word"); 
				var menu = markers[i].getAttribute("menu");
				var the_word = ""; 
				var id2 = markers[i].getAttribute("id2");
				
				var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
										parseFloat(markers[i].getAttribute("lng")));

				var marker = infoWinHTML(point, name, address, phone, url, yelp, rating, photo_url, menu, the_word, tp_cd1, tp_cd2, tp_cd3, id2);

				map.addOverlay(marker);

				//listDv.innerHTML += '<li><a href="javascript:openInfoWin(' + i + ')">' + name + '</a></li>';
				//qname='"' + name + '"';
				//var passThis= i + ", " + qname +"";
				//var passThis= i + ", \"" + name +"\"";
				//listDv.innerHTML += '<li><a href="javascript:openInfoWin(' + passThis + ')">' + name + '</a></li>';
				//listDv.innerHTML += "<li><a href=\"javascript:openInfoWin("+passThis+")\">" + name + "</a></li>";
				cleanname=name.replace("'","`")
				listDv.innerHTML += "<li><a href=\"javascript:openInfoWin(" +i+ ",'" +cleanname+ "')\">" +name+ "</a></li>";
				
				//I still need to figure out how to hover of the list to highlight (change) the marker to yellow
				//var passThis= i + ", '" + name +"'";
				//listDv.innerHTML += '<li id="li1" onmouseover="GEvent.trigger(markers[' + i + '],\'mouseover\')" onmouseout="GEvent.trigger(markers[' + i + '],\'mouseout\')" ><a href="javascript:openInfoWin(' + passThis + ')">' + name + '</a></li>';
				//listDv.innerHTML += '<li id="li1" onmouseover="GEvent.trigger(marker,\'mouseover\')" onmouseout="GEvent.trigger(marker,\'mouseout\')" ><a href="javascript:openInfoWin(' + passThis + ')">' + name + '</a></li>';


			}
 
			listDv.innerHTML += '</ul>';

			map.removeControl(loadingMessage); 

		} else if(responseCode == -1) {
			alert("Oh snap, your data request timed out. Please try later.");
		} else { 
			alert("Request resulted in error. Check XML file is retrievable.");
		}
	});
}


function changeType(form) { 
	var index=form.types.selectedIndex;
	id = form.types.options[index].value;
	lunchMe(id);
	var passThis = types[id];
	pageTracker._trackPageview("/cuisine/" + "'" + passThis + "'");
}


function openInfoWin(id, name) {
	lunches[id].openInfoWindowHtml(infoWinsCode[id]);
	map.panTo(dots[id]);
	//** POST event on PK unique id**/
	pageTracker._trackPageview("/openWin/" + "\"" + name + "\"");
}


function infoWinHTML( point, name, address, phone, url, yelp, rating, photo_url, menu, the_word, type1, type2, type3, id2 ) {

	var marker = new GMarker(point, {icon:icons["0"], title:name});

	var html = "<div id='marker'>";

//THIS IS TEMPORARY THE LINE BLEWO
	var type = "<type_here>";

	if(photo_url != ""){
		if(id2 < 629)
		html += "<img src='http://static.px.yelp.com/bpthumb/" + photo_url + "' class='image' width='100' height='100' />";
		else
		html += "<img src='http://static.px.yelp.com/bphoto/" + photo_url + "' class='image' height='100' width='75'/>";
	}

	type = "";
	if(type1 != "") {
		type += types[type1];
	}
	if(type2 != "") {
		type += ", " + types[type2];
	}
	if(type3 != "") {
		type += ", " + types[type3];
	}
	
	if(url != "") {
		//html += "<div id='info'><div id='name'><a href='http://www." + url + "' target='_blank' >" + name + "</a></div><em>" + type + "</em><br />" + address + "<br />" + phone + "<br /><br />";
		//html += "<div id='info'><div id='name'><a href='http://www." + url + "' target='_blank' onClick='javascript: pageTracker._trackPageview(\"/outgoing/" + url + "\");' >" + name + "</a></div><em>" + type + "</em><br />" + address + "<br />" + phone + "<br /><br />";
		html += "<div id='info'><div id='name'><a href='http://www." + url + "' target='_blank' onClick='javascript: pageTracker._trackPageview(\"/outgoing/" + url + "\");' >" + name + "</a></div><em>" + type + "</em><br />" + address + "<br />" + phone + "";
	}
	else {
		//html += "<div id='info'><div id='name'>                                      " + name +     "</div><em>" + type + "</em><br />" + address + "<br />" + phone + "<br /><br />";
		html += "<div id='info'><div id='name'>                                      " + name +     "</div><em>" + type + "</em><br />" + address + "<br />" + phone + "";
	}
	
	var percentage = rating / 5 * 100;


	if(menu != ""){
	check=menu.substring(0,1)
	if (check != "h")
		menu_link="http://chicago.menupages.com/screenmenu_b.asp?restaurantid=" + menu + "&areaid=25";
	else
		menu_link=menu;
	
	html += "<div id='menul'><a href='" + menu_link + "' target='_blank' onClick='javascript: pageTracker._trackPageview(\"/outgoing/menu/" + "'" + name + "'" + "\");'>Menu</a></div>";
	}


	if (rating != 0 || rating != "") {
	if (photo_url != "")
		//html += "<div id='rating_bar' style='margin-left:105px'><div style='width:" + percentage + "%'></div></div>";     ON BEFORE V2    Umm that looks redundant
		html += "<div id='rating_bar'><div style='width:" + percentage + "%'></div> </div> <br>";
	else
		html += "<div id='rating_bar'><div style='width:" + percentage + "%'></div> </div> <br>";
	}

/* 	if(the_word != "" && the_word != null) {
		html += "<div id='wordy'>" + the_word + "</div>";
	} */
	//html += "<div class='wordy'>" + the_word + "</div>";

	//html += "<div id='yelp'><a href='http://www.yelp.com/biz/" + yelp + "' target='_blank'><img src='http://static.px.yelp.com/static/20080513/i/new/developers/reviewsFromYelpYLW.gif' alt='Yelp Reviews' border='0'></a></div>"
	html += "<div id='yelp'><a href='http://www.yelp.com/biz/" + yelp + "' target='_blank'><img src='http://static.px.yelp.com/static/20080513/i/new/developers/reviewsFromYelpYLW.gif' alt='Yelp Reviews' border='0' onClick='javascript: pageTracker._trackPageview(\"/outgoing/yelp/" + yelp + "\");' ></a></div>"

	html += "</div>";

	GEvent.addListener(marker, 'click', function() {
		marker.openInfoWindowHtml(html);
		map.panTo(point);
		
			// THIS IS HOW IT WORKS IN THE SIDEBAR
			//lunches[id].openInfoWindowHtml(infoWinsCode[id]);
			//map.panTo(dots[id]);
			//** POST event on PK unique id**/
			cleanname=name.replace("'","`")
			pageTracker._trackPageview("/openWin/" + "'" + cleanname + "'");
		
		
	});
	
/* 	GEvent.addListener(marker[i], "click", function() {
marker[i].openInfoWindowHtml(label);
marker[i].visited = true;
GEvent.trigger(marker[i],"mouseout");
}); */


//marker[i] = new GMarker(point,{title:label, zIndexProcess:sendBack});
//map.addOverlay(marker);
//marker.setImage(icons["1"]);



/* 				GEvent.addListener(marker, 'mouseover', function() {
				marker.setImage(iconImageY);
				//document.getElementById("lunchList").getElementsByTagName("li").style.background-color = "yellow";
				//document.getElementsById("li1").style.background-color = "yellow";
				});
				
				GEvent.addListener(marker,'mouseout',function(){
				marker.setImage(iconImageB);
				//document.getElementById("lunchList").getElementsByTagName("li").style.background-color = "#EFEFEF";
				//document.getElementsById("li1").style.background-color = "#EFEFEF";
				}); */
	
	lunches.push(marker);
	dots.push(point);
	infoWinsCode.push(html);
	
	return marker;
}

