function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

$(document).ready(function(){
  //rollover images preloader
  MM_preloadImages('images/mainnavV2-home-o.gif','images/mainnavV2-thehotel-o.gif','images/mainnavV2-therooms-o.gif','images/mainnavV2-dining-o.gif','images/mainnavV2-promotions-o.gif','images/mainnavV2-location-o.gif','images/mainnavV2-reservations-o.gif');
});

//navigation set
function setnav(navsec, navitem) {
	if(navsec == 0)
		return;
	
	//if(navsec == 1 || navsec == 2 || navsec == 3 || navitem != 0)
	//	$("#nav_home").removeClass();
	//else
	//	return;
	$("#mainnav td:eq(" + navitem + ")").addClass("selected");	
}

// Mailing List Modal form script start
var mce_form_loaded;
mce_form_loaded = false;

	$(function(){
		// Dialog			
		$('#mc_embed_signup').dialog({
			title: 'Mailing List Sign-up', 
			autoOpen: false,
			bgiframe: true,
			height: 324,
			modal: true,
			width: 460
		});
		// Dialog Link
		$('#nav_maillist').click(function(){
			if(!mce_form_loaded) {
				$("#mc_embed_signup").load(
					"mce-form.php",
					{},
					function() {
						$('#mc_embed_close').click(function(){
									$('#mc_embed_signup').dialog('close');
									return false;
								});						
					}
				);
					
			}
			mce_form_loaded = true;
			$('#mc_embed_signup').dialog('open');
			clearMCForm();
			return false;
		});
		
		function clearMCForm(){
			$('#mc_embed_signup input[type=text]').each(
				function() {
					$(this).val('');
				}
			);
			$('#mc_embed_signup select').each(
				function() {
					$(this)[0].selectedIndex = 0;
				}
			);
			$('#mc_embed_signup div.mce_inline_error').each(
				function() {
					$(this).remove();
				}
			);
			$('#mce-error-response').hide();
			$('#mce-success-response').hide();
		}
		
	});
// Mailing List Modal form script end


//slideshow
$(document).ready(function() {			
	//Execute the slideShow
	//slideShow();
});

function slideShow(galleryId) {
	var slideSpeed = 4000; //milliseconds
	//Set the opacity of all images to 0
	$('#' + galleryId + ' a').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('#' + galleryId + ' a:first').css({opacity: 1.0});
	
	//Set the caption background to semi-transparent
	//$('#" + galleryId + ".caption').css({opacity: 0.7});

	//Resize the width of the caption according to the image width
	//$('#" + galleryId + " .caption').css({width: $('#gallery a').find('img').css('width')});
	
	//Get the caption of the first image from REL attribute and display it
	//$('#gallery .content').html($('#gallery a:first').find('img').attr('rel'))
	//.animate({opacity: 0.7}, 400);
	
	//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('gallery("' + galleryId + '")', slideSpeed);
	
}

function gallery(galleryId) {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#' + galleryId + ' a.show')?  $('#' + galleryId + ' a.show') : $('#' + galleryId + ' a:first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#' + galleryId + ' a:first') :current.next()) : $('#' + galleryId + ' a:first'));	
	
	//Get next image caption
	var caption = next.find('img').attr('rel');	
	
	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
	//Set the opacity to 0 and height to 1px
	//$('#gallery .caption').animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: '1px'}, { queue:true, duration:300 });	
	
	//Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
	//$('#gallery .caption').animate({opacity: 0.7},100 ).animate({height: '100px'},500 );
	
	//Display the content
	//$('#gallery .content').html(caption);
	
	
}