function set_menu_width() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	var sfSubEls = null;
	for (var i=0; i<sfEls.length; i++) {
    if (sfEls[i].getElementsByTagName("IMG").length > 0) {
      sfSubEls=sfEls[i].getElementsByTagName("UL");
      for (var x=0; x<sfSubEls.length; x++) {
        if (sfSubEls[x].offsetWidth < sfEls[i].offsetWidth) {
          sfSubEls[x].style.width=sfEls[i].offsetWidth+"px";
        }
      }
    }
	}
}

function set_menu_glow(img_src) {
  document.getElementById("top_menu_glow").style.background="url("+img_src+") repeat-x";
}

function reset_menu_glow() {
  document.getElementById("top_menu_glow").style.background="url("+menu_active_glow+") repeat-x";
}

function detect_ie6() {
  if (navigator.appVersion.indexOf("MSIE 6.0") != -1) {
    return true;  
  } else {
    return false;
  }
}

function print_page() {
  str = document.getElementById("printer_friendly").innerHTML;
  id_pos = (str.indexOf("Printerfriendly=")+16);
  id_length = str.substr(id_pos,str.length).indexOf("'");
  print_id = str.substr((id_pos),id_length);
  window.open("/Default.aspx?ID="+page_id+"&Printerfriendly="+print_id);
}

function news_archive_navigation(d) {
  if (typeof(m) == "undefined") {
    m = 0;
  }
  if (d == "next") {
    if (m > ((l_h * (p-1))*-1)) {
      document.getElementById("news_list_archive_content").style.marginTop = (m - l_h) + "px";
      m = m - l_h;
      c_p = c_p + 1;
      document.getElementById("news_archive_list_current_page").innerHTML=c_p;
    }
  } else if (d == "prev") {
    if (m < 0) {
      document.getElementById("news_list_archive_content").style.marginTop = (m + l_h) + "px";
      m = m + l_h;
      c_p = c_p - 1;
      document.getElementById("news_archive_list_current_page").innerHTML=c_p;
    } 
  }
}

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(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 + ")";
}
function shiftOpacity(id, millisec) {
    //if an element is invisible, make it visible, else make it ivisible
    if(document.getElementById(id).style.opacity == 0) {
        opacity(id, 0, 100, millisec);
    } else {
        opacity(id, 100, 0, millisec);
    }
}