
var __isIE = (document.all != null);
var __isMoz = __isIE ? false : (document.createRange() != null);
var __editLinkElement = null;

function onMasterLoad()
{
	// detemine if analytics should be turned on
    var analyticsOn = true;
    if (window.location.protocol == "https:")
    {
		analyticsOn = false;
	}
	else if ( window.location.hostname.toLowerCase() == "localhost" ) //|| window.location.hostname.toLowerCase() == "staging.mydomain.com")
	{
		analyticsOn = false;
	}
    try{ analytics(analyticsOn); }catch(ex){}
    
    // hide the divTransition element
    try
    {
        var div=document.getElementById("divTransition");
        if (div){div.style.display="none";}
    }
    catch(ex){}

	// ensure that the content div expands to the correct height
	var cdiv = document.getElementById("contentdiv");
	if ( cdiv && cdiv.style )
	{
		var de = document.documentElement;
		var height = "100%";
		if ( de && de.scrollHeight )
		{
			height = de.scrollHeight + "px";
		}			
		cdiv.style.height = height;
	}
}
function mdsCMS_editContent(element, adminUrl, evnt)
{
	CancelEventBubble(evnt);
	top.location.href = adminUrl;
}
function mdsCMS_showEditInfo(element, color, path, evnt)
{
		element.style.backgroundColor=color;
		element.style.border="dotted 1px green";
		element.style.cursor="pointer";
		element.title="Click on the highlighted content to Edit: " + path;
}

function mdsCMS_hideEditInfo(element)
{
	if (element)
	{
		element.style.backgroundColor="transparent";
		element.style.border="solid 1px transparent";
		element.style.cursor="default";
		element.title="";
	}
}
function analytics(on)
{
    var spn = document.getElementById("spnAnalytics");
    if ( on )
    {
        spn.style.color = "green";
//        _uacct = "";  // analytics account id goes here
//        urchinTracker(); // uncomment to run analytics
    }
    else
    {
        spn.style.color = "red";
    }
}


function CancelEventBubble(evnt)
{
	evnt = evnt ? evnt : event; 
	if (evnt)
	{
		evnt.returnValue = false;
		evnt.cancelBubble = true;
		
		// prevent IE's find dialog from popping up 
		// when we handle CTRL+F
		if (__isIE)
		{
			evnt.keyCode = 0;
		}
		else if (__isMoz)
		{
			if(evnt.cancelable)
			{
				evnt.preventDefault();
			}
			evnt.stopPropagation();
		}
	}
}

function GetSourceElement(evnt)
{
	evnt = evnt ? evnt : event; 
	var elm = null;
	if (evnt)
	{
		elm = evnt.srcElement ? evnt.srcElement : evnt.target;
	}
	return elm;
}
