$(function() {
	//Documentation located in special.docs.js
	
		 		   // Flash Email Signup
	
	$("div#flash-email-signup-calendar-page").each(function(){
															
			var cookieval = $.cookie("flashcheck");
		var flashopen ="intro";
		if ( cookieval == "flashopened" ) {
			flashopen =false;
		}												
 
		$(this).flash(
			{src:"../flash/signup.swf",
			 width:236,
			 height:515,
			 name:"homeMasthead",
			 id:"homeMasthead",
			 wmode:"transparent",
			 quality:"high"},
			 {version:"9"},
				function(htmlOptions) { //Use this to specify a query string, take out if not needed.
					htmlOptions.flashvars.openOnLoad = flashopen;
					$(this).html($.fn.flash.transform(htmlOptions));
			});
		 $.cookie("flashcheck", "flashopened", { expires: 7 });
	});
	
	// Flash Email Signup
	
	$("div#flash-email-signup").each(function(){
		var cookieval = $.cookie("flashcheck");
		var flashopen ="intro";
		if ( cookieval == "flashopened" ) {
			flashopen =false;
		}
		$(this).flash(
			{src:"flash/signup.swf",
			 width:236,
			 height:515,
			 name:"homeMasthead",
			 id:"homeMasthead",
			 wmode:"transparent",
			 quality:"high"},
			 {version:"9"},
				function(htmlOptions) { //Use this to specify a query string, take out if not needed.
					htmlOptions.flashvars.openOnLoad = flashopen;
					$(this).html($.fn.flash.transform(htmlOptions));
			});
		$.cookie("flashcheck", "flashopened", { expires: 7 });
	});
	 		   // Flash Email Signup
	
/*	$("div#flash-email-signup").each(function(){
	 
		 
	 
		$(this).flash(
			{src:"flash/signup.swf",
			 width:236,
			 height:515,
			 name:"homeMasthead",
			 id:"homeMasthead",
			 wmode:"transparent",
			 quality:"high"},
			 {version:"9"},
				function(htmlOptions) {  
					htmlOptions.flashvars.openOnLoad = true;
					$(this).html($.fn.flash.transform(htmlOptions));
			});
		 
	});*/
	
	
	
	
	
	$(".form-help").hide();
	$(".help-link").toggle(function() {
		$(".form-help").show();
		}, function() {
		$(".form-help").hide();
	});

	$("div#dhr-logo").flash(
		{src:"http://www.destinationhotels.com/flash/branding/flash_logoDhr_tan.swf?link=carolinainn",
		 width:250,
		 height:25,
		 wmode:"transparent",
		 allowScriptAccess:"always",
		 quality:"high"},
		 {version:"7"});
	
	$(".home div#masthead").flash(
		{src:"flash/home-masthead.swf",
		 width:684,
		 height:349,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"});

	$("#room-inset").flash(
		{src:"flash/rotating-inset.swf",
		 width:277,
		 height:192,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"},
			function(htmlOptions) { //Use this to specify a query string, take out if not needed.
				htmlOptions.flashvars.curAlbum = "guestroom";
				htmlOptions.flashvars.xmlPath = "flash/xml/inset-images.xml";
				$(this).html($.fn.flash.transform(htmlOptions));
		});
	$("#suite-inset").flash(
		{src:"flash/rotating-inset.swf",
		 width:277,
		 height:192,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"},
			function(htmlOptions) { //Use this to specify a query string, take out if not needed.
				htmlOptions.flashvars.curAlbum = "suite";
				htmlOptions.flashvars.xmlPath = "flash/xml/inset-images.xml";
				$(this).html($.fn.flash.transform(htmlOptions));
		});

	$("div#photo-gallery").flash(
		{src:"flash/photo_gallery.swf",
		 width:607,
		 height:439,
		 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/epostConfig.xml";
				htmlOptions.flashvars.xmlFile = "flash/xml/images.xml";
				$(this).html($.fn.flash.transform(htmlOptions));
		});
	//timeline
	$("div#timeline").flash(
		{src:"flash/timeline-new.swf",
		 width:588,
		 height:361,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"},
			function(htmlOptions) { //Use this to specify a query string, take out if not needed.
				htmlOptions.flashvars.xmlPath= "flash/xml/data.xml";
				$(this).html($.fn.flash.transform(htmlOptions));
		});


		// Events Peramlink JS
		
		var dir = location.href.substring(0,location.href.lastIndexOf('/')+1);
		var url = location.href.substring(dir.length,dir.length+19);
		if (url == '/hotel-events/chapel-hill-event-calendar') {
			$(".event-description").hide();
		}
	
	
	$("li.event").each(function(){
		var parent = $(this);
		$(".details-btn", parent).toggle(function() {
			$.get('/includes/events-calendar-details-dhr.php', { event_id:$(".details-btn a", parent).attr('id') },function(data) { 
				$(".details-btn", parent).removeClass("view-details").addClass("hide-details");
				$(".event-description", parent).html(data).animate({height:'show'},'slow');
			});
			return false;								   
			}, function() {
				$(".event-description", parent).animate({height:'hide'},'slow');
				$(".details-btn", parent).removeClass("hide-details").addClass("view-details");
		});
	});

	// Expand Collapse for Blog
	
	$(".post-more-content").hide();
	
	$(".blog-post").each(function() {
		var father = $(this);
		$("a.post-read-more-btn", father).toggle(function() {
			$(".post-more-content", father).animate({height:'show'},'slow');
			$(this).html("Hide Details");
		}, function() {
			$(".post-more-content", father).animate({height:'hide'},'slow');
			$(this).html("Read More");
		});
	});
	$(".blog-post").each(function() {
		var father = $(this);
		$("a.post-icon-more-btn", father).toggle(function() {
			$(".post-more-content", father).animate({height:'show'},'slow');
			$("a.post-read-more-btn", father).html("Hide Details");
		}, function() {
			$(".post-more-content", father).animate({height:'hide'},'slow');
			$("a.post-read-more-btn", father).html("Read Details");
		});
	});


	//social media sharing
	$('.share-link').bind('click',function() {
		$('.share-panel').hide();
		$(this).parents('.rss-item').find('.share-panel').css('display','inline');
		return false;
	});
	$('.share-close').click(function(){
		$(this).parents('.rss-item').find('.share-panel').slideUp('fast');
		return false;
	});
	
	if ($('body').is('.newsletter')){
		var contents = '<div id="tableo-contents-list"><ul>';
		$('div.article').each(function(i){
			$(this).attr('id','article-'+i).append('<div class="article-anchor"><a href="#content">Back to Top</a></div>');
			contents+='<li><a href="#article-'+i+'">'+$(this).find('h3').text()+'</a><br /><span>'+$(this).find('h4').text()+'</span></li>';
		});
		contents+='</ul></div>';
		$('div#tableo-contents').append(contents);
	}

	$("#spring-sale-modal").each(function() {
		var springModalWidth = ($(window).width()-$(this).width())/2;
		$(this).css('left',springModalWidth);
		$(this).css('top','120px');
		$(this).jqm({closeClass:'spring-sale-close,'}).jqmShow();
	});

});

/* Virtual Tour JS */

function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
popup = 1

}

function CloseWindow() {
if (popup == 1)
  {
  win.close();
    }
}

/* Photo gallery */

function openPreview(urlrequest) {
	window.open(urlrequest, 'myWindow', 'width=750,height=520,left=100,top=100,toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No');
	document.getElementById('flashCallBox').value = urlrequest;
}

function sendLocation(location) {
	//check if Flash object exists
	if (window.document.userMap) {
		//set title variable in _root timeline of the userMap movie
		window.document.userMap.SetVariable("locationID", location);
	}
}
