// ********  determining server/directory path  *****************

//Global Variables
var exp;
var jspPath = '';
var htmlPath = '';
//assign the current url to a variable
var currPath = location.href;

//set hosts for curr environment
if (currPath.indexOf('iwsd01') != -1) {
  jspHost = "www.astor.ru";
  staticHost = "www.astor.ru";
} else {
  jspHost = "www.astor.ru";
  staticHost = "www.astor.ru";
}

//determine whether the current url is for a .html or a .jsp page
//and assign variables for search regExp accordingly

if (homePage == 'yes') {
  jspPath = 'http:\/\/' + jspHost;
  htmlPath = '';
} else if (currPath.indexOf('/corp/') != -1) {
  //html pages on www.dupont.com or eq.
  //cut off text before corp
  exp = /.*\/corp\//;
  currPath = currPath.replace(exp,'corp\/');
  //cut off filename and qry string
  currPath = currPath.slice(0, currPath.lastIndexOf('/'));
  // replace dir. names with ..
  exp = /[^\/]+/g;
  htmlPath = currPath.replace(exp, '..');
  jspPath = 'http:\/\/' + jspHost;
} else if (currPath.indexOf('.jsp') != -1) {
  //html pages on www.dupont.com or eq.
  //cut off text before jsp
  exp = /.*\/jsp\//;
  currPath = currPath.replace(exp,'');
  //cut off filename and qry string
  currPath = currPath.slice(0, currPath.lastIndexOf('/'));
  // replace dir. names with ..
  exp = /[^\/]+/g;
  jspPath = currPath.replace(exp, '..');
  htmlPath = 'http:\/\/' + staticHost;
} else {
  htmlPath = 'http:\/\/' + staticHost;
  jspPath = 'http:\/\/' + jspHost;
}

// ********  creating dropdown nav  *****************

// Global Vars for nav

// initialize and give default values for dropdown menu color variables
var background = "#FFcc66";
var bgcolor = "#FFcc66";
var border_color = "#FF9933";
var menu_border = "#ffffff";
var hovercolor = "#FFcc66";
var dividercolor = "#FF9933";

// Simple Browser Check
var ie = "Microsoft Internet Explorer";
var netscape = "Netscape";
var mac = "MacPPC"
var browser = navigator.appName;
var os = navigator.platform;

var No3 = (parseInt(navigator.appVersion) > 3) ? 1:0;

if (navigator.userAgent == 'Mozilla/4.0 (compatible; MSIE 4.5; Mac_PowerPC)') {
  No3 = 0;
}
var layer = (document.getElementById && No3) ? "document.getElementById('L'+menu).style" : (document.all) ? "document.all['L'+menu].style" : (document.layers && No3) ? "document.layers['L'+menu]": 0;
var hideMe = (document.all || document.getElementById) ? "hidden" : "hide";
var showMe = (document.all || document.getElementById) ? "visible" : "show";
var timer;
if (document.layers && No3) {
  document.write('<style>.navdown {color:#000000; font-size:11px; font-family:Arial,sans-serif; font-weight:normal; text-decoration:none; padding-bottom : 3;  padding-top : 3;}</style>');
}
//////////////////////////////////////////////

/*  Create Your layers below by typing:
   Layer[incrementing number] = new LayerSpecs(Left Position, Top Position, Width, cell background color, cell hover color, cell divider color, List of Links Seperated by Commas)
*/

Layer = new Array();

Layer[1] = new LayerSpecs(365,149,170,'#c3d7eb','#ebf1ff','#ffffff');

Layer[2] = new LayerSpecs(365,149,170,'#c3d7eb','#ebf1ff','#ffffff',
  '<a href="/eng/news.html" class="navdown"><img src="/images/btn.gif" width=17 height=9 border=0>News</a>',
  '<a href="/eng/comp_1.html" class="navdown"><img src="/images/btn.gif" width=17 height=9 border=0>Research & Development</a>',
  '<a href="/eng/comp_2.html" class="navdown"><img src="/images/btn.gif" width=17 height=9 border=0>Production</a>',
  '<a href="/eng/comp_3.html" class="navdown"><img src="/images/btn.gif" width=17 height=9 border=0>Quality Control</a>');

Layer[3] = new LayerSpecs(512,149,170,'#c3d7eb','#ebf1ff','#ffffff',
  '<a href="/eng/prod_1.html" class="navdown"><img src="/images/btn.gif" width=17 height=9 border=0>Specialty Gases</a>');

Layer[4] = new LayerSpecs(650,149,128,'#c3d7eb','#ebf1ff','#ffffff');

/////////////////////////////////////////////////////////

