// set the browser type
var appName = navigator.appName;
var appVersion = navigator.appVersion;
var isMac = appVersion.indexOf('Macintosh');
isMac = (isMac > -1) ? true : false;
var isIE5 = appVersion.indexOf('MSIE 5');
isIE5 = (isIE5 > -1) ? true : false;
var isIE4 = appVersion.indexOf('MSIE 4');
isIE4 = (isIE4 > -1) ? true : false;
var isIE = (isIE5 || isIE4) ? true : false;
var nsIndex = appName.indexOf('Netscape');
var isNS = (nsIndex > -1) ? true : false;
var isNS4 = appVersion.indexOf('4.');
isNS4 = ((isNS4 == 0) && isNS) ? true : false;
var isNS6 = appVersion.indexOf('5.');
isNS6 = ((isNS6 == 0) && isNS) ? true : false;
var isDOM = (document.getElementById) ? true : false;

var onloadScriptArray = new Array();

function ExecuteOnload() {
    for (var i = 0; i < onloadScriptArray.length; i++) {
        eval(onloadScriptArray[i]);
    }
    return(true);
}

window.onload = ExecuteOnload;

function SetOnloadScript(s) {
    onloadScriptArray.push(s);
    return(true);
}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  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=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/**************** REMOVED AFETR EWE 4.3 **************
function FilterContent(c) {
    c = c.replace(/"/g, '\<dblquote\>');
    c = c.replace(/'/g, '\<sglquote\>');
    return c;
}
 **************** REMOVED AFETR EWE 4.3 **************/

function UnFilterContent(c) {
    c = c.replace(/\<dblquote\>/g, '"');
    c = c.replace(/\<sglquote\>/g, "'");
    return c;
}

/**************** REMOVED AFETR EWE 4.3 **************
function EmptyWebEditProControl(webeditcontrol, formfield)
{
    formfield.value = FilterContent(webeditcontrol.TextHTML);
    return true;
}

var ewTimeout = false;
var ewControl;
var ewInitialValue;  // Used for determining if contents have been modified

// Set a variable with the initial content of the control so we can
// compare with it later and see if the user has made any edits.  This
// function is called immediately after the control is initialized.
// NOTE: We have to do it this way because the html output from control
//       may vary from invocation to invocation.  Therefore, it is
//       necessary to compare values within the *same* invocation.
function SetInitialWebEditProValue()
{
    ewInitialValue = FilterContent(ewControl.TextHTML);
}

// This function is necessary because the control needs time to initialize
// before its value can be properly set.
function FillWebEditProControl(value, webeditcontrol)
{
    // we want to wait for one second before performing this function
    if (ewTimeout) {
        ewControl.TextHTML = UnFilterContent(value);
        // Need exit current func to allow control to initialize before we can get contents.
        setTimeout("SetInitialWebEditProValue()", 1);
        return true;
    } else {
        ewInitialValue = "";
        ewControl = webeditcontrol;
        ewTimeout = setTimeout("FillWebEditProControl('" + value + "')", 1000);
    }
}

function WebEditControlHasChanged()
{
    return (FilterContent(ewControl.TextHTML) != ewInitialValue);
}
 **************** REMOVED AFETR EWE 4.3 **************/

var CheckFormAuxTests = new Array();

function CheckFormForChanges(url) {
    var msg = "You have made changes to this form.  Discard Changes?";
    var result = true;
    var changed = false;
    for (var i=0; (!changed && (i<CheckFormAuxTests.length)); i++)
        changed = eval(CheckFormAuxTests[i]);
        
    var d = document;
    for (var i=0; (!changed && (i<d.forms.length)); i++) {
        var f = d.forms[i];
        changed = IsFormChanged(f);
    }
    if (changed)
        result = confirm(msg);
        
    if (result && url)
        window.location = url;
            
    return result;
}
