/*Dart Debugging Info */
dart = new Object();
var dartCalls = new Array( );
var dartCounter = 0;
var dartSite = '';
var dartZone = '';
var dartKeywords = '';
var statCall = '';

/* to fix background image flickering in IE */
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
if (isIE) {
    try {
      document.execCommand('BackgroundImageCache', false, true);
    } catch(e) {}
}

/*  Debug Tools                                                                                                           
    ----------- */
    function showDebugMessage(message){
        var msgDiv, bodyEl;
        msgDiv = document.getElementById('msgDiv') || null;
        bodyEl = document.body || document.documentElement;
        if (!msgDiv){
            msgDiv = document.createElement("DIV");
            msgDiv.id = 'msgDiv';
            bodyEl.appendChild(msgDiv);
        }
        msgDiv. innerHTML = message;
        return;
    }
    
/*	Shared Onload Event Handler Registration 
	---------------------------------------- */
	function runOnLoad(f){
		if(runOnLoad.loaded) f( );
		else runOnLoad.funcs.push(f);
	}
	runOnLoad.funcs = [];
	runOnLoad.loaded = false;
	runOnLoad.run = function( ) {
		if (runOnLoad.loaded) return;
		for(var i = 0; i < runOnLoad.funcs.length; i++){
			try{runOnLoad.funcs[i]( );}
			catch(e) {}
		}
		runOnLoad.loaded = true;
		delete runOnLoad.funcs;
		delete runOnLoad.run;
	};
	if(window.addEventListener) window.addEventListener("load", runOnLoad.run, false);
	else if (window.attachEvent) window.attachEvent("onload", runOnLoad.run);
	else window.onload = runOnLoad.run;
	
/*	Shared Onunload Event Handler Registration 
	---------------------------------------- */
	function addUnLoadEvent(func) {
		var oldonunload = window.onunload;
		if (typeof window.onunload != 'function') {
  			window.onunload = func;
		} else {
  			window.onunload = function() {
    			oldonunload();
    			func();
  			}
		}
	}

	
/*	Cookie Functions
	---------------- */
	/* begin common cookie functions.  see http://techweb/javascript_commons/docs/cookies.html for documentation. */
	function setCookie(name, value, escapeValue, expires, path, domain, secure) { //sets cookie value
		var cookieToken = name + '=' + ((escapeValue) ?  escape(value) : value) + ((expires) ? '; expires=' + expires.toGMTString( ) : '') + ((path) ? '; path=' + path : '') + ((domain) ? '; domain=' + domain : '') + ((secure) ? '; secure' : '');
		document.cookie = cookieToken;
	}
	function getCookie(name) { //gets cookie value
		var allCookies = document.cookie;
		var cookieName = name + "=";
		var start = allCookies.indexOf("; " + cookieName);
		if (start == -1) {
			start = allCookies.indexOf(cookieName);
			if (start != 0) return null;
		}
		else start += 2;
		var end = document.cookie.indexOf(";", start);
		if (end == -1) end = allCookies.length;
		return unescape(allCookies.substring(start + cookieName.length, end));
	}
	function deleteCookie(name, path, domain) { //deletes a cookie
		var value = getCookie(name);
		if (value != null) document.cookie = name + '=' + ((path) ? '; path=' + path : '') + ((domain) ? '; domain=' + domain : '') + '; expires=Thu, 01-Jan-70 00:00:01 GMT';
		return value;
	}
	function verifyCookieSafe( ) {
		setCookie('pingCookies', 'hello');
		if (getCookie('pingCookies')) return true;
		else return false;
	}

	var referrerCookieName = "referrer";	
	function gotoReferrer(refererFromHeader, referrerFromCookie) {
		if (!referrerFromCookie) {
			referrerFromCookie = deleteCookie(referrerCookieName, "/");
		}
		if (refererFromHeader == "/" && referrerFromCookie) {
			document.location = referrerFromCookie;
			return;
		}
				
		document.location = refererFromHeader;
	}

function _detectPushdownAd( defaultHeight, id)
{
    if (document.getElementById(id))
    {
                var pushdownAd = document.getElementById(id);
                var elements = pushdownAd.getElementsByTagName('*');
                var flash =  null;

                for(var x = 0; x < elements.length; x++)
                        if(elements[x] && elements[x].nodeName.toLowerCase() == "embed" && elements[x].offsetWidth > 1)
                        {
                                flash = elements[x];
                                break;
                        }

                if ( flash.offsetWidth && flash.offsetWidth < 780 )
                        pushdownAd.style.height = defaultHeight;
                else {
                        var newDiv = document.createElement("div");
                        newDiv.id = "banner_container_clearer";
                        newDiv.innerHTML = " ";
                        pushdownAd.parentNode.insertBefore( newDiv, pushdownAd.nextSibling );
                }

    }
}


function detectPushdownAd() {
	_detectPushdownAd( "96px", "banner_container" );
}
function detectPushdownAd_noBanner() {
	_detectPushdownAd( "0px", "pushdownAd" );
}


/* Trips Helper Functions and Global Variables
    -------------------------------------- */
    var userIsLogged = getCookie('amg_user_info') ; //is the user logged or not
    var tripsData = new Object( ); //global variable holding trips data
    var hasActionUi;
    function addCount( elementId, count ){
        var countEl = document.getElementById(elementId);
        if( countEl ) countEl.innerHTML = count + '&nbsp;saved';
    }
    /* trip list updates*/
    function updateGroupListsOnPage(updatedTripsData){
		var leftRailTripListEl, widgetTripListEl, tripsUrlPrefix, updatedTripList, groupNameEls, activeTripId;
		leftRailTripListEl = document.getElementById('lr_trip_list');
        widgetTripListEl = document.getElementById('mcw_tripList');
		tripsUrlPrefix = '/myconcierge/trips/';
		updatedTripList = updatedTripsData.groups;
		activeTripId = getActiveTripId( );
        if(leftRailTripListEl) createNewListEl(leftRailTripListEl);
        if(widgetTripListEl) createNewListEl(widgetTripListEl);
		function createNewListEl(previousList){
            var newListEl, itemEl, anchorEl;
            newListEl=document.createElement('UL');
            newListEl.className = previousList.className;
            newListEl.id = previousList.id;
			for(var i=0; i<updatedTripList.length; i++){
				itemEl = document.createElement('LI');
				if(activeTripId && activeTripId == updatedTripList[i].groupId)
					itemEl.className = 'active';
				anchorEl = document.createElement('A')
				anchorEl.href = tripsUrlPrefix + updatedTripList[i].groupId;
				anchorEl.innerHTML = updatedTripList[i].groupTitle + '&nbsp;(' + updatedTripList[i].itemCount + ')'
				itemEl.appendChild(anchorEl);
				newListEl.appendChild(itemEl);
			}
            previousList.parentNode.replaceChild(newListEl, previousList)
		}
		function getActiveTripId( ){
			var activeListItemEl, activeLinkPath, idPos, activeTripId; 
			activeListItemEl = getElements('active', 'LI', leftRailTripListEl)[0];
			if(!activeListItemEl) return false;
			activeLinkPath = activeListItemEl.getElementsByTagName('A')[0].href;
			idPos = activeLinkPath.indexOf(tripsUrlPrefix) + tripsUrlPrefix.length;
			activeTripId = activeLinkPath.slice(idPos);
			return activeTripId;
		}
	}
    
