// $Id: gmap.js 2182 2009-08-09 22:24:50Z dhh $


// All google map related stuff goes here


	var f_expand_img = "/images/system/overexpand.gif";
	var f_contract_img = "/images/system/overcontract.gif";

        var icon = new GIcon();
        icon.image = "/images/system/mm_20_red.png";
        icon.shadow = "/images/system/mm_20_shadow.png";
        icon.iconSize = new GSize(12, 20);
        icon.shadowSize = new GSize(22, 20);
        icon.iconAnchor = new GPoint(6, 20);
        icon.infoWindowAnchor = new GPoint(5, 1);

	var i_act = new GIcon();
	i_act.image = "/images/system/mm_20_orange.png";
        i_act.shadow = "/images/system/mm_20_shadow.png";
        i_act.iconSize = new GSize(12, 20);
        i_act.shadowSize = new GSize(22, 20);
        i_act.iconAnchor = new GPoint(6, 20);
        i_act.infoWindowAnchor = new GPoint(5, 1);


        var i_cs = new GIcon();
        i_cs.image = "/images/system/mm_20_gray.png";
        i_cs.shadow = "/images/system/mm_20_shadow.png";
        i_cs.iconSize = new GSize(12, 20);
        i_cs.shadowSize = new GSize(22, 20);
        i_cs.iconAnchor = new GPoint(6, 20);
        i_cs.infoWindowAnchor = new GPoint(5, 1);

        var i_fu = new GIcon();
        i_fu.image = "/images/system/mm_20_white.png";
        i_fu.shadow = "/images/system/mm_20_shadow.png";
        i_fu.iconSize = new GSize(12, 20);
        i_fu.shadowSize = new GSize(22, 20);
        i_fu.iconAnchor = new GPoint(6, 20);
        i_fu.infoWindowAnchor = new GPoint(5, 1);




//	var pt_world = new GLatLng(9.45, -96);
	var pt_world = new GLatLng(37, -96);
	var pt_americas = new GLatLng(38, -103);
	var pt_europe = new GLatLng(44.71, 10.28);
	var pt_pacific = new GLatLng(-28, 170);

	var ctrl_small = new GSmallMapControl();
	var ctrl_large = new GLargeMapControl();
	var ctrl_scale = new GScaleControl();
	var ctrl_type = new GMapTypeControl();
	var ctrl_overview = new GOverviewMapControl();

	var current_point_idx;

	var current_point;
	var current_zoom;
	var current_map;


	var prev_zoom;

	var outside = 'Propaganda';

	var stddiv = '<div class="gm_div">';
	var stddiv_small = '<div class="gm_div_small">';



function loadGMap(what){

	if (GBrowserIsCompatible()) {
		if (ge('Propaganda_Propaganda::image')){
			ge('Propaganda_Propaganda::image').setAttribute('align', 'center');
		}
		var gm = ge("gmap");
		if (what != 'world'){
			gm.style.width = '736px';
			gm.style.height = '344px';
		} else {
			gm.style.width = '736px';
			gm.style.height = '540px';
		}
		if (map){
			map = null;
		}
		map = new GMap2(gm);
		map.addControl(ctrl_small);
		map.addControl(ctrl_type);
		map.addControl(ctrl_overview);
		ctrl_overview.hide();
		map.addControl(ctrl_scale);
		map.enableContinuousZoom();
		map.enableDoubleClickZoom();
		map.addControl(new Continents());
		map.addControl(new Filters());
		outside = 'Propaganda';
		if (what == 'world'){
			world();
 			GEvent.addListener(map, "moveend", function() {
 				var center = map.getCenter();
				var zlevel = map.getZoom();
			});

		} else {
			outside = 'Destination';
			zoom(getCurrentPointIdxByObjectId(current_object),'locality');
		}
		map_prep_show_all();
		addOverlays();
		if (what == 'world'){
			var ip = find_first_point();
			if (ip){
				dest_click(ip);
			}
		}
	}

}


