$(function() {
	$('.jda').each(function(){
		$(this).accordion({
		   header: ".header",
		   autoHeight: false
		});
	});

	$(document).pngFix();
	
	if(BROWSER!='msie6') { $('body:not(.home) #content-inner').pageSearch(); }
	
	//$('#res-tabs').tabs();	
	$('#res-adv-search').click(function() {
		$(this).hide();
		$('#adv-search').slideDown("slow");		
		return false;
	});
	$('#res-simp-search').click(function() {
		$('#adv-search').slideUp("slow",function() { $('#res-adv-search').show(); });		
		return false;
	});
	$('.follow-link').initializeFollowing();
	
	
	/*------- Interior Flash ----------*/
	$("#photo-gallery").flash(
		{src:"flash/photo_gallery.swf",
		 width:466,
		 height:370,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"},
		function(htmlOptions) { //Use this to specify a query string, take out if not needed.
			htmlOptions.flashvars.epostConfigXML = "flash/xml/epostConfig.xml";
			htmlOptions.flashvars.imagesXML = "flash/xml/images.xml";
			htmlOptions.flashvars.langXML = "flash/xml/formLabels_english.xml";
			$(this).html($.fn.flash.transform(htmlOptions));
		});	
	$("#photo-gallery2").flash(
		{src:"flash/photo_gallery2.swf",
		 width:466,
		 height:370,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"},
		function(htmlOptions) { //Use this to specify a query string, take out if not needed.
			htmlOptions.flashvars.epostConfigXML = "flash/xml/epostConfig.xml";
			htmlOptions.flashvars.imagesXML = "flash/xml/photo-gallery-images2.xml";
			htmlOptions.flashvars.langXML = "flash/xml/formLabels_english.xml";
			$(this).html($.fn.flash.transform(htmlOptions));
		});	



    $("div#photo-gallery-beta").flash(
        {src:"flash/photo_gallery_beta.swf",
         width:700,
         height:392,
         wmode:"transparent",
         quality:"high"},       
         {version:"10"},
            function(htmlOptions) { //Use this to specify a query string, take out if not needed.
                htmlOptions.flashvars.epostConfigXML="flash/xml/epostConfig-beta.xml";
                htmlOptions.flashvars.imagesXML="flash/xml/images-beta.xml";
                htmlOptions.flashvars.langXML="flash/xml/i18n/en_formLabels.xml";
                $(this).html($.fn.flash.transform(htmlOptions));
        });
        
        
    // New photo galleries
    $("div#photo-gallery-meetings").flash(
        {src:"flash/photo_gallery_new.swf",
         width:470,
         height:391,
         wmode:"transparent",
         quality:"high"},       
         {version:"8"},
            function(htmlOptions) { //Use this to specify a query string, take out if not needed.
                htmlOptions.flashvars.epostConfigXML="flash/xml/epostConfig-new.xml";
                htmlOptions.flashvars.imagesXML="flash/xml/images-meetings.xml";
                htmlOptions.flashvars.langXML="flash/xml/i18n/en_formLabels.xml";
                $(this).html($.fn.flash.transform(htmlOptions));
        });  
    $("div#photo-gallery-golf").flash(
        {src:"flash/photo_gallery_new.swf",
         width:470,
         height:391,
         wmode:"transparent",
         quality:"high"},       
         {version:"8"},
            function(htmlOptions) { //Use this to specify a query string, take out if not needed.
                htmlOptions.flashvars.epostConfigXML="flash/xml/epostConfig-new.xml";
                htmlOptions.flashvars.imagesXML="flash/xml/images-golf.xml";
                htmlOptions.flashvars.langXML="flash/xml/i18n/en_formLabels.xml";
                $(this).html($.fn.flash.transform(htmlOptions));
        });    
    $("div#photo-gallery-spa").flash(
        {src:"flash/photo_gallery_new.swf",
         width:470,
         height:391,
         wmode:"transparent",
         quality:"high"},       
         {version:"8"},
            function(htmlOptions) { //Use this to specify a query string, take out if not needed.
                htmlOptions.flashvars.epostConfigXML="flash/xml/epostConfig-new.xml";
                htmlOptions.flashvars.imagesXML="flash/xml/images-spa.xml";
                htmlOptions.flashvars.langXML="flash/xml/i18n/en_formLabels.xml";
                $(this).html($.fn.flash.transform(htmlOptions));
        });    
    $("div#photo-gallery-general").flash(
        {src:"flash/photo_gallery_new.swf",
         width:470,
         height:391,
         wmode:"transparent",
         quality:"high"},       
         {version:"8"},
            function(htmlOptions) { //Use this to specify a query string, take out if not needed.
                htmlOptions.flashvars.epostConfigXML="flash/xml/epostConfig-new.xml";
                htmlOptions.flashvars.imagesXML="flash/xml/images-general.xml";
                htmlOptions.flashvars.langXML="flash/xml/i18n/en_formLabels.xml";
                $(this).html($.fn.flash.transform(htmlOptions));
        });
    $("div#photo-gallery-activities").flash(
        {src:"flash/photo_gallery_new.swf",
         width:470,
         height:391,
         wmode:"transparent",
         quality:"high"},       
         {version:"8"},
            function(htmlOptions) { //Use this to specify a query string, take out if not needed.
                htmlOptions.flashvars.epostConfigXML="flash/xml/epostConfig-new.xml";
                htmlOptions.flashvars.imagesXML="flash/xml/images-activities.xml";
                htmlOptions.flashvars.langXML="flash/xml/i18n/en_formLabels.xml";
                $(this).html($.fn.flash.transform(htmlOptions));
        });         
        
    
	$("#wedding-gallery").flash(
		{src:"flash/photo_gallery_weddings.swf",
		 width:862,
		 height:470,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"},
		function(htmlOptions) { //Use this to specify a query string, take out if not needed.
			htmlOptions.flashvars.epostConfigXML = "flash/xml/epostConfig.xml";
			htmlOptions.flashvars.imagesXML = "flash/xml/imagesWedding.xml";
			htmlOptions.flashvars.langXML = "flash/xml/formLabels_english.xml";
			$(this).html($.fn.flash.transform(htmlOptions));
		});	
		
	
//	$("div#photo-gallery").flash(
//			{src:"photoGallery/photo_gallery.swf?xmlCategory=photoGallery/weddings_xml.php",
//			 width:490,
//			 height:430,
//			 wmode:"transparent",
//			 quality:"high"},
//			 {version:"7"});
//	

	$("div#photoGallery").flash(
		{src:"/flash/photoGallery/photo_gallery.swf?xmlCategory=photoGallery/familyPhotos_xml.php",
		 width:490,
		 height:430,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"7"}
	);
	
	$("#guest-photo-gallery").flash(
		{src:"flash/guest_photo_gallery.swf",
		 width:480,
		 height:350,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"},
		function(htmlOptions) { //Use this to specify a query string, take out if not needed.
			htmlOptions.flashvars.imagesXML = "flash/xml/images.xml";
			$(this).html($.fn.flash.transform(htmlOptions));
		});	
	
	$("#photo-gallery-wrapper").each(function(){
		$("#photo-gallery2").hide();
		$("#pg-summer a").click(function(e){
			$("#photo-gallery-wrapper ul li").removeClass('current');
			$(this).parent().addClass('current');
			$("#photo-gallery").show();
			$("#photo-gallery2").hide();
			e.preventDefault();
		});
		$("#pg-winter a").click(function(e){
			$("#photo-gallery-wrapper ul li").removeClass('current');
			$(this).parent().addClass('current');
			$("#photo-gallery").hide();
			$("#photo-gallery2").show();
			e.preventDefault();
		});
	});

	$("#sr-crosswaters").flash({src:"flash/sr_courseCrosswaters.swf", width:700, height:400, wmode:"transparent", quality:"high"}, {version:"8"});
	$("#sr-meadows").flash({src:"flash/sr_courseMeadows.swf", width:700, height:400, wmode:"transparent", quality:"high"}, {version:"8"});
	$("#sr-woodlands").flash({src:"flash/sr_courseWoodlands.swf", width:700, height:400, wmode:"transparent", quality:"high"}, {version:"8"});
	$("#sr-meeting-space").flash({src:"flash/sr_meetingTour.swf", width:700, height:350, wmode:"transparent", quality:"high", name:"meetingtour", id:"meetingtour"}, {version:"8"});
	$("#video-tour").flash( {src:"video-tour.swf", width:318, height:280, wmode:"transparent", quality:"high" }, {version:"7"});
	$("#dhr-flash").flash( {src:"http://www.destinationhotels.com/flash/branding/flash_logoDhr.swf?link=sunriver-resort", width:250, height:25, wmode:"transparent", quality:"high", allowscriptaccess:"always"}, {version:"7"});
	
	$("#map-nav").flash({src:"/flash/sr_resortMap_userNav.swf", width:175, height:570, wmode:"transparent", quality:"high"}, {version:"8"});

	$("#debra-video").flash(
		{src:"/flash/debra-video.swf", 
 		 width:650, 
 		 height:409, 
 		 wmode:"transparent", 
		 quality:"high"}, 
		 {version:"8"},
		 function(htmlOptions) { //Use this to specify a query string, take out if not needed.
	 		htmlOptions.flashvars.flvPath = "/flash/assets/debra2.flv";
			htmlOptions.flashvars.skinPath = "/flash/SkinUnderAllNoFullNoCaption.swf";
			$(this).html($.fn.flash.transform(htmlOptions)); 
		});

	$("#debra-video2").flash(
		{src:"/flash/debra-video.swf", 
 		 width:650, 
 		 height:409, 
 		 wmode:"transparent", 
		 quality:"high"}, 
		 {version:"8"},
		 function(htmlOptions) { //Use this to specify a query string, take out if not needed.
	 		htmlOptions.flashvars.flvPath = "/flash/assets/debra3.flv";
			htmlOptions.flashvars.skinPath = "/flash/SkinUnderAllNoFullNoCaption.swf";
			$(this).html($.fn.flash.transform(htmlOptions)); 
		});


	$("#todd-video").flash(
		{src:"/flash/todd-video.swf", 
		 width:650, 
		 height:409, 
		 wmode:"transparent", 
		 quality:"high"}, 
		 {version:"8"},
		 function(htmlOptions) { //Use this to specify a query string, take out if not needed.
	 		htmlOptions.flashvars.flvPath = "flash/assets/todd2.flv";
			htmlOptions.flashvars.skinPath = "/flash/SkinUnderAllNoFullNoCaption.swf";
			$(this).html($.fn.flash.transform(htmlOptions)); 
		});
	
	$("#todd-video2").flash(
		{src:"/flash/todd-video.swf", 
		 width:650, 
		 height:409, 
		 wmode:"transparent", 
		 quality:"high"}, 
		 {version:"8"},
		 function(htmlOptions) { //Use this to specify a query string, take out if not needed.
	 		htmlOptions.flashvars.flvPath = "/flash/assets/todd3.flv";
			htmlOptions.flashvars.skinPath = "/flash/SkinUnderAllNoFullNoCaption.swf";
			$(this).html($.fn.flash.transform(htmlOptions)); 
		});	
	
	$("#liz-video").flash(
		{src:"/flash/liz-video.swf", 
		width:650, 
		height:409, 
		wmode:"transparent", 
		quality:"high"}, 
		{version:"8"},
		 function(htmlOptions) { //Use this to specify a query string, take out if not needed.
	 		htmlOptions.flashvars.flvPath = "flash/assets/liz2.flv";
			htmlOptions.flashvars.skinPath = "/flash/SkinUnderAllNoFullNoCaption.swf";
			$(this).html($.fn.flash.transform(htmlOptions)); 
		});
	$("#lindsay-video").flash(
		{src:"/flash/lindsay-video.swf", 
		width:650, 
		height:409, 
		wmode:"transparent", 
		quality:"high"}, 
		{version:"8"},
		 function(htmlOptions) { //Use this to specify a query string, take out if not needed.
	 		htmlOptions.flashvars.flvPath = "flash/assets/lindsay2.flv";
			htmlOptions.flashvars.skinPath = "/flash/SkinUnderAllNoFullNoCaption.swf";
			$(this).html($.fn.flash.transform(htmlOptions)); 
		});
	$("#lindsay-video2").flash(
		{src:"/flash/lindsay-video.swf", 
		width:650, 
		height:409, 
		wmode:"transparent", 
		quality:"high"}, 
		{version:"8"},
		 function(htmlOptions) { //Use this to specify a query string, take out if not needed.
	 		htmlOptions.flashvars.flvPath = "/flash/assets/lindsay3.flv";
			htmlOptions.flashvars.skinPath = "/flash/SkinUnderAllNoFullNoCaption.swf";
			$(this).html($.fn.flash.transform(htmlOptions)); 
		});
	$("#josee-video").flash(
		{src:"/flash/josee-video.swf", 
		width:650, 
		height:409, 
		wmode:"transparent", 
		quality:"high"}, 
		{version:"8"},
		 function(htmlOptions) { //Use this to specify a query string, take out if not needed.
	 		htmlOptions.flashvars.flvPath = "flash/assets/josee2.flv";
			htmlOptions.flashvars.skinPath = "/flash/SkinUnderAllNoFullNoCaption.swf";
			$(this).html($.fn.flash.transform(htmlOptions)); 
		});
	$("#josee-video2").flash(
		{src:"/flash/josee-video.swf", 
		width:650, 
		height:409, 
		wmode:"transparent", 
		quality:"high"}, 
		{version:"8"},
		 function(htmlOptions) { //Use this to specify a query string, take out if not needed.
	 		htmlOptions.flashvars.flvPath = "/flash/assets/josee3.flv";
			htmlOptions.flashvars.skinPath = "/flash/SkinUnderAllNoFullNoCaption.swf";
			$(this).html($.fn.flash.transform(htmlOptions)); 
		});

	$("#resort-map").flash({
		name: "userMap",
		src:"/flash/property-map.swf", 
		width:781, 
		height:594, 
		wmode:"transparent", 
		quality:"high"}, 
		{version:"8"},
		function(htmlOptions) { //Use this to specify a query string, take out if not needed.
			if(xloc!=''&&yloc!='') {
				htmlOptions.flashvars.initX = xloc;
				htmlOptions.flashvars.initY = yloc;
			}
			htmlOptions.flashvars.initZoom = zoom;
			htmlOptions.flashvars.initMap = initmap;	
            htmlOptions.flashvars.file = xmlFile;	
			$(this).html($.fn.flash.transform(htmlOptions));
		});	
	
	$("#wedding-movie").each(function() {
		var swf = $(this).attr('rel');							  
		$(this).flash(
		{src:"/flash/"+swf+".swf",
		 width:450,
		 height:299,
		 wmode:"transparent",
		 quality:"high"},
		 {version:"8"});	
	});

	
	/*--------- Masthead Flash -------------- */
	//$(".home #masthead div").flash({src:"/flash/homepage.swf", width:898, height:333, wmode:"transparent", quality:"high"}, {version:"8"});
	
	$(".home #masthead div").flash({
	src:"/flash/homepage.swf", 
	width:898, 
	height:333, 
	wmode:"transparent", 
	quality:"high"}, 
	{version:"8"},
	function(htmlOptions) { //Use this to specify a query string, take out if not needed.
		htmlOptions.flashvars.xmlPath = "http://www.mtbachelor.com/winter/mountain/snow_report/bachelor.xml";
		$(this).html($.fn.flash.transform(htmlOptions));
	});	
	
	$(".accomm-main #masthead div").flash({src:"/flash/Accommodations.swf", width:898, height:297, wmode:"transparent", quality:"high"}, {version:"8"});
	$(".act-main #masthead div").flash({src:"/flash/Activities.swf", width:898, height:297, wmode:"transparent", quality:"high"}, {version:"8"});
	$(".central-main #masthead div").flash({src:"/flash/CentralOregon.swf", width:898, height:297, wmode:"transparent", quality:"high"}, {version:"8"});
	$(".golf-main #masthead div").flash({src:"/flash/Golf.swf", width:898, height:297, wmode:"transparent", quality:"high"}, {version:"8"});
	$(".meetings-main #masthead div").flash({src:"/flash/Meetings.swf", width:898, height:297, wmode:"transparent", quality:"high"}, {version:"8"});
	$(".resort-main #masthead div").flash({src:"/flash/Resort.swf", width:898, height:297, wmode:"transparent", quality:"high"}, {version:"8"});
	$(".offers-main #masthead div").flash({src:"/flash/Special-Offers.swf", width:898, height:297, wmode:"transparent", quality:"high"}, {version:"8"});

	$('.spa .block > h2').sifr({ strSWF: '/fonts/academy-engraved.swf', strColor: '#5F6D69', strWmode: 'transparent', strCase: 'upper' }, { expressInstall: true });
	
	$('form#activity h3').sifr({ strSWF: '/fonts/georgia-bold.swf', strColor: '#787d9d', strWmode: 'transparent' }, { expressInstall: true });
	$('form#activity label#comment-label').sifr({ strSWF: '/fonts/georgia-bold.swf', strColor: '#787d9d', strWmode: 'transparent' }, { expressInstall: true });
	
	
	//Photo of the week popup
	$('#photo-of-the-week-link').each(function(){
											   
		//Center modal function
		var centerModal=function(hash){
			hash.w.show();
			hash.w.css("position","absolute");
			var top = ( $(window).height() - hash.w.outerHeight() ) / 2+$(window).scrollTop();
			if ( top < 0 ) {
				top = 10;
			}
			hash.w.css("top", top + "px");
			hash.w.css("left", ( $(window).width() - hash.w.outerWidth() ) / 2+$(window).scrollLeft() + "px");
		};
		$('#wrapper').after('<div id="week-photo-wrapper" class="jqmWindow"></div>');
		$.get('photo-of-the-week.php',function(data){
				$("#week-photo-wrapper").html(data);							   
		});
		$('#week-photo-wrapper').jqm({onShow:centerModal,trigger: '#photo-of-the-week-link'});

	});

	$('#offers').each(function() {
		var obj = $(this);
		var count = $(this).children().length;
		if(count>1) {
			//var rand = Math.floor(Math.random()*count)
			//$(this).children().hide().siblings(':eq('+rand+')').show().addClass('current');
			$(this).children().eq(0).addClass('current').siblings().hide();
			
			$('<div/>').attr('id', 'push-next')
			.html('<a href="">more offers</a> <img src="images/buttons/push-next.gif" alt="" />')
			.bind("click", function() {
				$(this).hide();
				if($('.current', obj).is(':last-child'))
					$('.current', obj).css({position: 'absolute', left: 0, top: 0}).fadeOut("slow", function() {
						$(this).removeClass('current');
					}).siblings('.offer:eq(0)').fadeIn(2500, function() { 
						$(this).addClass('current');
						$('#push-next').fadeIn("fast");
					});
				else
					$('.current', obj).css('position', 'absolute').fadeOut("slow", function() {
						$(this).removeClass('current');
					}).next('.offer').fadeIn(2500, function() { 
						$(this).addClass('current');
						$('#push-next').fadeIn("fast");
					});
				return false;
			}).prependTo(obj);	
		}
		
		$('div.headline a').bind("click", function() {
		if($('.current', obj).is(':last-child'))
			$('.current', obj).css({position: 'absolute', left: 0, top: 0}).fadeOut("slow", function() {
				$(this).removeClass('current');
			}).siblings('.offer:eq(0)').fadeIn(2500, function() { 
				$(this).addClass('current');
				$('#push-next').fadeIn("fast");
			});
		else
			$('.current', obj).css('position', 'absolute').fadeOut("slow", function() {
				$(this).removeClass('current');
			}).next('.offer').fadeIn(2500, function() { 
				$(this).addClass('current');
				$('#push-next').fadeIn("fast");
			});
		return false;
	})
		
	});
	

    $("#diamond-wrapper").each(function(){
        $(this).hide();
        var diamondBox = $(this);
        $("#diamond-click").click(function(){
            diamondBox.fadeIn();
            return false;
        });
        $("#diamond-close").click(function(){
            diamondBox.fadeOut();
            return false;
        });        
    
    });

	$('body:not(.home, .spa) .block').hover(function() { $(this).stop().animate({paddingTop: '9px'}, 'fast'); },
									  function() { $(this).stop().animate({paddingTop: '5px'}, 'fast'); });
	
	$('.send-to-list').click(function() {
		var len = $('#request-list li').length;
		if(len===10) {
			alert("Limit Reached");
		} else {
			var name = $(this).parents('td').prevAll('.property').text();
			var id = this.rel;
			var li = $('<li />').attr('id', 'prop-'+id).appendTo('#request-list');
			var el = this;
			    $.post('/update-list.php', { 
				func: 'add',
				springerId: id,
				propName: name
			    });
			$(el).effect("transfer", { to: li }, 600, function() {
				var cl = $('<img class="remove" src="../images/x.gif" title="Remove from List" />').click(function() {
					removeItem(this);
				});
				li.html(name).append(cl);
			}).hide();
		}
		return false;
	});
	
	$("#request-list").each(function(){
		$(this).sortable({
			axis: 'y',
			containment: 'parent',
			items: 'li',
			opacity: .5,
			cancel: '.remove',
			placeholder: 'sort-temp',
			update: function() { 
				var list = $('#request-list').sortable("serialize"); 
				$.post('/update-list.php', { func: 'sort', springerId: list }); 
			}
		});
	});
	
	$('#request-list li .remove').click(function() { removeItem(this); });
	
	function removeItem(el) {
		var id = $(el).parent().attr('id').replace(/(prop-)/,'');
		$.post('/update-list.php', { func: 'remove', springerId: id });
		$(el).parent().remove();
		if(BROWSER=='msie6'||BROWSER=='msie7') {
			$('a[rel='+id+']').show();
		} else {
			$('a[rel='+id+']').fadeIn('fast');
		}
	}
	
	$('#unit-description #text').jScrollPane({scrollbarWidth: 15, dragMinHeight: 34, dragMaxHeight: 34});
	
	$(".zoom-in:eq(0)").each(function() { $('<script type="text/javascript" src="/js/jquery.fancybox.js"></script>').appendTo('head'); });
	$('.zoom-in').each(function() {	$(this).fancybox(); });
	$('#vt-fancy').each(function() { $(".zoom-in", this).fancybox({ zoomSpeedIn: 0, zoomSpeedOut: 0, overlayShow: true, frameWidth: 800, frameHeight: 545 }); });
	$('.wd-fancy').each(function() { $(".zoom-in", this).fancybox({ zoomSpeedIn: 0, zoomSpeedOut: 0, overlayShow: true, frameWidth: 465, frameHeight: 315 }); });
	$('#blog-login-form').each(function() { $(".zoom-in", this).fancybox({ zoomSpeedIn: 0, zoomSpeedOut: 0, overlayShow: true, frameWidth: 465, frameHeight: 250 }); });
	$('#post-link').each(function() { $(".zoom-in", this).fancybox({ zoomSpeedIn: 0, zoomSpeedOut: 0, overlayShow: true, frameWidth: 465, frameHeight: 250 }); });
	
	$('#show-unit').each(function() {
		var href = $(this).attr('href').replace('sunriver-oregon-map', '/sunriver-flash-map')+"&inline=true";
		$(this).attr('href', href);
		$(this).fancybox({ zoomSpeedIn: 0, zoomSpeedOut: 0, overlayShow: true, frameWidth: 795, frameHeight: 610 }); 								
	});

	//inset videos
	$('#video-push a').each(function() {
		var href = $(this).attr('href').replace('/sunriver-oregon-video', '/sunriver-video');
		var href = $(this).addClass('thickbox').attr('href').replace('/sunriver-oregon-video', '/sunriver-video')+"&keepThis=true&TB_iframe=true&height=500&width=524";
		$(this).attr('href', href);
		$('body').addClass('video');
	});

	$('#msn-map').each(function() {				
		$(this).msnMap({ listView: true });
	});
	
	$('li.event a.btn-view-details').toggle(function() {
		var el = this;
		$.get('/includes/events-calendar-details-dhr.php', { event_id:$(this).attr('id') },function(data) { 
			$(el).children().attr('src', '/images/interior/btn-hide-details.gif').attr('alt', 'Hide Details')
				 .end().parent().children('.event-description').hide().html(data).slideDown('slow');
		});
		return false;								   
	},function() { 
		var el = this;
		$(el).children().attr('src', '/images/interior/btn-view-details.gif').attr('alt', 'View Details')
			 .end().parent().children('.event-description').slideUp('slow', function() { 
			 	$(this).html(''); 
			});
		return false;								   
	});


	$('#flickr-feed').each(function() {
		$('<script type="text/javascript" src="/js/jquery.fancybox.js"></script>').appendTo('head');
		var feed = this;
		var sec = $(this).attr('class');
		$.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?tags=sunriver,oregon,"+sec+"&format=json&jsoncallback=?",
		function(data){
			var items = [];
			while(items.length<3) {
				var dup = false;
				var rand = Math.floor(Math.random()*data.items.length)
				$.each(items, function(j, val) {
					if(rand == val)
						dup = true; 
				});
				if(!dup) { 
					items.push(rand); 
				}
			}
			var pic = data.items;
			$.each(items, function(i, v){
				var url = pic[v].media.m.replace("_m.jpg", "_t.jpg");
				var full = pic[v].media.m.replace("_m.jpg", ".jpg");
				$("<div"+((i==2)?' class="last"':'')+"/>").html('<a href="'+full+'" class="zoom-in" rel="group"><img src="'+url+'" alt="" /></a>').appendTo(feed);
			});
			$(".zoom-in", feed).fancybox(); 								
		});
	});
	
	$('.form-help').hide();
	$('.help-link').toggle( function() {
		$(this).parents('.field').children('.form-help').show();
		return false;
	},function(){ 
	  $(this).parents('.field').children('.form-help').hide();
	  return false;
	});
	
	
	//Shows and hides disclaimer info for photo submission
	$('div.terms').hide();
	$('a.toggle').toggle(function(){ 
	  $(this).parents('li').children('.terms').show();
	  return false;
	},function(){ 
	  $(this).parents('li').children('.terms').hide();
	  return false;
	});

	if(BROWSER=='msie6') {
		$('#nav > ul > li').hover(
			function() { $(this).addClass('hover'); },
			function() { $(this).removeClass('hover'); }
		);					
	}
	
	$('#nav > ul > li').hover(
		function() { $(this).children('ul').hide().fadeIn(300); },
		function() { $(this).stop().children('ul').hide(); }
	);


	// Share Functionality
	$('.share-link').click(function(event) {
		event.preventDefault();
		$('.share-panel').hide();
		$(this).parents('.rss-item').find('.share-panel').css('display','inline');
	});
	$('.share-close').click(function(event){
		event.preventDefault();
		$(this).parents('.rss-item').find('.share-panel').slideUp('fast');
	});


	$("select#reserve_addtl").change( function () {
		var el = $(this).parent().next();
		var el2 = $(this).parent().next().next();
		if($(this).val() == "yes") {
			el.show().children('label, select').addClass("required");
			el2.show().children('label, ul').addClass("required");
		} else {
			el.hide().children().removeClass("required").find("select").val("");
			el2.hide().children().removeClass("required");
			$('.validation-error', el).removeError('form#trailblazers-form');
			$('.validation-error', el2).removeError('form#trailblazers-form');
		}
	});


	//Difference table striping
	$('table#difference-table').children('tbody').children('tr:odd').addClass('stripe');
	$('table#difference-table').children('tbody').children('tr').each(function () { $(this).children('td:first').addClass('first'); });
	$('table#difference-table div.popup-wrapper').hide();
	$('table#difference-table div.popup-wrapper').each(function() { 
		var closer = $('<div>').addClass('popup-close');
		$(closer).html('<a href="">close X</a>');		
		$(this).append(closer);
		$(closer).children('a').bind('click',function(){ $(closer).parent().hide(); return false; });		
	});
	$('table#difference-table tr td a.popup-link').hover(function(){
		$('table#difference-table div.popup-wrapper').hide();											   
		elemPos = this;
		var popupheight = $(this).next('div.popup-wrapper').height();
		var linkwidth = $(this).width();
		$(this).next('div.popup-wrapper').css('top', (elemPos.offsetTop - popupheight - 90)+ 'px');
		$(this).next('div.popup-wrapper').css('left', (elemPos.offsetLeft + linkwidth)+ 'px');
		$(this).next('div.popup-wrapper').show();
	},
	function() {});


		$('form#activity').each(function() {
			var form = $(this);					
			$("ul.checkboxgroup input.other", form).not(':radio, :checkbox').hide();
			$("ul.checkboxgroup input.other", form).next().next('label').hide();
			$("ul.checkboxgroup input:not(:text)", form).click(function() {
				if($(this).hasClass('other')) {
					$(this).parent().addClass('highlight');
					$(this).siblings().addClass('required').show();
					if(!$(this).is(':checked')) {
						$('.validation-error', $(this).parents('ul')).removeError(form);
						$(this).siblings().removeClass('required').filter(':text').hide();
						$(this).next().next('label').hide();
						$(this).parent().removeClass('highlight');
					}
				} else if($(this).is(':radio')) {					
					$('.validation-error', $(this).parents('ul')).removeError(form);
					$('.other', $(this).parents('ul')).siblings().removeClass('required').filter(':text').hide();
				}
			});

			$("ul.checkboxgroup input:not(:text)").each(function() { 
				if ( $(this).is(':checked') ) {
					//var $(this) = $("ul.checkboxgroup input:not(:text)");
					//alert( $(this).attr('id') );
					$(this).parent().addClass('highlight');
					$(this).siblings().addClass('required').show();
				}
			});
		});

	//Connect Push
	$(document).ready(function(){
		if($.cookie('connect-rp') != 'clicked-connect') {
			$.cookie('connect-rp', 'not-clicked');
			$("div#bottom-connect-with-outer-wrapper").animate({ bottom: 0 }, 500 );
			//alert($.cookie('connect-with'));
		}
	});
	
	$('div#bottom-connect-with-outer-wrapper a').click(function() {
		$("div#bottom-connect-with-outer-wrapper").animate({ bottom: -60 }, 200 );
		$.cookie('connect-rp', 'clicked-connect');
		//alert($.cookie('connect-with'));		
	});

	/* Video popup link
	$('.video-link').each(function() {
	    var vid = $(this).next('.video'),
		container = $('<div id="video-popup" class="modal"/>')
	    .appendTo( $('#wrapper') )
	    .append( vid );
	    //.jqm({trigger:this});
	});*/

var vidSrc = $("div#video-dialog iframe").attr("src");
var flashWidth;
function ResizeFlash (flashWidth) { $("#photo-gallery").css("width",flashWidth); }


	$('#site-search').bind('click',function() { $(this).val(''); });

	
	var openFnVideo=function(hash){
		hash.w.show();
		$('div#video-dialog iframe').attr('src', vidSrc);
	};

	var openFn=function(hash){
		hash.w.show();
	};

	var hideFnVideo=function(hash){
		var embedVideo = $("div#video-dialog embed").clone();
		$("div#video-dialog embed").remove().appendTo('div#video-dialog');
		$('div#video-dialog iframe').attr('src', '');
		hash.w.hide()
		hash.o.remove();
	};
	
	var hideFn=function(hash){
		hash.w.hide()
		hash.o.remove();
	};

	var openFnYouTube=function(hash){
		var caption = $(hash.t).find('.thumb-caption').text();
		var video = $(hash.t).attr('id');
		var vidid = video;
		var vidtype = 'v';
		/*var playlist = '';
		var section = $(hash.t).closest('.yt-thumbs');
		if (section.attr('id') == 'yt-summer-thumbs') {
			playlist = '&amp;playlist=5wUzQnvOYLU,yob5_4Ci7tA,ncCjiVw3zO8,QK7gmKuBlsQ,eilyCxFi9Sc,ZyfxzntpUg8,nmBCW7qtmvM';
		}*/
		
		$("#yt-vid").html('<object width="640" height="386"><param name="movie" value="http://www.youtube.com/'+vidtype+'/'+vidid+'?&amp;version=3?fs=1&amp;hl=en_US&amp;autoplay=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/'+vidtype+'/'+vidid+'&amp;?version=3?fs=1&amp;hl=en_US&amp;autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="386"></embed></object>');
		
		$('#yt-modal-caption').text(caption);
		hash.w.show();
	};

	var hideFnYouTube=function(hash){
		hash.w.hide()
		hash.o.remove();
		$('#yt-vid').empty();
	};

	
	$('#dialog').each(function(){
		$('#dialog').jqm({trigger: 'a.reviews-link', onShow: openFn, onHide: hideFn});
	});
	
	$('#video-dialog').each(function(){
		$('#video-dialog').jqm({trigger: 'a.video-link', onShow: openFnVideo, onHide: hideFnVideo});
	});

	$('#yt-modal').each(function(){
		$('#yt-modal').jqm({trigger: 'a.youtube-link', onShow: openFnYouTube, onHide: hideFnYouTube});
	});
	
	$('a.youtube-link').click(function() {
		$(this).addClass('current');
	});

	//Youtube video gallery tabs
	$("#youtube").each(function(){
		var listItem, place;
		place = 0;
		$('#yt-player div.yt-thumbs:eq('+place+')').addClass('active');
		$("#yt-nav li a").click(function(e){
			e.preventDefault();
			$("#yt-nav li").removeClass('current');
			$(this).parent().addClass('current');
			
			listItem = $('#yt-nav li.current');
			place = $('#yt-nav li').index(listItem);
			//console.log(place);
			$('#yt-player div.yt-thumbs').removeClass('active');
			$('#yt-player div.yt-thumbs:eq('+place+')').addClass('active');

			var pyt = $(this).parent().attr('id');
			pyt = pyt.substr(6);
			//$(".ytvid").removeClass('current');
			//$("#yt-"+pyt).addClass('current');
			var vidid;
			var vidtype;
			switch(pyt){
				case 'general':
					vidid = 'ckUAm0cz1kk';
					vidtype = 'v';
					break;
				case 'summer':
					vidid = '7ED2C560D67D4C80';
					vidtype = 'p';
					break;
				case 'winter':
					vidid = 'D1693DE64B3468B9';
					vidtype = 'p';
					break;
				case 'wedding':
					vidid = 'FMcbmiyuH8s';
					vidtype = 'v';
					break;		
			}
			/*$("#yt-vid").html('<object width="780" height="390"><param name="movie" value="http://www.youtube.com/'+vidtype+'/'+vidid+'?fs=1&amp;hl=en_US&amp;autoplay=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/'+vidtype+'/'+vidid+'?fs=1&amp;hl=en_US&amp;autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="780" height="390"></embed></object>');*/
			
		});
		
	});
	$('#aquatic-gallery-images').cycle({
		fx: 'fade',
		timeout: 5000,
		pager:  '#gallery-nav',
		pauseOnPagerHover: true 
	});
	
	$('#countdown_dashboard').countDown({
		targetDate: {
			'day': 		26,
			'month': 	5,
			'year': 	2012,
			'hour': 	8,
			'min': 		0,
			'sec': 		0
		},
		omitWeeks: true
	})

});

(function($) {
	$.fn.pageSearch = function() {
		return this.each(function() {
			var page = $(this);
			var selObj, selText, btn;
			
			page.bind('mouseup.page', function() {
				if($('#popup-search').length)
					$('#popup-search').unbind('click').remove();
				
				if(document.selection) {
					selObj = document.selection.createRange();
					selText = selObj.text;
				} else {
					selObj = window.getSelection();
					selText = selObj.toString();
				}
				if(selText)
					createButton();
			});
		
			function createButton() {
				btn = $('<span id="popup-search" />').attr('title', 'Click here to search this site for the highlighted term').html("?");						
						
				if(document.selection) {
					var tmpEl = $('<div />').append(btn);
					var tmpRange = selObj.duplicate();
					tmpRange.setEndPoint( "StartToEnd", selObj);
					tmpRange.pasteHTML(tmpEl[0].innerHTML);
				} else {
					var range = selObj.getRangeAt(0);
					var tmpRange = document.createRange();
					tmpRange.setStart(selObj.focusNode, range.endOffset);
					tmpRange.insertNode(btn[0]);	
				}
				
				$('#popup-search').bind('mouseup.btn', function() { 
					window.location.href = "/search-results.php?site_search="+selText;						  
					return false; 
				});
			}
		});
	};

	$.fn.initializeFollowing = function() {
		return this.each(function() {
			$('.follow-link').click(function(event) {
				event.preventDefault();
				$('.follow-panel').hide();
				$(this).siblings('.follow-panel').css('display','inline');
			});
			$('.follow-close').click(function(event){
				event.preventDefault();
				$(this).parent('.follow-panel').slideUp('fast');
			});
		});
	};

})(jQuery);

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);
	}
}

function resortMapThickbox(map) {
	$('img#thickbox-map').attr('src','images/loadingAnimation.gif');
	$('#res-console form').css('position','static');
	switch (map){
		case 'caldera':
			$('img#thickbox-map').attr('src','images/interior/map-caldera.gif');
		  	tb_show('', '#TB_inline?height=335&width=875&inlineId=thickboxMap&modal=true', null);
		  	break;
		case 'crosswater':
			$('img#thickbox-map').attr('src','images/interior/map-crosswater.gif');
		  	tb_show('', '#TB_inline?height=458&width=875&inlineId=thickboxMap&modal=true', null);
		  	break;
		case 'sunriver':
			$('img#thickbox-map').attr('src','images/interior/map-sunriver.gif');
		  	tb_show('', '#TB_inline?height=530&width=567&inlineId=thickboxMap&modal=true', null);
		  	break;
		default:
		  	break;
	}			
}

function resizeBookingGallery(w){
    $('div#photo-gallery-beta').css('width',w+'px');
}

