/*OM*/
/*Change row colour*/
function sel(frm,cbox)
	{
	var ele=cbox
	while (ele.tagName!="TR")
		{ele=ele.parentElement;}
	if(cbox.checked)
		{ele.className="selbkg"}
	else
		{ele.className="dselbkg"}
	}

/*Select all checkboxes*/
function selectAll(frm, chkall, chkname)
	{
	var cboxes = eval("document." + frm.name + "." + chkname);
	if(cboxes != null)
		{
		if(cboxes.length>0)
			{
			for(var m=0; m < cboxes.length; m++)
				{
				cboxes[m].checked = chkall.checked;
				sel(frm, cboxes[m]);
				}
			}
		else
			{
			cboxes.checked = chkall.checked;
			sel(frm, cboxes);
			}
		}
	}

/*Check if single checkbox is selected*/
function isSingleSelected(frm, chkname, recs)
	{
	var cbox;
	var cnt = 0;
	if(recs == 0)
		{
		alert("no record selected");
		return false;
		}

	for(var m=1; m <= recs; m++)
		{
		cbox = eval("document." + frm.name + "." + chkname + "_" + m);
		if(cbox != null)
			{
			if(cbox.checked == true)
				{cnt++;}
			}
		}

	if(cnt == 1)
		{return true;}
	else
		{
		alert("Please select only a single record to proceed...");
		return false;
		}
	}

/*Check if any (1+) checkbox is selected*/
function isAnySelected(frm, chkname, recs)
	{
	var cbox;
	var cnt = 0;
	if(recs == 0)
		{
		alert("no record selected");
		return false;
		}

	for(var m=1; m <= recs; m++)
		{
		cbox = eval("document." + frm.name + "." + chkname + "_" + m);
		if(cbox != null)
			{
			if(cbox.checked == true)
				{cnt++;}
			}
		}

	if(cnt >= 1)
		{return true;}
	else
		{
		alert("Please select one or more record to proceed...");
		return false;
		}
	}

/*Open Popup Window*/
var popUpWin=0;
function popUpWindow(URLStr,mywidth,myheight,myleft,mytop,myscroll)
	{
	if(popUpWin)
		{
		if(!popUpWin.closed) 
			{popUpWin.close();}
		}
	popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=' + myscroll + ',resizable=no,copyhistory=yes,width='+mywidth+',height='+myheight+',left='+myleft+', top='+mytop+',screenX='+myleft+',screenY='+mytop+'');
	}

/*Open 2nd Popup Window*/
var popUpWin2=0;
function popUpWindow2(URLStr,mywidth,myheight,myleft,mytop,myscroll)
	{
	if(popUpWin2)
		{
		if(!popUpWin2.closed) 
			{popUpWin2.close();}
		}
	popUpWin2 = open(URLStr, 'popUpWin2', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=' + myscroll + ',resizable=no,copyhistory=yes,width='+mywidth+',height='+myheight+',left='+myleft+', top='+mytop+',screenX='+myleft+',screenY='+mytop+'');
	}


/*Check if single checkbox is selected*/
/*function isSingleSelected_bak(frm, chkname, recs)
	{
	if(recs == 0)
	  {
	  alert("no record");
	  return false;
	  }
	else
	  {
	  alert(eval("document." + frm.name + "." + chkname + "_" + 1));
	  alert("record found");
	  return false;
	  }
	
	var cboxes = eval("document." + frm.name + "." + chkname + "_" + 1);
	var cnt = 0;
	if(cboxes != null)
		{
		if(cboxes.length>0)
			{
			for(var m=0; m < cboxes.length; m++)
				{
				if(cboxes[m].checked == true)
					{cnt++;}
				}
			}
		else
			{
			if(cboxes.checked == true)
				{cnt++;}
			}
		}

	if(cnt == 1)
		{return true;}
	else
		{
		alert("Please select only a single row to proceed...");
		return false;
		}
	}
*/
