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) {
	var popwin = window.open(url, winname, "width="+width+",height="+height+",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;
		else
			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(!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;
}



function FindUploadCookieValue(UploadID)
{
	var name = "UD" + UploadID.toString() + "=";
	if(document.cookie.indexOf(name) != -1)
	{
		return unescape(document.cookie.substring(document.cookie.indexOf(name) + name.length));
	}
	return null;
}
