﻿
function DsiPageShowLoginNew()
{
	window.scroll(0, 0);
	document.getElementById("ContentDiv").style.display = "none";
	document.getElementById("NavLogin_ShowHideSpan").style.display = "";
}
function DsiPageHideLoginNew()
{
	document.getElementById("ContentDiv").style.display = "";
	document.getElementById("NavLogin_ShowHideSpan").style.display = "none";
}
jQuery("body").ready(BodyReady);
var uiBottomRightJ = null;
var uiFooterRightDiv = null;
var uiFooterRightDivJ = null;
var uiFooterLeftDiv = null;
var uiFooterLeftDivJ = null;
var uiLinksDiv = null;
var uiLinksDivJ = null;
var uiSidebarMaxTopDiv = null;
var uiSidebarMaxTopDivJ = null;
var uiBodyMainBackgroundInnerJ = null;
function BodyReady()
{
	setTimeout(BodyReadyAfterTimer, 0);
}
function BodyReadyAfterTimer()
{
	uiBottomRightJ = jQuery(".BottomRight");

	uiFooterRightDiv = document.getElementById("uiFooterRightDiv");
	uiFooterRightDivJ = jQuery("#uiFooterRightDiv");
	uiFooterLeftDiv = document.getElementById("uiFooterLeftDiv");
	uiFooterLeftDivJ = jQuery("#uiFooterLeftDiv");
	uiLinksDiv = document.getElementById("uiLinksDiv");
	uiLinksDivJ = jQuery("#uiLinksDiv");
	uiSidebarMaxTopDiv = document.getElementById("SidebarMaxTopDiv")
	uiSidebarMaxTopDivJ = jQuery("#SidebarMaxTopDiv");

	uiBodyMainBackgroundInnerJ = jQuery("#BodyMainBackgroundInner");


	WindowScroll();
	Update();
}
var BottomRightScrollIE6Mod = 0;
function WindowScroll()
{
	BottomRightScroll();
}
function WindowResize()
{
	//?
}

function Trace(str)
{
	document.getElementById("uiTestDiv").innerHTML = "<div>" + str + "</div>";  //+ document.getElementById("uiTestDiv").innerHTML;
}


function Update()
{
	var scrollTop = window.scroll().top;
	var scrollLeft = window.scroll().left;
	var clientHeight = window.size().height;
	var clientWidth = window.size().width;
	var ieOffset = 0;

	if (document.getElementById && !document.all)
	{
		ieOffset = -18;
	}

	try
	{
		if (uiLinksDiv != null)
		{

			if (uiLinksDiv.style.display == "none")
				uiLinksDiv.style.display = "";

			var left = uiSidebarMaxTopDivJ.offset().left;
			var top = uiSidebarMaxTopDivJ.offset().top + 35;

			var topMin = scrollTop + 15;

			if (top < topMin)
				top = topMin;

			uiLinksDivJ.css("top", top);
			uiLinksDivJ.css("left", left);
			uiLinksDivJ.css("display", "block");
		}

	}
	catch (ex) { }

	try
	{

		if (uiFooterRightDiv != null)
		{
			if (uiFooterRightDiv.style.display == "none")
				uiFooterRightDiv.style.display = "";

			var top = clientHeight + scrollTop - uiFooterRightDiv.offsetHeight + ieOffset;
			var left = clientWidth - uiFooterRightDiv.offsetWidth + ieOffset;

			var topMax = 0;
			var leftMin = 0;
			var leftMax = 0;

			uiFooterRightDivJ.css("top", top);
			uiFooterRightDivJ.css("left", left);
			uiFooterRightDivJ.css("display", "block");
		}

	}
	catch (ex) { }


	try
	{
		if (uiFooterLeftDiv != null)
		{
			if (uiFooterLeftDiv.style.display == "none")
				uiFooterLeftDiv.style.display = "";

			var top = clientHeight + scrollTop - uiFooterLeftDiv.offsetHeight + ieOffset;
			var left = 0;

			uiFooterLeftDivJ.css("top", top);
			uiFooterLeftDivJ.css("left", left);
			uiFooterLeftDivJ.css("display", "block");
		}

	}
	catch (ex) { }

}


window.size = function()
{
	var w = 0;
	var h = 0;

	//IE
	if (!window.innerWidth)
	{
		//strict mode
		if (!(document.documentElement.clientWidth == 0))
		{
			w = document.documentElement.clientWidth;
			h = document.documentElement.clientHeight;
		}
		//quirks mode
		else
		{
			w = document.body.clientWidth;
			h = document.body.clientHeight;
		}
	}
	//w3c
	else
	{
		w = window.innerWidth;
		h = window.innerHeight;
	}
	return { width: w, height: h };
}

window.scroll = function()
{
	var x, y;
	if (self.pageYOffset) // all except Explorer
	{
		x = self.pageXOffset;
		y = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
	// Explorer 6 Strict
	{
		x = document.documentElement.scrollLeft;
		y = document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		x = document.body.scrollLeft;
		y = document.body.scrollTop;
	}
	return { left: x, top: y };
}








function BottomRightScroll()
{
	try
	{
		if (uiBottomRightJ != null)// || BottomLeftJ != null)
		{

			var top = "";
			var right = "";
			if (document.getElementById && !document.all)
			{
				bottom = (0 - window.pageYOffset) + "px";
				right = (0 - window.pageXOffset) + "px";
			}
			else
			{
				if (navigator.appVersion.indexOf("MSIE 6.0;") == -1)
				{
					bottom = (0 - document.body.scrollTop) + "px";
					right = (0 - document.body.scrollLeft) + "px";
				}
				else
				{
					BottomRightScrollIE6Mod = BottomRightScrollIE6Mod == 0 ? 1 : 0;
					bottom = BottomRightScrollIE6Mod + "px";
					right = BottomRightScrollIE6Mod + "px";
				}
			}


			if (uiBottomRightJ != null)
			{
				uiBottomRightJ.css("bottom", bottom);
				uiBottomRightJ.css("right", right);
				uiBottomRightJ.css("display", "block");
			}

			//			if (BottomLeftJ != null)
			//			{
			//				BottomLeftJ.css("bottom", bottom);
			//				BottomLeftJ.css("left", "0px");
			//				BottomLeftJ.css("display", "block");
			//			}
		}
	}
	catch (ex) { }
}