$(function() {

    	var ie6 = window.ie6 = /*@cc_on!@*/false && !window.XMLHttpRequest;

	if ( ie6 ) {
	    $('#modal-home-close').css('background-image', 'url(images/blank.gif)');
	}
	
	// Navigation Function	
	if($('body').is('.home')) {	
		$('#meetings').css({ position: 'absolute', cssFloat: 'none' });
		$('#leisure').css({ position: 'absolute', cssFloat: 'none' });
	
		if( $('.current').attr('id') == 'leisure'){
			var lowerNavOffset = document.getElementById('leisure').offsetHeight;
			$('#leisure').css('top',0);
			$('#meetings').css('top',lowerNavOffset);
		}
	
		var navprimaryheight = (document.getElementById('leisure').offsetHeight) + (document.getElementById('meetings').offsetHeight);
		$('#nav-primary').css('height', navprimaryheight);
		var qsParms = new Array();
		var querystring = window.location.search.substring(1);
		var parms = querystring.split('&');
		for (var i=0; i<parms.length; i++) {
			var pos = parms[i].indexOf('=');
			if (pos > 0) {
				var key = parms[i].substring(0,pos);
				var val = parms[i].substring(pos+1);
				qsParms[key] = val;
			}
		}
			
		if (qsParms['sec'] == 'meetings') {
			flashsec = 'meetings';
			$('li#leisure').removeClass('current');
			$('li#meetings').addClass('current');
			var lowerNavOffset = document.getElementById('meetings').offsetHeight;
			$('#meetings').css('top',0);
			$('#leisure').css('top',lowerNavOffset);
			
		} else {
			flashsec = 'leisure';
			$('li#leisure').addClass('current');
		}
		
		$('#2masthead').flash({
			src: 'flash/masthead.swf',
			width: 729,
			height: 433,
			wmode: 'transparent',
			name: 'flashmasthead',
          flashvars: { section: flashsec }
		});			
		var flashPlayer;
		if(navigator.appName.indexOf('Microsoft') != -1) {
			flashPlayer = window.flashmasthead;
		} else {
			flashPlayer = window.document.flashmasthead;
		}	
		
		$('ul#nav-primary li').children('a').click( function() { 
			var currentlyClicked= $(this).parent().attr('id');
			var notClicked = $(this).parent().siblings('li').attr('id');
			var el = $('#'+currentlyClicked);
			var el2 = $('#'+notClicked);
			if ( currentlyClicked == 'leisure' || currentlyClicked == 'meetings' ) {
				flashPlayer.changeSection(currentlyClicked);
				//swap out nav
				if(parseInt(el.css('top')) != 0) {
					if ( currentlyClicked == 'meetings' )
						$('div#nav').css('backgroundColor','#807945');
					else
						$('div#nav').css('backgroundColor','#b47c3c');
	
					el.css('zIndex', -1);
					el2.css('zIndex', 0);					
					el.addClass('current');									
						
					lowerNavOffset = 356;	
						
					el.css('zIndex',100);
					el.animate({top: 0}, 800, function() { 
						el2.css('zIndex', 0);
						el2.css('top',lowerNavOffset+100);
						el2.removeClass('current');						
						el2.animate({top:lowerNavOffset},800);						
					});
				}
				$.ajax({
				  url: 'includes/push-' + currentlyClicked + '/special.php',
				  success: function(html){
					$('#push-left div:first-child').animate({opacity:0},700,function(){
					$('#push-left').html('').append(html);});
				  }
				});
				$.ajax({
				  url: 'includes/push-' + currentlyClicked + '/dining.php',
				  success: function(html){
					$('#push-right div:first-child').animate({opacity:0},700,function(){
					$('#push-right').html('').append(html);});
				  }
				});

				return false;
			}
		});
	} else {
		if ( ($('li#meetings').attr('class') != 'current last') && ($('li#leisure').attr('class') != 'current') ) {
			$('li#leisure').addClass('current');
		} else {
			var currentpri = $('ul#nav-primary').find('.current').attr('id');
			if(currentpri == 'meetings') { 
				$('li#meetings').css({ position: 'absolute', cssFloat: 'none' });
				$('li#leisure').css({ position: 'absolute', cssFloat: 'none' });
				var lowerNavOffset = document.getElementById('meetings').offsetHeight;
				$('li#meetings').css('top',0);
				$('li#leisure').css('top',lowerNavOffset);
			}
			
			if ( $('div#subnav').attr('id') != undefined ) {
				$('div#subnav').addClass(currentpri);
			}
		}
	}
	// Sifr
	// intPadding array order is: left, top, right, bottom - must match css for corresponding element
	//$('div#content div#breadcrumb span#main').sifr({ strSWF: 'flash/adobe-garamond-pro.swf', strColor: '#002b55;', strWmode: 'transparent' }, { expressInstall: true });
	//$('div#content div#breadcrumb span').sifr({ strSWF: 'flash/adobe-garamond-pro.swf', strColor: '#002b55;', strWmode: 'transparent' }, { expressInstall: true });
	//$('body.home div#content h2.push-header').sifr({ strSWF: 'flash/adobe-garamond-pro.swf', strColor: '#002b55;', strWmode: 'transparent', strCase: 'upper'}, { expressInstall: true });
	//$('body.home div#events-date h4').sifr({ strSWF: 'flash/georgia-italic.swf', strColor: '#ffffff;', strWmode: 'transparent', strFlashVars: 'textalign=center&' }, { expressInstall: true });
	//$('body.home div#events-date h5').sifr({ strSWF: 'flash/arial.swf', strColor: '#002b55;', strWmode: 'transparent', strFlashVars: 'textalign=center&', strCase: 'upper' }, { expressInstall: true });
	//$('div.tour-wrapper h4').sifr({ strSWF: 'flash/adobe-garamond-pro.swf', strColor: '#002b55;', strWmode: 'transparent', strFlashVars: 'textalign=center&' }, { expressInstall: true });
	//$('div#content h1.holiday-header').sifr({ strSWF: 'flash/adobe-garamond-pro.swf', strColor: '#002b55;', strWmode: 'transparent' }, { expressInstall: true });
	//$('div.package-links h4').sifr({ strSWF: 'flash/adobe-garamond-pro.swf', strColor: '#ffffff;', strLinkColor:'#ffffff', strHoverColor:'#ffffff', strWmode: 'transparent' }, { expressInstall: true });
	//$('div#room-types-content-wrapper h4').sifr({ strSWF: 'flash/adobe-garamond-pro.swf', strColor: '#23384d;', strWmode: 'transparent' }, { expressInstall: true });
	
	//$('table.avg-weather tbody tr td:odd').addClass('high');
	
	$('table.avg-weather tbody tr:odd').addClass('odd');
	$('table.avg-weather tr th:eq(1)').addClass('first');
	$('table.avg-weather tr td:eq(1)').addClass('first');
	$('table.avg-weather tbody tr').each(function(i){
		$(this).children('td:eq(1)').addClass('first');
		$(this).children('td:eq(2)').addClass('high');
		$(this).children('td:eq(4)').addClass('high');
		$(this).children('td:eq(3)').addClass('low');
		$(this).children('td:eq(5)').addClass('low');
	});
	
	// Flash
	$('div#dhr-flash').flash({src:'../www.destinationhotels.com/flash/branding/flash_logoDhr.swf@link=invernesshotel', width:250, height:25, wmode:'transparent', quality:'high', allowscriptaccess:'always'}, {version:'7'});
	$('div#interactive-map').flash({src:'flash/imap_redesign.swf', width:640, height:480, wmode:'transparent', quality:'high'}, {version:'7'});
	for(var i in $.browser) {
		if ($.browser[i])
			BROWSER = i + (($.browser.msie)?$.browser.version.charAt(0):'');
	}
	$('div#photo-gallery').flash({src:'flash/photo_gallery.swf',width:600,height:480,wmode:'transparent',quality:'high'},{version:'8'},
		function(htmlOptions) {
			htmlOptions.flashvars.browser = BROWSER;
			$(this).before($.fn.flash.transform(htmlOptions));			
		}
	);	
	
	$('div#meetings-gallery').flash( {src:'flash/photo_gallery.swf', width:466, height:420, wmode:'transparent', quality:'high'}, {version:'8'},
		function(htmlOptions) { 
			htmlOptions.flashvars.configFile = 'flash/xml/gallery_config_meetings.xml';
			htmlOptions.flashvars.xmlFile = 'flash/xml/images_meetings.xml';
			$(this).before($.fn.flash.transform(htmlOptions));						
	});
	
	$('div#weddings-gallery').flash({src:'flash/wedding_photo_gallery.swf', width:700, height:500, wmode:'transparent', quality:'high'},{version:'8'});	
	
	$('div#weddings-album').flash({src:'flash/wedding_album.swf', width:600, height:480,wmode:'transparent',quality:'high'},{version:'8'});	




});

