// Function for Minigalleries
	      function selectThumb(imgurl,text,bigimg,obj) {
					$(".sidegallery-item-selected").removeClass("sidegallery-item-selected").addClass("sidegallery-item");
					
					$("#side-bottom-content").html(text);
					$("#lightboximg").attr("href", "/" + bigimg);
					
					$("#sidegallery-highlight-img").fadeOut('slow',
						function(){
							$("#sidegallery-highlight-img").attr("src", "").attr("src", "/" + imgurl).fadeIn();
						});
					$(obj).attr("className","sidegallery-item-selected");
				}

				function arrowClick(top, size){
					var move = "57px";
					var speed = 500;
					
					if(top){
						if(parseInt($("#side-thumblist").css("margin-top")) <= -57){
							$("#side-thumblist").animate({
								marginTop: "+="+ move }, speed);
						}
					}
					else{
						if(-size + parseInt($("#side-thumblist").css("margin-top")) > parseInt($("#side-viewwindow").css("height"))){	
							$("#side-thumblist").animate({
								marginTop: "-=" + move }, speed);
						}
					}
				}
			
      
      
				
			// Script to hide the reservation menu.			
			function resHide(){
			
			if(document.getElementById('checkrates').style.display=='block' &&  document.getElementById('booknow-orig').style.display=='block')
			{
			document.getElementById('checkrates').style.display='none';
			document.getElementById('booknow-orig').style.display='none'
			}
			else
			{
			document.getElementById('checkrates').style.display='block';
			document.getElementById('booknow-orig').style.display='block';
			}
			}
			
			
			/*
 *  This script slides the front page map out and brings it to the front
 *  It also initializes google maps and places a map on the div
 */
out = false;
sliding = false;
initialized = false;

function initializeMap() {
	

	var latlng = new google.maps.LatLng(38.977, -76.501);
	
	var options = {
		zoom: 14,
		center: latlng,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	};
	var map = new google.maps.Map(document.getElementById("map_canvas"), options);
	
	// get hotel location
	var address = "174 West Street Annapolis, MD 21401-2824";
	//var address = "O'Callaghan Hotel-Annapols";

	var geocoder = new google.maps.Geocoder();
	geocoder.geocode({'address': address}, function(results, codestatus){
			map.setCenter(results[0].geometry.location);
		if(codestatus == google.maps.GeocoderStatus.OK){

			var image = new google.maps.MarkerImage("wp-content/themes/twentyten/images/shamrock.png", new google.maps.Size(41,44), new google.maps.Point(0,0), new google.maps.Point(35,30));
			
			var marker = new google.maps.Marker({
				map: map,
				position: results[0].geometry.location,
				title: "O'Callaghan Annapolis Hotel",
				icon: image
			});
			
			infowindow = new google.maps.InfoWindow();
			infowindow.setPosition(results[0].geometry.location);
			infowindow.setContent("O'Callaghan Hotel Annapolis<br>174 West Street<br>Annapolis, MD 21401-2824");
			infowindow.open(map, marker);
		}	
	});
}

function fixPositioning(out){
	
	if(out){
		$("#map_canvas").hide();
		$("#mapexpand").css("margin-top","-20px");
	}
	else{
		$("#mapexpand").css("margin-top","-410px");
	}
}

function slidezindex() {
	
	if (out) { 
		$("#map").css("z-index", "0").animate({
			marginLeft: "-=550px"
		},1000, fixPositioning(out));

		out = false;
	} else {
		$("#map").css("z-index", "150").animate({
			marginLeft: "-=550px"
		}, 1000, fixPositioning(out));
		out = true;
	}
	$("#map_canvas").css("overflow","visible");
	sliding = false;
}

function mapslide(){
	
	if(!sliding){
		sliding = true;
		if(!initialized){
			initializeMap();
			initialized = true;
		}
		$("#map_canvas").show();
		$("#map").animate({
			marginLeft: "+=550px"
		}, 1000, "swing");
		setTimeout("slidezindex()", 1000);
	}
}

