function popup(URL) { day = new Date(); id = day.getTime(); eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=650,height=600,left = 100,top = 100');");}// End  --><!--

var wpid = 42;
var directory = '/future';

var wpid = 42;


var NS4 = (document.layers) ? 1 : 0;
var IE4 = (document.all) ? 1 : 0;
var ver4 = (NS4 || IE4);
window.updatefield = 0;

if(top.name.length == 0 || top.name == "MainFrame" || top.name.indexOf("eGmain") == 0) {
	top.name = "eGmain" + wpid;
}

function ow(loc, name, width, height, replace, statusbar, scrollbars)
{
// this function opens a window
	if(!width) width = 540;
	if(!height) height = 560;
	if(!name.length) name = "unknown";
	if(!replace) name += uniqid();
	if (name == "admin") {
		hostname = window.location.hostname;
		i = 0;
		while (hostname.indexOf(".") > -1 && i < 3) {
			hostname = hostname.replace(/\./, "_");
			i++;
		}
		name = "eG_" + hostname + directory.replace(/\//g, "_") + "_" + name;
		name = name.replace(/-/,"_");
	} else {
		name = "eG_" + window.name + "_" + name;
	}
	
	xpos = (screen.width - width)/2;
	ypos = (screen.height - height)/2;
	
	wi = window.open(loc, name, 'width=' + width + ',height=' + height + ',resizable=1,status=1,menubar=0,scrollbars=1,screenX='+xpos+',screenY='+ypos+",left="+xpos+",top="+ypos);
	if(ver4) wi.focus();
	return(wi);
}

function NewWizard(loc,width,height)
{
	xpos = (screen.width - width)/2;
	ypos = (screen.height - height)/2;
		
	wi = window.open(loc, 'newwindow' + uniqid(), 'width=' + width + ',height=' + height + ',resizable=1,status=0,menubar=0,scrollbars=1,screenX='+xpos+',screenY='+ypos+",left="+xpos+",top="+ypos);
	if(ver4) wi.focus();
}

function NewBrowseWindow(loc,width,height)
{
	xpos = (screen.width - width)/2;
	ypos = (screen.height - height)/2;
		
	wi = window.open(loc, 'egBrowseWindow', 'width=' + width + ',height=' + height + ',resizable=1,status=0,menubar=0,scrollbars=1,screenX='+xpos+',screenY='+ypos+",left="+xpos+",top="+ypos);
	if(ver4) wi.focus();
}

function uniqid()
{
        var t = new Date();
	var m = t.getTime();
	return(m % 90000);
}

function getRef(name)
{	
	name = "eG" + name + wpid;
	return(window.open("",name));
}

function BamfTo(name, loc, focus)
{
	rf = getRef(name);
	rf.location = loc;
	if(focus && ver4) rf.focus();
}

function BamfSize(loc,x,y) { ow(loc,"bamfsize",x,y,0); }
function AdminPanel(loc) { ow(loc,"admin",700,500,1); }
function NewWindow(loc,w,h,close) { ow(loc,"newwindow",w, h,close); }
function NewWindowName(loc,name,w,h,close) { ow(loc,name,w,h,close); }
function bamf(loc) { ow(loc,"justbamf",400,100,0); }
function BamfHelp(loc) { ow(loc,"bamfhelp",400,300,1); }
function BamfLink(loc) { self.location = loc; }
function BamfPanel(loc) { ow(loc,"bamfpanel",300,500,0); }
function BamfNewPanel(loc) { BamfPanel(loc); }
function BamfPicker(loc,w,h,field) {
	if(!w) w = 350;
	if(!h) h = 250;
	window.updatefield = field;
	wr = ow(loc,"picker",w,h,0);
}
function CloseBamf() { return true; } 
function PullDownStart() { return true; }
function MsMenuInit() { if(IE4) MsMenuInit2(); }
function SetCookie(Name,Val) { document.cookie = Name + "=" + Val + ";expires=Wed, 23-Dec-2000 03:24:00 GMT;path=/;domain=.egrail.com;"; }
function setcookie(Name,Val,MyDate) { document.cookie = Name + "=" + Val + ";expires=" + MyDate + ";path=/;domain=.egrail.com;"; }
function setcookie2(Name,Val,MyDate,Domain) { document.cookie = Name + "=" + Val + ";expires=" + MyDate + ";path=/;domain=" + Domain + ";"; }
function setcookie3(Name,Val,MyDate,Domain,Path) { document.cookie = Name + "=" + Val + ";expires=" + MyDate + ";path=" + Path + ";domain=" + Domain + ";"; }
function setsessioncookie(Name,Val,Domain,Path) { document.cookie = Name + "=" + Val + ";path=" + Path + ";domain=" + Domain + ";"; }

function OpenWindow(Loc) { 	
	window.open(Loc); 
}
function ReplaceText(Pre, Post) {
	if (!IE4) { alert("Sorry, the browser you are using does not support the functions needed\nto perform this action.  Currently they are only available in\nInternet Explorer 4 or later."); return; }	
	var Selection;
	var Current;
	if (!document.selection) { alert("Please select an area of text, and try again."); return; }
	Selection = document.selection.createRange();
	Current = Selection.text;
	if (Current == '') return;
	Selection.text = Pre + Current + Post;
	Selection.parentElement().focus();
}
function SpellCheck(Obj) {
	var MyForm = document.forms[0];
	var oval = MyForm.elements[Obj].value;
	var ct = ow(directory + "/login.html?" + escape(Obj) + "=" + escape(oval) + "&FormSwitch=SpellCheck|" + escape(Obj),"spelling",400,400,1);
	ct.focus();
	return;
}
				
function HiliteThis(Name, Image) { ChangeImage(Name, Image); return true; }
function RestoreThis (Name, Image) { ChangeImage(Name, Image); return true; }
function HiliteThread(Name, Image) { ChangeImage(Name, Image); }
function RestoreThread(Name, Image) { ChangeImage(Name, Image); }
						
function ChangeImage(Name, Image) {
	if (!document.images || Image == null) return false;
	document.images[Name].src = Image;
	return true;
}


function BamfMain(loc) {
	self.location = loc;
}


function BamfMainPanel(loc) {
        r = getRef("admin");
        x = r.frames["egrail"]
        if(x)
                x.location = loc;
        else
                r.location = loc;
}

function GetFormVarsAsArgs(formname) {
	if (!formname) formname = 0;
	elements = document.forms[formname].elements;
	args = '?';
	for (i = 0; i < elements.length; i++) {
		args += elements[i].name + '=' + escape(elements[i].value);
		if (i+1 < elements.length) {
                	args += '&';
		}
	}       
	return(args);   
}       

