function stopOthers(id){
	LV2009Rebrand.stopOtherCTAGatewebPlayers(id);
}
function mediaplexTracking(){
	var page_url = escape(document.URL);
	var ref_url = escape(document.referrer);
	var mpt = new Date();
	var mpts = mpt.getTimezoneOffset() + mpt.getTime();

	if (window.location.protocol == "https:"){
		document.write("<iframe src=\"https:\/\/secure.img-cdn.mediaplex.com\/0\/14242\/universal.html?page_name=content&amp;mpt=" + mpts + "&amp;url=" + page_url + "&amp;ref=" + ref_url + "\" HEIGHT=0 WIDTH=0 FRAMEBORDER=0 style=\"display:none\"><\/iframe>");
	} else {
		document.write("<iframe src=\"http:\/\/img-cdn.mediaplex.com\/0\/14242\/universal.html?page_name=content&amp;mpt=" + mpts + "&amp;url=" + page_url + "&amp;ref=" + ref_url + "\" HEIGHT=0 WIDTH=0 FRAMEBORDER=0 style=\"display:none\"><\/iframe>");
	}
}

function kenshoo_conv(id,type,value,orderId,promoCode,valueCurrency) {
	promoCode = "lv50plus";
	var url = "https://www.xg4ken.com/media/redir.php?track=1&id=" + id + "&type=" + type + "&val=" + value + "&orderId=" + orderId + "&valueCurrency=" + valueCurrency + "&promoCode=" + promoCode + "&ref=" + document.referrer;
	var a = new Image(1,1);
	a.src = url;
	a.onload = function() { _uVoid(); }
}

function _uVoid(){
	return
}

