/*OM*/
/*Change row colour*/
function sel(frm,cbox)
	{
	var ele=cbox
	while (ele.tagName!="TR")
		{ele=ele.parentNode;}
	if(cbox.checked)
		{ele.className="selbkg"}
	else
		{ele.className="dselbkg"}
	}
//Date text box Validation
function KeyPressCheck(that)
{
	window.alert("Please click on the link to Select Date");
	return false;
}

/*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)
	{
	var cnt = 0;
	var cboxes = eval("document." + frm.name + "." + chkname);
	if(!cboxes)
		{
		cnt = 0;
		}
	else
		{
		if(cboxes.length>0)
			{
			for(var m=0; m < cboxes.length; m++)
				{
				if(cboxes[m].checked == true)
					{cnt++;}
				}
			}
		else
			{
			if(cboxes.checked == true)
				{cnt = 1;}
			}
		}
			
	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)
	{
	var cnt = 0;
	var cboxes = eval("document." + frm.name + "." + chkname);
	if(!cboxes)
		{
		cnt = 0;
		}
	else
		{
		if(cboxes.length>0)
			{
			for(var m=0; m < cboxes.length; m++)
				{
				if(cboxes[m].checked == true)
					{cnt++;}
				}
			}
		else
			{
			if(cboxes.checked == true)
				{cnt = 1;}
			}
		}
	
	if(cnt >= 1)
		{return true;}
	else
		{
		alert("Please select one or more record to proceed...");
		return false;
		}
	}

/*Check if single checkbox is selected*/
function isSingleSelectedOld(frm, chkname, recs)
	{
	var cbox;
	var cnt = 0;
	if(recs == 0)
		{
		alert("no record selected");
		return false;
		}

	if(recs == 1)
		{
		cbox = eval("document." + frm.name + "." + chkname);
		if(cbox.checked == true)
			{cnt = 1;}
		}
	else
		{
		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 isAnySelectedOld(frm, chkname, recs)
	{
	var cbox;
	var cnt = 0;
	if(recs == 0)
		{
		alert("no record selected");
		return false;
		}
	
	if(recs == 1)
		{
		cbox = eval("document." + frm.name + "." + chkname);
		if(cbox.checked == true)
			{cnt = 1;}
		}
	else
		{
		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 Popup Window*/
var popUpWin5=0;
function popUpWindow5(URLStr,mywidth,myheight,myleft,mytop,myscroll,mymenu,myresize)
	{
	if(popUpWin5)
		{
		if(!popUpWin5.closed) 
			{popUpWin5.close();}
		}
	popUpWin5 = open(URLStr, 'popUpWin5', 'toolbar=no,location=no,directories=no,status=no,menubar=' + mymenu + ',scrollbars=' + myscroll + ',resizable=' + myresize + ',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;
		}
	}
*/

