<!-- Start Script
var UTIL_NONE = "../pics/none.gif";

function util_bwcheck(){
   this.ver=navigator.appVersion; this.agent=navigator.userAgent
   this.dom=document.getElementById?1:0;
   this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
   this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
   this.ie7=(this.ver.indexOf("MSIE 7")>-1 && this.dom)?1:0;
   this.ie8=(this.ver.indexOf("MSIE 8")>-1 && this.dom)?1:0;
   this.ieX=(this.ver.indexOf("MSIE")>-1 && this.dom)?1:0; //catch all for IE so we don't have to update this after every IE version
   this.ie4=(document.all && !this.dom)?1:0;
   this.ie=this.ie4||this.ie5||this.ie6||this.ie7||this.ie8||this.ieX;
   this.mac=this.agent.indexOf("Mac")>-1;
   this.opera5=this.agent.indexOf("Opera 5")>-1;
   this.safari=this.agent.toUpperCase().indexOf("SAFARI")>-1;
   this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
   this.ns4=(document.layers && !this.dom)?1:0;
   this.nsver = 100;
   if ((pos = this.agent.indexOf("Netscape/")) >= 0) this.nsver = parseFloat(this.agent.substring(pos+9,this.agent.length),10);
   this.mzver = 100;
   if ((pos = this.agent.indexOf("rv:")) >= 0) this.mzver = parseFloat(this.agent.substring(pos+3,this.agent.length),10);
   this.bw=(this.ieX || this.ie8 ||this.ie7 || this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5 || this.safari || this.dom);
   return this
}

function util_isMacP() { return uIsMac; }
function util_isIeP() { return uIsIe; }
function util_isIe() { return uIsIe; }
function util_isMac() { return uIsMac; }
function util_isWin16() { return uIsWin16; }
function util_isSafari() { return util_bw.safari; }


function util_isWin16P() {
   var szPlatform;
   var pos;
   
   szPlatform = navigator.userAgent.toString();
   pos = szPlatform.indexOf("Win16");
   return (pos != -1) ? true : false;
   
}

var uIsWin16 = util_isWin16P();
var util_bw = util_bwcheck();
//var uIsIe = util_bw.ie || util_bw.dom;
/* above is ORIGINAL but util_bw.dom returns 1 even if you are in mozilla 
	Thus falsely identifying a Mozilla Browser as IE
	MODIFIED BY JMR 2005-03-04 Please look at.
*/
var uIsIe = util_bw.ie;
var uIsMac = util_bw.mac;

function util_browserVer() {
   var toRet;
   var curVe = 0;

   curVe = navigator.appVersion;
   if (curVe.indexOf("5.") >=0 ) {
      if (curVe.indexOf("5.0") >=0 ) {
        toRet = 5;
      } else {
        toRet = 5.5;
      }
   } else
   if (curVe.indexOf("4.") >=0 ) {
      toRet = 4;
   } else {
      toRet = 3;
   }

   return(toRet);
}

function util_getFrame(win, frameName) {
   if ((win != null) && (win.frames != null) && (frameName != null) && (frameName != "")) {
      for (var i=0; i<win.frames.length; i++) {
         //alert("getFrame " + i + ": '" + win.frames[i].name + "' '" + frameName + "'");
         if (win.frames[i] != null) {
            if ((win.frames[i].name != null) && (win.frames[i].name.toUpperCase() == frameName.toUpperCase())) {
      	      //alert("found !!");
      	      return(win.frames[i]);
            } else {
      	      var tmp = util_getFrame(win.frames[i], frameName);
      	      if (tmp != null) {
      	         return(tmp);
      	      }
      	   }
         }
      }
   }
   return(null);
}

function util_getFrameV(win, frameName) {
   if ((win != null) && (win.frames != null) && (frameName != null) && (frameName != "")) {
      for (var i=0; i<win.frames.length; i++) {
         //alert("getFrame " + i + ": '" + win.frames[i].name + "' '" + frameName + "'");
         if (win.frames[i] != null) {
            if ((win.frames[i].name != null) && (win.frames[i].name.toUpperCase() == frameName.toUpperCase())) {
      	      //alert("found !!");
      	      return(win.frames[i]);
            } else {
      	      var tmp = util_getFrameV(win.frames[i], frameName);
      	      if (tmp != null) {
      	         return(tmp);
      	      }
      	   }
         }
      }
   }
   return(null);
}


