/*------------------ Window Open ------------------*/
function win_subwin(theURL){
  window.open(theURL,'subwindow');
}
function win_subwin2(theURL){
	window.open(theURL,'idsite','menubar=no,toolbar=yes,status=yes,location=yes,scrollbars=yes,resizable=yes,width=800');
}
/*---------- Company Map Window ----------*/
function map_subwin(theURL){
	window.open(theURL,'idsite','menubar=no,toolbar=no,status=no,location=no,scrollbars=no,resizable=no,width=650,height=470');
}


function map_subwin2(theURL){
	window.open(theURL,'idsite','menubar=no,toolbar=yes,status=yes,location=yes,scrollbars=yes,resizable=yes,width=535,height=535');
}
/*--------------------------*/
function win_miniwin(theURL,theSize){
  window.open(theURL,'miniwin','menubar=no,status=yes,scrollbars=yes,resizable=yes,'+theSize);
}
function win_miniwin2(theURL,theSize){
	window.open(theURL,'miniwin2','menubar=no,toolbar=no,status=no,location=no,scrollbars=yes,resizable=yes,'+theSize);
	window.blur();
}
function win_miniwin3(theURL,theSize){
  window.open(theURL,'miniwin3','menubar=no,toolbar=no,status=yes,location=yes,scrollbars=yes,resizable=yes,'+theSize);
}
function win_miniwinTo(theURL,winName,theSize){
  window.open(theURL,winName,'scrollbars=yes,resizable=yes,'+theSize);
}

function win_fullscreen(theURL){
	ww=screen.availWidth;
	hh=screen.availHeight;
  window.open(theURL,'fullwin',"menubar=no,status=no,scrollbars=no,resizable=yes,width="+ww+",height="+hh+",top=0,left=0");
}
function win_fullscreen2(theURL)
{
	ww=screen.availWidth;
	hh=screen.availHeight;
	window.open(theURL,'fullwin',"menubar=no,status=no,scrollbars=yes,resizable=yes,width="+ww+",height="+hh+",top=0,left=0");
	return theURL;
}

function goTopLink() {
	var d=document;
	var scroll_left=d.body.scrollLeft || d.documentElement.scrollLeft || d.scrollX || 0;
	var scroll_top=d.body.scrollTop || d.documentElement.scrollTop || d.scrollY || 0;
	scrollTo(scroll_left/1.1, scroll_top/1.1);
	if(scroll_left>0 || scroll_top>0){
		var f=setTimeout("goTopLink()", 5);
	}else{
		clearTimeout(f);
	}
}
/*---------------------------------
Drop Down Menu
----------------------------------*/
function initRollovers() {
	if (!document.getElementById) return
	
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {		
		if (aImages[i].className == 'imgover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_o'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);
			
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	
			
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}
var TimeOut         = 500;
var currentLayer    = null;
var currentitem     = null;
var currentLayerNum = 0;
var noClose         = 0;
var closeTimer      = null;

function mopen(n) {
  var l  = document.getElementById("menu"+n);
  var mm = document.getElementById("mmenu"+n);
	
  if(l) {
    mcancelclosetime();
    l.style.visibility='visible';
    if(currentLayer && (currentLayerNum != n))
      currentLayer.style.visibility='hidden';
    currentLayer = l;
    currentitem = mm;
    currentLayerNum = n;			
  } else if(currentLayer) {
    currentLayer.style.visibility='hidden';
    currentLayerNum = 0;
    currentitem = null;
    currentLayer = null;
 	}
}

function mclosetime() {
  closeTimer = window.setTimeout(mclose, TimeOut);
}

function mcancelclosetime() {
  if(closeTimer) {
    window.clearTimeout(closeTimer);
    closeTimer = null;
  }
}

function mclose() {
  if(currentLayer && noClose!=1)   {
    currentLayer.style.visibility='hidden';
    currentLayerNum = 0;
    currentLayer = null;
    currentitem = null;
  } else {
    noClose = 0;
  }
  currentLayer = null;
  currentitem = null;
}

document.onclick = mclose