$(function() {
	$('form').initializeForm();
	$('.validate').formValidate(); 
	$('.vcalendar').eventPreview();
	$('.post').postPreview();
	$('.ajax-calendar').ajaxCalendar();
	$('.package').packagePreview({hideDetails : '<em class="alt">Hide Details</em>', viewDetails : '<em class="alt">View Details</em>'});
	$('.share-link').initializeSharing();
/*	if (typeof jQuery.prototype.msnMap != 'undefined') {	   
		$('#map').msnMap();
	}
*/
	// Sifr
	$('div#content h1').sifr({ strSWF: '/flash/adobe-caslon-pro-italic.swf', strColor: '#dfdfce', strWmode: 'transparent' },{ expressInstall: true });
	$('div#content h2').sifr({ strSWF: '/flash/arial.swf', strColor: '#98987d', strWmode: 'transparent' },{ expressInstall: true });
	
	//Home flash masthead
	$("div#home-masthead").flash(
		{src:"/flash/home-masthead.swf",
		 width:720,
		 height:471,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"},
			function(htmlOptions) { //Use this to specify a query string, take out if not needed.
				//htmlOptions.flashvars.configFile = "flash/xml/gallery_config.xml";
				htmlOptions.flashvars.xmlFile = "/flash/xml/home-masthead.xml";
				$(this).html($.fn.flash.transform(htmlOptions));
		});
	
	// Photo Gallery
	$("div#photo-gallery").flash( {src:"/flash/photo-gallery-houston.swf", width:475, height:650, wmode:"transparent", quality:"high"}, {version:"8"},
		function(htmlOptions) {
			htmlOptions.flashvars.myfolder = "/flash/houston-flash-gallery";
			htmlOptions.flashvars.xmlFile = "/flash/xml/galleryImages.xml";
			htmlOptions.flashvars.configFile = "/flash/xml/galleryImages.xml";
			$(this).html($.fn.flash.transform(htmlOptions));
		}
	);
	
	//Email form
	$("div#email-form").flash( {src:"/flash/email-form.swf", width:220, height:252, wmode:"transparent", quality:"high"}, {version:"8"});
	$("div#newsletter-flash").flash( {src:"/flash/newsletter-gallery.swf", width:660, height:411, wmode:"transparent", quality:"high"}, {version:"8"});
	//Newsletter
	
	
	//Home push items
	$('#push-bail-houston').jqm();

	//MSN Map
	var openFn=function(hash){
		hash.w.show();
		var leftPos = ($(window).width()-$('#map-container').width())/2;
		var topPos = Math.max($(window).scrollTop(),parseInt($('#map-container').css('top')));
		$('#map-container').css({left:leftPos,top:topPos});
		$('#map').msnMap({listView:true, hotelOnly: true});
	};
	var hideFn=function(hash){
		hash.w.hide()
		hash.o.remove();
		$('.places').remove();
	};
	$('#map-container').each(function(){ $(this).jqm({trigger:'#btn-msnmap', onShow: openFn, onHide: hideFn});});
	
	// Mag Deal lightbox
	
	var openFnModal=function(hash){
		hash.w.show();
		var leftPos = ($(window).width()-$('#mag-deal').width())/2;
		//var topPos = Math.max($(window).scrollTop(),parseInt($('#mag-deal').css('top')));
		$('#mag-deal').css({left:leftPos});
	};
	
	$('#mag-deal').jqm({trigger:'#push-mag', onShow: openFnModal, onHide: hideFn});

	//Accommodations Flash
	var accommclass = $('div#accomm-flash-wrapper').children('div#accomm-flash').attr('class');
	$("div#accomm-flash").flash( {src:"/flash/accommodations-new.swf", width:674, height:441, wmode:"transparent", quality:"high"}, {version:"8",update:false},
		function(htmlOptions) {
			htmlOptions.flashvars.xmlPath = "/flash/xml/accommodations-"+accommclass+".xml";
            if(accommclass=='concept' || accommclass=='magnificent7'){
                htmlOptions.flashvars.showInfoBox = "true";
            }
			$(this).html($.fn.flash.transform(htmlOptions));
		}
	);

	var first_paragraph = $('div#right-side + p')[0];
	if (!first_paragraph) return false;
	var text = first_paragraph.firstChild.nodeValue;	
	first_letter = text.substr(0,1);
	if (first_letter == '\n') {
		first_letter=text.substr(1,1);
		first_paragraph.firstChild.nodeValue = text.slice(2);
	} else {
		first_paragraph.firstChild.nodeValue = text.slice(1);

	}
	if ( text ) {
		//var newfl = $(first_letter).wrap('<span class="fl"></span>');
		$('div#right-side + p').prepend('<span class="fl">'+first_letter+'</span>');
	}	

});