

	// KML file location
	var KML_LOCATION = "assets/xml/ruby_tuesday.asp";
	var MIN_ZOOM_LEVEL = 4;
	var MAX_ZOOM_LEVEL = 18;
	
	// Option Constants
	var PHONE = 					"phone";
	var FAX = 						"fax";
	var HOUSE_CODE = 				"house_code";
	var PDF_TUEGO_MENU = 			"pdf_tuego_menu";
	var CATERING = 					"pdf_catering_menu";
	var ONLINE_RESERVATIONS = 		"onlineres";
	var ONLINE_RESERVATIONS_URL = 	"onlineres_url";
	var WINE = 						"have_wine";
	var BEER =						"have_beer";
	var LIQUOR = 					"have_liquor";
	var HAPPYHOUR = 				"prog_hh_4to7pm";
	var HAPPYHOUR_9_CLOSE =			"prog_hh_4to7_9toclose";
	var EARLY_SHOW_7_DAYS = 		"prog_earlyshow_7days";
	var EARLY_SHOW_MON_FRI = 		"prog_earlyshow_montofri";
	var GIMME_MINI = 				"prog_gimmemini";
	var BRUNCH = 					"prog_brunch";
	var MILITARY =					"prog_military";
	var CURBSIDE =					"curbside";
	var COLLEGE_CARD = 				"prog_collegecard";
	var BURGER_BAR = 				"prog_burgerbar";
	var DIN_MOVIE = 				"prog_dinmovie";
	var HOT_ADS = 					"prog_hotads";
	var HOT_KEY_CARDS = 			"prog_hotkeycards";
	var OPEN_MON_THUR = 			"hours_open_montothur";
	var CLOSE_MON_THUR = 			"hours_close_montothur";
	var HOURS_OPEN_FRI = 			"hours_open_fri";
	var HOURS_CLOSE_FRI = 			"hours_close_fri";
	var HOURS_OPEN_SAT = 			"hours_open_sat";
	var HOURS_CLOSE_SAT = 			"hours_close_sat";
	var HOURS_OPEN_SUN = 		 	"hours_open_sun";
	var HOURS_CLOSE_SUN	= 			"hours_close_sun";
	var LOCSTATUS	= 				"loc_status";
	var BRUNCH_MENU	= 				"brunch_menu";
	
	// Array of all the possible keys to search for in the KML file	(NOT USED)
	extendedDataKeys = [PHONE, FAX, HOUSE_CODE, PDF_TUEGO_MENU, CATERING, ONLINE_RESERVATIONS, ONLINE_RESERVATIONS_URL, WINE, BEER, LIQUOR, 
						HAPPYHOUR, HAPPYHOUR_9_CLOSE, EARLY_SHOW_7_DAYS,EARLY_SHOW_MON_FRI,GIMME_MINI,BRUNCH,MILITARY,CURBSIDE,COLLEGE_CARD,BURGER_BAR,
						DIN_MOVIE,HOT_ADS,HOT_KEY_CARDS,OPEN_MON_THUR,CLOSE_MON_THUR,HOURS_OPEN_FRI,HOURS_CLOSE_FRI,HOURS_OPEN_SAT,HOURS_CLOSE_SAT,
						HOURS_OPEN_SUN,HOURS_CLOSE_SUN,LOCSTATUS,BRUNCH_MENU];

	//optionKeys = 		[PDF_TUEGO_MENU, CATERING, ONLINE_RESERVATIONS_URL, WINE, BEER, LIQUOR, HAPPYHOUR, HAPPYHOUR_9_CLOSE, EARLY_SHOW_7_DAYS, EARLY_SHOW_MON_FRI,GIMME_MINI,BRUNCH,MILITARY,COLLEGE_CARD,BURGER_BAR];
						
	optionKeys = 		[PDF_TUEGO_MENU, CATERING, ONLINE_RESERVATIONS_URL, WINE, BEER, LIQUOR, BRUNCH, MILITARY, CURBSIDE];
					
	// Descriptions	
	optionNames = new Object();
	optionNames[PDF_TUEGO_MENU] = "RubyTueGo Service Available";
	optionNames[CATERING] = "Catering Service Available";
	optionNames[ONLINE_RESERVATIONS] = "Online Reservations Available";
	optionNames[ONLINE_RESERVATIONS_URL] = "Online Reservations Available";
	optionNames[WINE] = "Serves Wine";
	optionNames[BEER] = "Serves Beer";
	optionNames[LIQUOR] = "Serves Liquor";
	optionNames[HAPPYHOUR] = "Happy Hour";
	optionNames[HAPPYHOUR_9_CLOSE] = "Happy Hour 4P - 7P &amp; 9P - Close";
	optionNames[EARLY_SHOW_7_DAYS] = "Buy One Entr&eacute;e Get One Free 3:30P - 5:30P Everyday";
	optionNames[EARLY_SHOW_MON_FRI] = "Buy One Entr&eacute;e Get One Free 3:30P - 5:30P, Mon - Fri";
	optionNames[BRUNCH] = "Now Serving Brunch";
	optionNames[GIMME_MINI] = "Free Mini Burger at the bar 9P";
	optionNames[MILITARY] = "10% Military Discount";
	optionNames[CURBSIDE] = "Curbside Service";
	optionNames[COLLEGE_CARD] = "College ID Discount";
	optionNames[BURGER_BAR] = "Burger Bar planned location, 9P, build your burger at the bar.";

	
	// Global style object for applying styles to placemark elements in the KML
	placemarkStyles = new Object();
	
	





	// Parses window location to retreive $_GET['id'] essentially, type checks for an integer
	function get_id() {
		var id = window.location.href.split('?');
		var tmp = ( id.length == 2 ) ?  id[1].split('=') : '';
		id = (  tmp.length == 2 ) ? parseInt(tmp[1]) : '';
		id = ( typeof id == 'number' ) ?  id : '';	
		return id;
	}
	


	
	
	// Creates the GMarker with popup, etc
	function create_pin(loc,useBalloon) {
												
		// Style object, if exists
		var style = placemarkStyles[loc.styleId];
		
		if ( typeof style != 'undefined' ) {
						
			var icon = new GIcon(G_DEFAULT_ICON);
			
			if ( typeof style.iconStyle.icon != 'undefined' || style.iconStyle.icon != '' ) {
				icon.image = style.iconStyle.icon;
			}		
			
			var options = {
				title: 	loc.name,
				icon: 	icon 
			}
			
		} else {
			
			var options = {
				title: 	loc.name
			}
			
		}
		
		var iconX = new GIcon(G_DEFAULT_ICON);		
		iconX.image = 'images/rt_icon.png';
		iconX.iconAnchor = new GPoint(12, 24);
		//iconX.iconAnchor = new GPoint(21, 46);
    	iconX.infoWindowAnchor = new GPoint(21, 10);
    	iconX.iconSize = new GSize(34, 25);
		iconX.shadow = 'images/rt_icon_shadow.png';
		iconX.shadowSize = new GSize(34, 25);
		var options = {icon: iconX };
		
		// Create the marker itself, attaching a balloon if using one
		var marker = new GMarker(loc.point, options);
	//	if ( useBalloon ) marker.bindInfoWindowHtml(loc.description);
		if ( useBalloon ){
			
			GEvent.addListener(marker,"click", function() {
			displayPoint(loc);
			});
		}else{
			GEvent.addListener(marker,"click", function() {
			goToDetails(loc);
			});
		}


		
		return marker; 
	}
	function panMapView(Lat,Lng){
		//alert(Lat+" "+Lng);
		closeX();
		var tempx2=new GLatLng(Lng, Lat);
		map.panTo(new GLatLng(Lng, Lat));
		for (x in sideListArray){
			//alert(tempx2+'/'+sideListArray[x].point);
			if(Lng == sideListArray[x].pointX && Lat == sideListArray[x].pointY){
				var targetItemX = x;
			}
		}

		displayPoint(sideListArray[targetItemX]);
		//alert('test');
	}
	function goToDetails(loc){
		//if(document.location.hash == "#test"){
			// pan window
			map.panTo(loc.marker.getLatLng());
			renderDetails(loc);
		//}
	}
	function closeX(){
		$('#map_message').hide();
	}
	function displayPoint(loc){
		if ($('#map_message').is(':hidden')) $('#map_message').fadeIn();
		else $('#map_message').hide();

		var moveEnd = GEvent.addListener(map, "moveend", function() {
			var markerOffset = map.fromLatLngToDivPixel(loc.marker.getLatLng());
			var locdescription = loc.description.replace(", ", "<br />");
			//if(document.location.hash == "#test" && loc.extendedData[LOCSTATUS] != ""){
			if(loc.extendedData[LOCSTATUS] != ""){
				var htmlToPrint = '<div class="googleArrow"></div><div class="googlePop"><input type="button" value="" class="closeButton" onClick="closeX();" /><p class="googleTitle">'+loc.name+'</p><p>'+loc.extendedData[LOCSTATUS]+'</p><p><a href="locations_details.asp?id='+loc.extendedData[HOUSE_CODE]+'">See Details</a></p><p><a href="http://maps.google.com/maps?saddr='+addressX+'&daddr='+loc.point+'('+loc.address+' '+loc.cityStateZip+')" target="_blank">Get Driving Directions</a></p></div>';
			}else{
				var htmlToPrint = '<div class="googleArrow"></div><div class="googlePop"><input type="button" value="" class="closeButton" onClick="closeX();" /><p class="googleTitle">'+loc.name+'</p>'+locdescription+'<p><a href="http://maps.google.com/maps?saddr='+addressX+'&daddr='+loc.point+'('+loc.address+' '+loc.cityStateZip+')" target="_blank">Get Driving Directions</a></p></div>';
			}
			
			$("#map_message")
				.html(htmlToPrint)
				.fadeIn()
				.css({ top:markerOffset.y-50, left:markerOffset.x+26 });
			GEvent.removeListener(moveEnd);
		});
		map.panTo(loc.marker.getLatLng());
		gotoItemByPoint(loc.point);
	}
	
	//getDistance(m1.getPoint(),m2.getPoint());
	function getDistance(p1,p2){
		var rawDistance = p1.distanceFrom(p2);
		var kilometers = rawDistance/1000;
		var miles = ((kilometers *  0.621371192)*10)/10;
		return miles;
	}
	
	
	// Returns array of all location objects that are within the viewport
	function nearest_matches(centerPoint, radius, markers, limit) {
		
		limit = limit == 0 ? false : limit;
		var num_matches = 0;
		
		// Search all points and display those that are in radius ( using km here, distanceFrom() returns meters )
		var searchMarkers = [];
		for ( i = 0; i < markers.length; i++ ) {
			if ( markers[i].marker.getLatLng().distanceFrom(centerPoint) / 1000 <= radius && markers[i].marker.getLatLng().distanceFrom(centerPoint) / 1000 > 0.001) {
				if ( limit && ++num_matches > limit ) {
					return searchMarkers;
				}else{
					searchMarkers.push(markers[i]);
				}	
			}
		}
		
		return searchMarkers;
		
	}
	// Returns array of all location objects that are within the viewport
	function nearest_matchesAll(centerPoint, radius, markers, limit, state) {
		
		limit = limit == 0 ? false : limit;
		var num_matches = 0;
		var tempAddy = '';
		// Search all points and display those that are in radius ( using km here, distanceFrom() returns meters )
		var searchMarkers = [];
		for ( i = 0; i < markers.length; i++ ) {
			if ( markers[i].marker.getLatLng().distanceFrom(centerPoint) / 1000 <= radius) {
				if ( limit && ++num_matches > limit ) {
					return searchMarkers;
				}else{
					tempAddy = markers[i].cityStateZip;
					if(state != undefined){
						if (tempAddy.indexOf(" "+state+" ")!=-1){
							searchMarkers.push(markers[i]);
						}
					}else{
						searchMarkers.push(markers[i]);
					}
				}	
			}
		}
		
		return searchMarkers;
		
	}
	
	function sortASC(a, b){ return (a-b); }
	
	// Returns array of all location objects that are within the viewport
	function nearest_matcheslocations(centerPoint, radius, markers, limit,state) {
		
		limit = limit == 0 ? false : limit;
		var num_matches = 0;
		var tempAddy = '';
		// Search all points and display those that are in radius ( using km here, distanceFrom() returns meters )
		var searchMarkers = [];
		for ( i = 0; i < markers.length; i++ ) {
			if ( markers[i].marker.getLatLng().distanceFrom(centerPoint) / 1000 <= radius ) {
				if ( limit && ++num_matches > limit ){
					return searchMarkers;
				}else{
					tempAddy = markers[i].cityStateZip;
					if(state != undefined){
						if (tempAddy.indexOf(" "+state+" ")!=-1){
							searchMarkers.push(markers[i]);
						}
					}else{
						searchMarkers.push(markers[i]);
					}
				}
			}
		}
		
		return searchMarkers;
		
	}
	
	// Updates UI to reflect number of pins shown within search radius
		function updateStatus(matches) {
			$('#location_storenumber').html(matches);
		}
		
		
	
	// Takes map viewport, calls nearest_matches to find pins to drop on map, and actually adds the pins to the map
	function update_map(map,markers,homeMarker) {
		closeX();	
		// Map bounds, as GLatLngBounds object
		var bounds = map.getBounds();
		
		for ( var i = 0; i < markers.length; i++ ) {
		
			var m = markers[i];
			
			// Should be on map but isn't
			if ( bounds.containsLatLng(m.marker.getLatLng()) ) {
				if ( !m.onMap ) {
					map.addOverlay(m.marker);
					m.onMap = true;
				}
			} 
			
			// Is on map and shouldn't be
			else {
				if ( m.onMap ) {
					map.removeOverlay(m.marker);
					m.onMap = false;
				}
			}
		}
		if(document.location.hash == "#test"){
			//alert(markers.length);
		}
		updateStatus(markers.length);				
	}


	// Just shows the search markers
	function show_search_markers(map,markers,homeMarker) {
		//closeX();
		var bounds = map.getBounds();
		// Remove all other markers and redrop the homeMarker
		map.clearOverlays();
		if(homeMarker){
			map.addOverlay(homeMarker);
		}
		//$('#map_message').hide();
		// Draw only markers for viewable map area
		for ( var i = 0; i < markers.length; i++ ) {
			var m = markers[i];
			if ( bounds.containsLatLng(m.marker.getLatLng()) ) {
				map.addOverlay(markers[i].marker);
			}
		}

	}
	
		// Just shows the search markers
	function show_search_markersAll(map,markers,homeMarker) {
		var bounds = map.getBounds();
		// Remove all other markers and redrop the homeMarker
		map.clearOverlays();
		$('#map_message').hide();
		// Draw only markers for viewable map area
		for ( var i = 0; i < markers.length; i++ ) {
			var m = markers[i];
			if ( bounds.containsLatLng(m.marker.getLatLng()) ) {
				map.addOverlay(markers[i].marker);
			}
		}

	}




	// So user won't zoom out a ton and have thousands of markers on the map
	function restrict_map_zoom(map,min,max) {
		var types = map.getMapTypes();
		for ( var i = 0; i < types.length; i++ ) {
			types[i].getMinimumResolution = function () { return min; };
			types[i].getMaximumResolution = function () { return max; };
		}
	}





	
	// Grabs the correct node from the array of Location objects, returns a Location object
	function get_data(id,markers) {
		for ( var i = 0; i < markers.length; i++ ) {
			if ( markers[i].extendedData[HOUSE_CODE] == id ) {
				return markers[i];
			}
		}
	}




	
	
	
	// Just parses the KML into an array of Location object
	function parse_kml(kml,useBalloon) {
		
		// Index 0 will be style information (and header), 1 and on is placemark objects
		var places = kml.replace(/<\/Placemark>/gi, '').split('<Placemark>');
		
		// Parse the styles at the beginning of the document
		var styles = places[0].replace(/<\/Style>/gi, '').split(/<Style id="/ig);
		for ( var i = 1; i < styles.length; i++ ) {
			
			// Style id
			var id = styles[i].split('">')[0];
			
			// Store the properties on this style id
			placemarkStyles[id] = new Object();
			placemarkStyles[id].iconStyle = new Object();
			placemarkStyles[id].iconStyle.labelStyle = new Object();
			
			// Look for icon label styles
			var iconStyle = styles[i].split(/<\/IconStyle>/i)[0].split(/<IconStyle>/i);
			iconStyle = ( iconStyle.length > 1 ) ? iconStyle[1] : '';
		
			var labelStyles = styles[i].split(/<\/IconStyle>/i)
			labelStyles = ( labelStyles.length > 1 ) ?  labelStyles[1].split(/<LabelStyle>/i) : '';
			labelStyles = ( labelStyles.length > 1 ) ? labelStyles[1].split(/<\/LabelStyle>/i)[0] : '';
		
			var labelScale = labelStyles.split(/<scale>/i);
			labelScale = ( labelScale.length > 1 ) ? labelScale[1].split(/<\/scale>/i)[0] : '';
			placemarkStyles[id].iconStyle.labelStyle.labelScale = labelScale;
			
			// Look for the icon itself
			var icon = iconStyle.split(/<Icon>/i);
			icon = ( icon.length > 1 ) ? icon[1].split(/<href>/i)[1].split(/<\/href>/i)[0] : '';
			placemarkStyles[id].iconStyle.icon = icon;
			
		} 
				
		
		
		
		
		// Now deal with each placemark itself
		var markers = [];
		
		// Start with 1 as index 0 is all the style information
		for ( var i = 1; i < places.length; i++ ) {
		
			// For convenience
			var place = places[i];
		
			// Stores all the info
			var loc = new Location();
		
			// Strip away tags and find all the data I want to store
			loc.name = place.split('<name>')[1].split('<![CDATA[')[1].split(']]>')[0];
			//loc.description = place.split('<description>')[1].split('<![CDATA[')[1].split(']]>')[0];
			loc.address = place.split('<address>')[1].split('<![CDATA[')[1].split(']]>')[0];
			loc.cityStateZip = loc.address.split(',')[1];
			loc.address = loc.address.split(',')[0];
			
			// Find the style information
			var styleId = place.split(/<\/styleUrl>/i);
			styleId = ( styleId.length > 1 ) ? styleId[0].split(/<styleUrl>/i)[1].replace(/#/gi, '') : '';
			loc.styleId = styleId;
		
			// Store the latitude and longitude
			var coordinates = place.split('<Point>')[1].split('<coordinates>')[1].split('</coordinates>')[0].split(',');
			loc.point = new GLatLng(coordinates[1],coordinates[0]);
			loc.pointX = coordinates[1];
			loc.pointY = coordinates[0];
			// Store the extended store data, will contain all the option nodes itself
			var extendedDataString = place.split('<extendeddata>')[1].split('</extendeddata>')[0];		
			var extendedData = new Object();
			
			//	Hideous!
			//	For some reason, looping over an array of keys (even with only 1 key) caused a timeout and crap in browser
			// 	Doing it one by one caused no issue at all.  For performance and lack of time to further debug, doing with this.
			
			extendedData[PHONE] = extendedDataString.split('<data name="data"><value>a[');
			extendedData[PHONE] = extendedData[PHONE].length == 2 ? extendedData[PHONE][1].split(']')[0] : '';
			
			extendedData[FAX] = extendedDataString.split(',b[');
			extendedData[FAX] = extendedData[FAX].length == 2 ? extendedData[FAX][1].split(']')[0] : '';
			
			extendedData[HOUSE_CODE] = extendedDataString.split(',c[');
			extendedData[HOUSE_CODE] = extendedData[HOUSE_CODE].length == 2 ? extendedData[HOUSE_CODE][1].split(']')[0] : '';
			
			extendedData[PDF_TUEGO_MENU] = extendedDataString.split(',d[');
			extendedData[PDF_TUEGO_MENU] = extendedData[PDF_TUEGO_MENU].length == 2 ? extendedData[PDF_TUEGO_MENU][1].split(']')[0] : '';
			extendedData[PDF_TUEGO_MENU] = extendedData[PDF_TUEGO_MENU].replace(/\s/g, '_');			// Remove spaces
			extendedData[PDF_TUEGO_MENU] = (extendedData[PDF_TUEGO_MENU] != '' ) ? extendedData[PDF_TUEGO_MENU] + '' : '';	// Make pdf extension
			
			extendedData[CATERING] = extendedDataString.split(',e[');
			extendedData[CATERING] = extendedData[CATERING].length == 2 ? extendedData[CATERING][1].split(']')[0] : '';
			
			extendedData[ONLINE_RESERVATIONS] = extendedDataString.split(',f[');
			extendedData[ONLINE_RESERVATIONS] = extendedData[ONLINE_RESERVATIONS].length == 2 ? extendedData[ONLINE_RESERVATIONS][1].split(']')[0] : '';
			
			extendedData[ONLINE_RESERVATIONS_URL] = extendedDataString.split(',g[');
			extendedData[ONLINE_RESERVATIONS_URL] = extendedData[ONLINE_RESERVATIONS_URL].length == 2 ? extendedData[ONLINE_RESERVATIONS_URL][1].split(']')[0] : '';
			
			extendedData[WINE] = extendedDataString.split(',h[');
			extendedData[WINE] = extendedData[WINE].length == 2 ? extendedData[WINE][1].split(']')[0] : '';
			
			extendedData[BEER] = extendedDataString.split(',i[');
			extendedData[BEER] = extendedData[BEER].length == 2 ? extendedData[BEER][1].split(']')[0] : '';
			
			extendedData[LIQUOR] = extendedDataString.split(',j[');
			extendedData[LIQUOR] = extendedData[LIQUOR].length == 2 ? extendedData[LIQUOR][1].split(']')[0] : '';
			
			extendedData[HAPPYHOUR] = extendedDataString.split(',j1[');
			extendedData[HAPPYHOUR] = extendedData[HAPPYHOUR].length == 2 ? extendedData[HAPPYHOUR][1].split(']')[0] : '';
			
			//extendedData[HAPPYHOUR] = extendedDataString.split('<data name="'+HAPPYHOUR+'"><value>');
			//extendedData[HAPPYHOUR] = extendedData[HAPPYHOUR].length == 2 ? extendedData[HAPPYHOUR][1].split('</value>')[0] : '';
			
			//extendedData[HAPPYHOUR_9_CLOSE] = extendedDataString.split('<data name="'+HAPPYHOUR_9_CLOSE+'"><value>');
			//extendedData[HAPPYHOUR_9_CLOSE] = extendedData[HAPPYHOUR_9_CLOSE].length == 2 ? extendedData[HAPPYHOUR_9_CLOSE][1].split('</value>')[0] : '';
			
			//extendedData[EARLY_SHOW_7_DAYS] = extendedDataString.split('<data name="'+EARLY_SHOW_7_DAYS+'"><value>');
			//extendedData[EARLY_SHOW_7_DAYS] = extendedData[EARLY_SHOW_7_DAYS].length == 2 ? extendedData[EARLY_SHOW_7_DAYS][1].split('</value>')[0] : '';
			
			//extendedData[EARLY_SHOW_MON_FRI] = extendedDataString.split('<data name="'+EARLY_SHOW_MON_FRI+'"><value>');
			//extendedData[EARLY_SHOW_MON_FRI] = extendedData[EARLY_SHOW_MON_FRI].length == 2 ? extendedData[EARLY_SHOW_MON_FRI][1].split('</value>')[0] : '';
			
			//extendedData[GIMME_MINI] = extendedDataString.split('<data name="'+GIMME_MINI+'"><value>');
			//extendedData[GIMME_MINI] = extendedData[GIMME_MINI].length == 2 ? extendedData[GIMME_MINI][1].split('</value>')[0] : '';
			
			extendedData[BRUNCH] = extendedDataString.split(',j2[');
			extendedData[BRUNCH] = extendedData[BRUNCH].length == 2 ? extendedData[BRUNCH][1].split(']')[0] : '';
			
			extendedData[MILITARY] = extendedDataString.split(',k[');
			extendedData[MILITARY] = extendedData[MILITARY].length == 2 ? extendedData[MILITARY][1].split(']')[0] : '';
			
			extendedData[CURBSIDE] = extendedDataString.split(',l[');
			extendedData[CURBSIDE] = extendedData[CURBSIDE].length == 2 ? extendedData[CURBSIDE][1].split(']')[0] : '';
			
			//extendedData[COLLEGE_CARD] = extendedDataString.split('<data name="'+COLLEGE_CARD+'"><value>');
			//extendedData[COLLEGE_CARD] = extendedData[COLLEGE_CARD].length == 2 ? extendedData[COLLEGE_CARD][1].split('</value>')[0] : '';
			
			//extendedData[BURGER_BAR] = extendedDataString.split('<data name="'+BURGER_BAR+'"><value>');
			//extendedData[BURGER_BAR] = extendedData[BURGER_BAR].length == 2 ? extendedData[BURGER_BAR][1].split('</value>')[0] : '';
			
			//extendedData[DIN_MOVIE] = extendedDataString.split('<data name="'+DIN_MOVIE+'"><value>');
			//extendedData[DIN_MOVIE] = extendedData[DIN_MOVIE].length == 2 ? extendedData[DIN_MOVIE][1].split('</value>')[0] : '';
			
			//extendedData[HOT_ADS] = extendedDataString.split('<data name="'+HOT_ADS+'"><value>');
			//extendedData[HOT_ADS] = extendedData[HOT_ADS].length == 2 ? extendedData[HOT_ADS][1].split('</value>')[0] : '';
			
			//extendedData[HOT_KEY_CARDS] = extendedDataString.split('<data name="'+HOT_KEY_CARDS+'"><value>');
			//extendedData[HOT_KEY_CARDS] = extendedData[HOT_KEY_CARDS].length == 2 ? extendedData[HOT_KEY_CARDS][1].split('</value>')[0] : '';
			
			extendedData[OPEN_MON_THUR] = extendedDataString.split(',m[');
			extendedData[OPEN_MON_THUR] = extendedData[OPEN_MON_THUR].length == 2 ? extendedData[OPEN_MON_THUR][1].split(']')[0] : '';
			
			extendedData[CLOSE_MON_THUR] = extendedDataString.split(',n[');
			extendedData[CLOSE_MON_THUR] = extendedData[CLOSE_MON_THUR].length == 2 ? extendedData[CLOSE_MON_THUR][1].split(']')[0] : '';
			
			extendedData[HOURS_OPEN_FRI] = extendedDataString.split(',o[');
			extendedData[HOURS_OPEN_FRI] = extendedData[HOURS_OPEN_FRI].length == 2 ? extendedData[HOURS_OPEN_FRI][1].split(']')[0] : '';
			
			extendedData[HOURS_CLOSE_FRI] = extendedDataString.split(',p[');
			extendedData[HOURS_CLOSE_FRI] = extendedData[HOURS_CLOSE_FRI].length == 2 ? extendedData[HOURS_CLOSE_FRI][1].split(']')[0] : '';
			
			extendedData[HOURS_OPEN_SAT] = extendedDataString.split(',q[');
			extendedData[HOURS_OPEN_SAT] = extendedData[HOURS_OPEN_SAT].length == 2 ? extendedData[HOURS_OPEN_SAT][1].split(']')[0] : '';
			
			extendedData[HOURS_CLOSE_SAT] = extendedDataString.split(',r[');
			extendedData[HOURS_CLOSE_SAT] = extendedData[HOURS_CLOSE_SAT].length == 2 ? extendedData[HOURS_CLOSE_SAT][1].split(']')[0] : '';
			
			extendedData[HOURS_OPEN_SUN] = extendedDataString.split(',s[');
			extendedData[HOURS_OPEN_SUN] = extendedData[HOURS_OPEN_SUN].length == 2 ? extendedData[HOURS_OPEN_SUN][1].split(']')[0] : '';
			
			extendedData[HOURS_CLOSE_SUN] = extendedDataString.split(',t[');
			extendedData[HOURS_CLOSE_SUN] = extendedData[HOURS_CLOSE_SUN].length == 2 ? extendedData[HOURS_CLOSE_SUN][1].split(']')[0] : '';
			
			extendedData[LOCSTATUS] = extendedDataString.split(',u[');
			extendedData[LOCSTATUS] = extendedData[LOCSTATUS].length == 2 ? extendedData[LOCSTATUS][1].split(']')[0] : '';
			
			extendedData[BRUNCH_MENU] = extendedDataString.split(',v[');
			extendedData[BRUNCH_MENU] = extendedData[BRUNCH_MENU].length == 2 ? extendedData[BRUNCH_MENU][1].split(']')[0] : '';
			extendedData[BRUNCH_MENU] = extendedData[BRUNCH_MENU].replace(/\s/g, '_');			// Remove spaces	
			
			// ballow description
			loc.description = '<p>'+loc.address+'<br />'+loc.cityStateZip+'</p><p class="phoneNumber">'+extendedData[PHONE]+'</p><p><a href="locations_details.asp?id='+extendedData[HOUSE_CODE]+'">See Details</a></p>';
			
			// Store the extendedData on the Location object itself
			loc.extendedData = extendedData
					
			// Create pin and store overall object
			loc.marker = create_pin(loc,useBalloon);
			markers.push(loc);
		}

		return markers;
	}
	
	
	
	
	
	
	
	
	// Location object
	function Location() {
	
		var l = new Object();
		l.name = "Example Location";
		
		l.address = "1234 Somewhere Lane";
		l.cityStateZip = "Knoxville, TN 37919";
				
		l.marker = null;
		l.onMap = false;
		
		l.extendedData = new Object();
		
		return l;
	}