var Britannia2009Rebrand={
	LastProductRolloverShowTime:-1,
	AddProductRollover:function(nodeID){
		var productTRID = "#product-" + nodeID;
		var productRolloverID = "#product-rollover-" + nodeID;

		var productTR = $(productTRID + " th");
		var productRollover = $(productRolloverID);

		var position = productTR.offset({scroll:true});
		productRollover.css(
			{
				"top":-22,
				"left":80
			}
		);

		productTR.hover(
			function(){
				productRollover.show();
			},
			function(){
				productRollover.hide();
			}
		);
	},
	ExploreLVDropDownVisible:false,
	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
		//alert("in page load");
		Britannia2009Rebrand.SetupExploreLVDropDown();
	},
	SetupExploreLVDropDown:function(){
		var select = $("#exploreLV");

		if(select){
			// get current options..
			//Britannia2009Rebrand.ToggleExploreLVDropDown()
			//var newHtml = "<div id=\"exploreLVJS\"><div>Explore LV.com</div><ol>";
			var newHtml = "<div id=\"exploreLVJS\"><div onclick=\"Britannia2009Rebrand.ToggleExploreLVDropDown();return(false);\">Explore Britannia Rescue</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');
					onclick=onclick.replace(/\"/g,'\'');
					var newonlick = onclick.substring(onclick.indexOf("{")+1,onclick.indexOf("}"));

					if(href){
						newHtml += "<li><a href=\"" + href + "\" onclick=\"" + newonlick + "\">" + text + "</a></li>";
					}
				}
			);
			newHtml += "</ol></div>";
			
			//alert(newHtml);

			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(){
						//Britannia2009Rebrand.HideExploreLVDropDown();
					}
				);
			}
			*/
		}
	},
	ToggleExploreLVDropDown:function(){
		var dropDown = $("#exploreLVJS ol");

		if(dropDown){
			if(Britannia2009Rebrand.ExploreLVDropDownVisible){
				Britannia2009Rebrand.HideExploreLVDropDown();
			} else {
				Britannia2009Rebrand.ShowExploreLVDropDown();
			}
		}
	},
	ShowExploreLVDropDown:function(){
		var dropDown = $("#exploreLVJS ol");

		if(dropDown){
			Britannia2009Rebrand.ExploreLVDropDownVisible = true;
			dropDown.fadeIn("fast");
		}
	},
	HideExploreLVDropDown:function(){
		var dropDown = $("#exploreLVJS ol");

		if(dropDown){
			Britannia2009Rebrand.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");
	}
}
