/********************************************************************

rhFramework Javascript Routines 1.0
Author: Rob Hatcher
Purpose: Contains various Javascript functions to aid ASP.NET programming

/***** newWin: Creates a new centered window named 'name' with content from 'url' *****/

	function newWin(url,name) {
		var args = 'left=' + (screen.availwidth)*.020 + ','
			+ 'top=' + (screen.availheight)*.010 + ','
			+ 'height=' + (screen.availheight)*.87 + ','
			+ 'width=' + (screen.availwidth)*.95 + ','
			+ 'toolbar=yes,resizable=yes,scrollbars=yes,status=yes'
		var nW=window.open(url,name,args);
		nW.focus();
		return nW;
	}

function getTopOffset(elem) 
{
	var oParent=elem.offsetParent;
	var offset=0;
	while (oParent !=null)
	{
		if (oParent.tagName == 'body') break; 
		if (oParent.tagName == 'BODY') break; 
		offset=offset+oParent.offsetTop;
		oParent=oParent.offsetParent;
	}
	return(offset);
}

function getLeftOffset(elem) 
{
	var oParent=elem.offsetParent;
	var offset=0;
	while (oParent !=null)
	{
		if (oParent.tagName == 'body') break; 
		if (oParent.tagName == 'BODY') break; 
		offset=offset+oParent.offsetLeft;
		oParent=oParent.offsetParent;
	}
	return(offset);
}

function kbSetFocus(ctlName) 
{
	document.forms[0].elements[ctlName].focus();
}

function kbInitFocus(ctlName)
{
	if (ctlName==null) {
		if (document.forms.length > 0)
		{
			var TForm = document.forms[0];
			for (i=0;i<TForm.length;i++)
			{
				if ((TForm.elements[i].type=="text")||
				(TForm.elements[i].type=="textarea")||
				(TForm.elements[i].type=="checkbox") ||
				(TForm.elements[i].type.toString().charAt(0)=="s"))
				{
					document.forms[0].elements[i].focus();
					break;
				}
			}
		}
	}
	else {
		document.forms[0].elements[ctlName].focus();
   }
}