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=1 WIDTH=1 FRAMEBORDER=0><\/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=1 WIDTH=1 FRAMEBORDER=0><\/iframe>");
	}
}

function kenshoo_conv(id,type,value,orderId,promoCode,valueCurrency) {
	promoCode = "lv50plus";
	var url = "https://17.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,
	IE6ResizeKick:function(){
		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();
	},
	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);\">Explore LV.com</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){
						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");
		}		
	},
	ToggleExpander:function(expanderID){
		var isIE6 = ($.browser.msie && $.browser.version.substr(0,1)<7);
		var expanderHeader = $("#" + expanderID + " .expanderHeader");
		var expanderContent = $("#" + expanderID + " .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"
					}
				);
			}
		);
	}
}