function util_getEvent(win) {
   for (var i=0; i<win.frames.length; i++) {
      if (win.frames[i].event != null) {
	      return(win.frames[i].event);
      } else {
	      var tmp = util_getEvent(win.frames[i]);
	      if (tmp != null) {
	         return(tmp);
	      }
      }
   }
   return(null);
}

function util_getFrameW(f) {
   if (!util_isIe() || util_isSafari()) {
      return(f.innerWidth);
   } else {
      return(f.document.body.clientWidth);
   }
}

function util_getFrameH(f) {
   if (!util_isIe() || util_isSafari()) {
      return(f.innerHeight);
   } else {
      return(f.document.body.clientHeight);
   }
}

var firstRun = 0;
function util_loadPage(f, url) {
   //check if double page mode is selected and cfg option to use flash for double page is selected
   if (url.indexOf('dual/dframe.htm') >= 0 && doublePageModeType == 2){  
      var reqMajorVer = 9; //Major release number
      var reqMinorVer = 0; //Minor release number
      var reqRevision = 0; //Revision number

      //check if users flash is installed and over version 9.0.0
      flashAvailable = DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision);
      if (flashAvailable){  
         url = "../dual/sflash.htm"; //load sflash into url instead of dframe.htm
      }
   }
   //if the url reference sframe.htm, flash.php or visualmode is set to 8 set the frame view to flash mode.
   if (firstRun > 1 && (url.indexOf('/dual/sframe.htm') >= 0 || url.indexOf('flash.php') >= 0 || (parent.contents && parent.contents.visualMode == 8)) && parent.contents && parent.contents.setArticleFrame){
      parent.contents.setArticleFrame(1);
   }else{
      firstRun++;
   }
   if (url.indexOf('load/phodir.htm') >= 0 && parent.contents && parent.contents.setArticleFrame){
      parent.contents.setArticleFrame(0);
   }
   if (f) {
      if (util_isIe()) {
         if (util_browserVer() == 3) {
   	      f.location = url;
         } else {
   	     f.location.replace(url);
         }
      } else {
         //var regEx = new RegExp(":", "gi");
         //if ((url != null) && (url!= "")) {
         //   url = url.replace(regEx, "%3A");
         //}
         
         var pos;
         if ((url != null) && (url!= "")) {
            var UUU;
            
            UUU = url.toString();
            pos = UUU.indexOf(":");
            if (pos > 6) {
               url = UUU.substring(0, pos) + "%3A" + UUU.substring(pos+1, 300);
               //alert(url);
            }
         }
               
         if (util_isWin16()) {
            //alert("Set Location");
            f.self.location = url;
         } else {
            //alert("Replace Location");
            // f.location.replace(url);
            f.location.href = url;
         }
      }
   }
}

function util_findClass(el, type, value) {
   temp = el;
   val = value.toUpperCase();

   while ((temp != null) && (temp.tagName != "BODY")) {
      //alert(type + ": " + eval("temp." + type) + " - value : " + value + " - name: " + eval("temp.name"));
      //if (eval("temp." + type).toUpperCase() == value.toUpperCase()) {
      if (temp.className.toUpperCase() == value.toUpperCase()) {
	      el = temp;
	      return el;
      }
      temp = temp.parentElement;
   }
   //alert("Not found");
   return null;
}

function util_getKeyCode(evt) {
   var toRet;

   if (util_isIe()) {
      toRet = window.event.keyCode;   
   } else {
      toRet = evt.which;
   }
   return(toRet);
}

function util_isShift(evt) {
   var shift = (util_isIe()) ? window.event.shiftKey : evt.modifiers & Event.SHIFT_MASK
   
   return(shift);
}

function util_isCtrl(evt) {
   var ctrl = (util_isIe()) ? window.event.ctrlKey : evt.modifiers & Event.CONTROL_MASK
   
   return(ctrl);
}

function util_isAlt(evt) {
   var alt = (util_isIe()) ? window.event.altKey : evt.modifiers & Event.ALT_MASK
   
   return(alt);
}


function util_getFileNameBase(fileName) {
   var base;

   if (fileName != null) {
      var len;

      len = fileName.length;
      base = fileName.substr(0, Math.max(0, len-4));
   } else {
      base = "";
   }

   return(base);
}

function util_padString(str, len, mode) {
   return(util_padStringEx(str, len, mode, "&nbsp;"));
}

function util_padStringEx(str, len, mode, pad) {
   var i;
   var toRet;
   
   if (mode != 0) {
      toRet = "";
   } else {
      toRet = str;
   }
   
   for (i=str.length; i<len; i++) {
      toRet = pad + toRet;
   }
   
   if (mode != 0) {
      toRet += str;
   }

   return(toRet);
}