var LV2009Rebrand={
	ExploreLVDropDownVisible:false,
	ExploreLVDropDownDefaultText:"Explore LV.com",
	LoadDynamicStylesheets: function() {
		$("head").append('<link rel="stylesheet" type="text/css" href="/wcm/site/css/lv-rebrand-2009/scripted-elements.css"></link>');
	},
	
	
	// WEZ: START OF REVISIONS
	fixQuoteUrl: function(url){
		url = url.replace(/&amp;/g, '&');
		url = escape(url);
		//alert(url);
		
		return(url);
	},
	gatewebMainCTAID:null,
    gatewebPlayers: new Array(),
    registerGatewebPlayer: function (a) {

		// WEZ: Sanity check to make sure the id isn't already in the array
		for (var i = 0; i < LV2009Rebrand.gatewebPlayers.length; i++) if (LV2009Rebrand.gatewebPlayers[i] == a) return;
        LV2009Rebrand.gatewebPlayers.push(a);
		//alert(LV2009Rebrand.gatewebPlayers.length);
		
    },
    stopOtherGatewebPlayers: function (a, b) {
		// WEZ: Stop main if playing
		if (b == "true"){
			$('#' + LV2009Rebrand.gatewebMainCTAID).externalInterface({ method:'stopVideo'});
		}		
		
        for (var b = 0; b < LV2009Rebrand.gatewebPlayers.length; b++) {
            var c = LV2009Rebrand.gatewebPlayers[b];
										
            if (c != a) {
				//alert('stop ' + c);
                $("#"+c).externalInterface({method: "stopVideo"});
                if (b == null) $("#" + c).height(44);
               
            } else {

                 if (b == null) $("#" + c).height(210)
            }
        }
    },
    addExpanderGateweb: function (divID, video, width, height) {
		var div = $("#" + divID);
		if (div) {
			var expander = div.parents(".expander");
			if (expander) {
				$('#' + expander.attr('id') + ' ul').css('display', 'inline-block');
				$('#' + expander.attr('id') + ' ol').css('display', 'inline-block');

				var expanderHeader = expander.children(".expanderHeader");
				if (expanderHeader) {
					// WEZ: Removed -player and made sure you can only
					// Steve: don't see how we can remove '-player' as that would then give us a div & embed element with the same id 
					// register each player once.
					LV2009Rebrand.registerGatewebPlayer(divID + '-player');
					
					expanderHeader.click(function () {
						// WEZ: Sanity check to make sure it doesn't get called when it's contracting.
						// If it does get called then everything stops but itself (and it's already hidden).
						if(expander.height() > 22) {
							/*
							var flashvars = {video:video};
							var params = {wmode: "transparent"};
							var attributes = { name: divID };
							swfobject.embedSWF('/upload/Gateweb/extra-options-small.swf', divID, width, height, "9.0.0","expressInstall.swf", flashvars, params, attributes);
							*/
							
							// i had to revert to older SWFObject code as we currently use v1.5.. also had to change background to white & make video opaque to hide heart bullets that appeared behind the flash..
							var so = new SWFObject('/upload/Gateweb/extra-options-small.swf', divID + '-player', width, height, '9.00', '#ffffff');
							so.addParam('wmode', 'opaque');
							so.addVariable('video', video);
							so.write(divID);
							
							// WEZ: Did the element #main-flash exist anywhere on your current site? It didn't, which is why this failed.	
							//$('#main-flash').externalInterface({ method:'stopVideo'});
							LV2009Rebrand.stopOtherGatewebPlayers(divID + '-player');
							
							// WEZ: I'm unsure why $.html() is causing us an issue with the ExternalInterface calls to be honest,
							// but SWFObject is tried and tested. I've updated the code to the latest 2.2
							//h.html('<object id="' + c + '" name="' + c + '" width="' + d + '" height="' + a + '"><param name="FlashVars" value="video=' + e + '"></param><param name="movie" value="/upload/Gateweb/extra-options-small.swf"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="/upload/Gateweb/extra-options-small.swf" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" FlashVars="video=' + e + '" width="' + d + '" height="' + a + '"></embed></object>')
						}	
					})
				}
			}
		}
    },

	// WEZ: END OF REVISIONS
	hasFlash: function(){
		return(deconcept.SWFObjectUtil.getPlayerVersion().major > 0);
	},
	gatewebLandingPageCTACount: 0,
	AddLandingPageCTAGateweb: function(overlayId, videoUrl, linkUrl) {
		LV2009Rebrand.gatewebLandingPageCTACount++;
	
		var flashID = '0' + LV2009Rebrand.gatewebLandingPageCTACount + '-vidget';
		var so = new SWFObject('/upload/Gateweb/01-vidget.swf', flashID, '337', '200', '9.00', '#336699');
		so.addParam('wmode', 'transparent');
		so.addVariable('vidURL', videoUrl);
		so.write(overlayId);
	
		LV2009Rebrand.registerGatewebPlayer(flashID);
		
		// we need to find the heading... eeek..
		//landingBlock50 
		var overlay = $('#' + overlayId);
		var container = overlay.parents('div.landingBlock50');
		var h2 = container.find('h2');
		var h2Anchor = container.find('h2 a');
		//alert(h2.text());
		
		
		var titleOverlay = $('<div/>').appendTo(overlay);
		
		titleOverlay.css('background-color', 'red');
		titleOverlay.css(
			{
				position:'relative',
				width:h2Anchor.width(),
				height:30,
				top:-200,
				left:0,
				cursor:'pointer',
				opacity:0
			}
		);
		titleOverlay.click(
			function(){
				window.location.href = linkUrl;
				//alert('clicked ' + linkUrl);
			}
		);
		titleOverlay.mouseover(
			function(){
				h2Anchor.css('text-decoration', 'underline');
			}
		);
		titleOverlay.mouseout(
			function(){
				h2Anchor.css('text-decoration', 'none');
			}
		);
	
		//var flashvars = {vidURL:videoUrl};
		//var attributes = { name: flashID };
		//swfobject.embedSWF('/upload/Gateweb/01-vidget.swf', '04-vidget', '337', '210', "9.0.0","expressInstall.swf", flashvars, params, attributes);
	},
    stopOtherCTAGatewebPlayers: function (a) {
		for (var b = 0; b < LV2009Rebrand.gatewebPlayers.length; b++) {
            var c = LV2009Rebrand.gatewebPlayers[b];
			if(c != a){
				$("#"+c).externalInterface({method: "stopVideo"});
			}
        }
    },

	GlossaryListingInit: function() {
		$('#glossaryFilter input.button').hide();
		// force IE6 to redraw the container
		// otherwise the corner graphics are positioned incorrectly
		var isIE6 = ($.browser.msie && $.browser.version.substr(0,1) < 7);
		if(isIE6) {
			$('#contentArea').css('display', 'block');
		}
	},
	ShowGlossaryDefinition: function(term, pageCategoryId){
		$.ajax({
			url: '/processors/Glossary/GetDefinition?term=' + encodeURIComponent(term) + '&pageCategoryId=' + pageCategoryId,
			dataType: 'html',
			cache: false,
			success: function(data) {
				var body = $("body");

				// dim the background
				var background = $('<div class="glossaryBackground"></div>');
				background.css(
					{
						"opacity": 0.5,
						"width": body.width(),
						"height": body.height(),
						"z-index": 10000
					}
				);
				body.append(background);

				// display the popup
				var definition = $(data);
				body.append(definition);	

				// centre it
				definition.css(
					{
						"top": (($(window).height() - definition.outerHeight()) / 2 + $(window).scrollTop()) + 'px',
						"left": (($(window).width() - definition.outerWidth()) / 2 + $(window).scrollLeft()) + 'px'
					}
				);

				// on background click, remove the popup
				background.bind('click',
					function(){
						LV2009Rebrand.CloseGlossaryDefinition(background, definition);
					}
				);

				// on clicking close links, remove the popup
				$('.glossaryPopup a.glossaryClose').bind('click',
					function(){
						LV2009Rebrand.CloseGlossaryDefinition(background, definition);
						return false;
					}
				);

				// on escape key, remove the popup
				$(document).keydown(
					function(event) {
						if(event.keyCode == 27) {
							LV2009Rebrand.CloseGlossaryDefinition(background, definition);
						}
					}
				);
			}
		});
	},
	CloseGlossaryDefinition: function(background, definition) {
		background.remove();
		definition.remove();
		$(document).unbind('keydown');
	},
	GlossaryHighlightToggle: function(pageCategoryId) {
		if($('.glossaryOn').length > 0) {
			// glossary is on, so turn it off
			LV2009Rebrand.GlossaryUnhighlight();
		} else if($('#mainContent:has(.glossaryHighlightHidden)').length > 0) {
			// glossary has previously been turned on, re-enable it
			LV2009Rebrand.GlossaryRehighlight(pageCategoryId);
		} else {
			// turn glossary on for the first time
			LV2009Rebrand.GlossaryHighlight(pageCategoryId);
		}
	},
	GlossaryHighlight: function(pageCategoryId) {
		// hide the checkbox label and show a loading message
		$('.glossaryOff a').hide();
		$('.glossaryLoading').show();

		// load all the glossary terms
		$.ajax({
			url: '/processors/Glossary/GetAllTerms' + '?categoryId=' + pageCategoryId,
			dataType: 'json',
			cache: false,
			success: function(data) {
				// highlight each term
				$(data.glossaryTerms).each(
					function(index, termData) {
						$('#mainContent').highlight(termData.term);	
						// add 'glossaryHighlight' class to the first occurrence
						$('.highlight:eq(0)').addClass('glossaryHighlight').attr('title', 'Click for definition');
						// remove the highlight class from everything
						$('.highlight').removeClass('highlight');
					}
				);

				// attach click handlers to highlighted terms
				$('.glossaryHighlight').each(
					function(index, span) {
						span = $(span);
						var term = span.text();
						span.bind("click", 
							function(){
								LV2009Rebrand.ShowGlossaryDefinition(term, pageCategoryId);
								return false;
							}
						);
					}
				);

				// Hide the loading message and show the label again
				$('.glossaryLoading').hide();
				$('.glossaryToggle a').show();
			}
		});

		// turn the checkbox on
		$('.glossaryOff').removeClass('glossaryOff').addClass('glossaryOn');
	},
	GlossaryRehighlight: function(pageCategoryId) {
		// highlight the terms again
		$('.glossaryHighlightHidden').removeClass('glossaryHighlightHidden').addClass('glossaryHighlight');

		// attach click handlers to highlighted terms
		$('.glossaryHighlight').each(
			function(index, span) {
				span = $(span);
				var term = span.text();
				span.bind("click", 
					function(){
						LV2009Rebrand.ShowGlossaryDefinition(term, pageCategoryId);
						return false;
					}
				);
			}
		);

		// turn the checkbox on
		$('.glossaryOff').removeClass('glossaryOff').addClass('glossaryOn');
	},
	GlossaryUnhighlight: function() {
		// change the class on highlighted terms and remove the click events
		$('.glossaryHighlight').removeClass('glossaryHighlight').addClass('glossaryHighlightHidden').unbind('click');
		// turn the checkbox off
		$('.glossaryOn').removeClass('glossaryOn').addClass('glossaryOff');
	},
	GlossaryExpandToggle: function(liId) {
		var li = $('#' + liId);
		if(li.hasClass('expanded')) {
			// collapse
			$('#' + liId + " .glossaryDefinition").hide('fast');
			li.removeClass('expanded');
		} else {
			// expand
			$('#' + liId + " .glossaryDefinition").show('fast');
			li.addClass('expanded');
		}
	},
	GlossaryShowSection: function(section) {
		// store the section value in the hidden input
		$("#glossaryFilter input[name='section']").val(section);

		// update the view
		if(section == 'abc' || section == 'def' || section == 'ghi' || section == 'jkl'
			|| section == 'mno' || section == 'pqr' || section == 'stu' || section == 'vwxyz') {
			$('#glossarySectionHeading').text(section.toUpperCase());
			$('#glossaryList li:not(.' + section + ')').hide();
			$('.' + section).show();
		} else {
			$('#glossarySectionHeading').text('Full A-Z');
			$('#glossaryList li').show();
		}
	},
	GlossaryDynamicFilter: function(categoryId) {
		// build comma-separated list of categories
		var categories = '';
		$('#glossaryFilter input:checked').each(
			function() {
				if(categories != '') {
					categories += ',';
				}
				categories += $(this).val();
			}
		);

		// reload the glossary list
		$.ajax({
			url: '/processors/Glossary/DynamicFilterList?categories=' + categories,
			dataType: 'html',
			cache: false,
			success: function(data) {
				$('#glossaryList').replaceWith(data);
				// reapply section filter
				var section = $("#glossaryFilter input[name='section']").val();
				LV2009Rebrand.GlossaryShowSection(section);
			}
		});
	},
	SetupMainMenuHovers:function(){
		var isIE6 = ($.browser.msie && $.browser.version.substr(0,1) < 7);
		$('#primaryNav > ol > li').each(
			function(index, item){
				var tabLi = $(item);
				var menuPopup = tabLi.children('ol');
				tabLi.mouseenter(
					function() {
						if(isIE6) {
							menuPopup.show();
						}
						tabLi.addClass('hover');
					}
				);
				tabLi.mouseleave(
					function() {
						if(isIE6) {
							menuPopup.hide();
						}
						tabLi.removeClass('hover');
					}
				);
				if(isIE6) {
					menuPopup.css('width', Math.min(tabLi.width() * 1.5, 220));
				} else {
					menuPopup.css('min-width', tabLi.width());
				}
			}
		);
	},
	IE6ResizeKick:function(){
		//alert('ie resize kick');
		var isIE6 = ($.browser.msie && $.browser.version.substr(0,1)<7);
		if (isIE6){
			$("div").each(
				function(index, item){
					var htmlElement = $(item);
					htmlElement.css("height", htmlElement.css("height"));
				}
			);
		}
	}, 
	Continuity:function(){
		$("body").append("<link media=\"screen\" rel=\"stylesheet\" type=\"text/css\" href=\"/wcm/system/css/pageeditor_standalone.css\"/>");
		$.getScript("/wcm/system/csi/admin/dialogs.js", function(){
			$.getScript("/wcm/system/csi/admin/forms.js", function(){
				$.getScript("/wcm/system/csi/admin/continuity.js", function(){
					ContinuityStandalone.EditPage();
				});
			});
		});
		/*
		var e = document.createElement("script");
		e.src = "/wcm/system/csi/admin/continuity.js";
		e.type = "text/javascript";
		document.getElementsByTagName("head")[0].appendChild(e);
		
		timer = setTimeout(function(){if(ContinuityStandalone){ContinuityStandalone.EditPage();clearTimeout(timer);}}, 1000);
		*/
	},
	PageLoad:function(height){
		// call back to server to get size required for iframe
		LV2009Rebrand.SetupExploreLVDropDown();
		LV2009Rebrand.SetupMainMenuHovers();
		LV2009Rebrand.GlossaryListingInit();
		LV2009Rebrand.IE6ResizeKick();
		LV2009Rebrand.SetupExpanders();
		
		// hide address element in firefox..
		if($.browser.mozilla){
			$('#mkt-footer-address').css({'margin-left':'16px', 'margin-top':'6px', 'font-size':'10px', 'text-transform':'uppercase'});
			$('address').css('display', 'none');
		}
	},
	SetupExploreLVDropDown:function(){
		var select = $("#exploreLV");
		
		if(select){
			// get current options..
			//LV2009Rebrand.ToggleExploreLVDropDown()
			//var newHtml = "<div id=\"exploreLVJS\"><div>Explore LV.com</div><ol>";			
			var newHtml = "<div id=\"exploreLVJS\"><div onclick=\"LV2009Rebrand.ToggleExploreLVDropDown();return(false);\">" + LV2009Rebrand.ExploreLVDropDownDefaultText + "</div><ol>";			
			//var newHtml = "<div id=\"exploreLVJS\"><div onclick=\"alert('click');return(false);\">Explore LV.com</div><ol>";			
			select.children().each(
				function(){
					var option = $(this);
					var href = option.val();
					var text = option.text();
					var onclick = "" + option.attr('onclick');
					var id = option.attr('id');
					onclick=onclick.replace(/\"/g,'\'');
					var newonlick = onclick.substring(onclick.indexOf("{")+1,onclick.indexOf("}"));
					
					if(href){
						// removed hopefull fix for site overlay tracking.. adding -dynamic to the id of the dynamically generated menu items..
						// as they didn't want it deployed..
						//newHtml += "<li><a id=\"" + id + "-dynamic\" href=\"" + href + "\" onclick=\"" + newonlick + "\">" + text + "</a></li>";
						newHtml += "<li><a id=\"" + id + "\" href=\"" + href + "\" onclick=\"" + newonlick + "\">" + text + "</a></li>";
					}
				}
			);
			newHtml += "</ol></div>";
			
			var form = $("#exploreLVForm");
			form.replaceWith(newHtml);
			
			
			//alert(newHtml);
			//form.replaceWith("<p>here</p>");
			/*
			
			var dropDown = $("#exploreLVJS ol");
			if(dropDown){
				dropDown.css("z-index", 100000);
				dropDown.mouseout( 
					function(){
						//LV2009Rebrand.HideExploreLVDropDown();
					}
				);
			}
			*/
		}
	},
	ToggleExploreLVDropDown:function(){
		var dropDown = $("#exploreLVJS ol");
		
		if(dropDown){
			if(LV2009Rebrand.ExploreLVDropDownVisible){
				LV2009Rebrand.HideExploreLVDropDown();
			} else {
				LV2009Rebrand.ShowExploreLVDropDown();
			}
		}
	},
	ShowExploreLVDropDown:function(){
		var dropDown = $("#exploreLVJS ol");

		if(dropDown){
			LV2009Rebrand.ExploreLVDropDownVisible = true;
			dropDown.fadeIn("fast");
		}		
	},
	HideExploreLVDropDown:function(){
		var dropDown = $("#exploreLVJS ol");

		if(dropDown){
			LV2009Rebrand.ExploreLVDropDownVisible = false;
			dropDown.fadeOut("fast");
		}		
	},
	
	SetupExpanders:function(){
		var isIE7 = ($.browser.msie && $.browser.version.substr(0,1)==7);
		//var isIE7 = true;
		
		if(isIE7){
			//alert('setup expanders for IE7');
			$.each($('.expander'),
				function(index, expanderDiv){
					expanderDiv = $(expanderDiv);
					var id = expanderDiv.attr('id').substring(8);
					//alert('init expander ' + id);
					var expanderHeader = expanderDiv.find('.expanderHeader');
					
					// lets try putting an invisibe div over the top
					//alert(expanderHeader.width() + ' x ' + expanderHeader.height());
					//expanderHeader.append('here');
					expanderHeader.css('position', 'relative');
					var hiddenDiv = $('<div/>').appendTo(expanderHeader);
					hiddenDiv.css(
						{
							'position':'absolute',
							'top':0,
							'left':0,
							'width': expanderHeader.width(),
							'height': expanderHeader.height()						
						}
					);
					
					// setting a click handler didn't work
					/*
					expanderHeader.click(
						function(){
							alert('here');
							LV2009Rebrand.ToggleExpander(id);
						}
					);
					*/
					// replacing it with the same content with an anchor round didn't work..
					/*
					expanderHeader.replaceWith('<a id="expander-a-' + id + '"><div style="display:block" class="expanderHeader headerClosed">' + expanderHeader.html() + '</div></a>');
					var expanderA = $('#expander-a-' + id);
					expanderA.css('border', 'solid 1px red');
					expanderA.click(
						function(){
							alert('in click');
							LV2009Rebrand.ToggleExpander('expander' + id);
						}
					);
					*/
					// well puttin an anchor round itr didnt work
					/*
					var dummyA = $('<a href="http://www.google.com"/>');
					dummyA.click(
						function(){
							alert('clicked dummy a');
						}
					);
					dummyA.wrap(expanderHeader);
					*/
				}
			);
		}
	},
	
	ToggleExpander:function(expanderID){
		var isIE6 = ($.browser.msie && $.browser.version.substr(0,1)<7);
		var expanderHeader = $("#" + expanderID + " > div.expanderHeader");
		var expanderContent = $("#" + expanderID + " > div.expanderContent");
		// if ie 6 we need to shove the rounded corners down a bit.. grrrr...
		var mainContent = $("#mainContent");
		var bottomDiv = $("#mainContentBottom");
		var bottomDivPosition = bottomDiv.offset({scroll:true});
		var bottomDivTop = bottomDivPosition.top;

		if(expanderContent.css("display") == "none"){
			expanderContent.css("display", "block");
			expanderHeader.removeClass("headerClosed");
			expanderHeader.addClass("headerOpen");
			
			// move bottomDiv down
			if(isIE6){
				//bottomDiv.css("top", bottomDivTop + expanderContent.outerHeight());
				//mainContent.css("height", mainContent.outerHeight() + expanderContent.outerHeight() + 1);
				mainContent.css("height", mainContent.outerHeight() + 1);
			}
		} else {
			var expanderContentHeight = expanderContent.outerHeight();
			expanderContent.css("display", "none");
			expanderHeader.removeClass("headerOpen");
			expanderHeader.addClass("headerClosed");
			
			// move bottomDiv up
			if(isIE6){
				//bottomDiv.css("top", bottomDivTop - expanderContent.outerHeight());
				mainContent.css("height", mainContent.outerHeight() - 1 - expanderContentHeight);
			}
		}
	},
	ShowMboxControls:function(){
		//alert("show mbox controls");
	},
	HighlightUnTaggedLinks:function(){
		$("a").each(
			function(index, item){
				var a = $(item);	
				LV2009Rebrand.AddLinkHighlighter(a);		
			}
		);
		//alert("highlight untagged links");
	},
	UnknownIDHighlighterID:0,
	CurrentHighlighterTooltip:"",
	AddToHighlighterTooltip:function(content){
		LV2009Rebrand.CurrentHighlighterTooltip += "<p>" + content + "</p>";
	},
	AddErrorToHighlighterTooltip:function(content){
		LV2009Rebrand.CurrentHighlighterTooltip += "<p class=\"error\">" + content + "</p>";
	},    
	AddWarningToHighlighterTooltip:function(content){
		LV2009Rebrand.CurrentHighlighterTooltip += "<p class=\"warning\">" + content + " - check</p>";
	},
	AddLinkHighlighter:function(anchor){
		var body = $("body");	
		var anchorID = anchor.attr("id");
		var highlighterID = anchorID + "-highlighter";
		var color = "yellow";
		var anchorHref = anchor.attr("href").toLowerCase();
		
		LV2009Rebrand.CurrentHighlighterTooltip = "";
		LV2009Rebrand.AddToHighlighterTooltip(anchorHref);
		
		if(highlighterID == "-highlighter"){
			highlighterID = LV2009Rebrand.UnknownIDHighlighterID + "-highlighter";
			LV2009Rebrand.UnknownIDHighlighterID++;
			color = "red";
			LV2009Rebrand.AddErrorToHighlighterTooltip("No id defined");
		}		
		var anchorOnClick = String(anchor.attr("onclick"));
		
		
		if(anchorOnClick == "undefined"){
			color = "red";
			LV2009Rebrand.AddErrorToHighlighterTooltip("No onclick defined");
		} else {
			if(anchorHref.indexOf("http") == 0){
				// external link... do we have SiMigrateCookie??
				if(anchorOnClick.toLowerCase().indexOf("simigratecookie") == -1){
					LV2009Rebrand.AddWarningToHighlighterTooltip("External link with no SiMigrateCookie");
					color = "red";
				}
			}
		
			var bracketPos = anchorOnClick.indexOf("{");
			anchorOnClick = anchorOnClick.substr(bracketPos + 1, 10000);
			anchorOnClick = anchorOnClick.replace("}", "");
			
			var onclickBits = anchorOnClick.split(";");
			$(onclickBits).each(
				function(index, item){
					if(item.replace(/_/g, "") != ""){
						LV2009Rebrand.AddToHighlighterTooltip("- " + item);	
					}
				}
			);
			
			
		}
			
		//anchorOnClick = anchorOnClick.substr(0, anchorOnClick.indexOf("{"));
		body.append("<div class=\"link-taginfo-highlighter\" id=\"" + highlighterID + "\"></div>");
		
		var highlighter = $("#" + highlighterID);
		//highlighter.attr("title", highlighterTitle);
		var position = anchor.offset({scroll:true});
		highlighter.css(
			{
				"top":position.top,
				"left":position.left,
				"width":anchor.outerWidth(),
				"height":anchor.outerHeight(),
				"background-color":color,
				"opacity":"0.5"
			}
		);
		
		var highlighterTooltipID = highlighterID + "-tooltip";
		body.append("<div class=\"link-taginfo-highlighter-tooltip\" id=\"" + highlighterTooltipID + "\">" + LV2009Rebrand.CurrentHighlighterTooltip + "</div>");
		var highlighterTooltip = $("#" + highlighterTooltipID);
		highlighterTooltip.css(
			{
				"top":position.top + anchor.outerHeight(),
				"left":position.left
			}
		);
		highlighter.mouseover(
			function(){
				var tooltip = $("#" + highlighterTooltipID);
				tooltip.css(
					{
						"display":"block"
					}
				);
			}
		);
		
		highlighter.mouseout(
			function(){
				var tooltip = $("#" + highlighterTooltipID);
				tooltip.css(
					{
						"display":"none"
					}
				);
			}
		);
	},
	SetupSitemapFilter:function(){
		var siteMapItems = new Array();
		$('.siteMapBlock li').each(
			function(index, liItem){
				var linkInfo = new Object();
				linkInfo.li = $(liItem);
				linkInfo.text = '';
				linkInfo.li.find('a').each(
					function(index, anchorItem) {
						linkInfo.text += ',' + $(anchorItem).text().toLowerCase();
					}
				);
				siteMapItems.push(linkInfo);
			}
		);
		
		var filterTextBox = $('#advanced-site-map-filter-input');

		var keyTimer;
		filterTextBox.keyup(
			function(){
				// Run the filter when the user has stopped typing rather than on every keypress
				if(keyTimer) {
					clearTimeout(keyTimer);
				}
				keyTimer = setTimeout(
					function() {
						LV2009Rebrand.SitemapFilter(siteMapItems, filterTextBox.val());
					},
					500);
			}
		);

		filterTextBox.focus(
			function(){
				if(filterTextBox.attr('class') == 'intro-text'){
					filterTextBox.removeClass('intro-text');
					filterTextBox.val('');
				}
			}
		);
	},
	SitemapFilter:function(items, filterText){
		filterText = filterText.toLowerCase();

		// Fade all items in or out
		var fadesRemaining = items.length;
		$.each(items,
			function(index, item){
				if(item.text.indexOf(filterText) == -1){
					item.li.fadeOut('fast',
						function() {
							fadesRemaining--;
						}
					);
				} else {
					// is the parent block's heading hidden? if so, show it
					if(item.li.parents('.siteMapSection').find('h3:visible').length == 0) {
						fadesRemaining++;
						item.li.parents('.siteMapSection').find('h3').fadeIn('fast',
							function() {
								fadesRemaining--;
							}
						);
					}

					// is the parent row hidden? if so, show it
					if(item.li.parents('.siteMapBlock:visible').length == 0) {
						fadesRemaining++;
						item.li.parents('.siteMapBlock').fadeIn('fast',
							function() {
								fadesRemaining--;
							}
						);
					}

					item.li.fadeIn('fast',
						function() {
							fadesRemaining--;
						}
					);
				}
			}
		);

		// Wait for all fades to finish
		var wait = setInterval(
			function() {
				if(fadesRemaining == 0) {
					clearInterval(wait);

					// Hide the headings on empty boxes
					$('.siteMapSection').each(
						function(index, item) {
							if($(item).find('li:visible').length == 0) {
								$(item).find('h3').hide();
							}
						}
					);

					// Hide any completely empty rows
					$('.siteMapBlock').each(
						function(index, item) {
							if($(item).find('li:visible').length == 0) {
								$(item).hide();
							}
						}
					);
				}
			},
			500);
	},

	ContentCarouselNext: function(nodeId) {
		var carouselStrip = $('#carouselStrip' + nodeId);
		if(!carouselStrip.hasClass('carouselScrolling')) {
			// add an interlock class to prevent multiple simultaneous scrolls
			carouselStrip.addClass('carouselScrolling');
			// slide the strip leftwards
			carouselStrip.animate({left: '-=302px'}, 500, function() {
					// when the side has finished, move the first item to the end
					carouselStrip.children('.carouselItem:first').appendTo(carouselStrip);
					// adjust the strip position to compensate for the moved item
					carouselStrip.css('left', '0');
					// remove the interlock
					carouselStrip.removeClass('carouselScrolling');
				}
			);
		}
		return false;
	},
	ContentCarouselPrev: function(nodeId) {
		var carouselStrip = $('#carouselStrip' + nodeId);
		if(!carouselStrip.hasClass('carouselScrolling')) {
			// add an interlock class to prevent multiple simultaneous scrolls
			carouselStrip.addClass('carouselScrolling');
			// move the last item to the front
			carouselStrip.children('.carouselItem:last').prependTo(carouselStrip);
			// adjust the strip position to compensate for the moved item
			carouselStrip.css('left', '-302px');
			// slide the strip rightwards
			carouselStrip.animate({left: '+=302px'}, 500, function() {
					// remove the interlock
					carouselStrip.removeClass('carouselScrolling');
				}
			);
		}
		return false;
	}
}


