var g_httpCgiUrl = "/Stellent/websites/get_page.asp?";

/////////////////////////////////////////////////////////////////////////////
// Function : isSelected
// Comments :
/////////////////////////////////////////////////////////////////////////////
function isSelected()
{
    var pos = window.location.href.lastIndexOf("/");
    var docname = window.location.href.substring(pos+1, window.location.href.length);

    pos = this.m_href.lastIndexOf("/");
    var myname = this.m_href.substring(pos+1, this.m_href.length);

    if (docname == myname)
		return true;
	else
		return false;
}

/////////////////////////////////////////////////////////////////////////////
// Function : customSectionPropertyExists
// Comments :
/////////////////////////////////////////////////////////////////////////////
function customSectionPropertyExists(csp)
{
	return (typeof csp != _U && csp != null);
}

/////////////////////////////////////////////////////////////////////////////
// Function : getCustomSectionProperty
// Comments :
/////////////////////////////////////////////////////////////////////////////
function getCustomSectionProperty(csp)
{
	if (customSectionPropertyExists(csp))
	{
		return csp;
	}
	else
	{
		return "";
	}
}

/////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////
// Function : link
// Comments : NOTE: ssTargetWindow parameter is a CUSTOMIZATION
/////////////////////////////////////////////////////////////////////////////
function link(dDocName,ssTargetNodeId)
{
	if ((dDocName.search("http://") != -1) || (dDocName.search("https://") != -1))
        {
//=====================
// START CUSTOMIZATION
//=====================
		var nodeid = "";

		var pos=window.location.href.indexOf("?");
		var currentURL=""

		if (pos < 0){

			currentURL=window.location.href + "?";
		}else{

			currentURL=window.location.href.substring(0,pos) + "?";

		}

		if (ssTargetNodeId != _U && ssTargetNodeId != null)
		{
			nodeid = ssTargetNodeId;
		}
		else
		{
			nodeid = g_ssSourceNodeId;
		}
		window.location = currentURL  + "nodeId=" + nodeid + "&useSecondary=true&myExternalURL=" + dDocName.replace(/&/g, '{param}');
//=====================
// END CUSTOMIZATION
//=====================
        }

//=====================
// START CUSTOMIZATION
//=====================
	else if (dDocName.charAt(0) == '#')
        {
           window.location = window.location.href.split("#")[0] + dDocName;
        }
//===================
// END CUSTOMIZATION
//===================

        else
	{
		var newUrl = "";
		newUrl += g_httpCgiUrl;
		newUrl += "ssDocName=" + dDocName;

		var currentUrl = "" + window.location;

		// Continue propagation of the "SSContributor" parameter
		if( SSContributor )
		{
			var paramName = "SSContributor=";
			var pos = currentUrl.indexOf( paramName );
			if( pos != -1 )
			{
				var subStr = currentUrl.substring( pos+paramName.length, pos+paramName.length+1 );
				if( isTrue( subStr ) )
				{
					newUrl += "&" + paramName + "true";
				}
			}
		}

		// Continue propagation of the "previewId" parameter
		var previewId = "previewId=";
		var posStart = currentUrl.indexOf( previewId );
		if( posStart != -1 )
		{
			var posEnd = currentUrl.indexOf("&", posStart);
			var value = "";
			if (posEnd == -1)
			{
				value = currentUrl.substring(posStart+previewId.length, currentUrl.length);
			}
			else
			{
				value = currentUrl.substring(posStart+previewId.length, posEnd);
			}
			newUrl += "&" + previewId + value;
		}

		// We now always add the node that the link is on as part of the URl also.
		if( g_ssSourceNodeId != _U && g_ssSourceNodeId != null )
			newUrl += "&ssSourceNodeId=" + g_ssSourceNodeId;

		// If we have a specific target nodeId then add that to the URL also
		if( ssTargetNodeId != _U && ssTargetNodeId != null )
			newUrl += "&ssTargetNodeId=" + ssTargetNodeId;

		// Navigate to the new url
		window.location = newUrl;
	}
}

