
function open_help_popup(id)
{
	open_popup('../help_popup/help_popup.aspx?IDPopup='+id,440,440,'yes','yes');
}


function open_popup(strURL,intWidth,intHeigth,popupName,scroll,resize)
{
intLeft =	((screen.width - intWidth) / 2);
intTop =	((screen.height - intHeigth) / 2) - 30;
popup = window.open(strURL,popupName,'status=yes,scrollbars='+scroll+',resizable='+resize+',width='+intWidth+',height='+intHeigth+',left='+intLeft+',top='+intTop+'');
popup.focus();
}

function init_checkbox(strIDS)
{
arrIDS = strIDS.split(",");
var frm = document.forms['Form1'];
boolAllCheck = true;
for (var i=0;i<frm.elements.length;i++)
	{
	var e = frm.elements[i];
	if ((e.name == 'chkList') && (e.type=='checkbox'))
		{
		strValue = e.value;
		if (isValueInsideArray(strValue,arrIDS))
			{
			e.checked = true;
			highlight(e);
			}
		  else
			{
			boolAllCheck = false;
			}
		}
	}
if (frm.chkAll)
	{
	frm.chkAll.checked = boolAllCheck;
	}
}

function isValueInsideArray(strValue,arrList)
{
boolFind = false
for (x=0;x<arrIDS.length;x++)
	{
	strElement = arrList[x];
	strElement = replaceAll(strElement," ","");
	if (strElement == strValue)
		{
		boolFind = true;
		break;
		}
	}
return boolFind;
}

function replaceAll(strElement,strFind,strReplace)
{
while (strElement.indexOf(strFind) != -1)
	{
	strElement = strElement.replace(strFind,strReplace);
	}
return strElement;
}

function checkRow(theCheckbox)
{
if (theCheckbox.checked)
	{
	highlight(theCheckbox);
	}
  else
	{
	downlight(theCheckbox);
	}
	
var TB=TO=0;
var frm = document.forms['Form1'];

for (var i=0;i<frm.elements.length;i++)
	{
	var e = frm.elements[i];
	if ((e.name == 'chkList') && (e.type=='checkbox'))
		{
		TB++;
		if (e.checked)
			{
			TO++;
			}
		}
	}
if (TO==TB)
	{
	frm.chkAll.checked=true;
	}
else
	{
	frm.chkAll.checked=false;
	}
	
}

function highlight(E)
{
var ie = document.all?1:0
if (ie)
	{
	while (E.tagName!="TR")
		{
		E=E.parentElement;
		}
	}
  else
	{
	while (E.tagName!="TR")
		{
		E=E.parentNode;
		}
	}
if (E.className == "")
	{
	E.className = "H";
	}
  else
	{
	E.className = "H2";
	}
}

function downlight(E)
{
var ie = document.all?1:0
if (ie)
	{
	while (E.tagName!="TR")
		{
		E=E.parentElement;
		}
	}
  else
	{
	while (E.tagName!="TR")
		{
		E=E.parentNode;
		}
	}
if (E.className == "H")
	{
	E.className = "";
	}
  else
	{
	E.className = "dgAlternating1";
	}
}

function checkAll()
{
var frm = document.forms['Form1'];
for (var i=0;i<frm.elements.length;i++)
	{
	var e = frm.elements[i];
	if ((e.name == 'chkList') && (e.type=='checkbox'))
		{
		e.checked = frm.chkAll.checked;
		if (frm.chkAll.checked)
			{
			highlight(e);
			}
		else
			{
			downlight(e);
			}
		}
	}
}

function checkAtLeastOneCheck()
{
var boolAtLeastOneCheck = false;
var frm = document.forms['Form1'];
for (var i=0;i<frm.elements.length;i++)
	{
	var e = frm.elements[i];
	if ((e.name == 'chkList') && (e.type=='checkbox'))
		{
		if (e.checked)
			{
			boolAtLeastOneCheck = true;
			}
		}
	}
return boolAtLeastOneCheck;
}


function round (n, d) {
  n = n - 0; // force number
  if (d == null) d = 2;
  var f = Math.pow(10, d);
  n += Math.pow(10, - (d + 1)); // round first
  n = Math.round(n * f) / f;
  n += Math.pow(10, - (d + 1)); // and again
  n += ''; // force string
  return d == 0 ? n.substring(0, n.indexOf('.')) :
      n.substring(0, n.indexOf('.') + d + 1);
}

function isan(string,allowDec)
{
if (string == null)
	{
	string = '';
	}
if (string.length == 0)
	{
    return false;
    }
  else
	{
	for (var i=0;i < string.length;i++)
		{
		if (allowDec)
			{
			if ((string.substring(i,i+1) != '.') && (string.substring(i,i+1) != ','))
				{
				if ((string.substring(i,i+1) < '0') || (string.substring(i,i+1) > '9'))
					{
				    return false;
				    }
				}
			}
		  else
			{
			if ((string.substring(i,i+1) < '0') || (string.substring(i,i+1) > '9'))
				{
				return false;
				}
			}
		}
	return true;
	}
}
