$(function() {
	
	$('.follow-link').initializeFollowing();
	// Sifr

	$('body.spa div#content-wrapper h1').sifr({ strSWF: '/flash/trajan-pro.swf', strColor: '#50341b', strWmode: 'transparent' },{ expressInstall: true });
	$('body.spa div#content h2').sifr({ strSWF: '/flash/trajan-pro.swf', strColor: '#b46119', strWmode: 'transparent' },{ expressInstall: true });
	$('div#content-wrapper h1').sifr({ strSWF: '/flash/trajan-pro.swf', strColor: '#fbdaab', strWmode: 'transparent' },{ expressInstall: true });
	$('div#content h2').sifr({ strSWF: '/flash/trajan-pro.swf', strColor: '#b20838', strWmode: 'transparent' },{ expressInstall: true });
	$('div#content h3.genuine-header').sifr({ strSWF: '/flash/trajan-pro.swf', strColor: '#a65810', strWmode: 'transparent' },{ expressInstall: true });


	// Flash
	$("div#dhr-flash").flash( {src:"http://www.destinationhotels.com/flash/branding/flash_logoDhr.swf?link=innatloretto", width:250, height:25, wmode:"transparent", quality:"high", allowscriptaccess:"always"}, {version:"7"});
	$("body.home div#masthead").flash( {src:"flash/home.swf", width:665, height:361, wmode:"transparent", quality:"high"}, {version:"7"});
	$("div#special-form").flash( {src:"flash/special_offer_form_testzip.swf", width:221, height:221, align:'tl', salign:'tl', wmode:"transparent", quality:"high"}, {version:"7"});

	
	// Photo Galleries
	$("div#photo-gallery").flash(
		{src:"flash/photo_gallery.swf", width:466, height:416, wmode:"transparent", quality:"high"}, {version:"8"},
			function(htmlOptions) {
				htmlOptions.flashvars.configFile = "flash/xml/gallery_config.xml";
				htmlOptions.flashvars.xmlFile = "flash/xml/property.xml";
				$(this).html($.fn.flash.transform(htmlOptions));
		}
	);

	$("div#epostcard-gallery").flash(
		{src:"flash/photo_gallery.swf", width:466, height:416, wmode:"transparent", quality:"high"}, {version:"8"},
			function(htmlOptions) {
				htmlOptions.flashvars.configFile = "flash/xml/gallery_config.xml";
				htmlOptions.flashvars.xmlFile = "flash/xml/images.xml";
				$(this).html($.fn.flash.transform(htmlOptions));
		}
	);




	$('div#code-box').hide();
	$('a#promo-link').toggle(function() {
		$('div#code-box').slideDown();
		$(this).css('background-position', 'right bottom').parents('div#check-availability').addClass('check-long');
		return false; 
	}, function() { 
		$('div#code-box').slideUp();
		$(this).css('background-position', 'right 0').parents('div#check-availability').removeClass('check-long'); 
		return false; 
	});
	
	// General Toggelr
	$('.toggle-details').hide();
	$(".toggle-wrapper a.toggler").toggle(function() {
		$(this).parents(".toggle-wrapper").find(".toggle-details").animate({
			height: 'show'
		}, 'slow');
		// Changes the Text of the Control
		$(this).html("(read less)");
	}, function() {
		$(this).parents(".toggle-wrapper").find(".toggle-details").animate({
			height: 'hide'
		}, 'slow');
		// Changes the Text of the Control
		$(this).html("(read more)");
	});

	// Gift Certificates Form
	$('input#autoPopCbx').click( function() { 
		if ($('input#autoPopCbx').is(":checked")) {
			$('input#recipient_first_name').val( $('input#first_name').val() );	
			$('input#recipient_last_name').val( $('input#last_name').val() );
		} else {
			$('input#recipient_first_name').val('');	
			$('input#recipient_last_name').val('');
		}									  
	});
	$('form.giftform input#first_name').change( function() { 
		if ($('input#autoPopCbx').is(":checked")) {				
			$('input#recipient_first_name').val( $('input#first_name').val() );
		}
	});
	$('form.giftform input#last_name').change( function() { 
		if ($('input#autoPopCbx').is(":checked")) {				
			$('input#recipient_last_name').val( $('input#last_name').val() );
		}
	});
	
	// Spa Form
	$('span#event-yes').hide();
	$('select#special-event').change( function () {
		if($(this).val() === "yes") {
				$(this).parent().children('span#event-yes').show();
		} else {
			$(this).parent().children('span#event-yes').hide().children('span#event-yes input').val("");
		}
	});

	// Blog Form
	$('div.form-help').hide();
	$('a.help-link').toggle( function() {
		$(this).parents('div.field').children('div.form-help').show();
		return false;
	},function(){ 
	  $(this).parents('div.field').children('div.form-help').hide();
	  return false;
	});
	
	// Striped Table
	$('table.striped-table').children('tbody').children('tr:odd').addClass('stripe');

	// Thickbox Window Close
	$('a#close-window').click(function(){								   
		tb_remove();
	});

});


// Function to add/remove "over" class for drop down nav - remove if not needed
$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});

};   

//Follow Us Fn
$.fn.initializeFollowing = function() {
	return this.each(function() {
		$('.follow-link').live('click',function(event) {
			event.preventDefault();
			$('.follow-panel').hide();
			$(this).siblings('.follow-panel').css('display','inline');
		});
		$('.follow-close').live('click',function(event){
			event.preventDefault();
			$(this).parent().slideUp('fast');
		});
	});
};