﻿function show_region_key(name) {
    var el = document.getElementById (name);
    if (el != null)
        el.style.display = 'block';
}

function hide_region_key(name) {
    var el= document.getElementById (name);
    el.style.display = 'none';
}
function highlight_admin_menu(){
    var currentpage = location.href;
    var startidx = currentpage.indexOf ("Admin/");
    if (startidx == -1)
        startidx = currentpage.indexOf ("admin/");
    startidx = startidx + 6;
    var endidx = currentpage.indexOf (".", startidx);
    if (endidx!= -1) 
        currentpage = currentpage.substring(startidx, endidx);
    var el = document.getElementById (currentpage);
    if (el!=null)
        el.className = "active";
    return true;
}
function adjustWidth(){
    var windowWidth = getWindowWidth();
    var articleWidth = windowWidth-545;
    if (articleWidth < 350)
        articleWidth=325;
    var articleDiv = document.getElementById ("articles");
    if (articleDiv != null){
        articleDiv.style.width = articleWidth + "px";  
    }
}
function getWindowWidth(){
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && document.documentElement.clientWidth ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && document.body.clientWidth ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}