var Nav  = navigator.userAgent.toLowerCase();
var isNS = Nav.indexOf('netscape') >= 0;
var isMoz= (Nav.indexOf('mozilla') >= 0) && (!isNS) && (!document.all);
var isOpera = Nav.indexOf('opera') >= 0;
var isIE = document.all && !isOpera;
var isMacIE = isIE && Nav.indexOf('mac') >= 0;
var FlashInstalled = isFlashInstalled();
var tBox = false;
var onLoadScript = "";
var HTTPS = false;

document.onmousemove = domousemove;
document.onmouseover = domouseover;
document.onmouseout = domouseout;

function getElemPos(offsetTrail)
{
  var offsetLeft = 0;
  var offsetTop = 0;
  while (offsetTrail) {
      offsetLeft += offsetTrail.offsetLeft;
      offsetTop += offsetTrail.offsetTop;
      offsetTrail = offsetTrail.offsetParent;
  }
  if (navigator.userAgent.indexOf("Mac") != -1 && 
      typeof document.body.leftMargin != "undefined") {
      offsetLeft += document.body.leftMargin;
      offsetTop += document.body.topMargin;
  }
  return {left:offsetLeft, top:offsetTop};
}

function fo(id){return document.getElementById(id)}
function setScrBarColors(line, face) {
return; // let's get rid of this for now...
  if (!isIE) return;
  with (document.body.style) {
    scrollbarDarkShadowColor=line;
    scrollbar3dLightColor=line;
    scrollbarBaseColor=face;
    scrollbarFaceColor=face;
    scrollbarHighlightColor=face;
    scrollbarShadowColor=face;
  }
}
function domousemove(ev) {
  if (!isIE) return;
  var w = document.body.clientWidth;
  var h = document.body.clientHeight;
  var x = event.clientX;
  var y = event.clientY;
  if(x>w||y>h)
    setScrBarColors("#BC7E41","#78a4c0");
  else
    setScrBarColors("","");
}
function domouseover(ev) {
  window.status=''
  var El = (document.all)?window.event.srcElement:ev.target;
  if (El.className.indexOf("ltLink") > -1) { initFade(El,0,15); }
  return true;
}
function domouseout(ev) {
  var El = (document.all)?window.event.srcElement:ev.target;
  if (El.className.indexOf("ltLink") > -1) { initFade(El,15,0); }
  setScrBarColors("","");
}

function initFadeBtn(o,r1,g1,b1,r2,g2,b2,slow)
{
  if (!document.getElementById) return;
  o.st = 20;
  if (o._timer != null) clearInterval(o._timer);
  var rgb1 = o.style.backgroundColor;
  rgb1 = rgb1.toLowerCase();
  if (rgb1.substr(0,1) == "#") 
  {
    r1 = fromH(rgb1.substr(1,2));
    g1 = fromH(rgb1.substr(3,2));
    b1 = fromH(rgb1.substr(5,2));
  }
  else if(rgb1.substr(0,3) == "rgb")
  {
    rgb1 = rgb1.substr(rgb1.indexOf("(")+1);
    rgb1 = rgb1.substr(0,rgb1.indexOf(")"));
    rgb1 = rgb1.split(",");
    r1 = parseInt(rgb1[0]); g1 = parseInt(rgb1[1]); b1 = parseInt(rgb1[2]);
  }
  if (r1<0 || g1<0 || b1<0) return;
  if (!o.r1) o.r1_ = r1; if (!o.g1) o.g1_ = g1; if (!o.b1) o.b1_ = b1;

  o.r1 = r1;  o.g1 = g1;  o.b1 = b1;
  o.r2 = r2>=0?r2:o.r1_;  o.g2 = g2>=0?g2:o.g1_;  o.b2 = b2>=0?b2:o.b1_;
  o.dr = (o.r2-r1)/o.st;  o.dg = (o.g2-g1)/o.st;  o.db = (o.b2-b1)/o.st;
  o._timer=setInterval("doFadeBtn('"+o.id+"')",slow?35:15);
}

function doFadeBtn(id)
{
  var o = document.getElementById(id);
  var o1= document.getElementById(id+"_line");
  var o2= document.getElementById(id+"_line1");
  if (!o) return; if (!o.st) return;
  o.r1 += o.dr;  o.g1 += o.dg;  o.b1 += o.db;
  var col = "#"+hexC(o.r1)+hexC(o.g1)+hexC(o.b1);
  o.style.backgroundColor=col;
  if (o1) o1.style.backgroundColor = col;
  if (o2) o2.style.backgroundColor = col;
  o.st--;
  if (o.st <= 0)
  {
    clearInterval(o._timer);
    col = "#"+hexC(o.r1=o.r2)+hexC(o.g1=o.g2)+hexC(o.b1=o.b2);
    o.style.backgroundColor=col;
    if (o1) o1.style.backgroundColor= col;
    if (o2) o2.style.backgroundColor = col;
  }
}

