var whatBrowser = navigator.appName
var whatVer = parseInt(navigator.appVersion.charAt(0))
var bOk = false
var dOk = false

// Decide browser version
var ns4 = (document.layers)? true:false;
var ns6 = (document.getElementById)? true:false;
var ie4 = (document.all)? true:false;
var ie5 = false;

var calWin, helpWin, mapWin, searchWin, xWin
var theWin, theNextWin


// Microsoft Stupidity Check(tm).
if (ie4) {
	if ((navigator.userAgent.indexOf('MSIE 5') > 0) || (navigator.userAgent.indexOf('MSIE 6') > 0)) {
	   whatVer = 5
		ie5 = true;
	}
	if (ns6) {
	   ns6 = false;
	}
}

if ((whatBrowser == "Netscape" && whatVer > 2) || (whatBrowser == "Microsoft Internet Explorer" && whatVer > 3))
   { bOk = true }

if ((whatBrowser == "Netscape" && whatVer > 3) || (whatBrowser == "Microsoft Internet Explorer" && whatVer > 3))
   { dOk = true }

function upWinXY(winName,whatWin,winX,winY,scrollB,blnStatusBar,blnResizable) {
   var strScrollBars = 'no'
   var strStatus = 'no'
   var strResizable = 'no'

   if (scrollB) { strScrollBars = 'yes' }
   if (blnStatusBar) { strStatus = 'yes' }
   if (blnResizable) { strResizable = 'yes' }

   eval("if (("+winName+") && (!"+winName+".closed)) { "+winName+".close() }")

   if (ie4 || ie5) {
      eval(winName+" = window.open(whatWin,'','screenX=10,screenY=10,status="+blnStatusBar+",toolbar=no,location=no,resizable="+strResizable+",copyhistory=no,menubar=no,scrollbars="+strScrollBars+",width="+winX+",height="+winY+"')")
   }
   else {
      eval(winName+" = window.open(whatWin,'"+winName+"','screenX=10,screenY=10,status="+blnStatusBar+",toolbar=no,location=no,resizable="+strResizable+",copyhistory=no,menubar=no,scrollbars="+strScrollBars+",width="+winX+",height="+winY+"')")
   }
   if (whatWin.indexOf('http') < 0 ) {
     eval(winName+".moveTo(10,10)")
   }
}


//from menu.js
function imageOn(whatImage)
{
   if (bOk)
   { document [whatImage].src = eval(whatImage + "on.file") }
}

function imageOff(whatImage)
{
   if (bOk)
   { document [whatImage].src = eval(whatImage + "off.file") }
}

//old win.js functions
function launchWin(whatWin,addField,whatSize)  {

   var x = 500
   var y = 340

   if ((bOk) && (theWin) && (!theWin.closed))
      { theWin.close() }

   if (whatSize > 0)
   {
      if (whatVer > 3)
      {
        x = Math.round((whatSize/100) * screen.width)
        y = Math.round((whatSize/100) * screen.height)
      }
   }

   var winToLaunch = null

   if (addField == "N")
      { winToLaunch = whatWin }
   else
      { winToLaunch = whatWin + document.searchForm.keywords.value }

   if (whatBrowser == "Microsoft Internet Explorer")
      { theWin = window.open(winToLaunch,"", "status=no,toolbar=no,location=no,resizable=no,copyhistory=no,menu=no,scrollbars=yes,width="+x+",height="+y) }
   else
      { theWin = window.open(winToLaunch,"theWin", "status=no,toolbar=no,location=no,resizable=no,copyhistory=no,menu=no,scrollbars=yes,width="+x+",height="+y) }

   moveWinToStandardLoc(theWin)

   theWin.focus()
}

function LAUNCHWIN(whatWin,addField,whatSize) {
  launchWin(whatWin,addField,whatSize)
}

function launchWinXY(whatWin,winX,winY,scrollB) {
   if ((bOk) && (theWin) && (!theWin.closed))
      { theWin.close() }

   if (whatBrowser == "Microsoft Internet Explorer")
      { theWin = window.open(whatWin,"", "screenX=10,screenY=10,status=no,toolbar=no,location=no,resizable=no,copyhistory=no,menu=no,scrollbars="+scrollB+",width="+winX+",height="+winY) }
   else
      { theWin = window.open(whatWin,"theWin", "screenX=10,screenY=10,status=no,toolbar=no,location=no,resizable=no,copyhistory=no,menu=no,scrollbars="+scrollB+",width="+winX+",height="+winY) }

   moveWinToStandardLoc(theWin)
}

function moveWinToStandardLoc(winObj) {
  if (whatVer > 3) { winObj.moveTo(10,10) }
}

function closeWin() {
   if (bOk)
      {
      if ((theWin) && (!theWin.closed))
         {
         theWin.close()
         theWin = 0
         }
      }
   else
      { theWin.close() }
}

function launchNextWinXY(whatWin,winX,winY,scrollB)  {
   if (theNextWin) { theNextWin.close() }

   if (whatBrowser == "Microsoft Internet Explorer")
      { theNextWin = window.open(whatWin,"", "status=no,toolbar=no,location=no,resizable=no,copyhistory=no,menu=no,scrollbars="+scrollB+",width="+winX+",height="+winY) }
   else
      { theNextWin = window.open(whatWin,"theNextWin", "status=no,toolbar=no,location=no,resizable=no,copyhistory=no,menu=no,scrollbars="+scrollB+",width="+winX+",height="+winY) }

   moveWinToStandardLoc(theNextWin)
}

function closeNextWin() {
   if (bOk)
      {
      if ((theNextWin) && (!theNextWin.closed))
         {
         theNextWin.close()
         theNextWin = 0
         }
      }
   else
      { theNextWin.close() }
}

function closeMe() {
   if (bOk) { opener.closeWin() }
   else { self.close() }
}

function noObjWinNoScroll(whatWin,x,y)  {
  var strWin
  strWin = "screenX=10,screenY=10,"
  strWin = strWin + "status=no,toolbar=no,"
  strWin = strWin + "location=no,resizable=no,"
  strWin = strWin + "copyhistory=no,menu=no,"
  strWin = strWin + "scrollbars=no,width=" + x + ",height=" + y
  window.open(whatWin,"",strWin)
}

function noObjWin(whatWin,x,y)  {
  var strWin
  strWin = "screenX=10,screenY=10,"
  strWin = strWin + "status=no,toolbar=no,"
  strWin = strWin + "location=no,resizable=no,"
  strWin = strWin + "copyhistory=no,menu=no,"
  strWin = strWin + "scrollbars=yes,width=" + x + ",height=" + y
  window.open(whatWin,"",strWin)
}

function containsInvalidCharacters(strString) {
	return ((strString.indexOf("\"") >= 0) || (strString.indexOf("<") >= 0) || (strString.indexOf(">") >= 0));
}