function NavParent(url)
{
	if( window.opener )
		window.opener.location.href = url;
}

function NavParentAndClose(url)
{
	NavParent(url);
	window.close();
}

function RefreshParent()
{
	if( window.opener )
		window.opener.location.href = window.opener.location.href;
}

function RefreshParentAndClose()
{
	RefreshParent()
	window.close();
}

function SubmitParent()
{
	window.opener.document.forms[0].submit();
}

function SubmitParentAndClose()
{
	SubmitParent();
	window.close();
}

// Configure URL and window dimensions (width/height)
// To load via link, use something like below:
// <a href="javascript:modelesswin('http://www.google.com',600,400,0,0)">Click here</a>
function modelesswin(url,mwidth,mheight,mleft,mtop)
{
	if (document.all&&window.print) //if ie5+
		eval('window.showModelessDialog(url,"","help:0;resizable:1;scroll:1;unadorned:1;dialogWidth:'+mwidth+'px;dialogHeight:'+mheight+'px;status:0;center:0;dialogLeft:'+mleft+';dialogTop:'+mtop+'")')
	else
		eval('window.open(url,"","width='+mwidth+'px,height='+mheight+'px,resizable=1,scrollbars=0")')
}

function showModal( url, width, height, sizeable, scroll )
{
	var features = "dialogHeight:"+height+"px;dialogWidth:"+width+"px;center:1;help:0;resizable:"+sizeable+";scroll:"+scroll+";status:0;unadorned:1;";
	return window.showModalDialog( url, "", features );
}

/* Function to get the selected 'Value' from a control that has a series of options,
 *  such as a drop down list. */
function GetSelectedItem(selectCtl)
{
	var i;
	for( i = 0; i < selectCtl.options.length; i++ )
		if( selectCtl.options[i].selected )
			return selectCtl.options[i].value;
	
	return null;
}

function GetCheckedPartNos( tblName, chkCol, prtCol )
{
	var tbl = document.getElementById(tblName);
	if( tbl == null )
		return "";
		
	var rows = tbl.rows.length;
	var str = "";
	var qty = 0;

	for( i = 1; i < rows; i=i+1 )
	{
		if( tbl.rows(i).cells(chkCol).children(0).checked == true && tbl.rows(i).className != "tblHead" )
		{
			if( str.length > 0 )
				str += "|";
			str += tbl.rows(i).cells(prtCol).innerText;
		}
	}
	return str;
}

function GetCheckedRowIds( tblName, chkCol, prtCol )
{
	var tbl = document.getElementById(tblName);
	if( tbl == null )
		return "";
		
	var rows = tbl.rows.length;
	var str = "";
	var qty = 0;

	for( i = 1; i < rows; i=i+1 )
	{
		var chk = tbl.rows(i).cells(chkCol).children(0);
		if( chk != null && chk.checked == true && tbl.rows(i).className != "tblHead" )
		{
			if( str.length > 0 )
				str += "|";
			str += tbl.rows(i).id;
		}
	}
	return str;
}
function UserGroupSearch(path, controlname)
{
	if (path == '/') path = '';
	var val = showModal(path + '/Forms/Admin/UserGroupSearch.aspx', 420, 400, 0, 0 );
	if( val )
	{
	    document.getElementById(controlname.id).value = val;
		return true;
	}
	else
	{
		return false;
	}
}
function UserAccountSearch(path, controlname)
{
	if (path == '/') path = '';
	var val = showModal(path + '/Forms/Admin/AccountSearch.aspx', 420, 400, 0, 0);
	if( val )
	{
	    document.getElementById(controlname.id).value = val;
		return true;
	}
	else
	{
		return false;
	}
}