/*	General DOM-Traversal Utilities and Helper Functions
	----------------------------------------------- */
	function setCssOpacity(targetedElement, opacity) {
		opacity = (opacity == 100)?99.999:opacity;
		targetedElement.style.filter = "alpha(opacity: "+opacity+")";
		targetedElement.style.opacity = opacity/100;    
	}
	function resetCssOpacity(targetedElement) {
		targetedElement.style.filter = "alpha(opacity:)";
		targetedElement.style.opacity = 1;    
	}
	function fade(fadeElement, fadeSpeed, callback, callbackFreq){
		var fadeSpeed, opacity, clearer
		fadeSpeed =  fadeSpeed || 9;
		opacity = 0;
		clearer = setInterval(function( ){
			setCssOpacity(fadeElement, opacity);
			if(opacity+fadeSpeed < 99) opacity+=fadeSpeed;
			else{ 
				resetCssOpacity(fadeElement);
				clearInterval(clearer);
                if(callback){
                    var freq = callbackFreq || 500;
                    setTimeout(callback, freq);
                }
			}
		},10)
	}
	function fadeOut(fadeElement, fadeSpeed, callback, callbackFreq){
		var fadeSpeed, opacity, clearer
		fadeSpeed =  fadeSpeed || 9;
		fadeElement.style.zoom = '1'; //ie hasLayout
		opacity = 99;
		clearer = setInterval(function( ){
			setCssOpacity(fadeElement, opacity);
			if(opacity-fadeSpeed > 0) opacity-=fadeSpeed;
			else{ 
				setCssOpacity(fadeElement, 0);
				clearInterval(clearer);
				if(callback){
                    var freq = callbackFreq || 500;
                    setTimeout(callback, freq);
                }
			}
		},10)
	}
	function getElements(classname, tagname, root){
		if(!root) root = document;
		else if (typeof root == "string") root = document.getElementById(root);
		if(!tagname) tagname = "*";
		var all = root.getElementsByTagName(tagname);
		if(!classname) return all;
		var elements = [];
		for(var i = 0; i < all.length; i++){
			var element = all[i];
			if(isMember(element,classname))
				elements.push(element)
		}
		return elements;
	}
	function isMember(element, classname){
		var classes = element.className;
		if(!classes) return false;
		if(classes ==classname) return true;
		var whitespace = /\s+/;
		if (!whitespace.test(classes)) return false;
		var c = classes.split(whitespace);
		for(var i = 0; i < c.length; i++)
			if (c[i] == classname) return true;
		return false;
	}
	function isDescendant(ancestor, descendant){
		if(!ancestor || !descendant) return;
		var similarDescendants = ancestor.getElementsByTagName(descendant.nodeName);
		for(var i=0; i<similarDescendants.length; i++)
			if( similarDescendants[i] == descendant ) return true;
		return false;
	}
    function getAncestors(element){
        var parents = new Array( );
        while( element.parentNode ){
            if( element.parentNode.nodeType == 1 )
                parents.push(element.parentNode);
                element = element.parentNode;
        }
        return parents;
    }
    function getOffsetParents(element){
        var offsetParents = new Array( );
        while( element.offsetParent ){
            if( element.offsetParent.nodeType == 1 )
                offsetParents.push(element.offsetParent);
                element = element.offsetParent;
        }
        return offsetParents;
    }
    

/* Repurposable Mouseover Dropdown Menu Behavior
    --------------------------------------------- */
	function DropdownMenu(args){
		this.args = args;
		this.list = document.getElementById(args.listId);
		this.itemElements = this.getItems( );
		this.itemObjects = this.setupItems( );
	}
	DropdownMenu.prototype.getItems = function( ){
		var itemElements = new Array( );
		for(var i=0; i<this.list.childNodes.length; i++)
			if(this.list.childNodes[i].nodeName == 'LI')
				itemElements.push(this.list.childNodes[i]);
		return itemElements;
	}
	DropdownMenu.prototype.setupItems = function( ){
		var itemObjects, openFunc, closeFunc;
        openFunc = this.openFunc, closeFunc = this.closeFunc;
        itemObjects = new Array( );
		for(var i=0; i<this.itemElements.length; i++)
			itemObjects.push(
				new DropdownItem({
					itemElement: this.itemElements[i],
					hiddenMenuClass: this.args.hiddenMenuClass,
                    openFunc: this.args.openFunc,
                    closeFunc: this.args.closeFunc
				}) 
			);
		return itemObjects;
	}
	function DropdownItem(args){
		var instance = this;
		this.itemElement = args.itemElement;
		this.trigger = getElements(args.triggerClass,null,this.itemElement)[0];
        this.openFunc = args.openFunc;
        this.closeFunc = args.closeFunc;
        this.menu = getElements(args.hiddenMenuClass,null,this.itemElement)[0];
		if(this.menu){
			this.itemElement.onmouseover = function(event){instance.handleLIMouseOver(event);}
			this.itemElement.onmouseout = function(event){instance.handleLIMouseOut(event);}
		}
	}
	DropdownItem.prototype.handleLIMouseOver = function(event){
		var evt, prevElement;
        evt = event || window.event;
		prevElement = evt.relatedTarget || evt.fromElement;
		if(prevElement != this.itemElement && !isDescendant(this.itemElement,prevElement)) 
            this.activate( );
	}
	DropdownItem.prototype.handleLIMouseOut = function(event){
		var evt, nextElement;
        evt = event || window.event; 
		nextElement = evt.relatedTarget || evt.toElement;
		if(nextElement != this.itemElement && !isDescendant(this.itemElement,nextElement))
			this.deactivate( );
	}
	DropdownItem.prototype.activate = function(event){
        this.menu.className = this.menu.className.replace(/inactive/g,'');
        var ancestors = getAncestors(this.menu);
        for(var i=0; i<ancestors.length; i++)
            ancestors[i].style.zIndex = '1000'
        if(this.openFunc) this.openFunc( );
	}
	DropdownItem.prototype.deactivate = function(event){
        var ancestors = getAncestors(this.menu);
        for(var i=0; i<ancestors.length; i++)
            ancestors[i].style.zIndex = ''
		this.menu.className += ' inactive';
        if(this.closeFunc) this.closeFunc( );
	}

/*  CSV Text Field 
    (Comma Separated Text field with a pulldown to click and add values to the text field)
    --------------------------------------------------------------------------- */
	function CSVTextfield(args){
		this.containerEl = document.getElementById(args.containerElId);
		this.textfieldEl = document.getElementById(args.textfieldElId);
        this.changeHandler = args.changeHandler || null;
		this.containingFormEl = this.textfieldEl.form;
		this.valuesListEl = document.getElementById(args.valuesListElId);
		this.valueEls = getElements(args.valueElClass, null, this.containerEl);
		this.registerEventHandlers( );
	}
	CSVTextfield.prototype.registerEventHandlers = function( ){
		var CSVTextfield = this;
		this.textfieldEl.onfocus = function( ){CSVTextfield.handleFocus( );}
		for(var i=0; i<this.valueEls.length; i++)
			this.valueEls[i].onclick = function(event){CSVTextfield.addValueToTextfield(event);}
	}
	CSVTextfield.prototype.handleFocus = function( ){
		var CSVTextfield, collapseMethod;
		CSVTextfield = this;
		collapseMethod = function( ){CSVTextfield.collapse( )};
		this.expand( );
		this.textfieldEl.onblur = function(blurEvent){CSVTextfield.handleBlur(blurEvent)}
		for(var i=0; i<this.containingFormEl.elements.length; i++)
			if(this.containingFormEl.elements[i] != this.textfieldEl)
				window.addEventListener ? this.containingFormEl.elements[i].addEventListener('focus', collapseMethod, false) : this.containingFormEl.elements[i].attachEvent('onfocus', collapseMethod);
	}
	CSVTextfield.prototype.handleBlur = function(blurEvent){
		var CSVTextfield = this;
		CSVTextfield.containerEl.onclick = CSVTextfield.textfieldEl.onclick = function(clickEvent){
			var evt = clickEvent || window.event;
			if(evt.stopPropagation) evt.stopPropagation( );
			else evt.cancelBubble = true;
		}
		document.onclick = function(clickEvent){
			var clickEvent = clickEvent || window.event;
			CSVTextfield.collapse( );
			document.onclick = CSVTextfield.containerEl.onclick = CSVTextfield.textfieldEl.onclick = null; //remove the handlers
		}
	}
	CSVTextfield.prototype.addValueToTextfield = function(event){
		var evt, valueEl, newValue, currentFieldValue, lastChar;
		evt = event || window.event;
		valueEl = evt.srcElement || evt.target;
		newValue = valueEl.firstChild.nodeValue.toLowerCase( ); /*do tags come in as mixed case data?*/
		currentFieldValue = this.textfieldEl.value;
        lastChar = currentFieldValue.charAt(currentFieldValue.length-1);
        beforeLastChar = currentFieldValue.charAt(currentFieldValue.length-2);
        if(currentFieldValue == '')this.textfieldEl.value += newValue;
        else if(lastChar == ',') this.textfieldEl.value += ' ' + newValue;
        else if(beforeLastChar == ',' && lastChar == ' ') this.textfieldEl.value += newValue;
        else this.textfieldEl.value += ', ' + newValue;
        this.textfieldEl.focus( );
        if(this.changeHandler) this.changeHandler( );
	}
	CSVTextfield.prototype.expand = function( ){this.valuesListEl.className = this.valuesListEl.className.replace(/collapsed/, ' expanded')}
	CSVTextfield.prototype.collapse = function( ){this.valuesListEl.className = this.valuesListEl.className.replace(/expanded/, ' collapsed');}

/*  Custom Textarea
    (Text area with remaining count indicator)
    ------------------------------------- */
    function CustomTextarea(args){
        this.textareaEl = args.textareaEl || document.getElementById(args.textareaElId);
        this.limit = args.limit;
        this.indicatorText = args.indicatorText;
        this.indicator = this.getIndicator()
        this.init( );
    }
    CustomTextarea.prototype.init = function( ){
        var CustomTextarea = this;
        this.updateCount( );
        this.textareaEl.onkeyup = function( ){CustomTextarea.updateCount( )};
    }
    CustomTextarea.prototype.updateCount = function( ){
        var CustomTextarea, remaining; 
        CustomTextarea = this;
        window.setTimeout(function( ){
                remaining = CustomTextarea.limit - CustomTextarea.textareaEl.value.length;
                CustomTextarea.indicator.innerHTML = remaining;
                CustomTextarea.setState(remaining);
        },0);
    }
    CustomTextarea.prototype.setState = function(remaining){
        var isOverLimit = (remaining<1?true:false);
        if(isOverLimit) this.indicator.className = 'textcountIndicator overLimit';
        else this.indicator.className = 'textcountIndicator';
    }
    CustomTextarea.prototype.getIndicator = function(){
        var indicator, container;
        container = document.createElement('DIV');
        indicator = document.createElement('span');
        container.className = 'textcountContainer';
        indicator.className = 'textcountIndicator';
        container.innerHTML = this.indicatorText;
        indicator.innerHTML += this.limit;
        container.appendChild(indicator);
        this.textareaEl.parentNode.appendChild(container);
        return indicator;
    }
    