function preLoad(im)
{
  if(document.images)
  {
    if(!document._preload) {document._preload=new Array();document._pi = 0;}
    document._preload[document._pi] = new Image();
    document._preload[document._pi].src = im;
    document._pi++;
  }
}
function Src_on(s)
{
  var p = s.length;
  if (s.substr(p-7,4) == '_on.') return s;
  return s.substr(0,p-4)+'_on'+s.substr(p-4);
}

function adjustments()
{
//  if (isOpera && (FlashInstalled&!HTTPS))
//    document.getElementById('logo_div').style.marginBottom = "3px";
}

function highlightLTLink()
{
}

function GetCookie(Name,sName)
{
  var s="",s1="",aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
    var aCrumb = unescape(aCookie[i]).split("=");
    if (Name == aCrumb[0])
     if ((aCrumb.length >= 2) && (sName))
     {
      for (j=1;j<aCrumb.length;j++)
        s += aCrumb[j]+"=";
      s = s.split("&");
      for (j=0;j<s.length;j++)
      {
       s1 = s[j].split("=");
       if (sName == s1[0]) return s1[1];
      }
      return "";
     }
     else return aCrumb[1];
  }
  return "";
}

function isFlashInstalled()
{
  var flash = false;
  if ((navigator.userAgent.indexOf('MSIE') == -1) || (navigator.userAgent.indexOf('Opera') != -1)) {
    if (navigator.plugins["Shockwave Flash"]) {
      flash = true;
    } else {
      flash = false;
    }
  } else {
    try {
      obj = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
      flash = true;
    } catch(e) {
      flash = false;
    }
  }
  return(flash)
}


function isEmailValid(em)
{
  var p1=em.indexOf('@'), p2=em.lastIndexOf('.'), l=em.length; 
  return (p1 > 0) && (p2 > p1+1) && (p2 < l-1); 
}

function ShowHdLine(sID,bShow)
{
  var o = fo(sID);
  if (!o) return;
  if (bShow)
  {
    o.bVisible = true;
    o.style.display = "";
    if (isOpera) {
      o.style.visibility="visible"
      o.style.visibility="hidden"
      o.style.visibility="visible"
    }
  }
  else
  {
    o.bVisible = false;
    setTimeout("var o=fo('"+sID+"');if(o&&!o.bVisible)o.style.display = 'none'",200);
  }
}

function BoxHover(o,bHover,bKeepBG)
{
  function out(id)
  {
    var o = document.getElementById(id+"_top");
    if (o) o.className = o.className.substr(0,o.className.indexOf(" "));
    o = document.getElementById(id+"_img0");
    if (o) o.style.display="";
    o = document.getElementById(id+"_img1");
    if (o) o.style.display="none";
    o = document.getElementById(id+"");
    if (o) o.style.backgroundPosition="0px 0px";
  }
  if (!window.out) window.out = out;
  if (bHover) {
    if (o.bHover == 2) return;
    o.bHover = bHover;
    if (o.timer) clearTimeout(o.timer);
    var id =o.id;
    o = document.getElementById(id+"_top");
    if(o) o.className += " hover";
    o = document.getElementById(id+"_img0");
    if (o) o.style.display="none";
    o = document.getElementById(id+"_img1");
    if (o) o.style.display="";
    o = document.getElementById(id+"");
    if (o && !bKeepBG) o.style.backgroundPosition="185px 0px";
  } else if (o.bHover != 2) o.timer = setTimeout("out('"+o.id+"')",10);
}
// TOP NAVIGATION DROPDOWNS
var aDropDowns = new Array();
var iDDnum = 0;
var iFrame = null;

