function openPreview(urlrequest) {
	window.open(urlrequest, 'myWindow', 'width=820,height=615,left=0,top=0,toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No');
}

$(function() {
	//Documentation located in special.docs.js
	
	
	//fall-promo lightbox
		$("#fall-promo-modal").each(function() {
		var windowWidth = ($(window).width()-$(this).width())/2;
		$(this).css('left',windowWidth);
		$(this).css('top','120px');
		$(this).jqm({closeClass:'fall-promo-close,'}).jqmShow();
	}); 
	
	
	
	//Global variables
	for(var i in $.browser) {
		if ($.browser[i])
			BROWSER = i + (($.browser.msie)?$.browser.version.charAt(0):'');
	}
	
	// H1 (Home) - Heading Sifr
		$('body.home h1').sifr(
		{ strSWF: '/flash/clarendon-lt-std.swf', strCase: 'upper', strColor: '#614000', strLinkColor: '#614000', strHoverColor: '#614000', strWmode: 'transparent', intPadding: [0, 0, 0, 0], strFlashVars: 'letter-spacing=12&' },
		{ expressInstall: true }
		
	);
	
	
	// H1 - Heading Sifr
		$('div#main-content h1').sifr(
		{ strSWF: '/flash/clarendon-lt-std.swf', strCase: 'upper', strColor: '#2c1e03', strLinkColor: '#2c1e03', strHoverColor: '#2c1e03', strWmode: 'transparent', intPadding: [0, 0, 0, 0], strFlashVars: 'letter-spacing=12&' },
		{ expressInstall: true }
		
	);


	$('div#masthead-home').flash({
	    swf:"flash/homepage-masthead.swf",
	    width:730,
	    height:356,
		params:{
			allowscriptaccess:"always",
			wmode:"transparent",
			flashvars:{
			epostConfigXML:'/flash/xml/epostConfig.xml',
			gatewayURL:'/flashservices/gateway.php',
			imagesXML:'/flash/xml/homepage-mast.xml',
			langXML:'/flash/xml/i18n/' + LANG + '_formLabels.xml'/*,
			browser:BROWSER*/
			}
		}
	});	
	
	$('div#dhr-logo').flash({
	    swf:"http://www.destinationhotels.com/flash/branding/flash_logoDhr.swf?link=estancialajolla",
	    width:250,
	    height:25,
		params: {
			allowscriptaccess:"always",
			wmode: "transparent",
			flashvars:{}
		}
	});
	
	$('div#photo-gallery').flash({
	    swf:"flash/photo-gallery.swf",
	    width:668,
	    height:444,
		params:{
			allowscriptaccess:"always",
			wmode:"transparent",
			flashvars:{
			epostConfigXML:'/flash/xml/epostConfig.xml',
			gatewayURL:'/flashservices/gateway.php',
			imagesXML:'/flash/xml/images.xml',
			langXML:'/flash/xml/i18n/' + LANG + '_formLabels.xml'/*,
			browser:BROWSER*/
			}
		}
	});
//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});
		if (typeof jQuery.prototype.msnMap != 'undefined') {	   
			$('#map').msnMap({listView:true, hotelOnly: false});
		}
	};
	var hideFn=function(hash){
		hash.w.hide()
		hash.o.remove();
		$('.places').remove();
	};
	$('#map-container').each(function(){ $(this).jqm({trigger:'#map-link', onShow: openFn, onHide: hideFn});});

//interactive meetings map
	var openMeetingFn=function(hash){
		hash.w.show();
		var leftPos = ($(window).width()-$('#meeting-map-container').width())/2;
		var topPos = Math.max($(window).scrollTop(),parseInt($('#meeting-map-container').css('top')))+10;
		$('#meeting-map-container').css({left:leftPos,top:topPos});
	};
	$('#meeting-map-container').each(function(){ $(this).jqm({trigger:'a.meeting-map', onShow: openMeetingFn, onHide: hideFn});});
	$('div#meeting-map').flash({
	    swf:"flash/meeting-map.swf",
	    width:853,
	    height:560,
		params:{
			allowscriptaccess:"always",
			wmode:"transparent",
			flashvars:{
			xmlPath:"/flash/xml/meeting-map.xml"
			}
		}
	});

	$('.wedding-gallery').each(function(){
		var gallery = $(this);
		$('ul a',gallery).each(function(){
			var thumb = $(this);
			var foo = new Image();//preload images.. ghetto-style
			foo.src = thumb.attr('href');
			thumb.click(function(e){
				e.preventDefault();
				$('#wedding-photo img').fadeTo('fast',0.01,function(){
					$(this).attr('src',thumb.attr('href')).fadeTo('slow',1);
				});
			});
		});
	});
	
	// Booking console - Check availability promo code click button
	$("form#reservations-console").each(function(){
		var x = $(this);
		$("a#promo-click", x).click(function(){
			$("#dropdown-fields",x).show();
			if (BROWSER=='version6') { $('select', x).hide(); }
			return false;
		});
		$("#extra-fields-close").click(function() {
			$("#dropdown-fields",x).hide();
			if (BROWSER=='version6') { $('select', x).show(); }
			return false;
		});
	});
	$("#promo-done-btn").click(function(){
		$("#dropdown-fields").hide();
		if ($('#group-code').val() || $('#promo-code').val() || $('#iata-number').val()) {
			$("#promo-click").addClass("selected-promo-click");
		} else {
			$("#promo-click").removeClass("selected-promo-click");
		}
		return false;
	});
	
	for(var i in $.browser) {
		if ($.browser[i])
			BROWSER = i + (($.browser.msie)?$.browser.version.charAt(0):'');
	}
	numVisible=3;
	perClick=1;
	
	$('body.home .push-cycle-text, body.home .push-cycle-photo').each( function() {
		numElem = $('ul li',this).length;
		//console.log('Items:'+numElem);//number of total per
		$('ul',this).css({width:numElem*300+'px'});
		$('.cycle-prev').addClass('prev-dim');
		$(this).serialScroll({
			next:'.cycle-next',
			prev:'.cycle-prev',
			items:'li',
			step:perClick,
			lock:false,
			cycle:false,
			force:true,
			exclude:2,
			easing:'easeInOutQuart',
			onBefore:function( e, elem, $pane, $items, pos ){
				$('.cycle-prev').removeClass('prev-dim');
				$('.cycle-next').removeClass('next-dim');
				if( pos == 0 ) {
					$('.cycle-prev').addClass('prev-dim');
				}
				else if( pos == numElem-numVisible ) {
					$('.cycle-next').addClass('next-dim');
				}
				//console.log('numElem:'+numElem);
				//console.log(' pos:'+pos);
			}
		});
	});

	$('body.home .push-cycle-photo li').each( function() {
		$(this).hover(function(){
			$('.push-text',this).animate({"top": "84px"},'medium');
			},function(){
			$('.push-text',this).animate({"top": "150px"},'medium');
		});
	});
    
	// Removes border on last weather item
	$("#weather-week").each(function(){
		$("li:last",this).addClass("last");
	});
	
	// Wifi tabs
	$("#mcc-nav").each(function(){

		var mccNav = $(this);
		$("li#mcc-events a",mccNav).click(function(e){
			e.preventDefault();
			$("#wifi-mcc-content").html('').html('<p id="loading"><img src="images/ajax-loader.gif" alt="loading..." border="0" width="16" height="16" /></p>');
			$.get('direct/wifi-events.php', function(data){
				if ( $('#events-wrapper').length == 0 ) {
$('#wifi-mcc-content').empty()
					$('#wifi-mcc-content').append( $('<div id="events-wrapper"></div>') )
}
				$("#wifi-mcc-content #events-wrapper").html(data);
				//shareButton()
			});
			$("#mcc-nav li a").removeClass("current");
			$(this).addClass("current");
		});

		$("li#mcc-offers a",mccNav).click(function(e){
			e.preventDefault();
			$("#wifi-mcc-content").html('').html('<p id="loading"><img src="images/ajax-loader.gif" alt="loading..." border="0" width="16" height="16" /></p>');
			$.get('direct/wifi-offers.php', function(data){
				$("#wifi-mcc-content").html(data);
				$('.package').packagePreview()
				//shareButton()
			});
			$("#mcc-nav li a").removeClass("current");
			$(this).addClass("current");
			
		});
	});
	
    // Gift card form
    $('select#gift_amount').change(function(){
        var amount = parseInt($(this).val());
        var shipping = 0;
        shipping = parseInt($('input.gift-shipping:checked').val());
        if(amount!=0){
            $('input#gift_amount_other').parent().hide();
            $('input#gift_amount_other').removeClass('required');
            $('input#gift_amount_other').val('');
            $('input#grand_total').val(amount+shipping);
        }else{
            $('input#gift_amount_other').parent().show();
            $('input#gift_amount_other').addClass('required');
            $('input#gift_amount_other').focusout(function(){
                amount = parseInt($(this).val());
                $('input#grand_total').val(amount+shipping);    
            });   
        }

    });
    $('input.gift-shipping').each(function(){
        $(this).change(function(){
            var amount = parseInt($('select#gift_amount').val());
            var shipping = parseInt($(this).val());
            $('input#grand_total').val(amount+shipping);    
        });   
    });
    $('input#same_as_above').change(function(){
        if($(this).attr('checked')==true){
            $('select#rec_prefix').val($('select#prefix').val());
            $('input#rec_first_name').val($('input#first_name').val());
            $('input#rec_last_name').val($('input#last_name').val());
            $('input#rec_email').val($('input#email').val());
            $('input#rec_phone').val($('input#phone').val());
            $('input#rec_address1').val($('input#address1').val());
            $('input#rec_address2').val($('input#address2').val());
            $('input#rec_city').val($('input#city').val());
            $('select#rec_state').val($('select#state').val());
            if($('select#rec_state').val()=='--'){
                $('input#rec_state_other').parent().show();    
            }
            $('input#rec_state_other').val($('input#state_other').val());
            $('input#rec_zip').val($('input#zip').val());
        }else{
            $('input#rec_state_other').parent().hide(); 
            $('select#rec_prefix').val('');
            $('input#rec_first_name').val('');
            $('input#rec_last_name').val('');
            $('input#rec_email').val('');
            $('input#rec_phone').val('');
            $('input#rec_address1').val('');
            $('input#rec_address2').val('');
            $('input#rec_city').val('');
            $('select#rec_state').val('');
            $('input#rec_state_other').val('');
            $('input#rec_zip').val(''); 
        }
    });
    var amount = parseInt($('select#gift_amount').val());
    var shipping = 0;
    shipping = parseInt($('input.gift-shipping:checked').val());
    $('input#grand_total').val(amount+shipping);
	 
		$('#testimonials span.rest').hide();
			$('.testimonial cite').hide();
			$('.testimonial cite').after('<a class="read-more" href="#">read more</a>');
			$('.testimonial a.read-more').click(function() {
				 $(this).parent().find('cite').show();
				 $(this).parent().find('.inline-quote').hide();
				 $(this).parent().find('.rest').show();
				 $(this).before('<a class="read-less" href="#">close</a>');
				 $('.testimonial a.read-less').click(function() {
				$(this).parent().find('cite').hide();
				$(this).parent().find('.inline-quote').show();
				$(this).parent().find('.rest').hide();
				$(this).parent().find('.read-more').show();
				$(this).hide();
				return false;
				 });
				 $(this).hide();
				 return false;
			});	
		});

