function ChangeUser() {
	if (confirm('This will log you out and require user to login. Click OK to continue.')) { parent.location.href='login.asp' }
	}

function Logout() {
	if (confirm('You are about to log out from BOW. Click OK to confirm.')) { parent.location.href='logout.asp?validate=1' }
	}

function GetForm(frmName)
{
	el = GetFormInDocument(document, frmName);
	if (el != null) return el; 

	if (document.all == null)
		for (var i = 0; i < document.layers.length; i++) {
			el = GetFormInDocument(document.layers[i].document, frmName);
			if (el != null) return el;
		}
	return null;
}

function GetFormInDocument(inDoc, frmName)
{
	var elForm = null;
	with (inDoc) {
		elForm = forms[frmName];
		if (elForm != null) return elForm;

		for (var i = 0; i < forms.length; i++) {
			if (forms[i].name == frmName)
				return forms[i];
			}

		if (inDoc.all == null)
			for (var i = 0; i < inDoc.layers.length; i++) {
				el = GetFormInDocument(inDoc.layers[i].document, frmName);
				if (el != null) return el;
				}
		}
		return null;
}

function GetElementInDocument(inDoc, elementName)
{
	with (inDoc) {
		for (var i = 0; i < forms.length; i++) {
			if (forms[i].name == elementName) return forms[i];
			var el = GetElementInForm(forms[i], elementName)
			if (el != null) return el;
			}
		}
	return null;
}

function GetElementInForm(inForm, elementName)
{
	var el = null;
	with (inForm) {
		el = inForm.elementName;
		if (el != null) return el;
		for (var i = 0; i < elements.length; i++)
			if (elements[i].name == elementName)
				return elements[i];
		}
	return null;
}

function GetImageInDoc(inDoc, elementName)
{
	with (inDoc)
		for (var i = 0; i < images.length; i++)
			if (images[i].name == elementName) return images[i];
	return null;
}

function GetImage(elementname)
{
	var el = GetImageInDoc(document, elementname);
	if (el != null) return el;
	
	if (document.all == null)
		for (var i = 0; i < document.layers.length; i++) {
			el = GetImageInDoc(document.layers[i].document, elementname);
			if (el != null) return el;
		}

	return null;
}

function Focus(form_name, element_name)
{
	var el = GetElementInForm(GetForm(form_name), element_name);
	el.focus();
}

function openWindow(theURL, Width, Height)
{
	window.open(theURL, "popup", "status=yes,scrollbars=yes,width=" + Width + ",height=" + Height);
}

function findObj(n, d) { 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function showHideLayers() { //v3.0
  var i,p,v,obj,args=showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function swapImgRestore() { //v3.0
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
	var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function swapImage() { //v3.0
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
var showTime;
function show(oDiv) {
	clearTimeout(showTime);
	var elm = eval("document.all." + oDiv);
	elm.style.visibility="visible";
}
function hide(oDiv) {
	showTime = setTimeout(oDiv + '.style.visibility="hidden"',400);
}

function Href()
{
	if (string = document.selection.createRange().text)
	{
		href = prompt("Enter the URL to link to:", "http://");
		if (href != null)
		{
			document.selection.createRange().text = "<a href=\"" + href + "\">" + string + "</a>";
		}
	}
	else
	{
		alert("You must select a region of text first!");
	}
}

function Bold()
{
	if (string = document.selection.createRange().text)
	{
		document.selection.createRange().text = "<b>" + string + "</b>";
	}
	else
	{
		alert("You must select a region of text first!");
	}
}

function Italic()
{
	if (string = document.selection.createRange().text)
	{
		document.selection.createRange().text = "<i>" + string + "</i>";
	}
	else
	{
		alert("You must select a region of text first!");
	}
}

function datahandlerfollow(form) {
	var URL = document.ChooseApplicationFrm.ApplicationSelector.options[document.ChooseApplicationFrm.ApplicationSelector.selectedIndex].value;
	//document.location.href = "MemberList.asp?membergroup="+ URL;
	document.location.href = URL;
}
