/*
    Menu Javascript for Snowbomb.com
	Copyright 2007 Bomb Enterprises LLC

    Editied and commented by Chris H.
    August 19, 2007. 
*/


/*
 * RB 2/12/2010: Introduced variable, "verticalOffset"
 * CH 8/19/2007: Added Comments
 * The following 2 functions need to be edited if 
 * menus are moved around as they contain the positioning
 * information.
 */
 

// align layers to leftmost pixel location of master containment table
function alignLayers() {
  // CH: menuLayers div is hidden by default.. 
  // we need to enable it so we can see the dropdowns
  proxyLayerStyleName('menuLayers').display = "block";

  // NN4,NN6
  if(window.innerWidth) {
    winWidth = window.innerWidth;
  }
  // MSIE,Mozilla
  if(document.body.clientWidth) {
    winWidth = document.body.clientWidth;
  }

  // position popup menu layers
  if(winWidth) {
    newPos = (winWidth - 850) / 2;
    var thisPos=newPos+14;  // start with a slight indent

    var scaling=1.0;
    if (navigator.platform.indexOf("Linux") != -1) {
       scaling=0.93;  // Linux font is narrower
    }

	var verticalOffset = 126; // WSM:RB, 2010.02.12 - Previously 126; modified due to new Twitter bar at the top of the page

    proxyLayerStyleName('tclayer').left = thisPos + 'px';
    proxyLayerStyleName('tclayer').top = verticalOffset + 'px';
    thisPos+=parseInt(126*scaling);	// add the width of this menu item

	proxyLayerStyleName('lifttixlayer').left = thisPos + 'px';
    proxyLayerStyleName('lifttixlayer').top = verticalOffset + 'px';
    thisPos+=parseInt(129*scaling);	// add the width of this menu item
    
    proxyLayerStyleName('tripplanninglayer').left = thisPos + 'px';
    proxyLayerStyleName('tripplanninglayer').top = verticalOffset + 'px';
    thisPos+=parseInt(139*scaling);

    proxyLayerStyleName('condlayer').left = thisPos + 'px';
    proxyLayerStyleName('condlayer').top = verticalOffset + 'px';
    thisPos+=parseInt(121*scaling);

	proxyLayerStyleName('comlayer').left = thisPos + 'px';
    proxyLayerStyleName('comlayer').top = verticalOffset + 'px';
    thisPos+=parseInt(126*scaling);	// add the width of this menu item

//    proxyLayerStyleName('resortlayer').left = thisPos + 'px';
//    proxyLayerStyleName('resortlayer').top = verticalOffset + 'px';
//    thisPos+=parseInt(99*scaling);	// add the width of this menu item


//    proxyLayerStyleName('lodginglayer').left = thisPos + 'px';
//    proxyLayerStyleName('lodginglayer').top = verticalOffset + 'px';
//    thisPos+=parseInt(103*scaling);	// add the width of this menu item

//    proxyLayerStyleName('storelayer').left = thisPos + 'px';
//    proxyLayerStyleName('storelayer').top = verticalOffset + 'px';
//    thisPos+=parseInt(90*scaling);	// add the width of this menu item

//    proxyLayerStyleName('dealslayer').left = thisPos + 'px';
//    proxyLayerStyleName('dealslayer').top = verticalOffset + 'px';
//    thisPos+=parseInt(108*scaling);	// add the width of this menu item

    proxyLayerStyleName('accountlayer').left = thisPos + 'px';
    proxyLayerStyleName('accountlayer').top = verticalOffset + 'px';

  }
}

// hide all menu popup layers that might have become visible
function hideAllLayers() {
  proxyLayerStyleName('tclayer').visibility = 'hidden';
  proxyLayerStyleName('condlayer').visibility = 'hidden';
  proxyLayerStyleName('comlayer').visibility = 'hidden';
  proxyLayerStyleName('tripplanninglayer').visibility = 'hidden';
//  proxyLayerStyleName('resortlayer').visibility = 'hidden';
//  proxyLayerStyleName('lodginglayer').visibility = 'hidden';
  proxyLayerStyleName('lifttixlayer').visibility = 'hidden';
//  proxyLayerStyleName('storelayer').visibility = 'hidden';
 // proxyLayerStyleName('dealslayer').visibility = 'hidden';
  proxyLayerStyleName('accountlayer').visibility = 'hidden';
}



/*
 * CH 8/19/2007: Added Comments
 * CSS Generic layering functions
 */

// create proxy variable for refering to layer styles across DOMs
function proxyLayerStyleName(layername) {
  if (document.all) { // MSIE
    return document.all[layername].style;
  } else if (document.layers) { // NN4
    return document.layers[layername];
  } else { // NN6/Mozilla
    return document.getElementById(layername).style;
  }
}

// timeout id  (global)
var toID;

// display a layer
function showLayer(layername,linkid) {  
  alignLayers();
  clearTimeout(toID);
  toID = setTimeout("hideAllLayers()",4000);
  var layer = proxyLayerStyleName(layername);
  hideAllLayers();
  layer.visibility = 'visible'; 
}

// hide a layer
function hideLayer(layername,linkid) {
  var layer = proxyLayerStyleName(layername);
  layer.visibility = 'hidden'
}