/*	Show Social Site Links
	------------------------- */    
    function showShareLinks(state){
        var shareList, shareLink, pfSearchFilters;
        if ( document.getElementById('social_sites') ) shareList = document.getElementById('social_sites');
        if ( document.getElementById('share_link') ) shareLink = document.getElementById('share_link');
        if( document.getElementById('pfsearch') ) pfSearchFilters = document.getElementById('pfsearch').getElementsByTagName('SELECT');
        
        /* for slideshow pull up */
        var docLocation = window.location.href;
        var slideshow = new Boolean(false);
        if ( docLocation.indexOf("slideshow") != -1 )
            slideshow = true;  
        
        if (state == 'true')
        {
            shareList.style.display = "block";
            shareLink.style.backgroundPosition = "0 -17px";
            shareLink.style.color = "#000";
            if(pfSearchFilters) toggleFilterDisplay(false)
            
            if (slideshow == true)
            {
                shareLink.style.width = "30px";
                shareLink.style.height = "17px";
                shareLink.style.padding = "0 10px 0 8px";
                shareLink.style.position = "absolute";
                shareLink.style.left = "32px";
            }
        }
        else
        {
            shareList.style.display = "none";
            if(pfSearchFilters) toggleFilterDisplay(true);
            if (slideshow == false)
            {
                shareLink.style.backgroundPosition = "0 0";
                shareLink.style.color = "#ffd306";
            }
            else
            {
                shareLink.style.width = "auto";
                shareLink.style.height = "auto";
                shareLink.style.padding = "0";
                shareLink.style.position = "static";
                shareLink.style.color = "#FFD306";
                shareLink.style.backgroundPosition = "0 -34px";
            }
         }
         function toggleFilterDisplay(visibility){
             var vstate = (visibility ? 'visible' : 'hidden');
             for(var i=0; i<pfSearchFilters.length; i++)
                 pfSearchFilters[i].style.visibility = vstate;
         }
    }