// Loop to create master nav table(ie/nn6) or layer(nn4.x)
for(i=1; i<Layer.length; i++) {
  // imgHilite returns the image name to the mouseover/mouseoff function in rollover.js
  var imgHilite = rollArray[(i-1)].name;

  if (document.getElementById && No3) {
    document.write('<div onMouseOver="showOver(\''+imgHilite+'\');clearTimeout(timer)" onMouseOut="showOff(\''+imgHilite+'\');Hide('+i+')" ID="L'+i+'" STYLE="position:absolute; visibility:hidden; background:'+background+'; top:'+Layer[i].top+'; left:'+Layer[i].left+';"><table border="0" cellpadding="0" cellspacing="0">'+Layer[i].info+'</TABLE></div>');
  } else if (document.all && No3) {
    document.write('<SPAN onMouseOver="clearTimeout(timer);" onMouseOut="Hide('+i+')" ID="L'+i+'" STYLE="position:absolute; visibility:hidden; background:'+background+'; top:'+Layer[i].top+'; left:'+Layer[i].left+';"><table border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff" onmouseover="showOver(\''+imgHilite+'\');" onmouseout="showOff(\''+imgHilite+'\');">'+Layer[i].info+'</TABLE></SPAN>');
  } else if (document.layers && No3) {
    document.write('<LAYER onMouseOver="clearTimeout(timer);showOver(\''+imgHilite+'\');" onMouseOut="Hide('+i+');showOff(\''+imgHilite+'\');" ID="L'+i+'" VISIBILITY="hide" position="absolute" BGCOLOR="#ffffff" TOP="'+Layer[i].top+'" LEFT="'+Layer[i].left+'">'+Layer[i].info+'</LAYER>');
  }
}

function Show(menuNumber) {
  if(timer) {
    clearTimeout(timer);
  }
  for(menu=0; menu < Layer.length; menu++) {
    if(Layer[menu]) {
      eval(layer).visibility = hideMe;
    }
  }
  if (menuNumber > 0){
    var menu = menuNumber;
    eval(layer).visibility = showMe;
  }
}

function Hide(menuNumber) { timer = setTimeout("Show(0)", 200); }


function LayerSpecs(Left,Top,Width,bgcolor,hovercolor,dividercolor) {
  if(No3) {
    if (document.getElementById && document.all) {
      if (homePage=="yes") {
        this.left = Left;
        this.top = Top;
      } else {
        this.left = parseInt(Left) + 10;
        this.top = parseInt(Top) - 5;
      }
    } else if (document.getElementById && navigator.userAgent.indexOf('Gecko')) {
      if (homePage=="yes") {
        this.left = Left;
        this.top = Top;
      } else {
        this.left = parseInt(Left) + 8;
        this.top = parseInt(Top) - 12;
      }
    } else if (document.all) {
      if (homePage=="yes") {
        this.left = Left;
        this.top = Top;
      } else {
        this.left = parseInt(Left) + 10;
        this.top = parseInt(Top) - 5;
      }
    } else if (document.layers) {
      // Width = Width + 10;
      if (homePage=="yes") {
        this.left = parseInt(Left) + 0;
        this.top = parseInt(Top) - 1;
      } else {
        this.left = parseInt(Left) + 8;
        this.top = parseInt(Top) - 13;
      }
    }

    this.info  = "";

    // initialize layer position for NN4.x
    var T = 0;

    // Loop to populate master nav table/layer with content
    for(i=6; i<arguments.length; i++) {

      // check for 2 lines of content within layer and offset accordingly
      if( arguments[i].indexOf('<br>&nbsp;') != -1 ){
        var addOffset = 13;
      } else {
        var addOffset = 0;
      }

      // calculates table cell height for NN6 & IE
      var cellheight = 17 + addOffset;

      if (document.all){
        this.info += '<tr bgcolor="'+bgcolor+'" onMouseOver="this.bgColor=\''+hovercolor+'\';return true;" onMouseOut="this.bgColor=\''+bgcolor+'\';return true;"><TD WIDTH="'+Width+'" height="'+cellheight+'"><span style="line-height:103%;">'+arguments[i]+'</span></TD></TR><tr><td bgcolor="'+dividercolor+'"><img src="'+htmlPath+'/corp/images/spacer.gif" width="'+Width+'" height="1" border="0" alt=""></td></tr>';
      } else if (document.getElementById){
        this.info += '<tr bgcolor="'+bgcolor+'" onMouseOver="this.bgColor=\''+hovercolor+'\';return true;" onMouseOut="this.bgColor=\''+bgcolor+'\';return true;"><TD WIDTH="'+Width+'" height="'+cellheight+'">'+arguments[i]+'</TD></TR><tr><td bgcolor="'+dividercolor+'"><img src="'+htmlPath+'/corp/images/spacer.gif" width="'+Width+'" height="1" border="0" alt=""></td></tr>';
      } else if (document.layers){
        this.info += '<LAYER position="absolute" bgcolor="'+bgcolor+'" onMouseOver="this.bgColor=\''+hovercolor+'\';return true;" onMouseOut="this.bgColor=\''+bgcolor+'\';return true;" WIDTH="'+Width+'" TOP="'+T+'"><img src="'+htmlPath+'/corp/images/spacer_orange.gif" width="'+Width+'" height="1" border="0" alt=""><br>'+arguments[i]+'</LAYER><br>';
      }

    // increment layer position for NN4.x
    T += 17 + addOffset;
    }
  }
}
