// Copyright (C) 2007 Jeffrey Bazinet, http://www.vwd-cms.com/

var __isIE = (document.all != null);
var __isMoz = __isIE ? false : (document.createRange() != null);
var __editLinkElement = null;

function onMasterLoad()
{
	// detemine if analytics should be turned on
	// note: __analyticsOn and __analyticsId is set by VwdCms.MasterPage
    
    if (__analyticsOn)
    {
		if (__analyticsId == null || __analyticsId == "")
		{
			__analyticsOn = false;
		}
		else if (window.location.protocol == "https:")
		{
			__analyticsOn = false;
		}
		else if ( window.location.hostname.toLowerCase() == "localhost" )
		{
			__analyticsOn = false;
		}
	}
	// call the analytics function even if __analyticsOn == false because
	// it will indicate on the page that analytics is off by coloring 
	// the analytics text red
//    try{ 
analytics(); 
//}catch(ex){}
}
function VwdCms_editContent(element, adminUrl, evnt)
{
	CancelEventBubble(evnt);
	top.location.href = adminUrl;
}
function VwdCms_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 VwdCms_hideEditInfo(element)
{
	if (element)
	{
		element.style.backgroundColor="transparent";
		element.style.border="solid 1px transparent";
		element.style.cursor="default";
		element.title="";
	}
}
function analytics()
{
    var spn = document.getElementById("spnAnalytics");
    if ( __analyticsOn )
    {
        spn.style.color = "green";
        _uacct = __analyticsId;
        urchinTracker();
    }
    else
    {
        spn.style.color = "red";
    }
}

function si(a,i)
{
    // si (send inquiry) a=anchor/link element, i=index
    // e n c o d e d   c o n t a c t   a d d r e s s e s
    var u1 = String.fromCharCode(109,97,105,108,116,111,58);
    var u2 = new Array(3);
    u2[0] = String.fromCharCode(83,97,108,101,115);
    u2[1] = String.fromCharCode(83,117,112,112,111,114,116);
    u2[2] = String.fromCharCode(80,97,114,116,110,101,114,115);
    var u3 = String.fromCharCode(64,118,119,100,45,99,109,115,46,99,111,109);
    var u4 = String.fromCharCode(63,115,117,98,106,101,99,116,61);
    var u5 = String.fromCharCode(37,50,48,73,110,113,117,105,114,121);

    a.href = u1 + u2[i] + u3 + u4 + u2[i] + u5;
}

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;
}