/*	Open Social Site Links Popup
	------------------------- */
 function sbm_Window(url,title){
  var title=encodeURIComponent(title); 
  var newtitle = decodeURIComponent(title);
  if(newtitle.indexOf('&#244;')!=-1 || newtitle.indexOf('&ocirc;')!=-1 || newtitle.indexOf('&Ocirc;')!=-1 || /* newtitle.indexOf('&eacute;')!=-1 ||*/ newtitle.indexOf('&Eacute;')!=-1 || newtitle.indexOf('&egrave;')!=-1 || newtitle.indexOf('&Egrave;')!=-1 || newtitle.indexOf('&#218;')!=-1 || newtitle.indexOf('&#206;')!=-1 || newtitle.indexOf('&#232;')!=-1 || newtitle.indexOf('&#237;')!=-1 || newtitle.indexOf('&#233;')!=-1 || newtitle.indexOf('+')!=-1) {
      newtitle=newtitle.replace(/&#244;/g,"o");
      newtitle=newtitle.replace(/&ocirc;/g,"o");
      newtitle=newtitle.replace(/&Ocirc;/g,"O");
      newtitle=newtitle.replace(/&eacute;/g,"e");
      newtitle=newtitle.replace(/&egrave;/g,"e"); 
      newtitle=newtitle.replace(/&Eacute;/g,"E");
      newtitle=newtitle.replace(/&Egrave;/g,"E"); 
      newtitle=newtitle.replace(/&#218;/g,"u");
      newtitle=newtitle.replace(/&#232;/g,"e");
      newtitle=newtitle.replace(/&#233;/g,"e");
      newtitle=newtitle.replace(/&#206;/g,"I");
      newtitle=newtitle.replace(/&#237;/g,"i"); 
      //newtitle=newtitle.replace(/é/g,"e");
      newtitle=newtitle.replace(/\+/g,"and"); 
          
 }
 
  url = url + newtitle;
  var Newsbm=window.open(url,'name',"width=1000,height=500,directories=no,menubar=no,toolbar=no,scrollbars=yes,left=0,top=0,screenX=0,screenY=0");
}    
 
function gotoEmailAFriend( ) {
    window.location = "/services/emailafriend?referringPage=" + escape(location.href);
}

function gotoEmailAFriendNew( ) {
    var url = "/services/emailafriend?referringPage=" + escape(location.href);
    window.open(url);
}

function goTo(href) {
    if (href != '')
        window.location = href;
    else
        return false;
}
    
/*	Font Size Adjustment Tool
	------------------------- */
    var prefSheet = getCookie('prefSheet');
    if(prefSheet && prefSheet !='default') document.write('<link rel="stylesheet" type="text/css" href="' + prefSheet + '" />'); //so that sheet is inserted right away instead of onload
	function fontsizeSwitcherInit( ){
        if(!document.getElementById('font_switcher')) return;
		var small_sheetpath = '/styles/fontsize_tool/size1.css', large_sheetpath = '/styles/fontsize_tool/size3.css';
		var small_size_button = document.getElementById('fs_small_size'), default_size_button = document.getElementById('fs_default_size'), large_size_button = document.getElementById('fs_large_size');
		small_size_button.onclick = function( ){doStyleSwitch(small_sheetpath, small_size_button);}
		default_size_button.onclick = function( ){doStyleSwitch(null,default_size_button);}
		large_size_button.onclick = function( ){doStyleSwitch(large_sheetpath, large_size_button);}
        if(prefSheet && prefSheet !='default'){
            var trigger = (prefSheet==small_sheetpath ? small_size_button : large_size_button);
            fsActivateTrigger(trigger);
        }
	}
	runOnLoad(fontsizeSwitcherInit);
	function doStyleSwitch(sheetpath, trigger){
		removeAllSwitcherSheets( );
        if(sheetpath){ 
            insertSheet(sheetpath)
            setCookie('prefSheet', sheetpath,null,null,'/',null,null);
        }
        else setCookie('prefSheet', 'default',null,null,'/',null,null);
		fsActivateTrigger(trigger);
	}
	function fsActivateTrigger(trigger){
		fsDeactivateAllTriggers( );
		trigger.className = "active";
	}
	function fsDeactivateAllTriggers( ){
		var triggers = document.getElementById('font_switcher').getElementsByTagName('A');
		for(var i=0; i<triggers.length; i++)
			triggers[i].className = '';
	}
	function insertSheet(new_sheet_path){
		var new_link= document.createElement('LINK');
		new_link.rel = "stylesheet"
		new_link.type = "text/css"
		new_link.href = new_sheet_path;
		document.getElementsByTagName('HEAD')[0].appendChild(new_link);
	}
	function removeAllSwitcherSheets( ){
        var sheets = document.styleSheets;  //all browers
        for(var i=0; i<sheets.length; i++){
            if( sheets[i].href && sheets[i].href.match(/fontsize/) ){
                if(sheets[i].cssText){  //ie
                    sheets[i].cssText='';
                    return;
                }
                if(sheets[i].disabled){ //ff
                    sheets[i].disabled=true;
                    return;
                }
                if(sheets[i].ownerNode){ //saf
                    var linkNode = sheets[i].ownerNode;
                    linkNode.href='';
                    return;
                }
            }
        }
	}
    
    
/*	Concierge Utilities
	------------------- */
	function ConciergeUtility(args){
		//placeholder
	}
	ConciergeUtility.prototype.getXHR = function( ){
		XHR = new Object( );
		XHR._attempts = [
			function( ) { return new XMLHttpRequest( ) },
			function( ) { return new ActiveXObject("Msxml2.XMLHTTP") },
			function( ) { return new ActiveXObject("Microsoft.XMLHTTP") }
		];
		XHR._attempt = null;
		XHR.newRequest = function( ) {
			if(XHR._attempt != null) return XHR._attempt( );
			for(var i=0; i<XHR._attempts.length; i++) {
				try{
					var attempt = XHR._attempts[i];
					var request = attempt( );
					if (request != null){
						XHR._attempt = attempt;
						return request;
					}
				}
				catch(e){continue;}
			}
			XHR._attempt = function( ){throw new Error("XMLHttpRequest not supported");}
			XHR._attempt( );
		}
		return XHR.newRequest( );
	}
    var popUpWin;
    ConciergeUtility.prototype.openWindow = function(URLStr, type)
    {
      var width = 250;
      var height = 250;
      var scroll = "no";
      var resize ="no";
      if (popUpWin != null && popUpWin.open) popUpWin.close();
      
      if (type == 'articleSlideshow') {
      width = 776;
      height = 800;
      }
      if (type == 'truth') {
      width = 655;
      height = 310;
      resize = "yes";
      }    
      if (type == 'wordtrips') {
      width = 612;
      height = 774;
      scroll = "yes";
      }  
      if (type == 'instructions') {
      width = 660;
      height = 600;
      scroll = "yes";
      }    
      if (type == 'uber') {
      width = 1042;
      height = 768;
      scroll = "yes";
      }     
      if (type == 'guidelines') {
      width = 450;
      height = 400;
      scroll = "no";
      }      
       
      
      popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scroll+',resizable='+resize+',copyhistory=yes,width='+width+',height='+height);
    }
    var conUtil = new ConciergeUtility();
 //Javascript utility function
//Function to left trim a specific character from a string
function leftTrim(sString,startChar)
{
    while (sString.substring(0,1) == startChar)
    {
    sString = sString.substring(1, sString.length);
    }
    return sString;
}


function trim(str) {
    return rtrim(ltrim(str));
}

function ltrim(str) {
    return str.replace(/^\s+/g, "");
}

function rtrim(str) {
    return str.replace(/\s+$/g, "");
}

/*
 * Use this function to construct a querystring formatted string
 * containing all form element name and values to submit Ajax POST requests
 */
function getFormElementQueryString(form) {
    var params = [];
    params.addEl = function(el) {
        this.addPair(el.name, el.value);
    }
    params.addPair = function(name, value) {
        this.push(name + "=" + value);
    }
    
    for (var i=0; i<form.elements.length; i++) {
        var el = form.elements[i];
        if (el.type == "text" || el.type == 'hidden' || el.type == 'password') {
            params.addEl(el); 
        } else if (el.type == "radio" || el.type == "checkbox") {
            if (el.checked) {
                params.addEl(el);
            }
        } else if (el.type == "select-one") {
            params.addPair(el.name, el.options[el.options.selectedIndex].value);
        } else if (el.type == "select-multiple") {
            for (var j=0; j<el.options.length; j++) {
                if (el.options[j].selected) {
                    params.addPair(el.name, el.options[j].value);
                }
            }
        }
    }
        
    return params.join("&");
}

/*
 * This function returns first element node (nodeType = 1) of a DOM element.
 * It exists for the purpose of resolving browser incompatibilities 
 * when it comes to treating DOM elements: FF treats white space elements
 * as separate DOM elements while IE does not. 
 */
function getFirstElementNode(el) {
    var nwsrx = /\S/;
    for (var i=0; i<el.childNodes.length; i++) {
        var childNode = el.childNodes[i];
        if (childNode.nodeType == 1) {
            return childNode;
        }
    }
}

/*
 * Jumping to an anchor after reload - IE workaround
 */
if (location.hash != "") {
    location.href = location.hash;
}

function getEventKeyCode(e) {
   if (window.event) {
       return window.event.keyCode; //IE
   } else {
       return e.keyCode; //non-IE
   }
}


/*
 * This function attaches "Enter" keypress event callback (supplied)
 * to form text fields so that the form submits when you press enter
 * when cursor is in a text field.
 */
function enableEnterBtnTextFieldSubmitListener(form, callback) {
    var enterBtnListener = function(e) {
        var keyCode = getEventKeyCode(e);
        if (13 == keyCode) {
            callback();
        }        
    }
    
    //turning off enter key in the form (needed for Safari and other browsers
    // that chain enter key events and would submit the form anyway)
    form.onkeypress = function(e) {
        var keyCode = getEventKeyCode(e);
        return keyCode != 13;
    }
    
    //enabling enter key back for text fields
    for (var i=0; i<form.elements.length; i++) {
        var el = form.elements[i];
        if (el.type == "text" || el.type == "password") {
            if (window.addEventListener) {
                el.addEventListener("keypress", enterBtnListener, false);
            } else {
                el.attachEvent("onkeypress", enterBtnListener);
            }
        }
    }
}

/* Returns left offset coordinate for an element */
function getElementLeft(el) {
    var result = 0;
    while (el.offsetParent) {
        result += el.offsetLeft;
        el = el.offsetParent;
    }
    return result;
}

/* Returns top offset coordinate for an element */
function getElementTop(el) {
    var result = 0;
    while (el.offsetParent) {
        result += el.offsetTop;
        el = el.offsetParent;
    }
    return result;
}


/*	Marketing Widget
	--------------- */
	function MarketingWidget(args ){
		this.requestPath = args.requestPath;
		this.container = document.getElementById(args.containerId);
		this.tabs = this.getTabs(args.tabSections);
		this.errorClassName = args.errorClassName;
		this.successClassName = args.successClassName;
		this.registerHandlers( );
	}
	MarketingWidget.prototype.registerHandlers = function( ){
		var marketingWidget = this; 
		for(var i=0; i<this.tabs.length; i++){
			var tabObj = this.tabs[i]
			tabObj.tabEl.onclick = function( ){marketingWidget.switchTab(this)}
			if(tabObj.submitEl) tabObj.submitEl.onclick = function( ){ marketingWidget.submitRequest( this );}
			if(tabObj.formEl) tabObj.formEl.onsubmit = function( ){
				marketingWidget.submitRequest( this );
				return false; 
			}
		}
	}
	MarketingWidget.prototype.submitRequest = function(domElement){
		var marketingWidget, activeTab, util, xhr, fullRequestPath, params, responseObj;
		marketingWidget=this;
		activeTab = this.getTab(domElement);
		params = activeTab.getParams( ) + '&viewName=ajax.marketingwidget.response.view';
		fullRequestPath = this.requestPath/* + params*/;
		util = new ConciergeUtility( );
		xhr  = util.getXHR( );
		xhr.onreadystatechange = function( ) {
			if (xhr.readyState == 4 && xhr.status == 200){
				responseObj = eval('('+xhr.responseText+')');
				marketingWidget.handleResponse(responseObj, activeTab, params);
			}
		}
		xhr.open("POST", fullRequestPath, true);
		xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		/*
		xhr.setRequestHeader("Content-length", params.length);
		xhr.setRequestHeader("Connection", "close");
		*/
		xhr.send(params);
		this.showProgress(true)
	}
	MarketingWidget.prototype.handleResponse = function(response, activeTab, params){ //redirect user to full reg or show inline message
		this.showProgress(false)
                if (response.success) {
                        var omnitureEvents = this.collectOmnitureEvents(activeTab.formEl);
                        this.trackOmnitureEvents(omnitureEvents);
                }
		if(response.view.redirect){
			var strippedparams = params.replace('command=submit&','');
			strippedparams+='&isSuccessfulShortFormSubmission=true';
			window.location = response.view.redirectView + '?' + strippedparams;
			return;
		}
		var msg, msgClassName;
		msg = ( response.success ? response.view.thankYouMessage : response.error );
		msgClassName = ( response.success ? this.successClassName : this.errorClassName );
		activeTab.showMessage(msg, msgClassName, true);
	}
	MarketingWidget.prototype.getTabs = function( tabSections ){
		var tabs = [ ];
		for(var i=0; i<tabSections.length; i++)
			tabs.push( new WidgetTab({sectionText: tabSections[i]}) );
		return tabs;
	}
	MarketingWidget.prototype.getTab = function( tabProp ){
		for(var i=0; i<this.tabs.length; i++)
			for(var prop in this.tabs[i])
				if(this.tabs[i][prop] == tabProp)
					return this.tabs[i]	
	}
	MarketingWidget.prototype.switchTab = function(tabEl){
		this.resetTabs( );
		this.getTab(tabEl).toggleTab(true);
	}
	MarketingWidget.prototype.resetTabs = function(){
		for(var i=0; i<this.tabs.length; i++)
			this.tabs[i].resetTab( );
	}
	MarketingWidget.prototype.showProgress = function(isBusy){
		var descendants, state;
		state = ( isBusy ? 'wait' : '' ); //use empty string instead of 'auto' to maintain cursor values in stylesheets
		descendants = getElements(null,null,this.container);
		for(var i=0; i<descendants.length; i++)
			descendants[i].style.cursor = state;
	}
        MarketingWidget.prototype.collectOmnitureEvents = function(formEl) {
                var inputFields = formEl.getElementsByTagName("input");
                var eventCodes = new Array();
                for (var i=0; i<inputFields.length; i++) {
                        var input = inputFields[i];
                        if (input.type == 'checkbox' && input.checked) {
                                var eventId = input.value;
                                eventId = eventId.replace(/newsletter\.46/, 'event11');
                                eventId = eventId.replace(/newsletter\.11/, 'event12');
                                eventId = eventId.replace(/newsletter\.220/, 'event13');
                                eventCodes.push(eventId);
                        }
                }
                return eventCodes;
        }
        MarketingWidget.prototype.trackOmnitureEvents = function(events) {
                var eventStr = events.join(",");
                s.linkTrackVars="events";
                s.linkTrackEvents=eventStr;
                s.events=eventStr;
                s.tl(this,'o','AjaxCall');
        }
	/*Marketing Widget Tab*/
	function WidgetTab(args){
		this.sectionText = args.sectionText;
		this.tabEl = document.getElementById(this.sectionText + '_tab');
		this.contentEl = document.getElementById(this.sectionText + '_section');
		this.formEl = this.contentEl.getElementsByTagName('FORM')[0];
		this.submitEl = document.getElementById(this.sectionText + '_submit');
		this.msgEl = null;
	}
	WidgetTab.prototype.getParams = function( ){
		var inputs, queryString;
		queryString = '';
		inputs = this.formEl.getElementsByTagName('INPUT');
		for(var i=0; i<inputs.length; i++){
			var input = inputs[i];
			if( input.type.match(/checkbox/) && !input.checked ) 
				continue;
			if( input.type.match(/text|hidden|checkbox/i) )
				queryString += input.name + '=' + input.value + '&';
		}
		return queryString.substring(0, queryString.length-1);
	}
	WidgetTab.prototype.showMessage = function(message, messageClassName, mutex){
		var msgEl, mutex;
		msgEl = document.createElement('DIV');
		msgEl.className = messageClassName;
		msgEl.innerHTML = message;
		if(mutex) this.removeMessages( );
		this.contentEl.insertBefore(msgEl, this.contentEl.firstChild);
		this.msgEl = msgEl;
	}
	WidgetTab.prototype.removeMessages = function(){
		if(this.msgEl){
			this.contentEl.removeChild(this.msgEl)
			delete this.msgEl;
		}
	}
	WidgetTab.prototype.toggleTab = function(isVisible){
		this.tabEl.className = ( isVisible ? this.tabEl.className+' active' :this.tabEl.className.replace(/active/,''));
		this.contentEl.style.display = ( isVisible ? 'block' : 'none' );
	}
	WidgetTab.prototype.resetTab = function( ){
		this.toggleTab(false);
		this.removeMessages( );
		if(this.formEl) this.formEl.reset( );
	}
	
/*****************************/

/*	Sign In Or Register Manager */
    SiorManager.siors = [];
	function SiorManager(className, addRegLight, returnTo){
        this.className = className;
		this.siorComponents = [ ];
        this.addRegLight = addRegLight;
        this.util = new ConciergeUtility();
		this.init(returnTo);
	}
	SiorManager.prototype.init = function(returnTo){
			var manager = this, siorElements = getElements(this.className, null, null), siorElement;
			for(var i=0; i<siorElements.length; i++){
				siorElement = siorElements[i];
				if(!userIsLogged){
					this.siorComponents.push(new SignInOrRegisterComponent(siorElement, manager, this.addRegLight, returnTo))
				}else{
					this.doDefault(siorElement, returnTo);
				}
			}
	}
    SiorManager.prototype.resetAll = function() {
        for (var i=0; i<SiorManager.siors.length; i++) {
            SiorManager.siors[i].reset();
        }
    }
	SiorManager.prototype.reset = function( ){
		for(var i=0; i<this.siorComponents.length; i++)
			if( this.siorComponents[i].isActive )
				this.siorComponents[i].destroyComponent( );
	}
	//temporary hack to do defaults until we can modify the php
	SiorManager.prototype.doDefault = function(element, returnTo){
		if (element.innerHTML == 'Add a Comment'){
			element.href = '#addComment';
		} else if (element.id == 'postReplyButton'){
			element.href = '#postReply';
		} else if (returnTo != null) {
            element.href = returnTo;
        }
	}
	
/* Sign In Or Register Component */
	SignInOrRegisterComponent.BOTTOM = 1;
	SignInOrRegisterComponent.LEFT = 2;
	SignInOrRegisterComponent.RIGHT = 'rightAligned';
    SignInOrRegisterComponent.CENTER = 'centerAligned';
	SignInOrRegisterComponent.TOP = 'topAligned';
    SignInOrRegisterComponent.REG_LIGHT_BUTTON_CONTAINER_NAME = "joinNowButtonContainer";
    SignInOrRegisterComponent.SIGNIN_ERROR_DIV_NAME = "signInError";
    function SignInOrRegisterComponent(triggerEl, manager, addRegLight, returnTo){
       this.triggerEl = triggerEl;
	   this.manager = manager;
	   this.isActive = false;
	   this.xType = this.getXType( );
	   this.yType = this.getYType( );
       this.addRegLight = addRegLight;
       this.returnTo = returnTo;
       this.init( );
    }
    SignInOrRegisterComponent.prototype.init = function( ){
        var sior = this, clickHandler
        clickHandler = function(){
			sior.manager.resetAll();  
			sior.displayComponent();
            if (sior.addRegLight) {
                sior.addRegLightClickHandler();
            } else {
                sior.addRegFullClickHandler();
            }
		}
        if(window.addEventListener) 
            this.triggerEl.addEventListener('click', clickHandler, false);
        else if(window.attachEvent) 
            this.triggerEl.attachEvent('onclick', clickHandler);      
    }
    SignInOrRegisterComponent.prototype.displayComponent = function( ){
        closeRegLightForm();
       this.componentEl = this.makeComponentEl( );
       document.body.appendChild(this.componentEl);
       this.initSigninForm();
       this.positionComponent( );
	   this.isActive = true;
    }
    SignInOrRegisterComponent.prototype.destroyComponent = function( ){
        this.componentEl.parentNode.removeChild(this.componentEl);
        delete this.componentEl;
		this.isActive = false;
    }
	SignInOrRegisterComponent.prototype.getXType = function( ){
		var type = SignInOrRegisterComponent.LEFT;
		if (isMember( this.triggerEl, SignInOrRegisterComponent.RIGHT)) {
			type = SignInOrRegisterComponent.RIGHT;
        } else if (isMember(this.triggerEl, SignInOrRegisterComponent.CENTER)) {
            type = SignInOrRegisterComponent.CENTER;
        }
		return type;
	}
	SignInOrRegisterComponent.prototype.getYType = function( ){
		var type = SignInOrRegisterComponent.BOTTOM;
		if( isMember( this.triggerEl, SignInOrRegisterComponent.TOP ) )
			type = SignInOrRegisterComponent.TOP;
		return type;
	}
    SignInOrRegisterComponent.prototype.positionComponent = function( ){
		var newLeft, newTop, triggerElLeft, triggerElTop;
		triggerElLeft = newLeft = this.getTriggerElLeft( );
		triggerElTop = newTop = this.getTriggerElTop( );
		if (this.xType == SignInOrRegisterComponent.RIGHT){
			var componentWidth = this.componentEl.offsetWidth;
			var triggerWidth = this.triggerEl.offsetWidth;
			var deltaWidth = componentWidth - triggerWidth;
			newLeft = triggerElLeft - deltaWidth;
		} else if (this.xType == SignInOrRegisterComponent.CENTER) {
			var componentWidth = this.componentEl.offsetWidth;
			var triggerWidth = this.triggerEl.offsetWidth;
			var deltaWidth = (componentWidth + triggerWidth)/2;
            newLeft = triggerElLeft - deltaWidth;
        }
		if( this.yType == SignInOrRegisterComponent.TOP ){
			newTop = triggerElTop - this.componentEl.offsetHeight;
		}else{
			newTop += this.triggerEl.offsetHeight;
		}
        this.componentEl.style.top = newTop + 'px';
		this.componentEl.style.left = newLeft + 'px';
    }
    SignInOrRegisterComponent.prototype.getTriggerElTop= function( ){
        return getElementTop(this.triggerEl);
    }
    SignInOrRegisterComponent.prototype.getTriggerElLeft = function( ){
        return getElementLeft(this.triggerEl);
    }
    SignInOrRegisterComponent.prototype.getReturnTo = function( ){
        if(this.triggerEl.id == 'postReplyButton' && !location.href.match(/^.*#postReply$/)){
            return location.href + "#postReply";
		} else if (this.returnTo != null) {
            return this.returnTo;
        } else {
            return location.href;
        }
    }
    SignInOrRegisterComponent.prototype.makeComponentEl = function( ){
        var componentEl = document.createElement('DIV');
        componentEl.className = 'signInOrRegister';
        componentEl.id = 'sior_component';
        componentEl.appendChild( this.makeHeadlineEl( ) );
        componentEl.appendChild( this.makeSignInEl( ) );
        componentEl.appendChild( this.makeRegisterEl( ) );
        componentEl.appendChild( this.makeFooterEl( ) );
        componentEl.appendChild( this.makeCloseEl( ) );
        return componentEl;
    }
    SignInOrRegisterComponent.prototype.makeFooterEl = function( ){
        var footerEl = document.createElement('DIV');
        footerEl.className = 'footer';
        return footerEl;
    }
    SignInOrRegisterComponent.prototype.makeCloseEl = function( ){
        var closeEl, sior;
        sior = this;
        closeEl = document.createElement('A');
        closeEl.id = 'sior_close';
        closeEl.innerHTML = 'x';
        closeEl.onclick = function( ){ sior.destroyComponent( )}
        return closeEl;
    }
    SignInOrRegisterComponent.prototype.makeHeadlineEl = function( ){
        var headlineEl = document.createElement('H5');
        headlineEl.innerHTML = 'Sign In Or Register';
        return headlineEl
    }
	SignInOrRegisterComponent.prototype.makeSignInEl = function( ){
		var container, signInHTML, returnTo;
        returnTo = this.getReturnTo();
		signInHTML = 
        '<form method="post" action="/user/signin" name="loginForm">' +
            '<input type="hidden" name="returnto" value="' + returnTo + '" />' +
            '<h3>User Sign-In</h3>' +
            '<div id="' + SignInOrRegisterComponent.SIGNIN_ERROR_DIV_NAME + '" class="error" style="display:none">We\'re sorry, but we can\'t find the user name and password combination you\'ve submitted. Please try resubmitting your information. Please note: User name and password are case-sensitive.</div>' +
			'<div>' +
				'<p>Username:<br /><input type="text" class="textField" name="username" ></p>' +
				'<p>Password:<br /><input type="password" class="textField" name="password"></p>' +
			'</div>' +
            '<div><input type="checkbox" id="rememberme" name="rememberme" value="true" /><label for="rememberme">Remember me next time</label></div>' +
			'<p>' +
				'<span class="yellowOnBlackCssButton">' +
					'<a id="loginLight_submit">Sign In &#8250;</a>' +
				'</span>' +
				'<a class="forgotInfo" href="/user/forgotpassword?returnto=' + returnTo + '">Forgot your sign-in information?</a>' +
				'<input id="submit" type="image" src="/images/x.gif"/>' +
			'</p>' +
		'</form>';
		container = document.createElement('DIV');
		container.id = 'sior_login_form';
		container.innerHTML = signInHTML;
		return container;
	}
	SignInOrRegisterComponent.prototype.makeRegisterEl = function( ){
		var container, joinNowHTML;
        joinNowHTML =
		'<h3>Not A Member?</h3>' +
		'<p>Join Concierge.com to create Trip Plans, upload photos, post tips and reviews, and get answers to your travel questions.</p>' +
		'<p>It\'s fast and free!</p>' +
		'<span id="' + SignInOrRegisterComponent.REG_LIGHT_BUTTON_CONTAINER_NAME + '" class="yellowOnBlackCssButton"><a href="javascript:void(0)">Join Now&nbsp;&#8250;</a></span>';
		container = document.createElement('DIV');
		container.id = 'sior_join_invite';
		container.innerHTML = joinNowHTML;
        return container;
	}
    SignInOrRegisterComponent.prototype.addRegLightClickHandler = function() {
        var regLightButtonContainer = document.getElementById(SignInOrRegisterComponent.REG_LIGHT_BUTTON_CONTAINER_NAME);
        var sior = this;
        var rlm = new RegLightManager();
        regLightButtonContainer.onclick = 
            function () {    
                var coords = { top: sior.componentEl.style.top, 
                               left: sior.componentEl.style.left 
                             };
                rlm.displayForm(sior.getReturnTo(), coords, true); 
                sior.destroyComponent(); 
                rlm.initForm();
            };    
    }
    SignInOrRegisterComponent.prototype.addRegFullClickHandler = function() {
        var regLightButtonContainer = document.getElementById(SignInOrRegisterComponent.REG_LIGHT_BUTTON_CONTAINER_NAME);
        var sior = this;
        regLightButtonContainer.onclick = function () { window.location = "/user/registration?returnto=" + sior.getReturnTo(); };  
    }
    SignInOrRegisterComponent.prototype.initSigninForm = function() {
        var signInButton = document.getElementById("loginLight_submit");
        var sior = this;
        var formHandler = function() {
            sior.submitSigninForm();
        }
        signInButton.onclick = formHandler;
        enableEnterBtnTextFieldSubmitListener(document.loginForm, formHandler);          
    }
    SignInOrRegisterComponent.prototype.submitSigninForm = function() {
        this.resetErrorDivs();
        var form = document.loginForm;
        var params = getFormElementQueryString(form);
        var xhr = this.manager.util.getXHR();
        var sior = this;
		xhr.onreadystatechange = function( ) {
			if (xhr.readyState == 4 && xhr.status == 200){
				responseObj = eval('('+xhr.responseText+')');
                if (responseObj.loginFailed) {
                    var errorDiv = document.getElementById(SignInOrRegisterComponent.SIGNIN_ERROR_DIV_NAME);
                    errorDiv.style.display = "block";
                } else {
                    var returnTo = sior.getReturnTo();
                    if (returnTo.indexOf(location.href) != -1) {
                        window.location = sior.getReturnTo();
                        window.location.reload(true);
                    } else {
                        window.location = returnTo;
                    }
                }
			}
		}
        xhr.open("POST", "/ajax/user/login_light");
        xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xhr.setRequestHeader("Content-length", params.length);
        xhr.setRequestHeader("Connection", "close");
        xhr.send(params);        
    }
    SignInOrRegisterComponent.prototype.resetErrorDivs = function() {
        var errorDiv = document.getElementById(SignInOrRegisterComponent.SIGNIN_ERROR_DIV_NAME);
        errorDiv.style.display = "none";
    }
        
   
    function RegLightManager() {
        this.form = null;
        this.fieldNames = ['username', 'password1', 'password2', 'email'];
        this.errorDivs = {};
        this.errorDivs['error.newsletter.required'] = newsletterElId;
        this.fields = {};
        for (var i=0; i<this.fieldNames.length; i++) {
            var fieldName = this.fieldNames[i];
            var field = {
                parent: this,
                fieldName: fieldName,
                getFieldContainer: function() {
                    var formEl = this.parent.form.elements[this.fieldName];
                    if (formEl != null) {
                        for (var parentNode = formEl.parentNode; !parentNode.className.match(/^fieldRow.*/); parentNode = parentNode.parentNode) {}
                        return parentNode;
                    }
                    return null;
                },
                displayError: function() {
                    var fieldContainer = this.getFieldContainer();
                    this.parent.appendToClass(fieldContainer, "fieldError");
                    var label = fieldContainer.getElementsByTagName("label")[0];
                    this.parent.appendToClass(label, "labelError");
                },
                hideError: function() {
                    var fieldContainer = this.getFieldContainer();
                    this.parent.removeFromClass(fieldContainer, "fieldError");
                    var label = fieldContainer.getElementsByTagName("label")[0];
                    this.parent.removeFromClass(label, "labelError");
                }
            }
            this.fields[field.fieldName] = field;
        }
        this.util = new ConciergeUtility();
        this.newsletterContainerId = "newsletterContainer";
    }
    
    RegLightManager.prototype.displayForm = function(returnTo, coords, fixLeft) {
        var regLightEl = document.createElement("div");
        regLightEl.id = "regLight_component";
        regLightEl.className = "regLight";
        regLightEl.innerHTML = getRegLightPopupEl(returnTo);
        document.body.appendChild(regLightEl);
        regLightEl.style.top = (coords.top == null) ? "358px" : coords.top;
        regLightEl.style.left = (coords.left == null || fixLeft) ? this.getPrimaryRailOffsetLeft(5) + "px": coords.left;
        /*
         * changing ID for newsletter field row to avoid conflict with
         * hidden newsletter holder div
         */
        getFirstElementNode(document.getElementById(this.newsletterContainerId)).id = newsletterElId;
    }
    
    RegLightManager.prototype.initForm = function() {
        var form = document.regLightForm;
        var submitButton = document.getElementById("regLight_submit");
        var rlm = this;
        var formHandler = function() {
            rlm.validateForm();
        }
        submitButton.onclick = formHandler;
        enableEnterBtnTextFieldSubmitListener(form, formHandler);

        var usernameHandler = function(e) {
            rlm.validateUsername();
        }
        if (window.addEventListener) {
            form.username.addEventListener("blur", usernameHandler, false);
        } else {
            form.username.attachEvent("onblur", usernameHandler, false);
        } 
        this.form = form;
    }
    
    RegLightManager.prototype.validateForm = function() {
        this.resetErrorDivs();
        this.toggleInProgressSign(true);
        var form = document.regLightForm;
        var params = getFormElementQueryString(form);
        var xhr = this.util.getXHR();
        var rlm = this;
		xhr.onreadystatechange = function( ) {
			if (xhr.readyState == 4 && xhr.status == 200){
				responseObj = eval('('+xhr.responseText+')');
                var length = rlm.handleValidationErrors(responseObj);
                if (length == 0) {
                    document.regLightForm.submit();
                } else {
                    rlm.toggleInProgressSign(false);
                }
			}
		}
        xhr.open("POST", "/ajax/user/registration_light_popup/validate");
        xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        xhr.setRequestHeader("Content-length", params.length);
        xhr.setRequestHeader("Connection", "close");
        xhr.send(params);
    }
    
    RegLightManager.prototype.validateUsername = function() {
        var form = document.regLightForm;
        var rlm = this;
        var val = form.username.value;
        if (!val.match(/^[a-zA-Z0-9_]{3,40}$/)) {
            return;
        }
        
        var usernameErrorDiv = document.getElementById("usernameError");
        usernameErrorDiv.style.display = "none";
        this.fields["username"].hideError();        
        
        var xhr = this.util.getXHR();
        var url = "/ajax/user/registration_light_popup/validate_username?username=" + val;
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4 && xhr.status == 200) {
                var responseObj = eval('(' + xhr.responseText + ')');
                rlm.handleValidationErrors(responseObj, true);
            }
        }
        xhr.open("GET", url);
        xhr.send(null);
    }
    
    RegLightManager.prototype.handleValidationErrors = function(errors) {
        var length = 0;
        for (var i=0; i<errors.values.length; i++) {
            length++;
            var error = errors.values[i];
            var errorDiv = document.getElementById(error.fieldName + 'Error');
            if (errorDiv == null) {
                errorDiv = document.getElementById(error.errorDiv);
                var field = document.getElementById(this.errorDivs[error.errorDiv]);
                if (field) this.appendToClass(field, "fieldError labelError");
            } 
            errorDiv.style.display = "block";
            errorDiv.innerHTML = error.message;            
            if (error.fieldName != null) {
                var field = this.fields[error.fieldName];
                field.displayError();
            }
        }
        return length;
    }
    
    RegLightManager.prototype.resetErrorDivs = function() {
        for (var fieldName in this.fields) {
            var field = this.fields[fieldName];
            errorDiv = document.getElementById(field.fieldName + 'Error');
            errorDiv.style.display = "none";
            field.hideError();
        }
        for (var errorDiv in this.errorDivs) {
            document.getElementById(errorDiv).style.display = "none";
            var field = document.getElementById(this.errorDivs[errorDiv]);
            if (field) this.removeFromClass(field, "fieldError labelError");
        }
    }
    
    RegLightManager.prototype.toggleInProgressSign = function(display) {
        var progressSignDiv = document.getElementById("progress");
        progressSignDiv.style.display = (display) ? "inline" : "none";
    }
    
    RegLightManager.prototype.appendToClass = function(el, className) {
        var matchRegEx = eval("/" + className + "$/");
        if (!el.className.match(matchRegEx)) {
            el.className += " " + className;
        }
    }
    
    RegLightManager.prototype.removeFromClass = function(el, className) {
        var replaceRegEx = eval("/^(.*)\\s" + className + "$/");
        el.className = el.className.replace(replaceRegEx, "$1");
    }
       
    RegLightManager.prototype.getPrimaryRailOffsetLeft = function(offset) {
        var primaryRailEl = document.getElementById("primary_rail");
        var primaryRailLeft = getElementLeft(primaryRailEl);
        return primaryRailLeft + offset;
    }
    
    function closeRegLightForm() {
        var regLightEl = document.getElementById("regLight_component");
        if (regLightEl != null) {
            regLightEl.parentNode.removeChild(regLightEl);
        }
    }    
        
	/*Init*/
	runOnLoad( 
        function( ) {
            SiorManager.siors.push(new SiorManager('signInRequired', true));
        } 
    );    
    
/*	dreamtrip email a friend
	-------------------- */
function addRecipient(recipientName, recipientEmail, selectHidden) {

	var recipientNameObj = document.getElementById(recipientName);
	recipientNameObj.style.display = "block";

	var recipientEmailObj = document.getElementById(recipientEmail);
	recipientEmailObj.style.display = "block";

        document.getElementById("recipeForm").elements[selectHidden].value = "true";
}

function deleteRecipient(recipientName, recipientEmail, selectName, selectEmail, selectHidden) {

	var recipientNameObj = document.getElementById(recipientName);	
	recipientNameObj.style.display = "none";
	document.getElementById("recipeForm").elements[selectName].value= "";	

	var recipientEmailObj = document.getElementById(recipientEmail);	
	recipientEmailObj.style.display = "none";
	document.getElementById("recipeForm").elements[selectEmail].value= "";	

        document.getElementById("recipeForm").elements[selectHidden].value = "";
}


/*************************************************************************/
/************ Functions from concierge2 to be moved elsewhere later ******/
/*************************************************************************/

//Utility functions in use by weatherDestinations.jsp and goldlist.js
function browserConf( ) {
    if (this.loaded) {} else {
        var str = navigator.appVersion;
        this.macIE = str.match(/msie(.*)mac/i) != null;
        this.loaded = true;
    }
    return this;
}

function setText(option, text) {
        if (browserConf( ).macIE) {
                option.text = option.value = text;
        } else {
                option.innerHTML = text;
        }
}	

// Error message function 
function showMessage(msg, obj) {
    obj.innerHTML = msg;
}

/************ End functions from concierge2 ******/
var conciergeVideoWin=0;
function openVideoWindow(URLStr, title)
{
  if ( URLStr.indexOf('http') == -1)
  {
    location.href=URLStr;
    return;
  }

  if(conciergeVideoWin)
  {
    if(!conciergeVideoWin.closed) conciergeVideoWin.close( );
  }
  conciergeVideoWin = open(URLStr, title, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=1050,height=720');
}


 /* Parses URL Pathname
	Author: Jamie L. Marin, Senior Web Developer
	Date: June !5, 2005
*/

/* Sets varibles for URI pathname and pathname length */
var browserURI = location.pathname;
var uriLength = browserURI.length;

/* Creates Array */
var directories = new Array( );

/* Find out indexes of first, next, and last slashes */
var startSlash = browserURI.indexOf('/');
var nextSlash =  browserURI.indexOf('/', startSlash + 1);
var lastSlash = browserURI.lastIndexOf('/');
var slashCount = 0;

/* test for one deep section */ 
if (startSlash == lastSlash)
{
	directories[slashCount] = location.pathname.slice(startSlash + 1);
}


/* Loop to define sections from 1 to N */
while (startSlash != lastSlash || nextSlash != -1)
{
	directories[slashCount] = location.pathname.substring(startSlash + 1,nextSlash);	
	
	if (lastSlash + 1 != uriLength)
		directories[slashCount +1] = browserURI.slice(nextSlash + 1);
		
	startSlash = nextSlash;
	nextSlash =  browserURI.indexOf('/', startSlash + 1);		
	slashCount++;	
}

var paths = new Array( );

function parsePath(path) {
    var pathLength = path.length;    
    
    var sSlash = path.indexOf('/');
    var nSlash =  path.indexOf('/', sSlash + 1);
    var lSlash = path.lastIndexOf('/');
    var sCount = 0;
    
    if (sSlash == lSlash)
    {
    	paths[sCount] = path.slice(sSlash + 1);
    }    
    
    /* Loop to define sections from 1 to N */
    while (sSlash != lSlash || nSlash != -1)
    {
    	paths[sCount] = path.substring(sSlash + 1,nSlash);	
    	
    	if (lSlash + 1 != pathLength)
    		paths[sCount +1] = path.slice(nSlash + 1);
    		
    	sSlash = nSlash;
    	nSlash =  path.indexOf('/', sSlash + 1);		
    	sCount++;	
    }    

}

/* Set User Friendly Variables */
var firstDir = directories[0];
var lastDir = directories[directories.length-1];

/* set Omni-friendly path */
var omniHierarchy = "";
for (var i=0; i<directories.length; i++) {
    omniHierarchy += directories[i];
    if (i != directories.length - 1)
        omniHierarchy += ",";
}
var thisDomain = document.domain;
var setProp6 = "";
var setProp7 = "";
var setProp8 = "";
var setProp9 = "";
var videoIndex = thisDomain.indexOf('video');
var feedroomIndex = thisDomain.indexOf('feedroom');

if (directories[0] == "") {
    setProp6 = "homepage";
    omniHierarchy = "homepage";
    }
if (videoIndex != -1 || feedroomIndex != -1) {
    setProp6 = "video";
    omniHierarchy = "video";
    }    
if (directories.length >= 1 && directories[0] != "")
    setProp6 = directories[0];
if (directories.length >= 2)
    setProp7 = setProp6 + '/' + directories[1];
if (directories.length >= 3)
    setProp8 = setProp7 + '/' + directories[2];    
if (directories.length >= 4)
    setProp9 = setProp8 + '/' + directories[3];    
    
    
function setProps() {
    setProp6 = "";
    setProp7 = "";
    setProp8 = "";
    setProp9 = "";
    if (paths.length >= 1 && paths[0] != "")
    setProp6 = paths[0];
    if (paths.length >= 2)
        setProp7 = setProp6 + '/' + paths[1];
    if (paths.length >= 3)
        setProp8 = setProp7 + '/' + paths[2];    
    if (paths.length >= 4)
        setProp9 = setProp8 + '/' + paths[3];
}

/* PopUpWindow */


var popUpWin;
function openWindow(URLStr, type)
{
  var width = 250;
  var height = 250;
  var scroll = "no";
  var resize ="no";
  if (popUpWin != null && popUpWin.open) popUpWin.close();
  
  if (type == 'articleSlideshow') {
  width = 776;
  height = 800;
  }
  if (type == 'truth') {
  width = 565;
  height = 400;
  resize = "yes";
  }    
  if (type == 'wordtrips') {
  width = 612;
  height = 774;
  scroll = "yes";
  }  
  if (type == 'instructions') {
  width = 660;
  height = 600;
  scroll = "yes";
  }    
  if (type == 'uber') {
  width = 1024;
  height = 768;
  resize = "yes";
  }      
  
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars='+scroll+',resizable='+resize+',copyhistory=yes,width='+width+',height='+height);
}

function popWindow(address,name,scroll,resize,width,height) { 
       var detWindow="" 
        detWindow=window.open(address,name,'toolbar=no,location=0,directories=no,status=no,menubar=0,scrollbars=' + scroll + ',resizable=' + resize +',width=' + width + ',height=' +height);
}

var qsParm = new Array( );

var query = window.location.search.substring(1);
var parms = query.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);
        qsParm[key] = val;
    }
}


function returnToPage( ) {
    var gotoUrl = '/';
    var returnTo = qsParm['returnto'];
    if (returnTo != '') {
        gotoUrl = returnTo;
    }
    window.location = unescape(gotoUrl);
}

	function showbubble(elmnt) //onmouseover
	{
		document.getElementById(elmnt).style.display="inline"
	}
	function hidebubble(elmnt) //onmouseout
	{
		document.getElementById(elmnt).style.display="none"
	}

/*Ad Refresh*/
bw = new checkBrowser();

function checkBrowser(){
	this.ver=navigator.appVersion;
	this.dom= (document.getElementById)? 1 : 0;
	this.ie5=((this.ver.indexOf("MSIE 5") >= 0) && this.dom)? 1 : 0;
	this.ie4=(document.all && !this.dom)? 1 : 0;
    this.ns6=(this.dom && parseInt(this.ver) >= 6)? 1 : 0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5)? 1 : 0;
	this.ns4=(document.layers && !this.dom)? 1 : 0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5);
	
	this.editBody = function(rootName, code) {
		if (this.dom) {
			document.getElementById(rootName).innerHTML = code;
		} else if (this.ie4) {
			document.all[rootName].innerHTML = code;
		} else if (this.ns4) {
			document.layers[rootName].document.open();
			document.layers[rootName].document.write(code);
			document.layers[rootName].document.close();
		} 
	}
	this.getRef = function(rootName) {
		if (this.dom) {
			return  document.getElementById(rootName)
		} else if (this.ie4) {
			return document.all[rootName]
		} else if (this.ns4) {
			return document.layers[rootName];
		} 
	}
	
}

