function wordalert(storyurl,pdfsize,name){
msg="The file called \"" + name + "\" you are about to open is " + pdfsize + " in size. Depending on your internet connection, this file may take some time to download. To view a Word document, you must have Microsoft Word. If you are using a download manager, follow its instructions. ";
if(confirm(msg))self.location=storyurl;
}


//international gateway
function showpage(whichpage){
newwin=window.open(whichpage,"Gateway");
newwin.focus();
}


//rev:mm81402
function pdfalert(storyurl,pdfsize,name){
msg="The file called \"" + name + "\" you are about to open is " + pdfsize + " in size. Depending on your internet connection, this file may take some time to download. To view a PDF document, you must have Adobe Acrobat Reader. You can download Acrobat Reader free. Once you install Acrobat Reader, click the link to the PDF document. If your using a download manager, follow its instructions. ";
if(confirm(msg))self.location=storyurl;
}

//rev:mm8902
function excelalert(docurl,filesize,doctitle){
msg="The file called \"" + doctitle + "\" you are about to open is " + filesize + " in size. Depending on your internet connection, this file may take some time to download. To view an Excel document, you must have Microsoft Excel. If you are using a download manager, follow its instructions.";
if(confirm(msg))self.location=docurl;
}

//mm8902
function zipexcelalert(docurl,filesize,doctitle){
msg="The file called \"" + doctitle + "\" you are about to open is " + filesize + " in size. Depending on your internet connection, this file may take some time to download. To view a zipped document requires capability to \"UnZip\" files using WinZip, PkZip, etc.; follow the application\'s instructions. Then to view the unzipped Excel document, you must have Microsoft Excel. If you are using a download manager, follow its instructions.";
if(confirm(msg))self.location=docurl;
}

function powerpointalert(storyurl,pdfsize,name){
msg="The file called " + name + " you are about to open is " + pdfsize + " in size. Depending on your internet connection, this file may take some time to download. To view PowerPoint presentations, you must have PowerPoint installed on your computer. If you do not have PowerPoint installed but you do have an Office 2000 or Office XP installer CD-ROM, install PowerPoint from the CD-ROM. PowerPoint is also available for purchase from most computer retailers. If your using a download manager, follow its instructions. Microsoft Internet Explorer (MSIE) 5.5: The PowerPoint document will open within the browser window. MSIE 5.0 and earlier: PowerPoint will launch in a separate window and display the document. Or you may be prompted to open the document from its current location or save it to your computer. Choose your preference and continue.";
if(confirm(msg))self.location=storyurl;
}

function interstitial(storyurl){
window.open(storyurl,'mywindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=300,height=400');
}

function wirelessinterstitial(storyurl){
window.open(storyurl,'mywindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=300,height=400');
}

// this is used for java pop up windows 
// (see jason with questions)
function win(fileName) {
     myWin = window.open('','myWindow','scrollbars=no,directories=no,status=no,resizable=no,toolbar=no,copyhistory=no,location=yes,menubar=no,width=287,height=187,scrollbars=no,top=15,left=15')
     myWin.location.href = fileName;
}

// jason added this on 09/25/03 to keep code with consumers as we start to cross
// over consistant.  Using this with consumer interstitial (mst=interstitial2.html)
function popINTER(path) {
     myWin = window.open('','myWindow','scrollbars=auto,directories=no,status=no,resizable=no,toolbar=no,copyhistory=no,location=yes,menubar=no,width=340,height=255,top=15,left=15')
     myWin.location.href = path;
}


//mm061902
//for popup window, pass: ('[url]',[desired winHeight],[desired winWidth])
//for parent window insert: <body...onUnload="closeWin();">

var newWin, nameSuffix = 0; 

function openAnyWin(url){ 
    winHeight = (arguments.length >= 2)? parseInt(arguments[1]) : 580;
    winWidth = (arguments.length >= 3)? parseInt(arguments[2]) : 780;
    


    if(newWin && !newWin.closed){
        newWin.close(); 
        newWin = null; 
    } 

    nameSuffix = (nameSuffix == 1)? 0 : 1;

    newWin = window.open(url, "popup" + nameSuffix, "height=" + winHeight + ",width=" + winWidth + ",resizable=yes,scrollbars=1,left=100,top=100");
}   

function closeWin(){
    if(newWin && !newWin.closed){ 
        newWin.close(); 
        newWin = null; 
    } 
} 


function Starttest(page) {
  OpenWin = open(page, "CtrlWindow", "toolbar=no,menubar=no,location=no,status=no,scrollbars=yes,resizable=yes,width=500,height=600,left=90,top=0");
}

//
// NewWindow PopUp
// added by jason
// ex: [a href="javascript:NewWindow
// ('/images/6_11.jpg','611','270','213','center','front');"]
// 
//
var win=null;

function NewWindow(mypage,myname,w,h,pos,infocus){
if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}
settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes";win=window.open(mypage,myname,settings);
win.focus();
}

//mm082802
function goThere(form){
  var linkList=form.selectThis.selectedIndex
  if(!linkList==""){window.location.href=form.selectThis.options[linkList].value;}
}
    
//mm082902
function externalSiteInterstitial(storyurl){
window.open(storyurl,'mywindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=300,height=300');
}

// added for trouble downloading popups...
// just point to html file
// see jason for questions
function pop(fileName) {
     myWin = window.open('','myWindow','scrollbars=no,directories=no,status=no,resizable=yes,toolbar=no,copyhistory=no,location=yes,menubar=no,width=300,height=330,scrollbars=yes,top=15,left=15')
     myWin.location.href = fileName;
}
// image popup call (jason)
function store(fileName) {
     myWin = window.open('','myWindow','scrollbars=no,directories=no,status=no,resizable=yes,toolbar=no,copyhistory=no,location=yes,menubar=no,width=400,height=520,scrollbars=yes,top=15,left=15')
     myWin.location.href = fileName;
}
// image popup call (jason)
// toolbox, price list, palm instructions
//
function instructions(fileName) {
     myWin = window.open('','myWindow','scrollbars=no,directories=no,status=no,resizable=yes,toolbar=no,copyhistory=no,location=yes,menubar=no,width=470,height=500,scrollbars=yes,top=15,left=15')
     myWin.location.href = fileName;
}


var wpid = 1;
var directory = ''

var wpid = 1;

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(!name.length) name = "unknown";
        if(!replace) name += uniqid();
        name = "eG" + name;
        wi = window.open(loc, name, 'width=' + width + ',height=' + height + ',resizable=1,status=1,menubar=0,scrollbars=1');
        if(ver4) wi.focus();

        return(wi);
}

function NewWizard(loc,width,height)
{
        wi = window.open(loc, 'newwindow' + uniqid(), 'width=' + width + ',height=' + height + ',resizable=1,status=0,menubar=0,scrollbars=1');
        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,0); }
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;
}

// Kuba added this to keep framed pages in frames
function stayInFrame()
{
    if(top.location == location)
    {
        top.location.href = '/index.html';
    }
}
