var thePCC;
var PCCtop;
var PCCstop;
var px = document.layers ? "" : "px";
var IsNetscape = (navigator.appName.indexOf("Netscape") != -1);
var PccLocation = 0;
var browserName=navigator.appName;
function setPCCStart(startY, defaultStartX, pixelsFromTop)
{
	//var startX = 750;
	thePCC=getAnElement("divPCC");
	var startX = thePCC.x;
	if ( browserName == "Microsoft Internet Explorer" )
	{
		startX = ((document.body.offsetWidth-800)/2)+20;
		//startX = defaultStartX + 150;
	}
	PCCtop=getAnElement("topBar");
	VMessages = getAnElement("val-error-window");
	if (VMessages)
		InitializeVMessageHeight();
	PCCstop = getAnElement("bottomBar").offsetTop - thePCC.offsetHeight - 30;
	if(document.layers)thePCC.style=thePCC;
	thePCC.style.left = startX + px;
	thePCC.x = startX; thePCC.y = startY;
	//alert( thePCC.style.left );
	setPCC(pixelsFromTop);
}
function setPCC(pixelsFromTop)
{
	var pY = (IsNetscape ? window.pageYOffset : (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop) + pixelsFromTop;
	if (PccLocation == pY)
	{
		if(thePCC.y > PCCstop)thePCC.y = PCCstop;
		else
		{
			if ( browserName == "Microsoft Internet Explorer" )
			{
				startX = ((document.body.offsetWidth-800)/2)+20;
				thePCC.x = startX;
				thePCC.style.left = thePCC.x + px;
			}
			
			var dY = (pY > PCCtop.offsetTop) ? pY : PCCtop.offsetTop;
			thePCC.y += (dY - thePCC.y);
			thePCC.style.top=thePCC.y + px;
			if (VMessages)
			{
				if (VMessages.y)
					VMessages.style.top = thePCC.y + VMessages.y +  px;
				else
					VMessages.style.top = thePCC.y + px;
			}
		}
	}
	PccLocation = pY;
	setTimeout("setPCC(" + pixelsFromTop + ")", 250);
}
function getAnElement(id)
{
	return document.getElementById?document.getElementById(id):document.all?document.all[id]:document.layers[id];
}
function InitializeVMessageHeight()
{
	var valText = getAnElement('val-text');
	var tHeight = parseInt(valText.offsetHeight);
	if (tHeight > 192)
	{
		valText.style.height='192px';
		tHeight = 202;
	}
	VMessages.startHeight = (tHeight + 20)
	VMessages.style.height= VMessages.startHeight + 'px';
	if (document.CONFIG_FORM.val_module.value != '')
	{
		if (document.CONFIG_FORM.val_module.value.substr(0,4) == 'c_m_')
			valmodlink_comp(document.CONFIG_FORM.val_module.value,0);
		else
			valmodlink(document.CONFIG_FORM.val_module.value,0);
		document.CONFIG_FORM.val_module.value = '';
	}
}
