	   // MAIN NAVIGATION
	   //
		// Hide script from older browsers // 
		var urlAddress = location.href;
		var pageName = document.title;
			function addToFavorites()
			 {  if(window.sidebar){window.sidebar.addPanel(pageName, urlAddress, "")}
			else if (document.all) { window.external.AddFavorite(urlAddress,pageName) } 
			else if(window.opera && window.print){ // Opera
			var elem = document.createElement('a');
			elem.setAttribute('href',url);
			elem.setAttribute('title',title);
			elem.setAttribute('rel','sidebar');
			elem.click();}else { alert("Sorry! Your browser doesn't support this function.");
		} } //
		
		function navigate(section) {
			$("#subsectionNav li").hide();
			$("#sectionNav li a").css("background-position","top");
			$(".subsec-" + section).show();
			$("#sectionNavCarat").show();
			$("#subsectionNav").attr("class","subsec-" + section);
			$("li#" + section + " a").css("background-position","bottom");
		}
		
		// helper function for floated elements with varying heights
		function equalize(elems){
			var heights = [];
			$(elems).each(function () {
				heights.push($(this).height());
			}).height(heights.sort(function(a, b){
				// sort() defaults to lexicographical order, so 7 would be after 400.
				// This function sorts each item by numerical value in ascending order
				return a - b;
			}).pop() || 0);
		}
			
		// Plugin for detecting image load event firing, courtesy of @soundphed
		jQuery.fn.onImagesLoaded = function(_cb) { 
		  return this.each(function() {
			var $imgs = (this.tagName.toLowerCase()==='img')?$(this):$('img',this),
				_cont = this,
					i = 0,
			_done=function() {
			  if( typeof _cb === 'function' ) _cb(_cont);
			};
			if( $imgs.length ) {
			  $imgs.each(function() {
				var _img = this,
				_checki=function(e) {
				  if((_img.complete) || (_img.readyState=='complete'&&e.type=='readystatechange') )
				  {
					if( ++i===$imgs.length ) _done();
				  }
				  else if( _img.readyState === undefined ) // dont for IE
				  {
					$(_img).attr('src',$(_img).attr('src')); // re-fire load event
				  }
				}; // _checki \\
 
				$(_img).bind('load readystatechange', function(e){_checki(e);});
				_checki({type:'readystatechange'}); // bind to 'load' event...
			  });
			} 
			else {
				_done();
			}
		  });
		};

			//Slideshow
			//
			$(document).ready(function(){
				if($("#scrollText").length > 0){
					$('#splashImage .slideshow').onImagesLoaded(function(_this){
						$("#scrollText span").hide();
						$(_this).addClass('active').cycle({
							fx: 'fade',
							delay: 0,
							speed: 1000,
							timeout: 5000
						});
					});
					
//					var fadeCycle = (function () { 
//                        var collection = $("#splashImage div.active img").css({opacity:0}).eq(0).css({opacity:1}).addClass('ie6').end();
//                        var scrollText = $("#scrollText");
//                        //FadeOut text
//                        var textArr = [
//                            "<span class=\"bg-W\">Welcome to Seaport Boston.</span>",
//                            "<span class=\"bg-A\">A fresh point of view.<br />Dazzling city and harbor vistas.</span>",
//                            "<span class=\"bg-A\">A fresh approach.<br />Complimentary WiFi.<br /> Service Inclusive.</span>",
//                            "<span class=\"bg-R\">A refreshing break.<br /> One of Boston's best health clubs.</span>"
//                            ], 
//                            whichText = 0, whichImg = 0, timeout = null;

//                        scrollText.addClass("active").css({ opacity: 0 });

//                        return function cycler(){
//                            clearTimeout(timeout);
//                            var thisText = textArr[whichText];
//                            // Load in an image
//                                // Once thats loaded fade in the text
//                                // Pause for a bit
//                            // Fade both images out together
//                            collection.eq(whichImg).stop(true).animate({opacity: 1}, 1750, function() {
//                                $(this).addClass('ie6');
//                                scrollText.html(thisText).stop(true).delay(1000).animate({opacity: 1}, 1750, function() { 
//                                    scrollText.addClass('ie6').children().addClass('ie6');
//                                    var text = this;
//                                    timeout = window.setTimeout(function() {
//                                        whichText = (whichText + 1) % textArr.length;
//                                        whichImg = (whichImg + 1) % collection.length;
//                                        scrollText.removeClass('ie6').children().removeClass('ie6');
//                                        collection.add($(text)).stop(true).animate({opacity: 0}, 1750, function(){
//                                            $(this).removeClass('ie6');
//                                            cycler();
//                                        }); 
//                                    }, 4000);
//                                });
//                            });
//                        }
//					})();
					//var newslideshow = new fadeCycle();
				}
				else {
					$('#splashImage div.active').cycle({
						fx: 'fade',
						delay: 0,
						speed: 1500,
						timeout: 3500
					});
				}
			    
			  
                try{
                    $("#toolbarEmail a").fancybox({ 
                        width: 340,
                        height: 200
                    });
                    
                    $("a.popup").fancybox({ 
                        width: 430,
                        height: 270
                    });
                    $("a.Res").fancybox({ 
                        width: 330,
                        height: 125
                    });
                    $("a.roomDetails").fancybox({ 
                        width: 500,
                        height: 250
                    });
                    $("a.news").fancybox({ 
                        width: 330,
                        height: 175
                    });
                    $("a.mapit").fancybox({ 

                    });
                    $("a.Guarantee").fancybox({ 
                        width: 750,
                        height: 500
                    });
                    $("div.cta a.lightbox").fancybox({
                        type:'iframe',
                        width:1000,
                        height:956,
						autoScale:false,
						autoDimensions:false,
						centerOnScroll: true,
						onComplete: function(){
							if($("#fancybox-frame").attr("src") === "http://www.seaportboston.com/meetingandevents/explore.swf"){
								$("#fancybox-overlay").animate({
									'height':'+=200px'
								}, 200);
								$("<h2>Seaport Meeting Rooms Capacity Chart.<br />To view all rooms please use the right hand cursor to scroll.</h2>").css({
									'font-size': '20px',
									'color': '#66889B',
									'margin-left':'10px',
									'margin-bottom':'20px',
									'text-align':'center'
								}).prependTo("#fancybox-content");
							}
						}
                    });
                    
                    $("a.plan").fancybox();
                }
                catch(e){
                    // shhh.....
                    }
				if($('.specialPackage').length > 1){
					var packages = $('.specialPackage');
					equalize(packages);
                    $('.packageWrapper').height(packages.height()).cycle({ 
						fx: 'fade', 
						speed: 1000, 
						timeout: 6000 
					});
				}
			});
			
			$('#specialPackage').cycle({
			        fx: 'fade',
			        delay: 0,
			        speed: 1500,
			        timeout: 3500
			});
			
			
			// Account edit switch to edit mode
			function edit(){
			$(".Display").attr("readonly","false");
			$(".Display").removeClass("Display");
			$(".hidden").removeClass("hidden");
			}
			
			// Functionality to switch home page from business to neutral to pleasure
			/*
			function switchInterest(interest,button) {
				$(".slideshow").removeClass("active");
				$(".slideshow").hide();
				if (interest == "businessAppeal") { $("#businessSlides").addClass("active"); }
				else if (interest == "neutralAppeal") { $("#neutralSlides").addClass("active"); }
				else if (interest == "pleasureAppeal") { $("#pleasureSlides").addClass("active"); }
				$(".active").show();
				$('#splashImage div.active').cycle({
					fx: 'fade',
					delay: 0,
					speed: 4000,
					timeout: 1000
				});
				if (interest == "businessAppeal") { $(".promoList").addClass("vertical"); }
				else { $(".promoList").removeClass("vertical"); }
				
				$(".interestFocus").fadeOut(700);
				$("." + interest).fadeIn(700);
				if(jQuery.browser.version == 6.0) {
					interestHeight = $("div." + interest).get(0).clientHeight;
					if (interestHeight < 125) { interestHeight = 125; }
					$("#content").css('height',interestHeight);
				}
				$("#content").css('min-height',$("div." + interest).get(0).clientHeight);
				$('#personalizeSite a').removeClass('full');
				$('#' + button).addClass('full');
			}
			*/
			
			// Required field validator (highlights empty fields)
						
			function validateFields() {
				$("input.required").each(function(){
					var value = $(this).val();
					
					if (value == '') {
						$(this).addClass("incompleteField");
						$(this).prev('label').addClass("warningLabel");				
					}
					else {
						$(this).removeClass("incompleteField");
						$(this).prev('label').removeClass("warningLabel");
					}
					
					$('.incompleteField:first').focus();
				});
				
				$(".required").bind("blur", function() { if ($(this).val() != '') {
						$(this).removeClass("incompleteField");
						$(this).prev('label').removeClass("warningLabel");
					}
					else {
						$(this).addClass("incompleteField");
						$(this).prev('label').addClass("warningLabel");	
					}
				});
				
			}

			// a basic subnav accordion
			function subNavAccordion(selector){
				var subnav = $(selector),
					parents = subnav.children("li"),
					// helper function for hiding/showing child ul's
					registerParent = function(group){
						var newGroup;
						group.eq(group.length - 1).addClass("last");
						group.each(function(){
							// isolate the li's with child ul's,
							// and see if any nav items are active
							if($(this).children("ul").length) {
								if ($(this).hasClass('active')){ 
									$(this).addClass("expanded"); 
								} else { 
									$(this).addClass("collapsed"); 
								}
                                newGroup = $(this).children("ul").children("li")
								registerParent(newGroup);
								bindEvents(newGroup);
							}
						});
					}
					toggleVisiblity = function(el, action){
						if(action === "open"){
							el.next("ul:hidden").stop(true, true).slideDown().end()
								.parent().removeClass("collapsed").addClass("expanded active"); 
						} else {
							el.next("ul:visible").stop(true, true).slideUp().end()
								.parent().removeClass("expanded active").addClass("collapsed");
						}
					},
					bindEvents = function(handles){
						handles.filter(".collapsed, .expanded").children("a").bind("click", handleClick);
					},
					handleClick = function(e){
						e.preventDefault();
						var me = $(this),
							rent = me.parents("li");
						// toggle visibility of target section
						if (rent.hasClass("collapsed")) { 
							toggleVisiblity(me, "open");
						}
						else if (rent.hasClass("expanded")) {
							toggleVisiblity(me, "close");
						}
						// close any other open sections
						parents.add(parents.find("li")).filter(".expanded").not(rent)
							.find("ul:visible").slideUp().end()
							.removeClass("expanded active").addClass("collapsed");
					};
                registerParent(parents);
				bindEvents(parents);
			}

