﻿// JScript File

function adjustDiv(e)
{
	var df=document.getElementById('ctl00_updateProgress');
	if (df != null){
		var dfs = df.style;
		dfs.zIndex = "999";
		dfs.position = "absolute";

		var x,y;
		// get window dimensions
		if (self.innerHeight) // all except Explorer
		{
			x = self.innerWidth;
			y = self.innerHeight;
		}
		else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
		{
			x = document.documentElement.clientWidth;
			y = document.documentElement.clientHeight;
		}
		else if (document.body) // other Explorers
		{
			x = document.body.clientWidth;
			y = document.body.clientHeight;
		}

		x = (x - df.offsetWidth) / 2;
		y = (y - df.offsetHeight) / 2;
		
		// check for scrolling
		if (self.pageXOffset || self.pageYOffset) // all except Explorer
		{
			x += self.pageXOffset;
			y += self.pageYOffset;
		}
		else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop))
		// Explorer 6 Strict Mode
		{
			x += document.documentElement.scrollLeft;
			y += document.documentElement.scrollTop;
		}
		else if (document.body)
		// Other Explorers
		{
			x += document.body.scrollLeft;
			y += document.body.scrollTop;
		}

		//update position
		dfs.left = (x + 100) + "px";
		dfs.top = (y + 10) + "px";
	}
}

// check if progress panel exists
// then bind events
function conditionalEventBind(e){
	var check=document.getElementById('ctl00_updateProgress');
	if (check){
		window.onload=adjustDiv;
		window.onresize=adjustDiv;
		window.onscroll=adjustDiv;
		adjustDiv(e);
	}
}
//onload was disabled because omniture overlays will not working with it
//window.onload = conditionalEventBind;

if (Sys.WebForms != null)
{
	var pageRequestManager = Sys.WebForms.PageRequestManager.getInstance();

	if (pageRequestManager)
		pageRequestManager.add_beginRequest(BeginRequestHandler);
}

function BeginRequestHandler() {
	conditionalEventBind();
}