function getCurrentPointIdxByObjectId (object_id){
	for (var i = 0; i<points.length; i++){
		if (points[i].object_id == object_id){
			return i;
		}
	}
	return -1;
}

function americas (){
	map_hideFilters();
	map.closeInfoWindow();
	map.setCenter(pt_americas, 3, G_NORMAL_MAP);
	reset_backlink();
	current_zoom = 'region';
	map_btns_update('americas');
}

function europe (){
	map_hideFilters();
	map.closeInfoWindow();
	map.setCenter(pt_europe, 4, G_NORMAL_MAP);
	reset_backlink();
	current_zoom = 'region';
	map_btns_update('europe');

}

function pacific (){
	map_hideFilters();
	map.closeInfoWindow();
	map.setCenter(pt_pacific, 3, G_NORMAL_MAP);
	reset_backlink();
	current_zoom = 'region';
	map_btns_update('pacific');
}

function world (){
	map_hideFilters();
	map.closeInfoWindow();
	map.setCenter(pt_world, 2,G_NORMAL_MAP);
	reset_backlink();
	current_zoom = 'world';
	map_btns_update('world');

}


function map_btns_update (c) {
	

	ge('map_europe_btn').style.fontWeight = 'normal';
	ge('map_europe_btn').style.border = 'outset 1px #000';

	ge('map_pacific_btn').style.fontWeight = 'normal';
	ge('map_pacific_btn').style.border = 'outset 1px #000';

	ge('map_americas_btn').style.fontWeight = 'normal';
	ge('map_americas_btn').style.border = 'outset 1px #000';

	ge('map_world_btn').style.fontWeight = 'normal';
	ge('map_world_btn').style.border = 'outset 1px #000';

	if(c) {
		ge('map_'+c+'_btn').style.fontWeight = 'bold';
		ge('map_'+c+'_btn').style.border = 'inset 1px #000';
	}

}

function dest_click (i) {

	map_hideFilters();

	current_point_idx = i;
	make_info_window(i);
	set_backlink(i);
	prev_zoom = current_zoom;
	map.savePosition();
	map_btns_update();
}

function a_click (i) {
	make_attraction_window(i);
}


function reset_backlink(){
	current_point_idx = null;
	ge('backlink').style.display = 'none';
}

function back_to_link(){
	zoom(current_point_idx, current_zoom);
}

function set_backlink(i){
return;
	var p = points[i];
	if(p.name.length > 15) {
		ge('backlink').innerHTML = jssm['map']['got_lost_start'] + ' ' + p.name.substring(0,15);
	} else if (p.name.length > 4) {
		ge('backlink').innerHTML = jssm['map']['got_lost_start'] + ' ' + p.name;
	} else {
		ge('backlink').innerHTML = jssm['map']['got_lost_start'] + ' ' + p.name + ' ' + jssm['map']['got_lost_end'];
	}
	
	ge('backlink').style.display = '';
	ge('backlink').className = 'hor_btn_back';
	ge('backlink').onclick = back_to_link;
	//ge('backlink').onclick = back_to_link;
}

