//******************************************************************************
//****************************** Layers ****************************************
//******************************************************************************

var ie = false;
var nn = false;
var nn6 = false;

if(document.all){
 	 ie = true;
  }else if(document.getElementById){
 	nn6 =  true;
 }else {
  	nn = true;
  }

var which;
var whichOld = "empty";
var active = false;
var timerID;
var resettop = 0;

function showLayer(which) {
	if (nn) document.layers[which].visibility = "show"
	else if (ie) document.all[which].style.visibility = "visible"
	else document.getElementById(which).style.visibility = "visible"
	whichOld = which;
	active = which;
	return true;
}

function openLayer(which) {
	hideLayer(whichOld);
	if (nn)  {
		var oldheight = document.layers[which].top;
		resettop = oldheight;
		//oldheight = oldheight.replace("px","");
		var heightback = window.pageYOffset;
		var newheight = parseInt(oldheight)+heightback;
		document.layers[which].top = newheight;
		document.layers[which].visibility = "show";
		//document.layers[which].top = oldheight;
	}
	else if (ie) {
		var oldheight = document.all[which].style.top;
		resettop = oldheight;
		oldheight = oldheight.replace("px","");
		var heightback = document.body.scrollTop;
		var newheight = parseInt(oldheight)+heightback;
		document.all[which].style.top = newheight+"px";
		document.all[which].style.visibility = "visible";
	}
	else {
		var oldheight = document.getElementById(which).style.top;
		resettop = oldheight;
		oldheight = oldheight.replace("px","");
		var heightback = window.pageYOffset;
		var newheight = parseInt(oldheight)+heightback;
		document.getElementById(which).style.top = newheight+"px";
		document.getElementById(which).style.visibility = "visible";
	}
	
	whichOld = which;
	active = which;
	return true;
}

function hideLayer(whichOld) {
	reallyCloseLayer(whichOld);
	active = false;
	whichOld = "empty";
	clearTimeout(timerID);   
	return true;
}


function closeLayer(whichOld) {
		if (nn) timerID=setTimeout('reallyCloseLayer(whichOld)',600);
		else if (ie) timerID=setTimeout('reallyCloseLayer(whichOld)',600);
		else timerID=setTimeout('reallyCloseLayer(whichOld)',600);
		active = false;
	return true;
}

function reallyCloseLayer(whichOld){
	if (nn){
	document.layers[whichOld].top = resettop;
		document.layers[whichOld].visibility = "hide";
	}else if (ie){
		document.all[whichOld].style.top = resettop;
		document.all[whichOld].style.visibility = "hidden";
	}else{
		document.getElementById(whichOld).style.top = resettop;
		document.getElementById(whichOld).style.visibility = "hidden";
	}
}

function createLayer(id,left,top,width,height,content){
	if (nn){
		lay = '<layer name="'+id+'" position=absolute cursor=hand top="'+top+'" left="'+(left)+'px" width="'+width+'px" visibility="hide"  onMouseOver="clearTimeout(timerID);" onMouseOut="closeLayer(this);">';
		lay += content+'</layer>';
	}else{
		lay = '<div id="'+id+'" style="position:absolute; cursor:hand; left:'+left+'px; top:'+top+'px; width:'+width+'px; height:20px; z-index:60; visibility:hidden;background-color: '+sm_bgcolor+';" onMouseOver="clearTimeout(timerID);" onMouseOut="closeLayer(this);">';
		lay += content+'</div>';
	}
	return lay;
}
