
//bookmark this site
function bookmarksite(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}

//Pop Under
function hbcPop(key, country, state, city, mod) {
if (key==""){key=document.getElementById("rs_city").value;}
if (city==""){city=document.getElementById("rs_city").value;}
var page = "http://www.hotelsbycity.com/hotels/pop_up.php?key="+key+"&country="+country+"&state="+state+"&city="+city+"&mod="+mod;
var windowprops = "resizable=1,scrollbars=1,menubar=1,location=1,toolbar=1,titlebar=1,width=680,height=510, top=50, left=50";
newWindow = window.open(page, '', windowprops);
newWindow.blur();
}

$(document).ready(function()
{
	var id = $("div#map_container").find("div").attr("id"); 
	var map = init_map(id);
	
	//////////////////////////////////////////////////////
	
	$("div.atr_sub").hide();
	
	$(".atr_main_name").click(function()
	{
		var id = this.id.replace(/main/g, 'sub');
		var tmp = id.split("_");
		
		for(i = 1; i <= 25; i++)
		{
			if(i != tmp[2])
			{
				$("div#atr_sub_" + i).hide();
				$("img#bullet_" + i).attr("src", "/images/city/bullet.gif");
			}
		}
		
		if(!$("div#" + id).is(":visible"))
		{
			$("div#" + id).show();
			$("img#bullet_" + tmp[2]).attr("src", "/images/city/bullet_down.gif");
		}
		else
		{
			$("div#" + id).hide();
			$("img#bullet_" + tmp[2]).attr("src", "/images/city/bullet.gif");
		}
	});
});



function init_map(id)
{
	var target = id.split("_");
	if(GBrowserIsCompatible()) 
	{
		var map = new GMap2(document.getElementById(id));
		map.setCenter(new GLatLng(target[2], target[3]), 11);
		map.addControl(new GSmallMapControl());

		var baseIcon = new GIcon(G_DEFAULT_ICON);
		//baseIcon.image = "http://gmaps-samples.googlecode.com/svn/trunk/markers/green/blank.png";
		baseIcon.image = "/images/map/blank.png";
       	baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
        baseIcon.iconSize = new GSize(20, 34);
        baseIcon.shadowSize = new GSize(37, 34);
        baseIcon.iconAnchor = new GPoint(9, 34);
        baseIcon.infoWindowAnchor = new GPoint(9, 2);
		markerOptions = {icon:baseIcon};

		function createMarker(point, index, html) 
		{
			var marker = new GMarker(point, markerOptions);
			GEvent.addListener(marker, "click", function() 
			{
				marker.openInfoWindowHtml(html);
			});
			return marker;
		}		

		var _cid = $("div#master").children();
	 	var cid = $(_cid[0]).attr("id");
		var hotels = "";
		$.ajax 		({ 
			type: "GET", url: "/includes/gmap.php", data: "cid=" + cid, async: false,
			success: 
        	function(response)
       		{ 
				hotels = response.split("^");
        	}
    	});

		for(i = 0; i < hotels.length - 1; i++)
		{
			var target = hotels[i].split("_"); 
			var html = "<div class='info'>\
						<img src='" + target[7].replace(/ZZZZ/g, '_') + "' width='80' height='80' />\
						<b>" + target[1] + " </b><br><br> " + target[8] + " <div id='star'><img src='/images/stars/" + target[6] + "star.gif' /></div> \
						<div id='btn'> <a href='http://book.officialdowntownhotels.com/hotel/?refid=1430&rs_hid=" + target[0] + "'> Read More </a></div> </div>";
	
			var latlng = new GLatLng(target[2], target[3]);
			map.addOverlay(createMarker(latlng, i, html));
		}	
    }
	return map;
}








