var hideDiv = false;

document.onclick = doHide;

function doHide(e) {
	if (hideDiv) {
		showlayerdiv('company','hide');
		showlayerdiv('missions','hide');
		showlayerdiv('resources','hide');
	}
}

function showlayerdiv(layerName,showHide) {
	var what, layerRef, visibleVar;
	if (document.layers) { 
		layerRef="document.layers"; 
		styleSwitch=""; 
		visibleVar="show"; 
		what ="ns4"; 
	} else if(document.all) { 
		what ="ie4"; 
		layerRef="document.all"; 
		styleSwitch=".style"; 
		visibleVar="visible"; 
	} else if(document.getElementById) { 
		layerRef="document.getElementByID"; 
		styleSwitch=".style"; 
		visibleVar="visible"; 
		what="dom1"; 
	} else { 
		what="none"; 
	} 
	
	if (showHide == 'show') {
		layerVis = 'visible';
		hideDiv = true;
	} else {
		layerVis = 'hidden';
		hideDiv = false;
	}
	if (what == "none") { 
		return; 
	} else if (what == "dom1") {
		document.getElementById(layerName).style.visibility=layerVis;
	} else {
		eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="'+layerVis+'"');
	} 
}

function divOut(e) {
	if (!e) var e = window.event;
	var tg = (window.event) ? e.srcElement : e.target;
	if (tg.nodeName != 'DIV') return;
	var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
	while (reltg != tg && reltg.nodeName != 'BODY')
		reltg= reltg.parentNode
	if (reltg == tg) return;
	showlayerdiv('products','hide');
	showlayerdiv('manuals','hide');
}

function openWindow(theURL,winName,width,height,features) {
  var swidth = screen.width - 100;
  var sheight = screen.height - 100;
  var widthstr = "";
  var heightstr = "";
  if (width >= swidth) {
    width = swidth;
    widthstr = "width=" + width + ",";
  } else if (width >= 1) {
    widthstr = "width=" + width + ",";
  }
  if (height >= sheight) {
    height = sheight;
    heightstr = "height=" + height;
  } else if (height >= 1) {
    heightstr = "height=" + height;
  }
  if (features != "") {
    features = "," + features;
  }
  var allfeatures = widthstr + heightstr + features;
  var new_window = window.open(theURL,winName,allfeatures);
  new_window.focus();
}