function make_info_window(i){

	var p = points[i];
//FIXME: Languages for Info tab
	var infoTabs = new Array;
	var info = p.name + '<br/>';
	var nav = "";
	var inventory = "";
	var activities = "";
	var todo = "";
//	var todo_start = '<p>Local attractions that we can pre-book for you when you book the destination (the facility will be available in members area soon).</p>';
	var todo_start = '';
	var zfunc;
	var tfunc = 'gogo_tour(0, '+i+',1); return false;';
	var yfunc = 'return yoyo_frommap(\''+p.object_id+'\',\'Destination\',\''+p.uri+'\');';
	var info_head = 'Info';
	var zoom_word;
//	var full_details_link = "[<a href = \"javascript:void(0);\" onclick = \""+yfunc+"\">" + jssm['map']['show_full_details_start'] + "</a>] " + jssm['map']['show_full_details_end'];
	var full_details_link = "[<a href = \"javascript:void(0);\" onclick = \""+yfunc+"\">" + jssm['map']['show_full_details_start'] + "</a>]";

	if (current_zoom == 'area' || current_zoom == 'locality' || current_zoom == 'property'){
		if (p.name == 'Paris'){
			var sfunc = 'show_att_markers(); return false;';
			todo = stddiv;
			todo += '<table><tr>';
			todo +=  '<td class=\'gm_td\'>';
			todo += todo_start;
			todo += '</td></tr></table>';
			todo += "<br/>";
			todo += "[<a href = \"javascript:void(0);\" onclick = \""+tfunc+"\">Start guided tour</a>]";
			todo += "<br/><br/>";
//			todo += "[<a href = \"javascript:void(0);\" onclick = \""+sfunc+"\">" + jssm['map']['show_markers'] + "</a>]";
		}		

	}
	var fl= '';
	if (p.readiness == 'active' || p.readiness == 'coming'){
		if (current_object != p.object_id ){
			 fl = "<br/>" + full_details_link;
		}
	}


	if (current_zoom == 'area'){
		info = '';
		if ((p.readiness == 'active') && (outside == 'Propaganda' || current_object == p.object_id)){
			zfunc  = 'zoom('+i+',\'property\'); return false;';
			zoom_word = jssm['map']['zoom_in'];
			info += "[<a href = \"javascript:void(0);\" onclick = \""+zfunc+"\">" + zoom_word + ' ' + jssm['map']['zoom_to_p'] + "</a>]";
		}
		info += fl;
		info += stddiv;
		info_head = jssm['map']['area_info_title'];
		info += '<table><tr>';
		info += '<td class=\'gm_td\'>' + p.area_info;
		
		info += '</td>';
		info += '<td valign=\'top\'><img src=\'/images/'+p.area_img+'\' height=93 width=125></td></tr></table>';
	} else if (current_zoom == 'locality'){
		info = '';
		if (p.readiness == 'active' && (outside == 'Propaganda' || current_object == p.object_id)){
			zfunc  = 'zoom('+i+',\'property\'); return false;';
			zoom_word = jssm['map']['zoom_in'];
			info += "[<a href = \"javascript:void(0);\" onclick = \""+zfunc+"\">" + zoom_word + ' ' + jssm['map']['zoom_to_p'] + "</a>]";
		}
		info += fl;
		info += stddiv;
		info_head = jssm['map']['locality_info'];

		info += '<table><tr>';
		info += '<td class=\'gm_td\'>' + p.locality_info;
		info += '</td>';
		info += '<td valign=\'top\'>';
		if (p.locality_img.match(/^_thumb/) || p.locality_img == ''){
			info += '&nbsp;';
		} else {
			info += '<img src=\'/images/'+p.locality_img+'\' height=93 width=125>';
		}
		info += '</td></tr></table>';

	} else if (current_zoom == 'property'){
		info = '';
		info += fl;
		info += stddiv;
		info += '<table><tr>';
		info += '<td class=\'gm_td\'>' + p.overview;
//		info += 'Inventory:<br/>';
//		info += p.inventory;

		info += '</td>';
		info += '<td valign=\'top\'>';
		info += '<img src=\'/images/'+p.property_img+'\' height=93 width=125>';
		info += '</td></tr></table>';

		inventory = stddiv + p.inventory;
//		activities = stddiv + p.activities;
		info_head = jssm['map']['property_info'];
	} else {
		info = '';
		info += fl;
		if (p.readiness == 'active' && (outside == 'Propaganda' || current_object == p.object_id)){
			zfunc  = 'zoom('+i+',\'property\'); return false;';
			zoom_word = jssm['map']['zoom_in'];
			info += "<br/>[<a href = \"javascript:void(0);\" onclick = \""+zfunc+"\">" + zoom_word + ' ' + jssm['map']['zoom_to_p'] + "</a>]";
		}
		info += stddiv_small;
		info += '<table cellpadding="0" cellspacing="0"><tr>';	
		info += '<td valign=\'top\' align=\'left\'><i>' + p.name + '</i>:<br/>' + p.title + '</td>';
		info += '<td valign=\'top\' width="125"><img src=\'/images/'+p.property_img+'\' height=93 width=125></td></tr></table>';
		info_head = jssm['map']['destination_title'];
	}




// back link (for future properties)
	if (current_zoom == 'area' && p.readiness == 'future'){
		zfunc  = 'zoomBack(); return false;';
		info += "<br/>[<a href = \"javascript:void(0);\" onclick = \""+zfunc+"\">" + jssm['map']['zoom_back'] + "</a>]";
	}

// nav tab

	if (current_zoom != 'area'){
		zfunc  = 'zoom('+i+',\'area\'); return false;';
		if (current_zoom == 'locality' || current_zoom == 'property'){
			zoom_word = jssm['map']['zoom_out'];
		} else {
			zoom_word = jssm['map']['zoom_in'];
		}
		nav += "<span class = \"nav_btn\" onclick = \""+zfunc+"\">" + zoom_word + ' ' + jssm['map']['zoom_to_a'] + "</span>";
	}



	if (p.readiness == 'active' || p.readiness == 'coming'){
		if (current_zoom != 'locality'){
			zfunc  = 'zoom('+i+',\'locality\'); return false;';
			if (current_zoom == 'property'){
				zoom_word = jssm['map']['zoom_out'];
			} else {
				zoom_word = jssm['map']['zoom_in'];
			}
			nav += "<span class = \"nav_btn\" onclick = \""+zfunc+"\">" + zoom_word + ' ' + jssm['map']['zoom_to_l'] + "</span>";
		}
	}


	if (p.readiness == 'active'){
		if (current_zoom != 'property'){
			zfunc  = 'zoom('+i+',\'property\'); return false;';
			zoom_word = jssm['map']['zoom_in'];
			nav += "<span class = \"nav_btn\" onclick = \""+zfunc+"\">" + zoom_word + ' ' + jssm['map']['zoom_to_p'] + "</span>";
		}
	}

	if (p.readiness == 'active' || p.readiness == 'coming'){
		if (outside == 'Propaganda'){
			nav += "<span class = \"nav_btn\" onclick = \""+yfunc+"\">" + jssm['map']['show_full_details_start'] +  "</span>";
		}
	}

	if (info != ""){
		info += '</div>';
		infoTabs.push(new GInfoWindowTab(info_head, info));
	}
	if (inventory != ""){
		inventory += '</div>';
		infoTabs.push(new GInfoWindowTab(jssm['hacks']['inventory_title'], inventory));
	}

	if (todo != ""){
		todo += '</div>';
////TFODO		infoTabs.push(new GInfoWindowTab("Things to do", todo));
	}
	if (activities != ""){
		activities += '</div>';
		infoTabs.push(new GInfoWindowTab(jssm['hacks']['activities_title'], activities));
	}
	if (nav != "" && (outside == 'Propaganda' || current_object == p.object_id)){
		infoTabs.push(new GInfoWindowTab(jssm['map']['navigate_title'], nav));
	}
	p.marker.openInfoWindowTabsHtml(infoTabs);

}


