// Adding scrollbars dynamically so that CSS validates
function updateScrollBars(){
  if (document.all && document.getElementById){
    var scrollingDivAry = new Array(2)
    scrollingDivAry[0] = "rightColumn";
    scrollingDivAry[1] = "leftColumn";
    for (var l = 0; l < scrollingDivAry.length; l++){
      eval("document.getElementById('" + scrollingDivAry[l] + "').style.scrollbarBaseColor = '#000000'");
      eval("document.getElementById('" + scrollingDivAry[l] + "').style.scrollbarTrackColor = '#000000'");
      eval("document.getElementById('" + scrollingDivAry[l] + "').style.scrollbarFaceColor = '#242424'");
      eval("document.getElementById('" + scrollingDivAry[l] + "').style.scrollbarHighlightColor = '#000000'");
      eval("document.getElementById('" + scrollingDivAry[l] + "').style.scrollbar3dlightColor = '#000000'");
      eval("document.getElementById('" + scrollingDivAry[l] + "').style.scrollbarDarkshadowColor = '#000000'");
      eval("document.getElementById('" + scrollingDivAry[l] + "').style.scrollbarShadowColor = '#000000'");
      eval("document.getElementById('" + scrollingDivAry[l] + "').style.scrollbarArrowColor = '#5c8317'");
    }
  }
}

// Printer friendly popup
function printerFriendly(id){
  var popup = window.open("","","width=800, height=600, scrollbars=yes");
  var content = popup.document;
  content.open('text\/html');
  content.write('<html><head><title>Printer Friendly Version<\/title>');
  content.write('<link rel="stylesheet" type="text\/css" href="\/css\/popup.css" \/><\/head>');
  content.write('<body><div id="container" class="text">');
  content.write('<div id="topBar"></div><div id="content">')
  content.write(document.getElementById(id).innerHTML);
  content.write('<br \/><br style="clear:both;" \/><a href="javascript:window.close();">Close Window<\/a><\/div><\/body><\/html>')
  content.close();
}

// Scrolling top navigation functions
function scrollDown(id, num){
  document.getElementById(id).scrollTop += num;
}

function scrollUp(id, num){
  document.getElementById(id).scrollTop -= num;
}

// Scrolling section navigation functions
var scrollTimer;

function scroll(id, dir){
  var obj = document.getElementById(id);
  if (dir == 'right'){
    obj.scrollLeft += 1;
  }else{
    obj.scrollLeft -= 1;
  }
  scrollTimer = setTimeout("scroll('" + id + "', '" + dir + "')",0);
}

function scrollToEnd(id, dir){
  var obj = document.getElementById(id);
  if (dir == 'right'){
    obj.scrollLeft = 999999;
  }else{
    obj.scrollLeft = 0;
  }
}

function stopScroll(){
  clearTimeout(scrollTimer);
}    

// Opacity Change code from: 
// http://www.brainerror.net/scripts_js_blendtrans.php
// function to change opacity
function opacity(id, opacStart, opacEnd, millisec) {
  var speed = Math.round(millisec / 100); //speed for each frame
  var timer = 0;

  // determine the direction for the blending, if start and end are the same nothing happens
  if(opacStart > opacEnd) {
    for(var i = opacStart; i >= opacEnd; i--){
      setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
      timer++;
    }
  }else if(opacStart < opacEnd){
    for(var i = opacStart; i <= opacEnd; i++){
      setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
      timer++;
    }
  }
} 

// change the opacity for different browsers
function changeOpac(opacity, id) {
  var object = document.getElementById(id).style;
  object.opacity = (opacity / 100);
  object.MozOpacity = (opacity / 100);
  object.KhtmlOpacity = (opacity / 100);
  object.filter = "alpha(opacity=" + opacity + ")";
}