/////////////////////////////////////////////////////////////////////////////
// Function : nodelink
// Comments :
/////////////////////////////////////////////////////////////////////////////
function nodelink(nodeId)
{
	var newUrl = "";
	newUrl += g_httpCgiUrl;
	newUrl += "nodeId=" + nodeId;

	var currentUrl = "" + window.location;

	// Continue propagation of the "SSContributor" parameter
	if( SSContributor )
	{
		var paramName = "SSContributor=";
		var pos = currentUrl.indexOf( paramName );
		if( pos != -1 )
		{
			var subStr = currentUrl.substring( pos+paramName.length, pos+paramName.length+1 );
			if( isTrue( subStr ) )
			{
				newUrl += "&" + paramName + "true";
			}
		}
	}

	// Continue propagation of the "previewId" parameter
	var previewId = "previewId=";
	var posStart = currentUrl.indexOf( previewId );
	if( posStart != -1 )
	{
		var posEnd = currentUrl.indexOf("&", posStart);
		var value = "";
		if (posEnd == -1)
		{
			value = currentUrl.substring(posStart+previewId.length, currentUrl.length);
		}
		else
		{
			value = currentUrl.substring(posStart+previewId.length, posEnd);
		}
		newUrl += "&" + previewId + value;
	}

	// We now always add the node that the link is on as part of the URl also.
	if( g_ssSourceNodeId != _U && g_ssSourceNodeId != null )
		newUrl += "&ssSourceNodeId=" + g_ssSourceNodeId;

	// Navigate to the new url
	window.location = newUrl;
}
/////////////////////////////////////////////////////////////////////////////

//=====================
// START CUSTOMIZATION
//=====================
function BrowserDetectionObject()
{
	this.agt = navigator.userAgent.toLowerCase();
	this.appVersion = navigator.appVersion;
	this.majorVersion = parseInt(navigator.appVersion);
	this.minorVersion = parseFloat(navigator.appVersion) - this.majorVersion;

	this.is_ie = (this.agt.indexOf("msie") != -1);
	this.is_ns = ((this.agt.indexOf("mozilla")!=-1) &&
	              (this.agt.indexOf("spoofer")==-1) &&
	              (this.agt.indexOf("compatible") == -1) &&
	              (this.agt.indexOf("opera")==-1) &&
	              (this.agt.indexOf("webtv")==-1));

	if (this.is_ie)
	{
		this.majorVersion = parseInt(this.agt.substring(this.agt.indexOf("msie ")+5));
		this.minorVersion = parseInt(this.agt.substring(this.agt.indexOf("msie ")+7));
	}
	else if (this.is_ns && (this.agt.indexOf("netscape6/") != -1))
	{
		this.majorVersion = parseInt(this.agt.substring(this.agt.indexOf("netscape6/")+10));
		this.minorVersion = parseInt(this.agt.substring(this.agt.indexOf("netscape6/")+12));
	}
	else if (this.is_ns && (this.agt.indexOf("netscape/7") != -1))
	{
		this.majorVersion = parseInt(this.agt.substring(this.agt.indexOf("netscape/7")+9));
		this.minorVersion = parseInt(this.agt.substring(this.agt.indexOf("netscape/7")+11));
	}

	this.is_ns3   = (this.is_ns && (this.majorVersion == 3));
	this.is_ns4   = (this.is_ns && (this.majorVersion == 4));
	this.is_ns6   = (this.is_ns && (this.majorVersion == 6));
	this.is_ns7   = (this.is_ns && (this.majorVersion == 7));
	this.is_ns4up = (this.is_ns && (this.majorVersion >= 4));
	this.is_ns6up = (this.is_ns && (this.majorVersion >= 6));
	this.is_ns7up = (this.is_ns && (this.majorVersion >= 7));
	this.is_ie3   = (this.is_ie && (this.majorVersion == 3));
	this.is_ie4   = (this.is_ie && (this.majorVersion == 4));
	this.is_ie5   = (this.is_ie && (this.majorVersion == 5));
	this.is_ie6   = (this.is_ie && (this.majorVersion == 6));
	this.is_ie4up = (this.is_ie && (this.majorVersion >= 4));
	this.is_ie5up = (this.is_ie && (this.majorVersion >= 5));
	this.is_ie6up = (this.is_ie && (this.majorVersion >= 6));
}
var g_objBrowserDetection = new BrowserDetectionObject();
//===================
// END CUSTOMIZATION
//===================