function zoomIt(zpoint, zoom,  zmap, i){

	map.setCenter(zpoint, zoom,  zmap);
	map.closeInfoWindow();
// immediately open up info window
	if (outside == 'Propaganda'){
		make_info_window(i);
	}
}


function zoomBack (){
	current_zoom = prev_zoom;
	map.closeInfoWindow();
	map.returnToSavedPosition();
}


function zoom(i, new_level){
	var p = points[i];
	var zpoint;
	var zoom;
	var zmap;
	if (new_level == 'world' || new_level == 'region'){
		zpoint = p.area_point;
		zoom = current_zoom;
		zmap = current_map;
	} else if (new_level == 'area'){
		zpoint = p.area_point;
		zoom = p.area_zoom;
		zmap = p.area_map;
	} else if (new_level == 'locality'){
		zpoint = p.loc_point;
		zoom = p.loc_zoom;
		zmap = p.loc_map;
	} else if (new_level == 'property'){
		zpoint = p.property_point;
		zoom = p.property_zoom;
		zmap = p.property_map;
	}
	current_zoom = new_level;
	current_map = zmap;
	zoomIt(zpoint, zoom,  zmap, i);

}


function addOverlays (){

	for (var j=0; j<points.length; j++){
		points[j].overlay = true;
		ge('_ch_'+ points[j].dest_type).checked = false;
		map.addOverlay(points[j].marker);
	}	

}