function writeText(txt)
{
document.getElementById("desc").innerHTML=txt
}

function styleFlash_DoFSCommand(command, args) {
	var tileNum = parseInt(args), div, script;

	if (command == "updateAd") {
		bw.editBody("dartLayer" + tileNum, args.substr(args.indexOf("|") + 1));
		
	}
}
/* End Ad refresh */
var defaultConciergeVideoUrl="http://video.concierge.com";
var defaultConciergeVideoUrlVersionA="http://video.concierge.com/?utm_source=concierge%26utm_medium=link%26utm_term=video_journey%26utm_content=versionA%26utm_campaign=ofmt";
var defaultConciergeVideoUrlVersionB="http://video.concierge.com/?utm_source=concierge%26utm_medium=link%26utm_term=video_journey%26utm_content=versionB%26utm_campaign=ofmt";
var conciergeVideoWin=0;
function openVideoWindow(URLStr, title)
{
  if ( URLStr.indexOf('http') == -1)
  {
    location.href=URLStr;
    return;
  }

  if(conciergeVideoWin)
  {
    if(!conciergeVideoWin.closed) conciergeVideoWin.close();
  }
  conciergeVideoWin = open(URLStr, title, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=1050,height=720');
}

function openVideoWindowFromSlideShow(URLStr, title)
{
  /* Close the slideShow window first */
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  openVideoWindow(URLStr, title); 
}

function cancelEmail(){ 
    history.back(1);
} 

var firstDir = "suitcase";

/* Dart Targeting Code 
\/cntraveler/contests/livethecover2
\/cntraveler/contests/dreamtrip2007
\/cntraveler/contests/livethecover1

if (typeof uriPrefixForStats == 'undefined'){
		uriPrefixForStats = '\/suitcase';
	}
if (dartIndex != -1) {
    cDSite = 'con.dart/cnt_contests;';
    cDKw = 'kw=cntraveler;kw=contests;';
    var contest = uriPrefixForStats.slice(uriPrefixForStats.lastIndexOf('/') + 1)
    cDKw = cDKw + 'kw=' + contest
}

*/    

var bURI = location.pathname;
var bQuery = location.search;
var cDSite = 'con.dart/cnt_contests;';
var cDKw = 'kw=suitcase;';
var dreamIndex = bURI.indexOf('dream-trip');
var ltc3Index = bURI.indexOf('groups/live-the-cover-thailand');
var ltc2Index = bURI.indexOf('groups/live-the-cover');
var ltc1Index = bURI.indexOf('groups/conde-nast-traveler-live-the-cover-contest');
var galleryIndex = bURI.indexOf('gp/gallery');
var gallery2Index = bURI.indexOf('cntraveler/contests');

if (typeof kabListId == "undefined"){ cDKw = cDKw;  } else { cDKw = cDKw + 'kw=' + kabListId + ';'; }

if (dreamIndex != -1) {
    cDSite = 'con.dart/cnt_contests;';
    cDKw = 'kw=cntraveler;kw=contests;';
    cDKw = cDKw + 'kw=dreamtrip2007;';
}

if (ltc3Index != -1) {
    cDSite = 'con.dart/cnt_contests;';
    cDKw = 'kw=cntraveler;kw=contests;';
    cDKw = cDKw + 'kw=livethecover3;';
}

if (ltc2Index != -1 && ltc3Index == -1) {
    cDSite = 'con.dart/cnt_contests;';
    cDKw = 'kw=cntraveler;kw=contests;';
    cDKw = cDKw + 'kw=livethecover2;';
}

if (ltc1Index != -1) {
    cDSite = 'con.dart/cnt_contests;';
    cDKw = 'kw=cntraveler;kw=contests;';
    cDKw = cDKw + 'kw=livethecover1;';
}

if (galleryIndex != -1) {

    if ((bQuery.indexOf('AAAAARTkkrMAAAAAABBpqA')) != -1) {
        cDSite = 'con.dart/cnt_contests;';
        cDKw = 'kw=cntraveler;kw=contests;';
        cDKw = cDKw + 'kw=dreamtrip2007;';
    }
    
    if ((bQuery.indexOf('AAAABB4pOWEAAAAAACtAeA')) != -1) {
        cDSite = 'con.dart/cnt_contests;';
        cDKw = 'kw=cntraveler;kw=contests;';
        cDKw = cDKw + 'kw=livethecover3;';
    }    
    
    if ((bQuery.indexOf('AAAAA8-oDxsAAAAAACNKmg')) != -1) {
        cDSite = 'con.dart/cnt_contests;';
        cDKw = 'kw=cntraveler;kw=contests;';
        cDKw = cDKw + 'kw=livethecover2;';
    }    
    
    if ((bQuery.indexOf('AAAABB4pOWEAAAAAABbV0A')) != -1) {
        cDSite = 'con.dart/cnt_contests;';
        cDKw = 'kw=cntraveler;kw=contests;';
        cDKw = cDKw + 'kw=livethecover1;';
    }       
    
}

if (gallery2Index != -1) {
    cDSite = 'con.dart/cnt_contests;';
    cDKw = 'kw=cntraveler;kw=contests;';
}


/**** Microsoft Audience Extension ****/

function writeMicrosoftAudienceTag() {
    MSEXT_domain = document.location.host.split('.');
    MSEXT_domain = MSEXT_domain[(MSEXT_domain.length - 2)];
    MSEXT_path = document.location.pathname.split('/');
    MSEXT_request = document.location.protocol + "//view.atdmt.com/action/MSFT_CondeNet_AE_ExtData/v3/atc1." + MSEXT_domain;
    MSEXT_request += (MSEXT_path[1] != '') && (MSEXT_path[1] != undefined) ? "/atc2." + MSEXT_path[1] : '';
    MSEXT_request += (MSEXT_path[2] != '') && (MSEXT_path[2] != undefined) ? "/atc3." + MSEXT_path[2] : '';
    MSEXT_request += '/';
    var body = document.getElementsByTagName("body");
    if(body.length > 0) {
	    var newElem = document.createElement("img");
	    newElem.src = MSEXT_request;
	    newElem.height = "1";
	    newElem.width = "1";
	    body[0].appendChild(newElem);
    }
}
runOnLoad(writeMicrosoftAudienceTag);