function util_padInt(val, len) {
   var i, fact;
   var toRet;
   
   fact = 10;
   toRet = val;
   for (i=0; i<len; i++) {
      if (val < fact) {
	      toRet = "&nbsp;" + toRet;
      } 
      fact *= 10;
   }
      
   return(toRet);
}

function util_doubleBackSlash(str) {
   var out;
   var len;
   var j,i;

   j=0;
   out = new String("");
   len = str.length;
   for (i=0; i<len; i++) {
      ch = str.charAt(i); 
      if (ch == '\\') {
         out += "\\";
         j += 1;
      } else {
         out += ch;
         j++;
      }
   }
   return(out);
}

function util_clearBlanksBad_IEMAC(str) {
   var db = str.split(" ");
   var i,j,k;
   var out = "";

   for (i=0; (i<db.length) && (db[i] == ""); i++) { }
   for (j=db.length-1; (j>=0) && (db[j] == ""); j--) { }

   //alert(db.length + " - " + i + " - " + j);
   for (k=i; k<=j; k++) {
      //alert("'" + db[k] + "'");
      if (db[k] != "") {
         if (out != "") out = out + " ";
         out = out + db[k];
      }
   }
   return(out);
}

function util_clearBlanks(str) {
   return util_clearAllBlanks(str,0);
}
function util_clearAllBlanks(str,intern) {
   var db, sss;
   var i,j,k;
   var out = "";

   if (str != "") {
      sss = str.toString();
      db = sss.split(" ");
      
      for (i=0; (i<db.length) && (db[i] == ""); i++) { }
      for (j=db.length-1; (j>=0) && (db[j] == ""); j--) { }
   
      //alert(db.length + " - " + i + " - " + j);
      for (k=i; k<=j; k++) {
         //alert("'" + db[k] + "'");
         if (db[k] != "") {
            if (intern != 1 && out != "") out = out + " ";
            // if (out != "") out = out + " ";
            out = out + db[k];
         }
      }
   } else {
      out = str;
   }
   
   return(out);
}

function util_getFloat(val, size) {
   var str1, str2;
   var pos;
   var localVal;
   var toRet;
   var fact;

   fact = Math.pow(10, size);
   str1 = val.toString();
   pos = str1.indexOf(".")
   if (pos != -1) {
      //return(str1.substring(0, pos+size+1));
      localVal = parseFloat(val);
      localVal = localVal * fact + 0.5;
      str1 = localVal.toString();      
      pos = str1.indexOf(".");
      if (pos != -1) {
         str2 = str1.substring(0, pos+1);
         localVal = parseFloat(str2);
         toRet = localVal / fact;
      } else {
         localVal = parseFloat(str1);
         toRet = localVal / fact;
      }
   } else {
      toRet = str1;
   }

   return(toRet);
}

function util_parseWinDim(w, h) {
   var strW = w;
   var strH = h;

   if (strW.toUpperCase() == "MAX") {
      this.w = screen.availWidth - 10;
   } else {
      this.w = w;
   }

   if (strH.toUpperCase() == "MAX") {
      this.h = screen.availHeight - 28;
   } else {
      this.h = h;
   }

   return(this);
}

function util_getImgDim(w, h, box) {
   if ( (h!=0) && (w!=0) ) {
      if (h) {
         var fact = w / h;

         if (w > h) {
            this.w = box;
            this.h = Math.round(box / fact);
         } else {
            this.w = Math.round(box * fact);
            this.h = box;
         }
      } else {
         this.w = 0;
         this.h = box;
      } 
   } else {
         this.w = box;
         this.h = 0;
   }
   //alert(w + " " + h + " --> " + this.w + " " + this.h);
   return(this);
}


function util_resizeWindow(win, w, h) {
   if (!util_isIe()) {
      win.resizeTo(w, h);
   } else {
      //alert(w + " - " + h);
      //win.outerWidth = w;
      //win.outerHeight = h;      
      win.innerWidth = w;
      win.innerHeight = h;      
   }
}

function util_convertChar(str, ch1, ch2) {
   var out;
   var len,j,i;
   var ch;
   j=0;
   out = new String("");
   len = str.length;
   for (i=0; i<len; i++) {
      ch = str.charAt(i); 
      if (ch == ch1) {
         out += ch2;
         j += 3;
      } else {
         out += ch;
         j++;
      }
   }
   
   return(out);
}