function removeOverlays (){
	map.clearOverlays();
	for (var j=0; j<points.length; j++){
		points[j].overlay = false;
		//map.removeOverlay(points[j].marker);
	}
}

function sht (chbox){
	
	map_prep_show_custom ();

	var on = chbox.checked;
	for (var i=0; i<points.length; i++){

		var p = points[i];

		if ('_ch_'+p.dest_type != chbox.id){
			continue;
		}
		if (on){
			if (!p.overlay){
				if(points[i].readiness && ge('_ch_'+points[i].readiness).checked) {

					points[i].overlay = true;
					map.addOverlay(p.marker);
				}
			}
		} else {
			if (p.overlay){
				map.removeOverlay(p.marker);
				p.overlay = false;
			}
		}
	}
}



function sht_av (chbox){

	if (!is_using_filters){
		select_all_d_types();
	}
	map_prep_show_custom(chbox.id);

	var on = chbox.checked;
	for (var i=0; i<points.length; i++){
		var p = points[i];

		if ('_ch_'+p.readiness!= chbox.id){
			continue;
		}
		if (on){
			if (!p.overlay){

				if(ge('_ch_'+points[i].dest_type).checked) {
					points[i].overlay = true;
					map.addOverlay(p.marker);
				}
			}

		} else {
			if (p.overlay){
				map.removeOverlay(p.marker);
				p.overlay = false;
			}
		}
	}
}

function select_all_d_types (){
	for (var i=0; i<points.length; i++){
		var p = points[i];
		if (!p.overlay){
			points[i].overlay = true;
			map.addOverlay(p.marker);
		}
		ge('_ch_'+points[i].dest_type).checked = true;
	}
}

function unselect_all_d_types (){
	for (var i=0; i<points.length; i++){
		ge('_ch_'+points[i].dest_type).checked = false;
	}
}


function ptcp(){
	map.closeInfoWindow();
	map.panTo(points[current_point_idx].property_point);
}



function yoyo_frommap (first, second, uri){
	SetCookie('frommap',1);

	if(CM && CM.object_id) {
		return yoyo(first, second);
	} else {
		window.location = '/'+currentLanguage+'/destination/'+uri+'.html';
	}
	return false;
}






