var block_content = '';

var beer_icon = new YImage();
beer_icon.src = 'http://media.tribecafilmfestival.org/images/stella_updated.jpg';
beer_icon.size = new YSize(42,65);

var subw_icon = new YImage();
subw_icon.src = 'http://media.tribecafilmfestival.org/designimages/orange_box.png';
subw_icon.size = new YSize(35,32);

var rest_icon = new YImage();
rest_icon.src = 'http://media.tribecafilmfestival.org/designimages/olive_box.png';
rest_icon.size = new YSize(35,32);

var hotel_icon = new YImage();
hotel_icon.src = 'http://media.tribecafilmfestival.org/designimages/purple_box.png';
hotel_icon.size = new YSize(35,32);

var theatre_icon = new YImage();
theatre_icon.src = 'http://media.tribecafilmfestival.org/designimages/+venue_blue_updated.png';
theatre_icon.size = new YSize(35,32);

// insert a <br /> befor "New York
line_break_hack = new RegExp("New York");

function AddMarker(NAME,ADDRESS,PHONE,DESC,URL,POINT_ID,POINT_TYPE) {
// set marker
switch (POINT_TYPE) {
case 'subway':
		k = subways.length;
		var m = new YMarker(ADDRESS,subw_icon);
		subways[k] = NAME;
		
		// add click action
		YEvent.Capture(m, EventsList.MouseClick,  function() {ShowDesc(m,DESC)} );
		
		m.addLabel('<div class="pin_label">S' + (k+1) + '</div>');
		
		map.addOverlay(m);
		// get stuff for the link block
		marker_ids = map.getMarkerIDs();
		// always the last marker ID
		marker_id = marker_ids[marker_ids.length-1];
		block_content += '<li><b class="subway">S' + (k+1) + ' - </b> <a href="#linky" onclick="DisplayMarker(\'' + marker_id + '\',\'' + escape(NAME) + '\',\'' + escape(ADDRESS) + '\',\'' + escape(DESC) + '\');return false">' + NAME + '</a>';
		// block_content += '&nbsp;' + ADDRESS;
		//block_content += '<a href="http://maps.yahoo.com/index.php#mvt=m&q1=' + escape(ADDRESS) + '" target="_blank">&raquo; Get Directions</a>';
		block_content += '</li>';
		break;
		case 'restaurant':
		k = restaurants.length;
		var m = new YMarker(ADDRESS,beer_icon);
		//This is where the replacement img could go)
		//var newMarker= new YMarker(geoPoint, createCustomMarkerImage());

restaurants[k] = NAME;

		// add click action
		YEvent.Capture(m, EventsList.MouseClick,  function() {ShowDesc(m,DESC)} );
		the_image="http://media.tribecafilmfestival.org/designimages/stella-for-maps.jpg";
		m.addLabel('<div class="pin_label" >SA' + (k+1) + '</div>');
		
		map.addOverlay(m);
		// get stuff for the link block
		marker_ids = map.getMarkerIDs();
		// always the last marker ID
		marker_id = marker_ids[marker_ids.length-1];
		block_content += '<li><b class="restaurant">SA' + (k+1) + ' - </b> <a href="#linky" onclick="DisplayMarker(\'' + marker_id + '\',\'' + escape(NAME) + '\',\'' + escape(ADDRESS) + '\',\'' + escape(DESC) + '\')">' + NAME + '</a><br /><img src="http://media.tribecafilmfestival.org/designimages/stella-for-maps.jpg">';
		block_content += ADDRESS.replace(line_break_hack,' New York') + ' ';
		// block_content += PHONE + '<br />';
		//block_content += '| <a href="'+ URL + '">&raquo; Read Review</a><br />';
		block_content += ' | <a href="http://maps.yahoo.com/index.php#mvt=m&q1=' + escape(ADDRESS) + '" target="_blank">&raquo; Get Directions</a>';
		block_content += '<br><br></li>';
		break;

case 'hotel':
		k = hotels.length;
		var m = new YMarker(ADDRESS,hotel_icon);
		hotels[k] = NAME;
		
		// add click action
		YEvent.Capture(m, EventsList.MouseClick,  function() {ShowDesc(m,DESC)} );
		
		m.addLabel('<div class="pin_label">H' + (k+1) + '</div>');
		
		map.addOverlay(m);
		// get stuff for the link block
		marker_ids = map.getMarkerIDs();
		// always the last marker ID
		marker_id = marker_ids[marker_ids.length-1];
		block_content += '<li><b class="hotel">H' + (k+1) + ' - </b> <a href="#linky" onclick="DisplayMarker(\'' + marker_id + '\',\'' + escape(NAME) + '\',\'' + escape(ADDRESS) + '\',\'' + escape(DESC) + '\')">' + NAME + '</a> | ';
		block_content += ADDRESS.replace(line_break_hack,' New York') + '';
		// block_content += PHONE + '<br />';
		//block_content += '<a href="'+ URL + '">&raquo; Read Review</a><br />';
		block_content += ' | <a href="http://maps.yahoo.com/index.php#mvt=m&q1=' + escape(ADDRESS) + '" target="_blank">&raquo; Get Directions</a><br /><br />';	
		block_content += '</li>';
		break;

case 'venue':
		k = hotels.length;
		var m = new YMarker(ADDRESS,theatre_icon);
		hotels[k] = NAME;
		
		// add click action
		YEvent.Capture(m, EventsList.MouseClick,  function() {ShowDesc(m,DESC)} );
		
		m.addLabel('<div class="pin_label">V' + (k+1) + '</div>');
		
		map.addOverlay(m);
		// get stuff for the link block
		marker_ids = map.getMarkerIDs();
		// always the last marker ID
		marker_id = marker_ids[marker_ids.length-1];
		
		//b.subway {color: #f37121; font-weight: normal;}
		block_content += '<li><span style="color: #0000ff; font-weight: normal;">V</span>' + (k+1) + ' - </b> <a href="#linky" onclick="DisplayMarker(\'' + marker_id + '\',\'' + escape(NAME) + '\',\'' + escape(ADDRESS) + '\',\'' + escape(DESC) + '\')">' + NAME + '</a> |';
		 block_content += ADDRESS.replace(line_break_hack,'| New York') + ' | ';
		 block_content += PHONE + '';
		//block_content += '| <a href="'+ $cms.content.outsideReviewURL + '">&raquo; Web Site</a>';
		//block_content += DESC;
		block_content += ' | <a href="http://maps.yahoo.com/index.php#mvt=m&q1=' + escape(ADDRESS) + '" target="_blank">&raquo; Get Directions</a>';
		block_content += '<br><br></li>';
		break;
/*
// theater
		default:
		theatre = new YMarker(ADDRESS,POINT_ID);
		// add click action
		YEvent.Capture(theatre, EventsList.MouseClick,  function() {ShowDesc(theatre,DESC)} );
		theatre.addLabel( '<div class="theatre_label">' + NAME + '</div>' );
		map.addOverlay(theatre);
		map.drawZoomAndCenter(ADDRESS, 3);
		marker_ids = map.getMarkerIDs();
		marker_id = marker_ids[marker_ids.length-1];
		//DisplayMarker(marker_id,escape(NAME),'','');
		break;*/
		} // end switch
		} // end AddMarker()


