function openInMe(url){
	//name = window.self.name;
	//x = 0;
	//if (name)
	//	x = 1;
	//else
	//	name = "_TBS";
	window.open (url, "_top");
}

// This one opens centered on top of the original window and is MODAL
function opencenteredmodal(url, width, height){
	var parentwidth;
	var parentheight;
	var cNewTop;
	var cNewLeft;
	var f;
	parentwidth = document.body.clientWidth;
	parentheight = document.body.clientHeight;
	cNewLeft = ((parentwidth/2) - (width/2)) + window.screenLeft;
	cNewTop = (parentheight/2) - (height/2) + window.screenTop;
	f = "dialogwidth:" + width + "px;dialogheight:" + height + "px;";
	f = f + "dialogtop:" + cNewTop + "px;dialogleft:" + cNewLeft + "px;";
	f = f + "status:no;scroll:yes;resizable:yes;help:no;";
	//return window.showModalDialog("/" + getPath() + "/openmodal.aspx",url,f);
	return window.showModalDialog(getPath() + "/openmodal.aspx",url,f);
	//window.showModalDialog(url, "", f);
	}

// This one fills the parent window and is MODAL
function fillcenteredmodal(url){
	var parentwidth;
	var parentheight;
	var cNewTop;
	var cNewLeft;
	var f;
	
	width = document.body.clientWidth - 6;
	height = document.body.clientHeight - 6;
	
	parentwidth = document.body.clientWidth;
	parentheight = document.body.clientHeight;
	cNewLeft = ((parentwidth/2) - (width/2)) + window.screenLeft;
	cNewTop = (parentheight/2) - (height/2) + window.screenTop;
	f = "dialogwidth:" + width + "px;dialogheight:" + height + "px;";
	f = f + "dialogtop:" + cNewTop + "px;dialogleft:" + cNewLeft + "px;";
	f = f + "status:no;scroll:yes;resizable:yes;help:no;";

	//return window.showModalDialog("/" + getPath() + "/openmodal.aspx",url,f);
	return window.showModalDialog(getPath() + "/openmodal.aspx",url,f);
	//window.showModalDialog(url, "", f);
	}

function getPath() {
	path = window.location.pathname;
	l = path.length;
	path = path.substr(1, l);
	l = path.indexOf("/");
	path = path.substr(0,l);
	if (path == "") return "";
	else return "/" + path;
	//return path;
}

function opencenteredwindow(url, width, height){
	var parentwidth;
	var parentheight;
	var cNewTop;
	var cNewLeft;
	var f;
	parentwidth = document.body.clientWidth; // Gets width of current window
	parentheight = document.body.clientHeight; // Gets height of current window
	cNewLeft = ((parentwidth/2) - (width/2)) + window.screenLeft; // Crazy stuff
	cNewTop = (parentheight/2) - (height/2) + window.screenTop; // Continued crazy stuff
	f = "width=" + width + ",height=" + height; // feature string
	f = f + ",top=" + cNewTop + ",left=" + cNewLeft;
	f = f + ",status=no,toolbar=no,menubar=no,location=yes,scrollbars=yes,resizable=yes";
	window.open(url,"",f); // open window
	//window.blur(); // puts the new window into focus after a postback from original window
	}
	
// This one is sized to fill the original window's work area
function fillparentwindow(url, name){
	var insetwidth;
	var insetheight;
	var insettop;
	var insetleft;
	var f;
	insetwidth = document.body.clientWidth + 12;
	insetheight = document.body.clientHeight - 6;
	insettop = window.screenTop;
	insetleft = window.screenLeft;
	f = "width=" + insetwidth + ",height=" + insetheight;
	f = f + ",top=" + insettop + ",left=" + insetleft;
	f = f + ",toolbar=0,titlebar=no,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0";
	window.open(url,name,f);
	//name.focus();
	window.blur();
	}
	
// These function are used with image buttons.
function buttonHover(theBTN) {
	document.getElementById(theBTN).style.border = "outset";
	document.getElementById(theBTN).style.borderWidth = "2px";
}

function buttonOut(theBTN) {
	document.getElementById(theBTN).style.border = "solid";
	document.getElementById(theBTN).style.borderWidth = "2px";
}

function buttonDown(theBTN) {
	document.getElementById(theBTN).style.border = "inset";
	document.getElementById(theBTN).style.borderWidth = "2px";
}

function buttonUP(theBTN) {
	document.getElementById(theBTN).style.border = "solid";
	document.getElementById(theBTN).style.borderWidth = "2px";
}
function telephoneformat(control){
	var sIn;
	var sOut = "";
	var i;

	sIn = control.value;
	if (sIn.length > 9){
		for (i=0; i < sIn.length; i++){
			switch (sIn.charAt(i)){
			case "0":
				sOut = sOut + sIn.charAt(i);
				break;
			case "1":
				sOut = sOut + sIn.charAt(i);
				break;
			case "2":
				sOut = sOut + sIn.charAt(i);
				break;
			case "3":
				sOut = sOut + sIn.charAt(i);
				break;
			case "4":
				sOut = sOut + sIn.charAt(i);
				break;
			case "5":
				sOut = sOut + sIn.charAt(i);
				break;
			case "6":
				sOut = sOut + sIn.charAt(i);
				break;
			case "7":
				sOut = sOut + sIn.charAt(i);
				break;
			case "8":
				sOut = sOut + sIn.charAt(i);
				break;
			case "9":
				sOut = sOut + sIn.charAt(i);
				break;
			default:
				break;
			}
		}
		if (sOut.length == 10) {
			control.value = sOut;
			return true;
		}
		else {
			alert("Not a valid Telephone number. Need Area Code, Prefix, and number. Example 3045554444");
			//control.value = "";
			control.focus();
			control.select();
			return false;
		}
	}
	else {
		alert("Not a valid Telephone number. Need Area Code, Prefix, and number. Example 3045554444");
		//control.value = "";
		control.focus();
		control.select();
		return false;
	}
}