function __util_getMousePosX(w) {
   
   if (w!=null) {
      if (util_isIe()) {
         return (w.event.x); 
      } else {
         return (w.event.screenX);  
      }
   }
   return (-1);   
}   

function util_getMousePosX(evt) {
   
   if (util_isIe()) {
      if (evt!=null) {
         return (evt.x); 
      }
   } else {
      if (evt!=null) {
         return (evt.screenX);  
      }
   }
   return (-1);   
}   

function util_getMousePosY(evt) {
   
   if (util_isIe()) {
      if (evt!=null) {
         return (evt.y); 
      }
   } else {
      if (evt!=null) {
         return (evt.screenY);  
         
      }
   }
   return (-1);
}

function util_MoveWindow(w, x, y) {
   
   if (w!=null) {
      if (util_isIe()) {
         //alert("Moving to : " + x + " - " + y);
         w.moveTo(x, y);
      } else {
         w.moveTo(x, y);
      }
   } else {
      //alert("Window NULL");
   }
}   

function util_isSame(str1, str2) {
   var S1, S2;
   
   S1 = "";
   S2 = "";
   if (str1 != "") {
      S1 = str1.toUpperCase();
   }
   if (str2 != "") {
      S2 = str2.toUpperCase();
   }
   
   return(S1 == S2);
}

function util_CorrectMargin(where,what,textVal,StSindex,ruleIndex) {
  if(util_isIe()) {
     if (textVal != "" && where.indexOf("BODY") >= 0) {
        var listComp = textVal.split(" ");
        var toWrite =""
        for (var i=0;i<listComp.length;i++) {
           var num = parseInt(listComp[i]);
           num += 10;
        
           toWrite += num + "px "
        }
        if (toWrite != "" && StSindex >= 0) {
           document.styleSheets[StSindex].addRule(where,what + ":"+toWrite);
           //alert(where + what + textVal + " - " +listComp.length + " - " + toWrite);
        }
     }
  }
}

var utilStS = -1;
var StStext = null;
function util_GetStyle(where,what) {
   var findAny = false;
   var toWrite = null;
   var callBack = null;
   StStext = null;
   if (where.substring(0,1)=="*") {
      findAny=true;
      callBack = where.substring(1,20);
   }
   utilStS = -1

   if (util_isIe()) { // && !util_isMac()) {
      for (var i=0;i<document.styleSheets.length;i++) {
         // toWrite += i + " " + document.styleSheets[i] +"\n";
         var uptoRule = document.styleSheets[i].rules.length;
                //alert (" rules:"+uptoRule);
         for (var j=0;j<uptoRule;j++) {
            // toWrite += " " +j + " " + document.styleSheets[i].rules[j].selectorText +"\n";
            if (findAny || document.styleSheets[i].rules[j].selectorText == where) {
               var valw = eval("document.styleSheets[i].rules[j].style."+ what)
                //alert (valw);
               if (valw) {
                  if (callBack && callBack != "") {
                     eval(
                     callBack + "('" + document.styleSheets[i].rules[j].selectorText +
                     "','"+ what +
                      "','"+valw+"', " + i + " , " +j+");")
                  }
                  toWrite = valw;
                  utilStS = i;
                  if (findAny) StStext = document.styleSheets[i].rules[j].selectorText;
               }
            }
         }
      }
   }
   return toWrite;
}

function util_CenterPage(winW, winH) {
   var maxW, maxH, posW, posH;
   
   posW = 0;
   posH = 0;
   maxW = screen.availWidth;
   maxH = screen.availHeight;
   
   if ((winW == null) || (winW == "")) {
      winW = screen.availWidth;
   }
   if ((winH == null) || (winH == "")) {
      winH = screen.availHeight;
   }
   //alert(maxW + " - " + maxH + "\n" + winW + " - " + winH);
   
   if ((maxW > 0) && (maxH > 0) && (winW > 0) && (winH > 0)) {
      if (maxW > winW) {
         posW = Math.round((maxW - winW) / 2)
      } else {
         posW = 0;
      }
      
      if (maxH > winH) {
         posH = Math.round((maxH - winH) / 2)
      } else {
         posH = 0;
      }
      
      //alert(posW + " - " + posH);
      util_MoveWindow(window, posW, posH);
   }
}

function util_ShowForm(fName) {
   var toW, f, e;
   
   toW = "";
   f = eval("document." + fName);
   
   if (f != null) {
      toW += "Action : " + f.action + "\n";
      
      e = f.elements;
      if (e != null) {
         for (i=0; i<e.length; i++) {
            toW += e[i].name + ": " + e[i].value + "\n";
         }
      }
   }
   
   return(toW);
}