/**
* Change the selection
*/
function ChangeSection(SECTION) {
LoadLocations(locations,SECTION);
}

/**
* Open the Smart Window, and enter description
* @param mixed OBJ
* @param String DESC
*/
function ShowDesc(OBJ, DESC) {
OBJ.openSmartWindow(DESC);
}

/**
* Used by the links to display the location detail
* @param string MARKER_ID
* @param string NAME the name of the location
* @param String ADDRESS
* @param string DESC
*/
function DisplayMarker(MARKER_ID,NAME,ADDRESS,DESC) {
OBJ = map.getMarkerObject(MARKER_ID);
ShowDesc(OBJ,'<div>' + unescape(DESC) + '<div>');
} // end DisplayMarker()


/**
* Load all the locations <br />
* @param array LOCATION this is an array of all locations
* @param string  SECTIOn the section to load
*/
function LoadLocations(LOCATION,SECTION) {
// start by removing all the markers
//map.removeMarkersAll();
// reset lengths
subways = Array();
restaurants = Array();
hotels = Array();

// initiate block content
block_content = '<ul>';
// each location is:
// 0=> name, 1=> address, 2=> phone, 3=> description, 4=>Read Review url, 5=> point_id (not really used), 6=> point type
for (i=0;i<LOCATION.length;i++) {
if (LOCATION[i][6] == '' || LOCATION[i][6] == SECTION) {
AddMarker(LOCATION[i][0],LOCATION[i][1],LOCATION[i][2],LOCATION[i][3],LOCATION[i][4],LOCATION[i][5],LOCATION[i][6]);
}
}

block_content += '</ul>';
return block_content;
} // end LoadLocations()

function ChangeVenue(URL, isPopup) {
if (URL.length) {
if(isPopup == "true")
URL = URL + "?c=y&isPopup=true";

window.location.href = URL;
}
}