function fillFields()
{
	if(document.gift_card.same_above.checked == true){
	  document.gift_card.recipient_prefix.value=document.gift_card.prefix.value;
	  document.gift_card.recipient_first_name.value=document.gift_card.first_name.value;
	  document.gift_card.recipient_last_name.value=document.gift_card.last_name.value;
	  document.gift_card.recipient_email.value=document.gift_card.email.value;
	  document.gift_card.recipient_phone.value=document.gift_card.phone.value;
	  document.gift_card.recipient_address1.value=document.gift_card.address1.value;
	  document.gift_card.recipient_address2.value=document.gift_card.address2.value;
	  document.gift_card.recipient_city.value=document.gift_card.city.value;
	  document.gift_card.recipient_state.value=document.gift_card.state.value;
	  document.gift_card.recipient_zip.value=document.gift_card.zip.value;
	}else{
		  document.gift_card.recipient_prefix.value='';
		  document.gift_card.recipient_first_name.value='';
		  document.gift_card.recipient_last_name.value='';
		  document.gift_card.recipient_email.value='';
		  document.gift_card.recipient_phone.value='';
		  document.gift_card.recipient_address1.value='';
		  document.gift_card.recipient_address2.value='';
		  document.gift_card.recipient_city.value='';
		  document.gift_card.recipient_state.value='';
		  document.gift_card.recipient_zip.value='';
	}
}
function updateGiftAmountValue(dropdownValue) {
	var radioLength = document.gift_card.shipping.length;
	for(var i = 0; i < radioLength; i++) {
		if(document.gift_card.shipping[i].checked) {
			var shippingAmount = document.gift_card.shipping[i].value;
		}
	}
	document.gift_card.total.value = ( parseInt(dropdownValue.value) + parseInt(shippingAmount) );
}
function updateShippingValue(radioValue) {
	document.gift_card.total.value = ( parseInt(radioValue.value) + parseInt(document.gift_card.gift_amount.value) );
}

