var ua=navigator.userAgent.toLowerCase();
var gecko=false;
var webkit=false;
if (ua.indexOf("gecko")>0) gecko=true;
if (ua.indexOf("webkit")>0) webkit=true;
function cacheHost() { var c=Math.floor(Math.random()*10)+1; return "http://cache"+c+".theglobalweb.com"; }
var defimage=new Image(222,46);
defimage.src=cacheHost()+"/m/0.jpg";
var obj=document.getElementsByTagName("label");
for (var i=0; i<obj.length; i++) {
  if (obj[i].className=="mlabel") {
    obj[i].onmouseover=function(e) { this.style.color="#006000"; this.style.borderBottom="1px dotted #006000"; }
    obj[i].onmouseout=function(e) { this.style.color="#009000"; this.style.borderBottom="1px dotted #009000"; }
  }
}
var obj=document.getElementsByTagName("button");
for (var i=0; i<obj.length; i++) {
  if (obj[i].className=="button") {
    obj[i].onmouseover=obj[i].onmouseup=function(e) {
      if (parseInt(this.getAttribute("enabled"))<1) return;
      this.style.backgroundPosition="-82px 0px";
      if (gecko) this.style.paddingTop="0px";
    }
    obj[i].onmouseout=function(e) {
      if (parseInt(this.getAttribute("enabled"))<1) return;
      this.style.backgroundPosition="0px 0px";
      if (gecko) this.style.paddingTop="0px";
    }
    obj[i].onmousedown=function(e) {
      if (parseInt(this.getAttribute("enabled"))<1) return;
      this.style.backgroundPosition="-164px 0px";
      if (gecko) this.style.paddingTop="1px";
    }
  }
  if (obj[i].className=="widebutton") {
    obj[i].onmouseover=obj[i].onmouseup=function(e) {
      if (parseInt(this.getAttribute("enabled"))<1) return;
      this.style.backgroundPosition="-102px 0px";
      if (gecko) this.style.paddingTop="0px";
    }
    obj[i].onmouseout=function(e) {
      if (parseInt(this.getAttribute("enabled"))<1) return;
      this.style.backgroundPosition="0px 0px";
      if (gecko) this.style.paddingTop="0px";
    }
    obj[i].onmousedown=function(e) {
      if (parseInt(this.getAttribute("enabled"))<1) return;
      this.style.backgroundPosition="-204px 0px";
      if (gecko) this.style.paddingTop="1px";
    }
  }
  if (obj[i].className=="xwidebutton") {
    obj[i].onmouseover=obj[i].onmouseup=function(e) {
      if (parseInt(this.getAttribute("enabled"))<1) return;
      this.style.backgroundPosition="-122px 0px";
      if (gecko) this.style.paddingTop="0px";
    }
    obj[i].onmouseout=function(e) {
      if (parseInt(this.getAttribute("enabled"))<1) return;
      this.style.backgroundPosition="0px 0px";
      if (gecko) this.style.paddingTop="0px";
    }
    obj[i].onmousedown=function(e) {
      if (parseInt(this.getAttribute("enabled"))<1) return;
      this.style.backgroundPosition="-244px 0px";
      if (gecko) this.style.paddingTop="1px";
    }
  }
}
var obj=document.getElementsByTagName("input");
for (var i=0; i<obj.length; i++) {
  if (obj[i].className=="button") {
    obj[i].onmouseover=obj[i].onmouseup=function(e) {
      this.style.backgroundPosition="-82px 0px";
      if (gecko) this.style.paddingTop="0px";
    }
    obj[i].onmouseout=function(e) {
      this.style.backgroundPosition="0px 0px";
      if (gecko) this.style.paddingTop="0px";
    }
    obj[i].onmousedown=function(e) {
      this.style.backgroundPosition="-164px 0px";
      if (gecko) this.style.paddingTop="1px";
    }
  }
  if (obj[i].className=="shortbutton") {
    obj[i].onmouseover=obj[i].onmouseup=function(e) {
      if (parseInt(this.getAttribute("enabled"))<1) return;
      this.style.backgroundPosition="-62px 0px";
      if (gecko) this.style.paddingTop="0px";
    }
    obj[i].onmouseout=function(e) {
      if (parseInt(this.getAttribute("enabled"))<1) return;
      this.style.backgroundPosition="0px 0px";
      if (gecko) this.style.paddingTop="0px";
    }
    obj[i].onmousedown=function(e) {
      if (parseInt(this.getAttribute("enabled"))<1) return;
      this.style.backgroundPosition="-124px 0px";
      if (gecko) this.style.paddingTop="1px";
    }
  }
  if (obj[i].className=="widebutton") {
    obj[i].onmouseover=obj[i].onmouseup=function(e) {
      this.style.backgroundPosition="-102px 0px";
      if (gecko) this.style.paddingTop="0px";
    }
    obj[i].onmouseout=function(e) {
      this.style.backgroundPosition="0px 0px";
      if (gecko) this.style.paddingTop="0px";
    }
    obj[i].onmousedown=function(e) {
      this.style.backgroundPosition="-204px 0px";
      if (gecko) this.style.paddingTop="1px";
    }
  }
}
function load(url,callback) {
  var xmlhttp;
  if (gecko) {
    xmlhttp=new XMLHttpRequest();
    xmlhttp.callback=callback;
    xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4) {
        xmlhttp.onreadystatechange=null;
        xmlhttp.callback(xmlhttp.responseXML.documentElement);
      }
    }
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
  } else {
    xmlhttp=new ActiveXObject("Microsoft.XMLDOM");
    xmlhttp.async="true";
    xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4) {
        xmlhttp.onreadystatechange=function() {};
        callback(xmlhttp.documentElement);
      }
    }
    xmlhttp.load(url);
  }
  delete xmlhttp;
}
function text(node) {
  if (!node) return "";
  if (gecko) return node.textContent;
  else return node.text;
}
function base64(str) {
  var out="";
  var c1,c2,c3,e1,e2,e3,e4;
  var k="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+_=";
  var i=0;
  while (i<str.length) {
    c1=str.charCodeAt(i++);
    c2=str.charCodeAt(i++);
    c3=str.charCodeAt(i++);
    e1=c1>>2;
    e2=((c1 & 3)<<4)|(c2>>4);
    e3=((c2 & 15)<<2)|(c3>>6);
    e4=(c3 & 63);
    if (isNaN(c2)) { e3=e4=64; } else if (isNaN(c3)) { e4=64; }
    out=out+k.charAt(e1)+k.charAt(e2)+k.charAt(e3)+k.charAt(e4);
  }
  return out;
}
function getTop(obj) {
  var y=0;
  while (1) {
    y=y+obj.offsetTop;
    if (!obj.offsetParent) break;
    obj=obj.offsetParent;
  }
  return y;
}
function getLeft(obj) {
  var x=0;
  while (1) {
    x=x+obj.offsetLeft;
    if (!obj.offsetParent) break;
    obj=obj.offsetParent;
  }
  return x;
}
function makeUniqueId() {
  var id="id"+Math.floor(Math.random()*10)+Math.floor(Math.random()*10)+Math.floor(Math.random()*10);
  while (document.getElementById(id)) id="id"+Math.floor(Math.random()*10)+Math.floor(Math.random()*10)+Math.floor(Math.random()*10);
  return id;
}
var url;
if (typeof(usealtmenu)=="undefined") url="/act/getmenu"; else url="/act/getmenu2";
load(url,function(xml) {
  var m=document.getElementById("mainmenu").getElementsByTagName("li");
  var menus=xml.getElementsByTagName("submenuitem");
  for (var i=0; i<menus.length; i++) {
    var id=menus.item(i).getAttribute("id");
    if (id&&id.length) {
      var grpid=parseInt(menus.item(i).getAttribute("groupid"));
      sm[id]=new Submenu(id,grpid);
      var obj=document.createElement("table");
      obj.className="menutable";
      obj.cellSpacing=0;
      obj.cellPadding=0;
      var rows=menus.item(i).getElementsByTagName("menurow");
      for (var k=0; k<rows.length; k++) {
        var caption=text(rows.item(k));
        var href=rows.item(k).getAttribute("href");
        var issep=parseInt(rows.item(k).getAttribute("isseparator"));
        var ishdr=parseInt(rows.item(k).getAttribute("isheading"));
        var imgid=parseInt(rows.item(k).getAttribute("imageid"));
        if (issep) {
          var tr=obj.insertRow(-1);
          var td=tr.insertCell(-1);
          td.className="separator";     
        } else if (ishdr) {
          var tr=obj.insertRow(-1);
          var td=tr.insertCell(-1);   
          td.className="heading";
          td.innerHTML=caption;
          var align=rows.item(k).getAttribute("align");
          if (align&&align.length) td.style.textAlign=align;
        } else {
          var tr=obj.insertRow(-1);
          var td=tr.insertCell(-1);
          td.className="menurow";
          td.innerHTML=caption;
          td.setAttribute("href",href);
          td.submenu=sm[id];
          if (imgid) {
            td.image=new Image(222,46);
            td.image.src=cacheHost()+"/m/"+imgid+".jpg";
          }
          td.onmouseover=function(e) {
            this.style.color="#ffffff";
            this.style.background="#000000";
            this.submenu.setImage(this.image);
          }
          td.onmouseout=function(e) {
            this.style.color="#000000";
            this.style.background="#ffffff";
          }   
          td.onclick=function(e) {
            var href=this.getAttribute("href");
            href=href.replace(/\$thispage/,document.getElementById("thispage").value);
            window.location.href=href;
          }
        }
      }
      sm[id].addContent(obj);
    }
  }
  var menus=xml.getElementsByTagName("menuitem");
  for (var i=0; i<menus.length; i++) {
    var id=menus.item(i).getAttribute("id");
    if (id&&id.length) {
      for (var j=0; j<m.length; j++) {
        var item=m[j];
        var target=item.getAttribute("for");
        if (target&&target==id) {
          var pos=item.getAttribute("pos");
          var img=parseInt(item.getAttribute("img"));
          if (img) pm[id]=new Imagemenu(id,item,pos); else pm[id]=new Menu(id,item,pos);
          var obj=document.createElement("table");
          obj.className="menutable";
          obj.cellSpacing=0;
          obj.cellPadding=0;
          var rows=menus.item(i).getElementsByTagName("menurow");
          for (var k=0; k<rows.length; k++) {
            var caption=text(rows.item(k));
            var href=rows.item(k).getAttribute("href");
            var issep=parseInt(rows.item(k).getAttribute("isseparator"));
            var ishdr=parseInt(rows.item(k).getAttribute("isheading"));
            var isexp=parseInt(rows.item(k).getAttribute("isexpando"));
            var imgid=parseInt(rows.item(k).getAttribute("imageid"));
            if (isexp) {
              var exptarget=rows.item(k).getAttribute("submenu");
              var tr=obj.insertRow(-1);
              var td=tr.insertCell(-1);
              td.className="menurow_exp";
              td.innerHTML=caption;
              td.setAttribute("exptarget",exptarget);
              td.onmouseover=function(e) {
                this.style.color="#ffffff";
                this.style.backgroundColor="#000000";
                this.style.backgroundPosition="bottom right";
                var t=this.getAttribute("exptarget");
                if (sm[t]) {
                  var x=getLeft(this)+215;
                  var y=getTop(this)-60;
                  sm[t].show(x,y,this);
                }
              }
              td.onmouseout=function(e) {
                this.style.color="#000000";
                this.style.backgroundColor="#ffffff";
                this.style.backgroundPosition="top right";
                var t=this.getAttribute("exptarget");
                if (sm[t]) {
                  spmhide=sm[t];
                  stimer=setTimeout("hideSubMenu()",50);
                }
              }   
            } else if (issep) {
              var tr=obj.insertRow(-1);
              var td=tr.insertCell(-1);
              td.className="separator";
            } else if (ishdr) {
              var tr=obj.insertRow(-1);
              var td=tr.insertCell(-1);
              td.className="heading";
              td.innerHTML=caption;
              var align=rows.item(k).getAttribute("align");
              if (align&&align.length) td.style.textAlign=align;
            } else {
              var tr=obj.insertRow(-1);
              var td=tr.insertCell(-1);
              td.className="menurow";
              td.innerHTML=caption;
              td.setAttribute("href",href);
              td.menu=pm[id];
              if (imgid) {
                td.image=new Image(222,46);
                td.image.src=cacheHost()+"/m/"+imgid+".jpg";
              }
              td.onmouseover=function(e) {
                this.style.color="#ffffff";
                this.style.background="#000000";
                if (this.image) this.menu.setImage(this.image); else this.menu.setImage(defimage);
              }
              td.onmouseout=function(e) {
                this.style.color="#000000";
                this.style.background="#ffffff";
              }
              td.onclick=function(e) {
                var href=this.getAttribute("href");
                href=href.replace(/\$thispage/,document.getElementById("thispage").value);
                window.location.href=href;
              }
            }
          }
          pm[id].addContent(obj);
        }
      }
    }
  }
});
var li=document.getElementById("mainmenu").getElementsByTagName("li");
for (var i=0; i<li.length; i++) {
  var item=li[i];
  item.main=0;
  if (item.className=="lmenu") { item.main=li[i+1]; }
  if (item.className=="cmenu") { item.main=li[i]; }
  if (item.className=="amenu") { item.main=li[i-1]; }
  if (item.className=="rmenu") { item.main=li[i-2]; }
  if (item.main) {
    item.onmouseover=function(e) {
      var target=this.main.getAttribute("for");
      if (target&&pm[target]) {
        var p=this.main.getAttribute("pos");
        pm[target].show(getLeft(this.main)-11,224,p);
      }
    }
  }
}
var gwtab=document.getElementById("globalwebtab");
var gwtimer=0;
gwtab.onmouseover=function(e) {
  if (!gwcanclose) return;
  if (!gwopen) {
    var j=0;
    gwopen=true;
    for (var i=-69; i<=0; i++) {
      var cmd="gwtab.style.top=\""+i+"px\"";
      setTimeout(cmd,j*2);
      j++;
    }
  } else {
    if (gwtimer) {
      clearTimeout(gwtimer);
      gwtimer=0;
    }
  }
}
gwtab.onmouseout=function(e) {
  if (!gwcanclose) return;
  gwtimer=setTimeout(function() {
    gwopen=false;
    var j=0;
    for (var i=0; i>-70; i--) {
      var cmd="gwtab.style.top=\""+i+"px\"";
      setTimeout(cmd,j*2);
      j++;
    }
  },500);
}
if (gwopen) {
  var j=0;
  for (var i=-69; i<=0; i++) {
    var cmd="gwtab.style.top=\""+i+"px\"";
    setTimeout(cmd,j*2);
    j++;
  }
}
if (!webkit&&!gecko) {
  window.onerror=function(a,b,c) { return true; }
}
function setStyle(obj,style) {
  var s=style.split(";");
  for (var i=0; i<s.length; i++) {
    var d=s[i].split("=");
    eval("obj.style."+d[0]+"=\""+d[1]+"\"");
  }
}
function Point(x,y) {
  this.className="Point";
  this.x=parseInt(x);
  this.y=parseInt(y);
  return this;
}
Point.prototype.addPoint=function(pt) {
  if (!(pt instanceof Point)) return;
  this.x=this.x+pt.x;
  this.y=this.y+pt.y;
}
Point.prototype.subtractPoint=function(pt) {
  if (!(pt instanceof Point)) return;
  this.x=this.x-pt.x;
  this.y=this.y-pt.y;
}
Point.prototype.clone=function() {
  return new Point(this.x,this.y);
}
Point.prototype.toString=function() {
  return this.className+"["+this.x+","+this.y+"]";
}
function mousePosition(e) {
  var x=y=0;
  if (!e) e=window.event;
  if (e.pageX) x=e.pageX;
  if (e.pageY) y=e.pageY;
  if (!x&&e.clientX) x=e.clientX;
  if (!y&&e.clientY) y=e.clientY;
  return new Point(x,y);
}
function getPosition(obj) {
  return new Point(getLeft(obj),getTop(obj));
}
function contextLoad(url,context,callback) {
  var xmlhttp=new XMLHttpRequest();
  xmlhttp.context=context;
  xmlhttp.callback=callback;
  xmlhttp.onreadystatechange=function(e) {  
    if (this.readyState==4) {
      this.onreadystatechange=null;
      xmlhttp.callback(xmlhttp.context,xmlhttp.responseXML.documentElement);
    }
  }
  xmlhttp.open("GET",url,true);   
  xmlhttp.send(null);
}
function text(node) {
  if (!node) return "";
  if (node.textContent) return node.textContent;
  if (node.text) return node.text;
  return "";
}
function base64(str) {   
  var out="";
  var c1,c2,c3,e1,e2,e3,e4;
  var k="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+_=";
  var i=0;
  while (i<str.length) {
    c1=str.charCodeAt(i++);
    c2=str.charCodeAt(i++);
    c3=str.charCodeAt(i++);
    e1=c1>>2;
    e2=((c1 & 3)<<4)|(c2>>4);
    e3=((c2 & 15)<<2)|(c3>>6);
    e4=(c3 & 63);
    if (isNaN(c2)) { e3=e4=64; } else if (isNaN(c3)) { e4=64; }
    out=out+k.charAt(e1)+k.charAt(e2)+k.charAt(e3)+k.charAt(e4);
  }
  return out;
}
function getWindowSize() {
  var w=parseInt(document.documentElement.clientWidth);
  var h=parseInt(document.documentElement.clientHeight);
  if (webkit||isNaN(w)||w==0) w=parseInt(window.innerWidth);
  if (webkit||isNaN(h)||h==0) h=parseInt(window.innerHeight);
  return new Point(w,h);   
}
function getScrollTop() {
  if (webkit) return parseInt(document.body.scrollTop);
  var s=parseInt(document.documentElement.scrollTop);
  if (isNaN(s)) s=parseInt(document.body.scrollTop);
  return s;
}