function util_ChangeCasing(val, mode) {
   var valOK;
   
   valOK = val;
   if (val != "") {
      if (mode == "1") {
         valOK = val.toUpperCase();
      } else if (mode == "-1") {
         valOK = val.toLowerCase();
      }
   } 
   
   return(valOK);
}

function util_getU(label, shortcut) {
   var upperL, upperS, sPos, sLen, toRet;
   
   toRet = label;
   if ((label != "") && (shortcut != "")) {
      upperL = label.toUpperCase();
      upperS = shortcut.toUpperCase();
      
      sPos = upperL.indexOf(upperS);
      //alert(upperL + " - " + upperS + " - " + sPos);
      if (sPos >= 0) {
         toRet = label.substring(0, sPos) + "<U>" + label.substring(sPos, sPos + shortcut.length) + "</U>" + label.substring(sPos + shortcut.length, 200);
      }
   }
   
   return(toRet);
}

function util_GetAdress(url) {
   var toRet, par, par1, subst;

   toRet = "";   
   par = url.indexOf("?")
   subst = "";
   if (par >= 0) {
      par1 = url.indexOf("&")
      /* Extract from par to par1 or the end of the line */
      if (par1 >= 0) {
         subst = url.substring(par, par1);
      } else {
         subst = url.substr(par);
      }
      //alert(subst);

      /* Remove p= from subst */
      par1 = subst.indexOf("=");
      toRet = subst;
      if (par1 >= 0) {
         toRet = subst.substr(par1+1);
      }
      toRet = "/" + toRet + "/";
      
   } else {
     toRet = "/_address_localhost:5001_/";
   }

   return(toRet);
}

function noBadChars(str) {
   var out;
   var len,j,i, index;
   var ch;
   var from = "|,.;:%'";
   var to   = "       ";

   j=0;
   out = new String("");
   len = str.length;
   for (i=0; i<len; i++) {
      ch = str.charAt(i); 
      
      index = from.indexOf(ch);
      if ((index >= 0) && (index < to.length)) {
         out += to.charAt(index); ;
         j++;
      } else {
         out += ch;
         j++;
      }
   }
   
   return(out);
}

function onlyAlphaNum(str) {
   var out;
   var len,j,i;
   var ch, chCode;

   j=0;
   out = new String("");
   len = str.length;
   for (i=0; i<len; i++) {
      ch = str.charAt(i);
      chCode = str.charCodeAt(i);
      
      if (((chCode >= 48) && (chCode <= 57)) || 
          ((chCode >= 65) && (chCode <= 90)) ||
          ((chCode >= 97) && (chCode <= 122)))
      {
         out += ch;
      } else {
         out += " ";
      }
      j++;
   }
   
   return(out);
}

function util_escapeFlag(inStr) {
	var outStr, re;
   re = /-/gi;
   //alert(re);
	//outStr = inStr.replace(re,"%2D");
	outStr = inStr.replace(re,"%20");
	//alert(outStr);
   re = /\//gi;
	outStr = outStr.replace(re,"%2F");
	return outStr;
}

function util_doubleBackSlash1(Str) {
   var re = /\\/gi;
   Str = Str.replace(re, "\\\\");
   return Str;
}

/*
 * Handle quick search string
 * Events are attached on input form in load/pagectrl.js (function loadData)
 */
var initialString = null;

function util_searchHasFocus( ) {
   var inputString   = this.value;
   
   // If initial string has not been initialized
   // save input text to reset it onBlur if input
   // input text is empty
   if( initialString == null ) {
      initialString = inputString;
   }
   
   // Empty input text
   if( inputString == initialString ) {
      this.value = '';
   }
}

function util_searchLostFocus(  ) {
   var inputString   = this.value;
   
   // If input text is empty restore it with saved string
   if( inputString == '' ) {
      this.value = initialString;
   }
}
// -- End --

/*
function util_ReplaceStr(str, toRemove, to) {
   var toRet, pos;
   
   toRet = str;
   if ((str != "") && (toRemove != "")) {
      pos = str.indexOf(toRemove);
      if (pos >= 0) {
         toRet = cmd.substring(0, pos) + cmd.substring(pos+toRemove.length, str.length);
      }
   }
   
   return(toRet);
}
*/

/* correct margins for ie */
// util_GetStyle("*util_CorrectMargin","margin");
// End Script -->


function util_createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function util_readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function util_eraseCookie(name) {
	createCookie(name,"",-1);
}

