// Broswer detection - these must be consistent on every page.  make sure the old script file has the same variables.
var NS4 = (document.layers) ? 1 : 0;
var IE4 = ((document.all) && (!document.getElementById)) ? 1 : 0;
var DOM = (document.getElementById) ? 1 : 0;  // ns6+ and ie5+ and mozilla
var NS6 = ((!document.all) && (document.getElementById)) ? 1 : 0;  // ns6+ and mozilla, not ie6
var IE = (navigator.appName == "Microsoft Internet Explorer") ? 1 : 0;
var PC = (navigator.platform == "Win32") ? 1 : 0;
var MAC = ((navigator.appVersion.indexOf("PPC") >0) || (navigator.appVersion.indexOf("Mac") >0)) ? 1 : 0;

function BuildHeadlines(cat) {
  var str = '';
  var hlLabel = '';
  try {
    var test = eval("news_" + tt[i][2]);
  }
  catch(er) {
    return str;
  }
  var hl = eval("news_" + tt[i][2]);
  if (hl.length < 1) return str;
  str = '<td class="ddNews" width="*"><div class="ddNews"><div class="ddNewsHdr">' + tt[i][3] + ' HEADLINES</div><table border="0" cellspacing="0" cellpadding="0">';
  if (hl.length < 6) {
    var numHl = hl.length;
  } else {
    var numHl = 6;
  }
  for ( j = 0 ; j < numHl ; j++ ) {
      str += "<tr valign='top'><td><b>&middot;</b>&nbsp;</td><td><a href='/content/view?contentId=" + hl[j][0] + "'>" + hl[j][1] + "</a></td></tr>";
  }
  str += "</td></table></div>";
  return str;
}

function Initms() {
  for (i = 0; i < tt.length; i++) {  // set m properties
  var ff = eval("nav_" + tt[i][1]);
  w_m = "gn" + tt[i][1];
  w_m = document.getElementById(w_m);
    if (tt[i][0] == 1) { // parent ms
      w_m.isChildm = 0;
      w_m.onmouseover = Overm;
      w_m.onmouseout = Outm;
      for ( j = 0 ; j < ff.length ; j++ ) {
        w_mItem = "nav_" + tt[i][1] + "_" + j;
        w_mItem = document.getElementById(w_mItem);
        w_mItem.onmouseover = OvermEl;
        w_mItem.onmouseout = OutmEl;
        if (ff[j][3]) w_mItem.childm = ff[j][4];
        w_mItem.destination = ff[j][0];
        w_mItem.newWin = ff[j][2];
        w_mItem.w_Class = "dd";
        w_mItem.onclick = LinkingPage;
      }
    }
    else { //child ms
      w_m.isChildm = 1;
      w_m.onmouseover = OverChildm;
      w_m.onmouseout = OutChildm;
      for ( j = 0 ; j < ff.length ; j++ ) {
        w_mItem = "nav_" + tt[i][1] + "_" + j;
        w_mItem = document.getElementById(w_mItem);
        w_mItem.onmouseover = OverChildmEl;
        w_mItem.onmouseout = OutChildmEl;
        w_mItem.destination = ff[j][0];
        w_mItem.newWin = ff[j][2];
        w_mItem.w_Class = "dd";
        w_mItem.onclick = LinkingPage;
      }
    }
  }
}


function ShowLayer(el,event) {
  var showEl = "gn" + el;
  if (showEl == "gnhome" || (!DOM)) return;
  clearTimeout(timer);
  HideAllLayers();
  isOver = true;
  var w_El = document.getElementById(showEl);
  w_Anchor = "nav_" + el;
  if (document.getElementById(w_Anchor)){
    var myObject = document.getElementById(w_Anchor);
    ddLeft = ddLeft + myObject.offsetLeft;
    while (myObject.offsetParent) {
      ddTop += myObject.offsetTop;
      ddLeft += myObject.offsetLeft;
      myObject = myObject.offsetParent;
    }
    ddTop += 18; ddLeft -=7;
  }
  if (w_El.className == "dd1") {var w_ElWidth = 400;}
  else if (w_El.className == "dd2") {var w_ElWidth = 130;}
  if ((ddLeft + w_ElWidth) > document.body.clientWidth) {
    ddLeft = document.body.clientWidth - w_ElWidth;
  }
  w_El.style.top = ddTop;
  w_El.style.left = ddLeft;
  ToggleSelect('hidden');
  w_El.style.visibility = "visible";
  ddTop = 0; ddLeft = 0;
}

