// JScript source code
function npcom_togglefields(oVis, sCtl1, sCtl2, sCtl3, sCtl4, sCtl5, sCtl6, sCtl7, sCtl8)
{
	//oVis.checked = !oVis.Checked
	var oCtl = dnn.dom.getById(sCtl1);
	if (oCtl != null)
	{
		if (oVis.checked)
		{
			oCtl.style.display = '';
		}
		else
		{
			oCtl.style.display = 'none';
		}
	}	
	
	oCtl = dnn.dom.getById(sCtl2);
	if (oCtl != null)
	{
		if (oVis.checked)
		{
			oCtl.style.display = '';
		}
		else
		{
			oCtl.style.display = 'none';
		}
	}
	oCtl = dnn.dom.getById(sCtl3);
	if (oCtl != null)
	{
		if (oVis.checked)
		{
			oCtl.style.display = '';
		}
		else
		{
			oCtl.style.display = 'none';
		}
	}
	oCtl = dnn.dom.getById(sCtl4);
	if (oCtl != null)
	{
		if (oVis.checked)
		{
			oCtl.style.display = '';
		}
		else
		{
			oCtl.style.display = 'none';
		}
	}
	oCtl = dnn.dom.getById(sCtl5);
	if (oCtl != null)
	{
		if (oVis.checked)
		{
			oCtl.style.display = '';
		}
		else
		{
			oCtl.style.display = 'none';
		}
	}
	oCtl = dnn.dom.getById(sCtl6);
	if (oCtl != null)
	{
		if (oVis.checked)
		{
			oCtl.style.display = '';
		}
		else
		{
			oCtl.style.display = 'none';
		}
	}
	oCtl = dnn.dom.getById(sCtl7);
	if (oCtl != null)
	{
		if (oVis.checked)
		{
			oCtl.style.display = '';
		}
		else
		{
			oCtl.style.display = 'none';
		}
	}
	oCtl = dnn.dom.getById(sCtl8);
	if (oCtl != null)
	{
		if (oVis.checked)
		{
			oCtl.style.display = '';
		}
		else
		{
			oCtl.style.display = 'none';
		}
	}
}

// JScript source code
function npcom_showhidetables(sTblShowList, sTblHideList)
{
        // do hide list first so that if replicated in show list then corrects itself.
	var aryTablesHide = sTblHideList.split(';');
	for (var i=0; i<aryTablesHide.length; i++)
	{
		if (aryTablesHide[i].length > 0)
		{
			var hCtl = dnn.dom.getById(aryTablesHide[i]);
			
			if (hCtl != null)
			{
			        hCtl.style.display = 'none';
    			        dnn.setVar(hCtl.id + ':exp', 0);
			}	
		}
	}

	var aryTablesShow = sTblShowList.split(';');
	for (var i=0; i<aryTablesShow.length; i++)
	{
		if (aryTablesShow[i].length > 0)
		{
	                var sCtl = dnn.dom.getById(aryTablesShow[i]);
	                if (sCtl != null)
	                {
		               sCtl.style.display = '';
    			       dnn.setVar(sCtl.id + ':exp', 1);
	                }	
	        }
	}
}

function npcom_XYPos(zxc)
{
    zxcObjLeft = zxc.offsetLeft;
    zxcObjTop = zxc.offsetTop;
    while(zxc.offsetParent!=null)
    {
        zxcObjParent=zxc.offsetParent;
        zxcObjLeft+=zxcObjParent.offsetLeft;
        zxcObjTop+=zxcObjParent.offsetTop;
        zxc=zxcObjParent;
    }
    return [zxcObjLeft,zxcObjTop];
}

function npcom_settextvalue(sCtl, sText)
{
	//oVis.checked = !oVis.Checked
	var oCtl = dnn.dom.getById(sCtl);
	if (oCtl != null)
	{
	    oCtl.value = sText;
	}	
}

function npcom_settextvaluetoxpos(cCtl, sCtl)
{
	var xCtl = dnn.dom.getById(cCtl);
	if (xCtl != null || window.event != null)
	{
	    //var cleft = npcom_XPos(xCtl)
	    //var x = window.event.clientX-cleft;
	    var oCtl = dnn.dom.getById(sCtl);
	    if (oCtl != null)
  	    {
  	        var bx = npcom_XYPos(xCtl)[0]
  	        var cx = window.event.x;
  	        if (cx != null) 
	            oCtl.value = parseInt((cx-bx)*100/xCtl.width);
	        else
	            oCtl.value = "0";
	    }	
	}  
}

function npcom_settextvaluetodiff(cCtl1, cCtl2, sCtl)
{

	var xCtl1 = dnn.dom.getById(cCtl1);
	var xCtl2 = dnn.dom.getById(cCtl2);
	if (xCtl1 != null || xCtl2 != null)
	{
	    var oCtl = dnn.dom.getById(sCtl);
	    if (oCtl != null)
  	    {
  	        var bx = xCtl1.value;
  	        var cx = xCtl2.value;
  	        if (cx != null && bx != null) 
  	            if (bx-cx>0)
	                oCtl.value = parseInt(bx-cx);
	            else
	                oCtl.value = parseInt(cx-bx);	            
	        else
	            oCtl.value = "0";
	    }	
	}  
}

function npcom_swapImgRestore() { 
  var i,x,a=document.npcom_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function npcom_displayStatusMsg(msgStr) { 
  status=msgStr;
  document.npcom_returnValue = true;
}

function npcom_preloadImages() { 
  var d=document; if(d.images){ if(!d.npcom_p) d.npcom_p=new Array();
    var i,j=d.npcom_p.length,a=npcom_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.npcom_p[j]=new Image; d.npcom_p[j++].src=a[i];}}
}

function npcom_findObj(n, d) { 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=npcom_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function npcom_swapImage() { 
  var i,j=0,x,a=npcom_swapImage.arguments; document.npcom_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=npcom_findObj(a[i]))!=null){document.npcom_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