// Control: Continent buttons

    function Continents() {
    }
    Continents.prototype = new GControl();
    Continents.prototype.initialize = function(map) {

      var container = ce("div");
	container.style.width = '400px';

	var tbl =  ce("table");
	tbl.border = 0;
	tbl.cellPadding = 0;
	tbl.cellSpacing = 4;
	var row1 = tbl.insertRow(0);


	var cell1 = row1.insertCell(0);
      var btnW = ce("div");
	btnW.className= 'hor_btn';
	btnW.id= 'map_world_btn';
      container.appendChild(btnW);
      btnW.appendChild(document.createTextNode(jssm['map']['map_world']));
      GEvent.addDomListener(btnW, "click", function() {
        world();
      });
	cell1.appendChild(btnW);



	var cell2 = row1.insertCell(1);
      var btnA = ce("div");
	btnA.className= 'hor_btn';
	btnA.id= 'map_americas_btn';
      container.appendChild(btnA);
      btnA.appendChild(document.createTextNode(jssm['map']['map_americas']));
      GEvent.addDomListener(btnA, "click", function() {
        americas();
      });
	cell2.appendChild(btnA);


	var cell3 = row1.insertCell(2);
      var btnE = ce("div");
	btnE.className= 'hor_btn';
	btnE.id = 'map_europe_btn';
      container.appendChild(btnE);
      btnE.appendChild(document.createTextNode(jssm['map']['map_europe']));
      GEvent.addDomListener(btnE, "click", function() {
        europe();
      });
	cell3.appendChild(btnE);

	var cell4 = row1.insertCell(3);
      var btnP = ce("div");
	btnP.className= 'hor_btn';
	btnP.id = 'map_pacific_btn';
      container.appendChild(btnP);
      btnP.appendChild(document.createTextNode(jssm['map']['map_pacific']));
      GEvent.addDomListener(btnP, "click", function() {
        pacific();
      });
	cell4.appendChild(btnP);

	var cell5 = row1.insertCell(4);
        var zoomInDiv = ce("div");
	zoomInDiv.id = 'backlink';
	zoomInDiv.style.display = 'none';
	zoomInDiv.className= 'hor_btn';
	
	cell5.appendChild(zoomInDiv);

	container.appendChild(tbl);

      map.getContainer().appendChild(container);
      return container;
    }

    Continents.prototype.getDefaultPosition = function() {
      return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(50, 3));
    }

// Control: Filter buttons


    function Filters() {
    }
    Filters.prototype = new GControl();
    Filters.prototype.initialize = function(map) {

	var container = ce("div");
	container.style.backgroundColor = '#FFF';
	container.style.border = '1px solid #000';
	container.style.opacity = '0.85';
	container.style.filter = 'alpha(opacity=85)';

	var tbl =  ce("table");
	tbl.border = 0;
	tbl.cellPadding = 0;
	tbl.cellSpacing = 2;
	tbl.id = 'map_filters_main_tbl';
	var row1 = tbl.insertRow(0);

	var cell1 = row1.insertCell(0);
	cell1.innerHTML = '<img id=\'flick_filter\' src=\''+f_contract_img+'\'>&nbsp;';
	cell1.innerHTML += jssm['map']['filters'];
	cell1.id = 'filters_head';
	cell1.style.fontSize = '8pt';
	cell1.style.verticalAlign = 'middle';
	cell1.style.textAlign = 'left';
	cell1.style.cursor = 'pointer';

	GEvent.addDomListener(cell1, "click", function() {
		var f_i = ge('flick_filter');
		if (f_i.src.indexOf(f_contract_img) != -1){
			f_i.src = f_expand_img;
		} else {
			f_i.src = f_contract_img;
		}
		toggle_block('map_filter_tbl');

		if (ge('map_filter_tbl').style.display == 'none') {
			ge('map_filters_main_tbl').parentNode.style.width = '80px';
		} else {
			ge('map_filters_main_tbl').parentNode.style.width = '326px';
		}
	});
	container.appendChild(tbl);



	var tblb =  ce("table");
	tblb.id = 'map_filter_tbl';
	tblb.style.margin = '5px';
	tblb.style.display = 'none';
	tblb.border = 0;
	tblb.cellPadding = 0;
	tblb.cellSpacing = 0;
	var row1 = tblb.insertRow(0);
	var cell1b = row1.insertCell(0);
	cell1b.style.backgroundColor = '#000';
	cell1b.style.textAlign='left';

	var tbl =  ce("table");
	tbl.border = 0;
	tbl.cellPadding = 5;
	tbl.cellSpacing = 1;

	var row1 = tbl.insertRow(0);

	var cell1 = row1.insertCell(0);
	cell1.id = 'map_all_title'
	cell1.style.fontSize = '8pt';
	cell1.onclick = function () { map_prep_show_all();removeOverlays();addOverlays();return false; };
	cell1.innerHTML = jssm['map']['show_all'];
	cell1.style.verticalAlign = 'top';
	cell1.style.textAlign = 'left';
	cell1.style.width = '60px';
	cell1.style.backgroundColor = '#FFF';
	cell1.style.cursor = 'pointer';
	cell1.rowSpan = 2;

	var cell2 = row1.insertCell(1);
	cell2.id = 'map_type_title'
	cell2.style.fontSize = '8pt';
	cell2.innerHTML = jssm['map']['d_types'];
	cell2.style.width = '116px';
	cell2.style.backgroundColor = '#DDD';
	cell2.style.textAlign = 'left';

	var cell3 = row1.insertCell(2);
	cell3.id = 'map_av_title'
	cell3.style.fontSize = '8pt';
	cell3.innerHTML = jssm['map']['av'];;
	cell3.style.width = '116px';
	cell3.style.backgroundColor = '#DDD';
	cell3.style.textAlign = 'left';



	var row2 = tbl.insertRow(1);

	var cell2 = row2.insertCell(0);
	cell2.appendChild(ge('map_filter_type_'));
	cell2.style.backgroundColor = '#FFF';
	cell2.style.verticalAlign = 'top';
	cell2.style.fontSize = '8pt';
	cell2.style.textAlign = 'left';

	var cell3 = row2.insertCell(1);
	cell3.appendChild(ge('map_filter_av_'));
	cell3.style.backgroundColor = '#FFF';
	cell3.style.fontSize = '8pt';
	cell3.style.verticalAlign = 'top';
	cell3.style.textAlign = 'left';

	cell1b.appendChild(tbl);
	container.appendChild(tblb);


	map.getContainer().appendChild(container);
	return container;
    }


    Filters.prototype.getDefaultPosition = function() {
      return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(5, 110));
    }


