
function getWindowWidth() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

  return myWidth;
}

function getWindowWidth_old() {
    
    if(window.innerWidth) {
        return window.innerWidth;
    } 
    
    return document.body.clientWidth
}


function ResizeMenuItems(branding_page) {

  var mar_x, ul_x;

  if( branding_page ) {
    mar_x = 22;
    ul_x = 10;
  }
  else {
    mar_x = 26;
    ul_x = 11;
  }

  var debug = 0;

  var width = getWindowWidth();
  if( width < 720 )   // our default menu width
    return;

  var delta = width - 720 - mar_x;  // replace 2X with the margin value??
  var xd = parseInt(delta/6);    // six menu items

  var o1 = document.getElementById("one");
  var o2 = document.getElementById("two");
  var o3 = document.getElementById("three");
  var o4 = document.getElementById("four");
  var o5 = document.getElementById("five");
  var o6 = document.getElementById("six");
  var hor_menu_w = document.getElementById("nav_hor");

  var menu_width = hor_menu_w.style.width;
  if( !menu_width )
    menu_width = 720;

  if( debug ) {
    alert("width=" + width + " o1=" + o1.style.width +
       ",o2=" + o2.style.width + ",o4=" + o4.style.width +
       ",o5=" + o5.style.width + ",hor_menu_w=" + menu_width +
       ",delta=" + delta + "\nmar_x = " + mar_x + ",ul_x = " + ul_x);
  }


//menu_width = 720 + delta - ul_x;
//if( menu_width < 720 )    // mininum menu width
//  menu_width = 720;

  var tot_w = 0;

  var v = 110 + xd + 'px';      // 110 is width of o1, o2 and o3
  o1.style.width = v;
  o2.style.width = v;
  o3.style.width = v;
  tot_w += 3*(110+xd);

  v = 130 + xd + 'px';          // 130 is width of o4
  o4.style.width = v;
  tot_w += 130+xd;

  v = 150 + xd + 'px';          // 150 is width of o5
  o5.style.width = v;
  tot_w += 150+xd;

  v = 100 + xd + 'px';          // 100 is width of o6
  o6.style.width = v;
  tot_w += 100+xd;

  hor_menu_w.style.width =  tot_w + 'px';

  if( debug ) {
    alert("tot_=" + tot_w + " vs. menu_width=" + menu_width);
  }

  return;
}


function ShowWidths() {

  var width = getWindowWidth();
  if( width < 720 )   // our default width
    return;

  var delta = width - 720 - 20;  // replace 20 with the margin value
  var xd = parseInt(delta/6);

  var o1 = document.getElementById("one");
  var o2 = document.getElementById("two");
  var o3 = document.getElementById("three");
  var o4 = document.getElementById("four");
  var o5 = document.getElementById("five");
  var o6 = document.getElementById("six");
  var hor_menu_w = document.getElementById("nav_hor");

   alert("width=" + width + " o1=" + o1.style.width +
	",o2=" + o2.style.width + ",o4=" + o4.style.width +
	",o5=" + o5.style.width + ",hor_menu_w=" + hor_menu_w.style.width );

  return;


}

