var isIE = document.all;

function UPC_GetElement(id)
{
	var element = document.getElementById ? document.getElementById(id) : document.all ? document.all[id] : document.layers[id];
	return element;
}

function winopen(url, winname, width, height) {

				// Modified by: Mario Ghecea
				// Date: 4/13/2007
				// Purpose: To allow the centering of pop-up windows of all types
				// using the passed in width and height as part of a simple centering
				// equation using the client window size.
				
				var winW = 630, winH = 460, popW = width, popH = height;
				var centerX = 0, centerY = 0;

				if (parseInt(navigator.appVersion)>3) {
				if (navigator.appName=="Netscape") {
				winW = window.innerWidth;
				winH = window.innerHeight;
				}
				if (navigator.appName.indexOf("Microsoft")!=-1) {
				winW = document.body.offsetWidth;
				winH = document.body.offsetHeight;
				}
				}

				centerX = (winW - popW) /2;
				centerY = (winH - popH) /2;				
				var popwin = window.open(url, winname, "width=" + width + ", height = " + height + ",top=" + centerY + ",left=" + centerX + ",menubar=no,status=no,location=no,toolbar=no,scrollbars=no");
				popwin.focus();
}

function winclose(url) {
	if (window.opener)
	{
		if (url != null && url.length > 0)
			window.opener.location.href = url;
	
		window.opener.location.reload();
		window.opener.focus();
	}
	window.close();
}

function findPosX(obj)
{
 	var curleft = 0;
	
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	
	return curleft;
}

function findPosY(obj)
{
 	var curtop = 0;
	
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	
	return curtop;
}

function getQueryString()
{
	var locationstring = location.search.substring(1,location.search.length);
	//gets rid of the leading ?

	if (locationstring.length != 0)
	{
		var args = locationstring.split("&");
		
		var array = new Object();
		
		for (var i = 0; i < args.length; i++) 
		{
			var namevalue = args[i].split("=");
			var thename = unescape(namevalue[0]).toLowerCase();
		
			array[thename] = (namevalue.length == 2 ? unescape(namevalue[1]) : "");
		}

		return array;
	}
}

function getXmlHttp()
{
	if((navigator.appName == "Microsoft Internet Explorer") || !window.XMLHttpRequest)
	{
		var xmls = new Array(
			"Msxml2.XMLHTTP.5.0",
			"Msxml2.XMLHTTP.4.0",
			"Msxml2.XMLHTTP.3.0",
			"Msxml2.XMLHTTP",
			"Microsoft.XMLHTTP"
			);
		
		for(var a = 0; a < xmls.length; a++)
		{
			try {return new ActiveXObject(xmls[a]);}
			catch(e) {}
		}
	}
	else
	{
		try {return new XMLHttpRequest();}
		catch(e) {}
	}
	
	return null;
}