function fcallback(htmlOptions) {
	htmlOptions.flashvars.txt = this.innerHTML;
	this.innerHTML = '<div>'+this.innerHTML+'</div>';
	var $alt = $(this.firstChild);
	htmlOptions.height = $alt.height();
	htmlOptions.width = $alt.width();
	$alt.addClass('alt');
	$(this).addClass('flash-replaced').prepend($.fn.flash.transform(htmlOptions));
}

function winSize() {
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	return {w:myWidth, h:myHeight}
}

function fix_bg_size(){
	var selector = '#bg img:not([class=hide])';
	
	$(selector).removeAttr('width');
	$(selector).removeAttr('height');

	var img = $(selector);
	var w = $(img).width();
	var h = $(img).height();

	var win = winSize();
	
	if(w/h > win.w/win.h){
		$(selector).attr('height', win.h);
	}else{
		$(selector).attr('width', win.w);
	}
}

var bg_slideshow_num = 0;
var bg_slideshow_count = 0;

$(function(){
	$('body').fadeIn();
	// $('form').submit(function (){
	// 	$.post( $(this).attr('action'), $(this).serialize(), function(data) { $('#msgs').html(data); });
	// 	return false;
	// });
	
	$("#lnkReserve").click(function(){
		window.open($(this).attr('href'), '', 'fullscreen=no, toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=1000,height=700,left=100,top=100'); 
		return false;
	});
	
	$('div.interior div.copy h2:not([class]), div.special h2').flash(
        { 
            src: '/site/images/gillsans.swf', 
			wmode: 'transparent',
            flashvars: { 
                css: ['* {color: #cd6f1e;}'].join(' ')
            }
        },
        { version: 7 },
        fcallback
    );

	var n = $('#bg img');
	bg_slideshow_count = n.length;

	$('#bg-img-0').load(function(){
		fix_bg_size();
		
		/*
		if(bg_slideshow_count > 1){
			var t = window.setInterval(function(){
				bg_slideshow_num++;
				if(bg_slideshow_num >= bg_slideshow_count) bg_slideshow_num = 0;
				$('#bg img').removeClass('hide').hide();
				$('#bg-img-' + bg_slideshow_num).fadeIn();
			}, 5000);		
		}
		*/
		
	});

	$(window).resize(function() {
		fix_bg_size();
	});
	
	fix_bg_size();

/*	$("#content").fadeTo("slow", 0.9, function(){
		$("#content").css(filter:'');
	});
*/

	// Collapse submenu
	/*
	$('#submenu ul li ul').each(function(index){
		$(this).parent().find('a').click(function(){
			
			var li = $(this).parent().has('ul');
			if(li.length){
				$('#submenu ul li').removeClass('active');
				$(this).parent().addClass('active');				
				//$(this).parent().find('ul').toggle();
				return false;
			}
			
		});
	});
	*/
	
});