function map_hideFilters() {
	var tmp = ge('map_filter_tbl');
	if (tmp) {
		tmp.style.display = 'none';
		ge('map_filters_main_tbl').parentNode.style.width = '80px'
	}

}

var is_using_filters = false;

function map_prep_show_all () {

	if(ge('map_all_title') && ge('map_all_title').style.fontWeight != 'bold') {

		ge('map_all_title').style.fontWeight = 'bold';
		ge('map_type_title').style.fontWeight = 'normal';
		ge('map_av_title').style.fontWeight = 'normal';
		ge('_ch_active').checked = false;
		ge('_ch_coming').checked = false;
		ge('_ch_future').checked = false;
		is_using_filters = false;
		ge('filters_head').style.fontWeight = 'normal';
	}
	unselect_all_d_types();

}


function map_prep_show_custom (av) {

	if(ge('map_type_title').style.fontWeight != 'bold') {
		removeOverlays();
		if(av) {
			if(av == '_ch_active') {
				ge('_ch_active').checked = true;
			} else if(av == '_ch_coming') {
				ge('_ch_coming').checked = true;
			} else if(av == '_ch_future') {
				ge('_ch_future').checked = true;
			}
		} else {

			ge('_ch_active').checked = true;
			ge('_ch_coming').checked = true;
			ge('_ch_future').checked = true;
		}
		is_using_filters = true;
		ge('filters_head').style.fontWeight = 'bold';
		ge('map_all_title').style.fontWeight = 'normal';
		ge('map_type_title').style.fontWeight = 'bold';
		ge('map_av_title').style.fontWeight = 'bold';
	}


}
function find_first_point(){
	var ret;
	for (var i=0; i<points.length; i++){
		if (points[i].uri == 'lake_tahoe'){
			return i;
		}
	}
	return ret;
}
