var visibility = new Array();
var Window_InitialHeight;
var Window_InitialWidth;

if (document.layers != null) {
	visibility["visible"] = "show";
	visibility["hidden"] = "hide";

	Window_InitialWidth = window.innerWidth;
	Window_InitialHeight = window.innerHeight;

	window.captureEvents(Event.RESIZE);
	window.onresize = Window_OnResize;
	
} else {
	visibility["visible"] = "visible";
	visibility["hidden"] = "hidden";

	window.onresize = Window_OnResize; 
}

function CenterLayer(layerId)
{
	var content = GetElementStyleById(layerId);
	content.top = Math.round((GetClientHeight() - GetElementHeight(layerId)) / 2);
	content.left = Math.round((GetClientWidth() - GetElementWidth(layerId)) / 2);
	content.visibility = visibility["visible"];
}


function CenterLayerHorizontally(layerId)
{
	var content = GetElementStyleById(layerId);
	content.left = Math.round((GetClientWidth() - GetElementWidth(layerId)) / 2);
	setTimeout("GetElementStyleById('" + layerId + "').visibility = '" + visibility["visible"] + "'", 30 );
}


function CenterLayerVertically(layerId)
{
	var content = GetElementStyleById(layerId);
	content.top = Math.round((GetClientHeight() - GetElementHeight(layerId)) / 2);
	setTimeout("GetElementStyleById('" + layerId + "').visibility = '" + visibility["visible"] + "'", 30);
}


function CenteredNotScrollingWindow(url, name, height, width)
{
  var windowHeightCenter = Math.round((screen.height / 2) - (height / 2));
  var windowWidthCenter = Math.round((screen.width / 2) - (width / 2));

  window.open(url, name, 'width=' + width + ',height=' + height + ',toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0,top=' + windowHeightCenter + ',left=' + windowWidthCenter);
}


function CenteredScrollingWindow(url, name, height, width)
{
  var windowHeightCenter = Math.round((screen.height / 2) - (height / 2));
  var windowWidthCenter = Math.round((screen.width / 2) - (width / 2));

  window.open(url, name, 'width=' + width + ',height=' + height + ',toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0,top=' + windowHeightCenter + ',left=' + windowWidthCenter);
}


function GetClientHeight()
{
	if(window.innerHeight != null) {
		return window.innerHeight;
		
	} else {
		return document.body.clientHeight;
	}
}


function GetClientWidth()
{
	if(window.innerWidth != null) {
		return window.innerWidth;
		
	} else {
		return document.body.clientWidth;
	}
}


function GetElementById(layerId)
{
	if (document.getElementById != null) {
		return document.getElementById(layerId);
		
	} else if (document.all != null) {
		return document.all[layerId];
		
	} else if (document.layers != null) {
		return document.layers[layerId];
		
	} else {
		return 0;
	}
}


function GetElementHeight(layerId)
{
	if (document.getElementById != null || document.all != null) {
		return GetElementById(layerId).offsetHeight;
		
	} else if (document.layers != null) {
		return GetElementStyleById(layerId).clip.height;
		
	} else {
		return 0;
	}
}


function GetElementWidth(layerId)
{
	if (document.getElementById != null || document.all != null) {
		return GetElementById(layerId).offsetWidth;
		
	} else if (document.layers != null) {
		return GetElementStyleById( layerId ).clip.width;
		
	} else {
		return 0;
	}
}


function GetElementStyleById(layerId)
{
	if (document.getElementById != null) {
		return document.getElementById(layerId).style;
		
	} else if (document.all != null) {
		return document.all[layerId].style;
		
	} else if (document.layers != null) {
		return document.layers[layerId];
		
	} else {
		return null;
	}
}


function LaunchUrlToOpener(url)
{
	if (window.opener != null && !window.opener.closed) {
		window.opener.location.href = url;
	
	} else {
		window.open(url);
	}
}

		
function TextBoxDefault(textBox, word, type)
{
	switch (type.toLowerCase())
	{
		case "focus":
			if(textBox.value == word) {
				textBox.value = "";
			}
			break;
		case "blur":
			if(textBox.value == "") {
				textBox.value = word;
			}
			break;
		default:
	}
}


function Window_OnResize()
{
	if (document.layers && (Window_InitialWidth != window.innerWidth || Window_InitialHeight != window.innerHeight)) {
		document.location = document.location;
		
	} else if (!document.layers) {
		if(document.getElementById("PlaceHolder") != null || document.all["PlaceHolder"] != null) {
			CenterLayerHorizontally("PlaceHolder");
		}	
		
	}

	return( false );
}