function ToggleSelect(visState) {
  if (!IE) return;
  for (i=0; i < document.all.tags('SELECT').length; i++){
    var obj = document.all.tags('SELECT')[i];
    if (!obj || !obj.offsetParent) continue;
    obj.style.visibility = visState;
  }
}

function ShowChildLayer(childm, mItem) {
  var childm = "gn" + childm;
  clearTimeout(timer);
  HideChildLayers();
  var w_El = document.getElementById(childm);
  if (document.getElementById(mItem)){
    var myObject = document.getElementById(mItem);
    while (myObject.offsetParent) {
      ddTop = ddTop + myObject.offsetTop;
      ddLeft = ddLeft + myObject.offsetLeft;
      myObject = myObject.offsetParent;
    }
  }
  w_El.style.top = ddTop - 5;
  w_El.style.left = ddLeft + 107;
  w_El.style.visibility = "visible";
  ddTop = 0; ddLeft = 0;
}

function HideAllLayers() {
  if (isOver || isOverChild) return;
  for (i = 0; i < tt.length; i++) {
    w_El = "gn" + tt[i][1];
    w_El = document.getElementById(w_El);
    w_El.style.visibility = "hidden";
    w_El.style.left = 0;
  }
  ToggleSelect('visible');
}

function HideChildLayers() {
  if (isOverChild) return;
  for (i = 0; i < tt.length; i++) {
    if (tt[i][0] == 2) {
      w_El = "gn" + tt[i][1];
      w_El = document.getElementById(w_El);
      w_El.style.visibility = "hidden";
    }
  }
}

function Overm() {
  clearTimeout(timer);
  isOver = true;
}

function OverChildm() {
  clearTimeout(timerChild);
  isOverChild = true;
}

function Outm() {
  clearTimeout(timer);
  isOver = false;
  timer = setTimeout("HideAllLayers()",300);
}

function OutChildm() {
  clearTimeout(timerChild);
  isOverChild = false;
  timerChild = setTimeout("HideAllLayers()",300);
}

function OvermEl() {
  this.className = 'ddHigh';
  this.style.cursor = 'hand';
  if (this.childm || isOverChild) {
    ShowChildLayer(this.childm, this.id);
  }
  if (!this.childm) {
    HideChildLayers();
  }
}

function OverChildmEl() {
  this.className = 'ddHigh';
  this.style.cursor = 'hand';
}

function OutmEl() {this.className = this.w_Class;}
function OutChildmEl() {this.className = this.w_Class;}
function LinkingPage() {
  var url = String(this.destination);
  if (!this.newWin) {window.location.href = url;}
  else {window.open(url);}
}


function ImgInit() {
 if (document.images) {
  I2Pon = new Image();
  I2Pon.src = "../img/design/first_center_key2.gif";  
  
  I2Poff = new Image();
  I2Poff.src = "../img/design/first_center_key2o.gif";    

  PC2Pon = new Image();
  PC2Pon.src = "../img/design/first_center_key4.gif";  
  
  PC2Poff = new Image();
  PC2Poff.src = "../img/design/first_center_key4o.gif";    

  Anotheron = new Image();
  Anotheron.src = "../img/design/first_center_key5.gif";  
  
  Anotheroff = new Image();
  Anotheroff.src = "../img/design/first_center_key5o.gif";    

  }
}


function changeImages() {
     if (document.images) {
          for (var i=0; i<changeImages.arguments.length; i+=2) {
               document[changeImages.arguments[i]].src = eval(changeImages.arguments[i+1] + ".src");
          }
     }
} 

function newwin_price(){
	NW=window.open
("price.htm","Price","status=no,toolbar=no,scrollbars=1,width=350,height=450,top=30,left=40")
 }