function DDhover(id,b,th)
{
  id = aDropDowns[id];
  function DDout(id)
  {
    var d = document.getElementById(id);
    if (d && d.style.display != "none")
    { 
      d.style.display = "none";
      if (d.th) d.th.className = "";
      if (iFrame) iFrame.style.display = "none";
    }
  }
  function DDcloseAll(id)
  {
    for (var i=0;i<aDropDowns.length;++i)
      if (id != aDropDowns[i])
      {
        clearTimeout(d.timer);
        DDout(aDropDowns[i]);
      }
  }
  if (!window.DDout) window.DDout = DDout;
  var d = document.getElementById(id);
  if (d)
  {
    if (b)
    {
        if (d.timer)
        {
          clearTimeout(d.timer);
          d.timer = null;
        }
        d.style.display = "block";
        if (th)
        {
          DDcloseAll(id);
          var pos = getElemPos(th);
          if (pos.left + d.offsetWidth > document.body.clientWidth+document.body.scrollLeft)
            pos.left -= d.offsetWidth - th.offsetWidth;
          d.style.left= pos.left;
          d.style.top = pos.top+th.offsetHeight;
/////////////////////
          var db = fo(d.id+"body");
          db.style.height = "auto";
          var iScrollersHeight = 20; // Approximate offset height of both UP and DOWN scrollers in px.
          var iMaxHeight = document.body.clientHeight + document.body.scrollTop - d.offsetTop - iScrollersHeight;
          if ((iMaxHeight < d.offsetHeight + iScrollersHeight) && (!isOpera))
          {
          	db.style.height = iMaxHeight-iScrollersHeight;
            fo(d.id+"top").style.display = "block";
            fo(d.id+"bottom").style.display = "block";
          }
          else
          {
          	db.scrollTop = 0;
            fo(d.id+"top").style.display = "none";
            fo(d.id+"bottom").style.display = "none";
          }
/////////////////////
          d.th = th;
          th.className = "hovered";
          if (!iFrame) iFrame = document.getElementById("DDiFrame");
          if (isIE) with (iFrame.style)
          {
            left= d.style.left;
            top = d.style.top;
            width = d.offsetWidth;
            height= d.offsetHeight;
            display = "block";
          }

        }
    } else d.timer = setTimeout("DDout('"+id+"')",600);
  } 
}
function DDscroll(th, bStart)
{
  var sID = th.id, o = null, p, iStep;
  if ((p=sID.indexOf("top"))>0)
  {
    o = fo(sID.substr(0,p)+"body");
    iStep = -2;
  }
  if ((p=sID.indexOf("bottom"))>0)
  {
    o = fo(sID.substr(0,p)+"body");
    iStep = 2;
  }
  if (!o) return;
  if (o.theTimer) clearInterval(o.theTimer);
  if (bStart)
    o.theTimer = setInterval("DDscroll_step('"+o.id+"',"+iStep+")",15);
  else
    o.theTimer = null;

}
function DDscroll_step(sID, iStep)
{
  var o = fo(sID);
  function resetTimer() {clearInterval(o.theTimer);o.theTimer = null;}
  if (!o) return;
  if ((o.scrollTop + iStep <= 0) && (iStep < 0))
  {
    o.scrollTop = 0;
    resetTimer();
    return;
  }
  if (o.scrollTop + o.offsetHeight + iStep >= o.scrollHeight)
  {
    o.scrollTop = o.scrollHeight;
    resetTimer();
    return;
  }
  o.scrollTop += iStep;
}
function HighlightMainMenu()
{
  function parseURL(s)
  {
    s = s.replace("https://","").replace("http://","");
    return unescape(s.substr(s.indexOf("/")));
  }
  var strURL = parseURL(window.location.href);
  var bDone = false;
  var a = document.getElementsByName("mmL");
  for (var i=0;i<a.length;++i)
    if ((strURL!="/") && (parseURL(a[i].href).indexOf(strURL) >= 0))
    {
      a[i].id = "current";
      bDone = true;
      break;
    }
  //if (!bDone)
  {
  a = document.getElementsByName("mL");
  for (var i=0;i<a.length;++i)
    if ((strURL!="/") && (parseURL(a[i].href).indexOf(strURL) >= 0))
    {
      a[i].id = "current";
      BoxHover(a[i].parentNode.parentNode.parentNode.parentNode,2);
      if (!bDone)
      {
        var p = document.getElementById(a[i].parentNode.parentNode.parentNode.id.replace("_","__"));
        if (p) p.id="current";
        bDone = true;
        //break;
      }
    }
  }
}

function showTab(a,i)
{
  var o = document.getElementById("selectedTab");
  if (o) o.id = "";
  a.id = "selectedTab";
  var j = 0;
  while (o=document.getElementById("tabPage"+(j++)))
    if (o.style.display == "block")
    {
      o.style.display = "";
      break;
    }
  o=document.getElementById("tabPage"+i);
  if (o) o.style.display = "block";
}