




function to_pageTracker(page) {
	_gaq.push(['_trackPageview', page]);
}
	


if($.tablesorter) {
	// add parser through the tablesorter addParser method 
	$.tablesorter.addParser({ 
		// set a unique id 
		id: 'commas_and_dollars', 
		is: function(s) { 
			// return false so this parser is not auto detected 
			return false; 
		}, 
		format: function(s) { 
			// format your data for normalization 
			s = s.replace('.00','');
			s = s.replace('$','');
			s = s.replace(',','');
			return parseInt(s);
		}, 
		// set type, either numeric or text 
		type: 'numeric' 
	}); 
	
}

$.urlParam = function(name){
	var results = new RegExp('/' + name + '').exec(window.location.href);
	if(results == undefined)
		return -1;
	else
		return results[1] || 0;
}


$('document').ready(function(){
	
	
	// Laura - Rewrites hash values used in floorplans when going to a n"L" unit
	if (location.href.indexOf("#") > -1) {
		hash_val = $.trim(location.href.split("#")[1]);
		
		if (hash_val.indexOf("/") > -1) {
			unit = hash_val.split("/")[1];
			
			if(unit.substr(unit.length-1) ==  "L") {
				unit = unit.substr(0,unit.length-1) 
				floor_no = hash_val.split("/")[0];
				flr = floor_no.substr(floor_no.length-1);
				url = "floor"+(flr-1)+"/"+unit;
				
				location.assign(location.href.replace(/\/?#([^.]*)/, '#'+url));
				window.location = location.href.replace(/\/?#([^.]*)/, '#'+url);
				//window.location.hash = url; 
		
			}
			if(unit.substr(unit.length-1) == "B") {
				unit = unit.substr(0,unit.length-1) 
			//	flr = hash_val.split("/")[0].substr(-1);
				url = "terrace/"+unit;
				location.assign(location.href.replace(/\/?#([^.]*)/, '#'+url))
				window.location = location.href.replace(/\/?#([^.]*)/, '#'+url);
				//window.location.hash = url; 
				
				
			}	
	  }
	}
	//

	
	
//Laura - Load after page loads
	$('body').append('<iframe marginheight="0" frameborder="0" scrolling="no" marginwidth="0" src="http://pixel.fetchback.com/serve/fb/pdc?cat=&name=landing&sid=2383" _mce_src="http://pixel.fetchback.com/serve/fb/pdc?cat=&name=landing&sid=2383" height="1" width="1"></iframe>');

	
	// Laura December 8 2010
	// Used for VBR. Updates all links to include param
	var isVBR = $.urlParam('vbr');

	if(isVBR != -1) {
		
		// hide stuff for vbr 
		$('.vbr_site').hide();
		$('.contact_us_link_inside').hide();
	//	$('title').text("The Ritz-Carlton Residences, Vail");
		

		// update links to include /vbr
		$("a[href^='index.php']").each(function() { 
	      this.href = this.href.replace(/index.php/, 
	         "vbr/index.php");
	   });
	   
	  $('#top_lang a').each(function() { 
	      this.href = this.href.replace('index.php', 
	         "vbr/index.php");
	   });
	   
	   $('#content_left_box.furnished_units a').each(function() {
	   	  this.href = this.href.replace('index.php', 
	         "vbr/index.php");
	   	
	  	});
	  	
	   if($('a.furnished-link').length > 0) {
	   $('a.furnished-link').each(function() {
	   	h = this.href;
	      this.href = this.href.replace(/.com/, 
	         ".com/vbr");
	   	
	  	});
	  }
	 }
	 
	 $('.tell-me-more').click(function() {
	 			if(isVBR != -1) 
	 				url = "vbr/index.php?page=winter-landing";
	 			else
	 				url = "index.php?page=winter-landing";
	 				
	 			window.location = url;
		});
	 
	 




	$('#nav ul ul').each(function(i) {
		total = $(this).children().length;
		ht = total * 15;
	});
	
	// TRH 09/09/10 - This is the code for the rollover on the main nav items, which are now images
	$('.nav_link_image').hover(function() {
		img_link = $(this).children('img');
		if(($(this).hasClass('active')) == false) {
			new_src = img_link.attr('src').replace('.png', '_s.png');
			img_link.attr('src', new_src);
		}
	},function() {
		img_link = $(this).children('img');
		if(($(this).hasClass('active')) == false) {
			img_link.attr('src', (img_link.attr('src').replace('_s.png', '.png')));
		}
	});
	
	// sliding functionality for content tabs
	// TODO: Try to use classes to break into 3 default behaviors (slide from left, slide from right, slide down into bottom area)
	$('#content_tab_home').toggle(
		function() { 
			$('#content_tab_home').clearQueue();
			$('#content_tab_home').animate({ right: "0px" }, 1000);
		}, 
		function() { 
			$('#content_tab_home').clearQueue();
			$('#content_tab_home').animate({ right: "385px" }, 1000);
		}
	);
	$('#take_a_tour_button').toggle(
		function() { 
			$('#content_tab_home_right').clearQueue();
			$('#content_tab_home_right').animate({ right: "-424px" }, 1000);
		}, 
		function() { 
			$('#content_tab_home_right').clearQueue();
			$('#content_tab_home_right').animate({ right: "-905px" }, 1000);
		}
	);
	
	$('#content_tab_lifestyle').toggle(
		function() { 
			$('#content_tab_lifestyle').clearQueue();
			$('#content_tab_lifestyle').animate({ top: "-290px" }, 1000);
		}, 
		function() { 
			$('#content_tab_lifestyle').clearQueue();
			$('#content_tab_lifestyle').animate({ top: "-30px" }, 1000);
		}
	);	
	$('#lang_es_ES #content_tab_lifestyle').toggle(
		function() { 
			$('#content_tab_lifestyle').clearQueue();
			$('#content_tab_lifestyle').animate({ top: "-330px" }, 1000);
		}, 
		function() { 
			$('#content_tab_lifestyle').clearQueue();
			$('#content_tab_lifestyle').animate({ top: "-30px" }, 1000);
		}
	);	

	
	$('#content_tab_residences').toggle(
		function() { 
			$('#content_tab_residences').clearQueue();
			$('#content_tab_residences').animate({ top: "-290px" }, 1000);
		}, 
		function() { 
			$('#content_tab_residences').clearQueue();
			$('#content_tab_residences').animate({ top: "-30px" }, 1000);
		}
	);
	
	$('#lang_es_ES #content_tab_residences').toggle(
		function() { 
			$('#content_tab_residences').clearQueue();
			$('#content_tab_residences').animate({ top: "-333px" }, 1000);
		}, 
		function() { 
			$('#content_tab_residences').clearQueue();
			$('#content_tab_residences').animate({ top: "-30px" }, 1000);
		}
	);
	
	
	// initialize the first slide out. slides start from a default hidden position
	// TODO again, try to generalize this with classes
	setTimeout(function(){ $('#content_tab_home').click(); }, 500);
	//setTimeout(function(){ $('#content_tab_home_right').click(); }, 500);
	setTimeout(function(){ $('#content_tab_lifestyle').click(); }, 500);
	setTimeout(function(){ $('#content_tab_residences').click(); }, 500);
		
	// these are the sliding tabs on the bottom of the home page
	$('.content_bottom_tab').hover(
		function() {
			$(this).clearQueue();
			$(this).animate({ height: "138px" }, 300);
		},
		function() {
			$(this).clearQueue();	
			$(this).animate({ height: "73px" }, 300);
		}
	);
	// these are the sliding tabs on the bottom of the home page
	$('#lang_es_ES .content_bottom_tab').hover(
		function() {
			$(this).clearQueue();
			$(this).animate({ height: "173px" }, 300);
		},
		function() {
			$(this).clearQueue();	
			$(this).animate({ height: "108px" }, 300);
		}
	);
	
	
	// excellent, my code seems to be making itself better. good to know it isn't limited by my programming skill :-)
	$('#nav > ul > li.notmobile').hover(
		function() {
		//	$(".nav_link",this).addClass("active");







			if($('#slider_home2').length > 0) { $('#slider_home').data('nivo:vars').stop = true; } //Stop the Slider
			if($('#slider').length > 0) { $('#slider').data('nivo:vars').stop = true; } //Stop the Slider

			total = $('ul', this).children().length;
			//ht = total * 26; // TRH 09/15/10 - I set this for an even length on each item. The list of 3 items (in which two word wrap) wasn't very happy about this equation
			ht = 5 * 20; // TRH 09/15/10 - assuming four items.
			$(this).find("ul").clearQueue();
			
			//ie6 fix
			if ($.browser.msie && $.browser.version.substr(0,1)<7) {
				$("ul",this).animate({ top: "43px" }, 0);
			}
			//normal behavior
			else {
				$("ul",this).animate({ top: "46px" }, 0);
			}
			
			$(this).find("ul").animate({ height: ht +"px"}, 300);
		},
		function(){
		//	$(".nav_link",this).removeClass("active");
		
			if($('#slider_home2').length > 0) { $('#slider_home').data('nivo:vars').stop = false; } //Restart the Slider }
			if($('#slider').length > 0) { $('#slider').data('nivo:vars').stop = false; } //Restart the Slider }
		
			$(this).find("ul").clearQueue();
			$(this).find("ul").animate({ height: "0px" }, 300);
			$("ul",this).animate({ top: "-500px" }, 0);
		}
	);
	
	//APS 2-3-2011 this is for the mobile menu, opens and closes on click
		
		$('#nav > ul > li.mobile').click(
		function() {
		//	$(".nav_link",this).addClass("active");
			
			if($(this).hasClass('open')){
				//alert('open');
				$('#nav > ul > li.open > ul:visible').animate({ height: "0px" }, 300);
				$('#nav > ul > li.open > ul:visible').animate({ top: "-500px" }, 0);
				$(this).removeClass('open');
			}
			
			else{
			$(this).addClass('open');
			
			if($('#slider_home2').length > 0) { $('#slider_home').data('nivo:vars').stop = true; } //Stop the Slider
			if($('#slider').length > 0) { $('#slider').data('nivo:vars').stop = true; } //Stop the Slider

			total = $('ul', this).children().length;
			//ht = total * 26; // TRH 09/15/10 - I set this for an even length on each item. The list of 3 items (in which two word wrap) wasn't very happy about this equation
			ht = 5 * 20; // TRH 09/15/10 - assuming four items.
			$(this).find("ul").clearQueue();
			
			//ie6 fix
			if ($.browser.msie && $.browser.version.substr(0,1)<7) {
				$("ul",this).animate({ top: "43px" }, 0);
			}
			//normal behavior
			else {
				$("ul",this).animate({ top: "46px" }, 0);
			}
			
			$(this).find("ul").animate({ height: ht +"px"}, 300);
			}
		}
	);
	
	// Initialize the kGallery
	if($('#gallery').length > 0) $('#gallery').kGallery();
	if($('#slideshow_image').length > 0) $('#slideshow_image').kSlideshow();

	// This section is for the calendar
	$('.calendar_hover_link').hoverIntent(function(e){
		td_index = $(this).parent().parent().parent();
		
		tooltip = $(this).find('.tooltip_window');
		adjustment = tooltip.find('.tooltip_window_adjustment');
		content_div = adjustment.find('.tooltip_window_content');
		header_div = adjustment.find('.tooltip_window_header > img');
		footer_div = adjustment.find('.tooltip_window_footer > img');
		
		target = $(this).attr('href');
		
		if(content_div.html().length == 0) { 
			content_div.load(target, function() {
				pos_x = td_index.prevAll().length;
				pos_y = td_index.parent().prevAll().length;
				
				adjustment.css('left',  '+20px');
				adjustment.css('top', '-60px');
				
				if(pos_x > 3) {
					adjustment.css('left', (parseFloat(adjustment.css('left')) - tooltip.width() + 70) + 'px');
					header_div.attr('src', 'images/tooltip_header_right.png');
				}
				if(pos_y > 1) {
					adjustment.css('top', (parseFloat(adjustment.css('top')) - tooltip.height() - 50) + 'px');
					
					header_div.attr('src', 'images/tooltip_header_none.png');
					if(pos_x > 3) {
						footer_div.attr('src', 'images/tooltip_footer_right.png');
					} else {
						footer_div.attr('src', 'images/tooltip_footer_left.png');
					}
					header_div.css({height:8});
					footer_div.css({height:20});
				}
				else {
					header_div.css({height:20});
					footer_div.css({height:8});
				}
				if (jQuery.browser.msie) {
					// if IE, specifically 7, we need to move the tooltip to the left
					if(parseInt(jQuery.browser.version) == 7) {
						//alert('adjustment for ie7');
						adjustment.css('left', (parseFloat(adjustment.css('left')) - 100) + 'px');
					}
				}
				
				tooltip.stop(true,true);
				tooltip.fadeIn(300);
			}); 
		} else {
			tooltip.stop(true,true);
			tooltip.fadeIn(300);
		}
		
	},function() {
		tooltip.stop(true,true);
		tooltip.fadeOut(300);
	});
	$('.calendar_hover_link').click(function() {
		return false;
	});
	
	// TRH 09/07/10 - Accordion Links on sub pages
	$('.accordion_link').toggle(function() {
		accordion_content = $(this).find('.accordion_content');
		accordion_content.slideDown(300);
		return false;
	}, function() {
		accordion_content = $(this).find('.accordion_content');
		//full_height = content.css('height')
		accordion_content.slideUp(300);
		return false;
	});
	
	if($('.colorbox_popup').length > 0) {
		$('.colorbox_popup').colorbox({
			onOpen:function(){ if($('#slider_home').length > 0) { $('#slider_home').data('nivo:vars').stop = true; }; },
			onClosed:function(){ if($('#slider_home').length > 0) { $('#slider_home').data('nivo:vars').stop = false; } }, 
			innerWidth:"640px",
			innerHeight:"360px", 
			iframe:true, 
			opacity: 0.6
		}); 
	}
	
	// Home page - height increased to show share buttons below video
	if($('#take_a_tour_div .colorbox_popup').length > 0) {
		$('.colorbox_popup').colorbox({
			onOpen:function(){ if($('#slider_home').length > 0) { $('#slider_home').data('nivo:vars').stop = true; }; },
			onClosed:function(){ if($('#slider_home').length > 0) { $('#slider_home').data('nivo:vars').stop = false; } }, 
			innerWidth:"640px",
			innerHeight:"395px", 
			iframe:true, 
			opacity: 0.6
		}); 
	}
	
	
	if($('.colorbox_news').length > 0) {
	$('.colorbox_news').colorbox({
		innerWidth:"640px",
		innerHeight:"360px", 
		iframe:true,
		opacity: 0.6
	}); 
	}
	
	$("a[rel='vailcam']").colorbox({
		slideshow: true,
		slideshowSpeed: 5000,
		opacity: 0.6
	});	
	
	//APS 1-11-2012 - colorbox for mobile floorplan PDFs
	/*
	$("a.floorplan_link").colorbox({
		iframe: true,
		innerHeight: "360px",
		innerWidth: "640px"
	});
	*/
	
	//APS 2-6-2012 - colorbox for designer popups
	$("a.furnished_designer_eddy").colorbox({
		inline: true,
		href: "#designer_eddy",
		opacity: 0.6,
		innerWidth:"593px",
		innerHeight:"627px"
	});
	
	$("a.furnished_designer_alicia").colorbox({
		inline: true,
		href: "#designer_alicia",
		opacity: 0.6,
		innerWidth:"593px",
		innerHeight:"642px"
	});
	
	$("a.furnished_designer_amy").colorbox({
		inline: true,
		href: "#designer_amy",
		opacity: 0.6,
		innerWidth:"593px"
	});
	
	$("a.furnished_designer_andrea_lawrence").colorbox({
		inline: true,
		href: "#designer_andrea_lawrence",
		opacity: 0.6,
		innerWidth:"593px"
	});
	
	$("a.furnished_designer_kellye_andrea").colorbox({
		inline: true,
		href: "#designer_kellye_andrea",
		opacity: 0.6,
		innerWidth:"593px"
	});
	
	$("a.furnished_designer_mikhail").colorbox({
		inline: true,
		href: "#designer_mikhail",
		opacity: 0.6,
		innerWidth:"593px"
	});
	
	// Nivo Slider
	if($('#slider').length > 0) {
		$('#slider').nivoSlider({
			effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
			slices:1,
			animSpeed:1000, //Slide transition speed - TRH This is milliseconds, not speed
			pauseTime:5000,
			startSlide:0, //Set starting Slide (0 index)
			directionNav:false, //Next & Prev
			//directionNavHide:true, //Only show on hover
			controlNav:true, //1,2,3...
			controlNavThumbs:false, //Use thumbnails for Control Nav
			//controlNavThumbsFromRel:false, //Use image rel for thumbs
			//controlNavThumbsSearch: '.jpg', //Replace this with...
			//controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
			keyboardNav:true, //Use left & right arrows
			pauseOnHover:true, //Stop animation while hovering
			manualAdvance:false, //Force manual transitions
			captionOpacity:0.8, //Universal caption opacity
			beforeChange: function(){},
			afterChange: function(){},
			slideshowEnd: function(){} //Triggers after all slides have been shown
		});
		//$('.nivo-controlNav a').html("<img src='images/box.gif' />");
	}
	if($('#slider_home').length > 0) {
	
		$('#slider_home').nivoSlider({
			effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
			slices:1,
			animSpeed:1000, //Slide transition speed - TRH This is milliseconds, not speed
			pauseTime:5000,
			startSlide:0, //Set starting Slide (0 index)
			directionNav:false, //Next & Prev
			//directionNavHide:true, //Only show on hover
			controlNav:true, //1,2,3...
			controlNavThumbs:false, //Use thumbnails for Control Nav
			//controlNavThumbsFromRel:false, //Use image rel for thumbs
			//controlNavThumbsSearch: '.jpg', //Replace this with...
			//controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
			keyboardNav:true, //Use left & right arrows
			pauseOnHover:true, //Stop animation while hovering
			manualAdvance:false, //Force manual transitions
			captionOpacity:0.8, //Universal caption opacity
			beforeChange: function(){},
			afterChange: function(){},
			slideshowEnd: function(){} //Triggers after all slides have been shown
		});
		//$('.nivo-controlNav a').html("<img src='images/box.gif' />");
	}
     
$('.availability tr').not('.no_floorplan').hover (
	function() {
		$(this).addClass('is_hover');
	},
	function() {
		$(this).removeClass('is_hover');
	}
);

     
    
	 /* Load table sorting for availability */
	if($('.availability table').length > 0) {
	//	$('.availability_table').tablesorter();
	
		$('.availability table').tablesorter({
		headers: { 
				0: {
					sorter: 'commas_and_dollars'
				},
				1: {
					sorter: false 
				},
				2: {
					sorter: false 
				},
				3: {
					sorter:'commas_and_dollars'
				}       
			},
			sortList: [[0,0]]
			// 	sortList: [[3,0]]
		});
	
	//APS 2-2-2011  - click behavior for availability table on mobile devices	
	$('.availability.mobile table tr').not('.no_floorplan').not('.availability table tr:first').not('.availability table tr:eq(1)').click(function(){
		if($(this) != $('#availability_table tr:first')){
			var room_num = $(this).children().first().html();
			var floor = '';
			
			if(room_num.search(/PH/i) != -1)
				room_num = room_num.substr(0,room_num.length-2);
			
			if(room_num < 100) {
				floor = 'terrace';
			}
			else {
				floor = 'floor' + (room_num - (room_num % 100)) / 100;
			}
			target = 'uploads/fp_pdf/'+ $.trim(room_num) +'.pdf';
			window.open(target);
		}
	});
	
	/* Click behavior for availability table */
	$('.availability.notmobile table tr').not('.no_floorplan').not('.availability table tr:first').not('.availability table tr:eq(1)').click(function(){
		if($(this) != $('#availability_table tr:first')){
			var room_num = $(this).children().first().html();
			var floor = '';
			
			if(room_num.search(/PH/i) != -1)
				room_num = room_num.substr(0,room_num.length-2);
			
			if(room_num < 100) {
				floor = 'terrace';
			}
			else {
				floor = 'floor' + (room_num - (room_num % 100)) / 100;
			}
			target = 'index.php?page=floorplans#' + floor + '/' + room_num;
			window.location = target;
		}
	});
		
    $("li.col_unit").toggle(function() {
    	 $(this).removeClass('sortup'); 	
    	 $(this).addClass('sortdown');
        var sorting = [[0,1]]; 
        $(this).parent().parent().find('table').trigger("sorton",[sorting]); 
    }, function() {
    	 $(this).removeClass('sortdown'); 	
    	 $(this).addClass('sortup');
        var sorting = [[0,0]]; 
        $(this).parent().parent().find('table').trigger("sorton",[sorting]); 
    	});
    	
    $("li.col_bath").toggle(function() {
    	 $(this).removeClass('sortup'); 	
    	 $(this).addClass('sortdown');
        var sorting = [[2,1]]; 
        $(this).parent().parent().find('table').trigger("sorton",[sorting]); 
    }, function() {
    	 $(this).removeClass('sortdown'); 	
    	 $(this).addClass('sortup');
        var sorting = [[2,0]]; 
        $(this).parent().parent().find('table').trigger("sorton",[sorting]); 
    	});
    	
		
    $("li.col_area").toggle(function() {
    	 $(this).removeClass('sortup'); 	
    	 $(this).addClass('sortdown');
        var sorting = [[3,1]]; 
        $(this).parent().parent().find('table').trigger("sorton",[sorting]); 
    }, function() {
    	 $(this).removeClass('sortdown'); 	
    	 $(this).addClass('sortup');
        var sorting = [[3,0]]; 
        $(this).parent().parent().find('table').trigger("sorton",[sorting]); 
    	});
    	
    $("li.col_price").toggle(function() {
    	 $(this).removeClass('sortup'); 	
    	 $(this).addClass('sortdown');
        var sorting = [[4,1]]; 
        $(this).parent().parent().find('table').trigger("sorton",[sorting]); 
    }, function() {
    	 $(this).removeClass('sortdown'); 	
    	 $(this).addClass('sortup');
        var sorting = [[4,0]]; 
        $(this).parent().parent().find('table').trigger("sorton",[sorting]); 
    	});
    	
		
	}
	
	
	//$('.col_header li.sortdown').css('cursor', 'pointer');
	//$('.col_header li.sortup').css('cursor', 'pointer');
	//$('.col_header li.sortme').css('cursor', 'pointer');
     
     
	 /* Load table sorting for availability */
	if($('#availability_table').length > 0) {
		$('#availability_table').tablesorter({
			headers: { 
				0: {
					sorter: 'commas_and_dollars'
				},
				1: {
					sorter: 'commas_and_dollars'
				},
				2: {
					sorter: false 
				},
				3: {
					sorter:'commas_and_dollars'
				},
				4: {
					sorter:'commas_and_dollars'
				},
				6: {
					sorter: false
				}
       },
			sortList: [[1,0],[0,0],[3,0]]
			// 	sortList: [[3,0]]
		});
	}
	/* Click behavior for availability table */
	$('#availability_table tr').not('#availability_table tr:first').click(function(){
		if($(this) != $('#availability_table tr:first')){
			var room_num = $(this).children().first().html();
			var floor = '';
			
			if(room_num.search(/PH/i) != -1)
				room_num = room_num.substr(0,room_num.length-2);
			
			if(room_num < 100) {
				floor = 'terrace';
			}
			else {
				floor = 'floor' + (room_num - (room_num % 100)) / 100;
			}
			target = 'index.php?page=floorplans#' + floor + '/' + room_num;
			window.location = target;
		}
	});
	
	$.simpleWeather({
		location: 'Vail, CO',
		unit: 'f',
		success: function(weather) {
			$("#weather").html(weather.temp+"&deg;F");
		},
		error: function(error) {
			$("#weather").html("<p>"+error+"</p>");
		}
	});
	
	//load_floorplan_interiors();
	
	$("a[rel='floorplan_interior']").colorbox({
		slideshow: true,
		slideshowSpeed: 5000,
		opacity: 0.6
	});
	
	$(".floorplan_slideshow").colorbox({
		slideshow: true,
		slideshowSpeed: 5000,
		opacity: 0.6
	});
	
	//popup contact form
});

function show_floorplan_360(room_number) {
	
	if(room_number.search(/L/i) != -1 || room_number.search(/B/i) != -1)
		room_number = room_number.substr(0,room_number.length-1) 
		
	
		rm = "uploads/images/floorplan_images/360/"+room_number+".jpg";
		var flashvars = { img:rm };
		var params = { wmode:'opaque' };
		var attributes = {};
		var html = '<div id="flashcontent"></div>';
		if(room_number == 314) {
			html = html + '<div style="position: absolute; top: 0; left: 0; height: 20px; padding: 6px 6px 2px 6px; background-color: #000;">';
			html = html + '<a class="tab_link tab_clicked" style="margin-right: 10px;" onclick="tabclick(this); var flashvars = { img: \'uploads/images/floorplan_images/360/314.jpg\'}; var params = { wmode:\'opaque\' }; swfobject.embedSWF(\'swf/360.swf\', \'flashcontent\', \'885\', \'450\', \'9.0.0\',\'\', flashvars, params); return false;">Living Areas</a>';
			html = html + '<a class="tab_link" onclick="tabclick(this); var flashvars = { img: \'uploads/images/floorplan_images/360/314b.jpg\'}; var params = { wmode:\'opaque\' }; swfobject.embedSWF(\'swf/360.swf\', \'flashcontent\', \'885\', \'450\', \'9.0.0\',\'\', flashvars, params); return false;">Master Suite</a>';
			html = html + '</div>';
		}
		if(room_number == 405) {
			html = html + '<div style="position: absolute; top: 0px; left: 0px; height: 20px; padding: 6px 6px 2px 6px; background-color: #000;">';
			html = html + '<a class="tab_link tab_clicked" style="margin-right: 10px;" onclick="tabclick(this); var flashvars = { img: \'uploads/images/floorplan_images/360/405.jpg\'}; var params = { wmode:\'opaque\' }; swfobject.embedSWF(\'swf/360.swf\', \'flashcontent\', \'885\', \'450\', \'9.0.0\',\'\', flashvars, params); return false;">Living Area</a>';
			html = html + '<a class="tab_link" style="margin-right: 10px;" onclick="tabclick(this); var flashvars = { img: \'uploads/images/floorplan_images/360/405b.jpg\'}; var params = { wmode:\'opaque\' }; swfobject.embedSWF(\'swf/360.swf\', \'flashcontent\', \'885\', \'450\', \'9.0.0\',\'\', flashvars, params); return false;">Master Suite</a>';
			html = html + '<a class="tab_link" style="margin-right: 10px;" onclick="tabclick(this); var flashvars = { img: \'uploads/images/floorplan_images/360/405c.jpg\'}; var params = { wmode:\'opaque\' }; swfobject.embedSWF(\'swf/360.swf\', \'flashcontent\', \'885\', \'450\', \'9.0.0\',\'\', flashvars, params); return false;">Loft Den</a>';
			html = html + '<a class="tab_link" onclick="tabclick(this); var flashvars = { img: \'uploads/images/floorplan_images/360/405d.jpg\'}; var params = { wmode:\'opaque\' }; swfobject.embedSWF(\'swf/360.swf\', \'flashcontent\', \'885\', \'450\', \'9.0.0\',\'\', flashvars, params); return false;">Balcony</a>';
			html = html + '</div>';
		}
		if(room_number == 614){
			// html = html + '<div style="position:absolute; top: 0px; left: 0px; height: 20px; padding: 5px;">COMING SOON</div>';
		}
		
		
	// Laura - April 15, 2011
	// Check if image exists	
	$.post(
		"php/load360.php",
		{ rm : rm },
		function(data){
			if(data != 1) {
				html = html + '<div style="position:absolute; top: 0px; left: 0px; height: 20px; padding: 5px;"><img src="uploads/images/floorplan_images/360/none.jpg" /></div>';
				
				$.colorbox({
					innerWidth: '885px',
					innerHeight: '450px',
					html: html,
					scrolling: false,
					opacity: 0.6
				});
			} else {
			
				$.colorbox({
					innerWidth: '885px',
					innerHeight: '450px',
					html: html,
					scrolling: false,
					onComplete: function() {
						swfobject.embedSWF("swf/360.swf", "flashcontent", "885", "450", "9.0.0","", flashvars, params, attributes);
					},
					opacity: 0.6
				});
			}
		}
	);
}

//APS 12/10/2010 - this is for changing the link color on the 360 links
function tabclick(that){
	//alert('hey: '+that);
	if($(that).hasClass("tab_clicked")){
	}
	else{
		$("a.tab_link").removeClass("tab_clicked");
		$(that).addClass("tab_clicked");
	}
	
}

function show_floorplan_interiors(room_number) {

	if(room_number.search(/L/i) != -1 || room_number.search(/B/i) != -1)
		room_number = room_number.substr(0,room_number.length-1) 
		
	// Spreadsheet data
	// Codes are Kitchen, Bathroom, Hardware
	roomdata = new Array();
	roomdata[1] = new Array('C','C','A');
	roomdata[2] = new Array('B','C','A');
	roomdata[3] = new Array('A','C','B');
	roomdata[4] = new Array('A','A','A');
	roomdata[5] = new Array('A','B','A');
	roomdata[6] = new Array('A','C','A');
	roomdata[7] = new Array('A','A','A');
	roomdata[100] = new Array('A','C','A');
	roomdata[101] = new Array('C','C','A');
	roomdata[102] = new Array('C','C','A');
	roomdata[103] = new Array('A','A','A');
	roomdata[107] = new Array('A','A','A');
	roomdata[108] = new Array('A','B','A');
	roomdata[110] = new Array('C','C','A');
	roomdata[111] = new Array('B','C','A');
	roomdata[112] = new Array('A','C','B');
	roomdata[200] = new Array('A','C','A');
	roomdata[201] = new Array('A','B','A');
	roomdata[202] = new Array('C','C','A');
	roomdata[203] = new Array('A','C','A');
	roomdata[207] = new Array('A','A','A');
	roomdata[208] = new Array('A','B','A');
	roomdata[212] = new Array('A','A','B');
	roomdata[214] = new Array('B','C','A');
	roomdata[215] = new Array('A','C','A');
	roomdata[216] = new Array('C','C','A');
	roomdata[217] = new Array('C','C','A');
	roomdata[300] = new Array('A','C','A');
	roomdata[305] = new Array('A','C','A');
	roomdata[307] = new Array('B','B','A');
	roomdata[308] = new Array('C','A','A');
	roomdata[310] = new Array('A','C','A');
	roomdata[311] = new Array('B','C','A');
	roomdata[312] = new Array('C','C','A');
	roomdata[314] = new Array('C','C','A');
	roomdata[315] = new Array('B','A','B');
	roomdata[316] = new Array('C','C','A');
	roomdata[317] = new Array('B','C','B');
	roomdata[402] = new Array('C','C','A');
	roomdata[405] = new Array('C','C','A');
	roomdata[407] = new Array('A','B','B');
	roomdata[408] = new Array('A','C','B');
	roomdata[410] = new Array('B','C','A');
	roomdata[411] = new Array('A','C','A');
	roomdata[412] = new Array('C','C','A');
	roomdata[414] = new Array('C','C','A');
		roomdata[415] = new Array('A','C','A');
	roomdata[416] = new Array('C','C','A');
	roomdata[508] = new Array('C','C','A');
	roomdata[510] = new Array('C','C','A');
	roomdata[511] = new Array('A','B','A');
	roomdata[512] = new Array('C','C','A');
	roomdata[514] = new Array('C','C','A');
	roomdata[516] = new Array('C','C','A');
	roomdata[614] = new Array('C','C','A');
	roomdata[615] = new Array('C','C','A');
	roomdata[616] = new Array('C','C','A');



	// Codes are Kitchen, Bathroom, Hardware
	roomdata[620] = new Array('D','D','D');
	roomdata[624] = new Array('D','D','D');
	roomdata[625] = new Array('D','D','D');

	$.post(
		"php/loadinteriors.php",
		{ kcode : roomdata[room_number][0], bcode : roomdata[room_number][1], hcode : roomdata[room_number][2], room_num : room_number },
		function(data){
			
			$('.floorplan_slideshow').remove();
			
			$('body').append(data);
			
			$(".floorplan_slideshow").colorbox({
				slideshow: true,
				slideshowSpeed: 5000,
				opacity: 0.6
			});
			
			$(".floorplan_slideshow:first").click();
		}
	);
	

}

function show_floorplan_views(room_number) {
	
	if(room_number.search(/L/i) != -1 || room_number.search(/B/i) != -1)
		room_number = room_number.substr(0,room_number.length-1) 
		
	$.colorbox({
		href: 'uploads/images/floorplan_images/views/' + room_number + '.jpg',
		slideshow: true,
		slideshowSpeed: 5000,
		opacity: 0.6
	})
}

function show_take_a_tour() {

	if($('#slider_home').length > 0) { 
		alert("Stop home slider");
		$('#slider_home').data('nivo:vars').stop = true; 
	};
	
	$.colorbox({
		href:"index.php?page=take-a-tour",
		onClosed:function(){ if($('#slider_home2').length > 0) { $('#slider_home').data('nivo:vars').stop = false; } }, 
		innerWidth:"640px",
		innerHeight:"395px", 
		iframe:true, 
		opacity: 0.6
	}); 
}

function show_contact_us_mini() {
	var isVBR = $.urlParam('vbr');
	
	if(isVBR != -1) {
		$.colorbox({
			html:'<div style="height:100%; width: 100%; background-color: #FFF; padding: 20px;"><p>Please contact your local Vail real estate broker.</p></div>',
			opacity: 0.6,
			innerWidth:"413px",
			innerHeight:"380px"
		});
	}
	else {
		$.colorbox({
			href:'php/contact_us_mini.php',
			opacity: 0.6,
			innerWidth:"593px",
			innerHeight:"780px",
			iframe:true
		});
	}
}



function download_pdf(room_number, mylang) {	
	switch(room_number) {
		case '1':
			//	room_number = '001_terrace';
				break;
	}
	
	if(room_number.search(/L/i) != -1 || room_number.search(/B/i) != -1)
		room_number = room_number.substr(0,room_number.length-1) 
	
	var milliseconds = new Date().getTime();
	
	if(mylang == 'es_ES')
		pdf = 'uploads/fp_pdf_ES/' + room_number + '.pdf?breakcache=' + milliseconds;
	else
		pdf = 'uploads/fp_pdf/' + room_number + '.pdf?breakcache=' + milliseconds;
		
//	alert(pdf);
	window.open(pdf,'Floorplan'+room_number);
	//return false; 
}



function share_floorplan(sectioncode, room_number, floor_num) {	
	switch(room_number) {
		case '1':
				floor = 'terrace';
				break;
		default:
				floor = 'floor'+floor_num;
	}
	if(room_number.search(/L/i) != -1 || room_number.search(/B/i) != -1)
		room_number = room_number.substr(0,room_number.length-1);
	
	var milliseconds = new Date().getTime();

	title = "Unit+"+room_number;
	share = 'http://www.theresidencesvail.com/index.php?page=floorplans&fp='+floor_num+'-'+room_number+'&nocache='+milliseconds+'#'+floor+'/'+room_number;

	url = 'http://api.addthis.com/oexchange/0.8/forward/'+sectioncode+'/offer?url='+escape(share)+'&username=ritzvail';
	//url = 'http://api.addthis.com/oexchange/0.8/forward/facebook/offer?url='+encodeURIComponent(share)+'&title=Stephen+McIntyre&username=ritzvail';
	
	analytics = '/share/'+sectioncode+'/index.php/floor'+floor+'/'+room_number;
	
	to_pageTracker(analytics);
	//pageTracker._trackPageview(url); 
	
	if(sectioncode == 'email') {
		emailFloorPlan();
		/*
		$.colorbox({
			href: url,
			innerWidth:"536px",
			innerHeight:"565px", 
			iframe:true, 
			opacity: 0.6
		}); 
		*/
	} else {
		
		window.open(url,'Floorplan'+room_number);
	}
	//return false; 
	
}



// Called from Take a Tour video popup
	function emailTour() {
		$('#share_tour_video .addthis_button_email').trigger('click');
	}
	
	function emailFloorPlan() {
		$('#email_floorplan .addthis_button_email').trigger('click');
	}
	

$('document').ready(function(){

    var add_button = null;
	
	// Listen for the share event
    addthis.addEventListener('addthis.menu.share', shareEventHandler);
    $('.addthis_button_facebook').mouseover(function() {
      add_button = $(this).parent();
    });
    
    
    /*
    function shareEventHandler(evt) {
      if (evt.type == 'addthis.menu.share') {
      	analytics = '/share/' + evt.data.service+'/'+add_button.attr('addthis:url');
   //   	alert(analytics);
        to_pageTracker(analytics);
      }
    }
		*/
		
    
    
    function shareEventHandler(evt) {
    	url = add_button.attr('addthis:url');
    	addthis_url = url.substr(url.indexOf(window.location.host) + window.location.host.length);
    	
      if (evt.type == 'addthis.menu.share') {
      	// analytics = '/share/' + evt.data.service+'/'+add_button.attr('addthis:url');
      	analytics = '/share/' + evt.data.service+addthis_url;
    //	alert(analytics);
        to_pageTracker(analytics);
      }
    }



});
