var DOCloaded    = false;
var arrIDsToHide = new Array ("ban_enchanter_1");
var ns = (navigator.appName == 'Netscape');
var ie = (document.all);
var ns4 = (ns && parseInt(navigator.appVersion) >= 4 && parseInt(navigator.appVersion)<5);
var ie4 = (ie && parseInt(navigator.appVersion) >= 4);
var ie5 = (ie4 && navigator.appVersion.indexOf("MSIE 5.")!=-1);
var ns5 = (ns && parseInt(navigator.appVersion) >= 5);
var oper = (window.opera != null);
var ns6 = (document.getElementById&&!ie);

function CreateMenu(n,x,y,w,str,url,parent){
var s,lt;
if (ns4) {lt="LAYER";} else {lt="DIV";}

if (ns4) {
if (parent==null || parent=="") { s='<'+lt+' id=menu'+n+' left='+x+' top='+y+' width='+w+' visibility=hide onmouseover="showMenus(\'menu'+n+'\',\'on\',\'\')" onmouseout="killMenus(\'menu'+n+'\')">';}
else { s='<'+lt+' id=menu'+n+' left='+x+' top='+y+' width='+w+' visibility=hide onmouseover="showMenus(\'menu'+n+','+parent+'\',\'on\',\'\')" onmouseout="killMenus(\'menu'+n+','+parent+'\')">';}
}
else { s='<'+lt+' id=menu'+n+' style="VISIBILITY: hidden; Z-INDEX: '+n+'; POSITION: absolute; LEFT: '+x+'px; TOP: '+y+'px; WIDTH: '+w+'px;">';}

s+='<table  border=0 cellspacing=0 cellpadding=1 class="menu">';
var mitems = str.split('|');
var urls = url.split('|');
for (i=0;i<mitems.length;i++) {
turl=String(urls[i]);
mtype=String(urls[i]).substring(0,4);
w_s = 102;
s+='<tr bgcolor="#739F4C"><td height=7></td></tr>';
if ( parent == null || parent == "" ) { 
	s += '<tr bgcolor="#739F4C">';
	s += '<td width="' + w_s + '" onmouseover="this.style.backgroundColor=\'#9AD16A\';showMenus(\'menu'+n+'\',\'on\',\'\')" ';
	s += 'onmouseout="this.style.backgroundColor=\'#739F4C\';killMenus(\'menu'+n+'\')" onClick="openMenu(\''+escape(turl)+'\')" style="CURSOR: hand; FONT-FAMILY:  Times New Roman; FONT-SIZE: 10px; COLOR: #FFFFFF;  TEXT-DECORATION: none;">';
	s += '<div style="width:100%">';
	s += '&nbsp;'+mitems[i]+'&nbsp;'
	s += '</div>';
}
else {
	s += '<tr bgcolor="#739F4C">';
	s += '<td width="' + w_s + '" onmouseover="this.style.backgroundColor=\'#9AD16A\';showMenus(\''+parent+',menu'+n+'\',\'on\',\'\')" ';
	s += 'onmouseout="this.style.backgroundColor=\'#739F4C\';killMenus(\''+parent+',menu'+n+'\')" onClick="openMenu(\''+escape(turl)+'\')" style="CURSOR: hand; FONT-FAMILY: Times New Roman;  FONT-SIZE: 10px; COLOR: #FFFFFF; TEXT-DECORATION: none;">';
	s += '<div style="width:100%">';
	s += '&nbsp;'+mitems[i]+'&nbsp;';
	s += '</div>';
}
if(i!=mitems.length-1){s+='</td></tr>';}
else {s+='</td></tr>';}
}
s+='<tr bgcolor="#739F4C"><td height=7></td></tr></table>';
s+='</'+lt+'>\n';
document.write(s);
LMoveTo('menu'+n,x,y);
}
function Align(v,a){
if (v < a) { return a;}else{return v;}
}
function AreaWidth(){
if(oper || ns4){ return(window.innerWidth); }
else if(ie4){ return(document.body.clientWidth); }
}
function AreaHeight(){
if(ns4 || oper){ return(window.innerHeight);}
else if(ie4){ return(document.body.clientHeight); }
}
function LMoveTo(ly,X,Y){
	if(ie4){
		document.all[ly].style.pixelLeft=X;
		document.all[ly].style.pixelTop=Y;
	} else if(oper){
		var el = document.getElementById(ly);
 		el.style.pixelLeft=X;
		el.style.pixelTop=Y;
	} else if(ns5){
		var el = document.getElementById(ly);
 		el.style.left=X;
		el.style.top=Y;
	} else if(ns4){
		document.layers[ly].left=X;
		document.layers[ly].top=Y;
	}
}

function LShow(ly){
	if (ie4){ document.all[ly].style.visibility='visible';
	} else if(ns4){ document.layers[ly].visibility='show';
	} else if(oper || ns5){ document.getElementById(ly).style.visibility='visible';}
}

function LGetVis(ly){
	if(((ie4 || oper) && document.all[ly].style.visibility=='visible')||(ns4 && document.layers[ly].visibility=='show')){ return(1);
	} else { return(0); }
}

function LHide(ly){
	if(ie4){ document.all[ly].style.visibility='hidden';
	} else if(ns4){ document.layers[ly].visibility='hide';
	} else if(oper|| ns5){ document.getElementById(ly).style.visibility='hidden';}
}

function LToggle(ly){
	if(ie4){ if(document.all[ly].style.visibility == 'hidden') {document.all[ly].style.visibility = 'visible';} else {document.all[ly].style.visibility = 'hidden';}
	} else if(ns4) {if(document.layers[ly].visibility == 'hide') {document.layers[ly].visibility = 'show';} else {document.layers[ly].visibility = 'hide';}} 
else if(oper|| ns5){if(document.getElementById(ly).style.visibility == 'hidden') {document.getElementById(ly).style.visibility = 'visible';} else {document.getElementById(ly).style.visibility = 'hidden';};}
}

var layertimer;
var lastmenues;
var active = 0;

function killMenus(strWen, strStatus){
	layertimer = setTimeout("showMenus('"+strWen+"', 'off')", 300);
	return false;
}
function killMenusNS(strWen){
if (ns4) { killMenus(strWen); }
}

function showMenus(strWen, strStatus, strCoord) {
	if(strStatus == "on"){
		if(layertimer){ clearTimeout(layertimer) }
	}
	var tempWen = strWen.split(",");
	var strOut="";

	if(DOCloaded) 
	{
		if (arrIDsToHide && arrIDsToHide.length) //  array of ids of elements that should be hidden
	        {
	            for (var intI=0; intI<arrIDsToHide.length; intI++)
	            {
	                var objEl = document.getElementById(arrIDsToHide[intI]);
	                if (objEl)
	                {
	                    objEl.style.display = (strStatus == "off" ? "block" : "none");
	                }
	            }
	        }

		clearTimeout(active);
		if(lastmenues){
			tempLastmenues = lastmenues.split(",");
			for (i=0;i<tempLastmenues.length;i++) {LHide(tempLastmenues[i]);}
			lastmenues = null;
		}
		if(strStatus=="on"){
		    if(strCoord!=null && strCoord!=""){
		        tempCoord = strCoord.split("|")
		    }
			tempActualLayers=strWen.split(",")
			for (i=0; i < tempWen.length; i++){
    		    if(strCoord!=null && strCoord!=""){
                    T = tempCoord[i].split(",")
                    if (T[0]!="" && T[1]!=""){
    			        LMoveTo(tempActualLayers[i], T[0], T[1]);
    			    }
    		    }
              LShow(tempActualLayers[i])
            }
			lastmenues = strWen;
		}
	} else {
		active = setTimeout("showMenus('" + strWen + "','" + strStatus + "','" + strCoord + "')",2000);
	}
	return false;
}

function openMenu(link){
	link = unescape(link);
	if ( link.indexOf("javascript:") != 0 )
		link = "document.location='"+link+"'";
	setTimeout(link, 0);
}

var expDays = 30;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function setCookie(name, value){
    document.cookie = name + "=" + escape(value)+"; expires=" + exp.toGMTString();
}

function getCookie(name){
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
        begin += 2;
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
        end = dc.length;
    return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name){
    if (getCookie(name))
        document.cookie = name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

var hiddenObjects = new Array();

function hideElementsIfNeeded(overDiv){
	unhideElements();
	if( agent_usefx ) 
		hideElements('SELECT', overDiv);
	hideElements('OBJECT', overDiv);
}

function hideElements(elmID, overDiv){
	for( var i = 0;	i <	document.all.tags( elmID ).length; i++ ){
		obj = document.all.tags(elmID)[i];
		if( !obj || !obj.offsetParent	)
			continue;

		var position = getElementPosition(obj);
		objTop = position[0];
		objLeft = position[1];
		objHeight = obj.offsetHeight;
		objWidth = obj.offsetWidth;

		if ( ( overDiv.offsetLeft + overDiv.offsetWidth ) <= objLeft );
		else if ( ( overDiv.offsetTop + overDiv.offsetHeight ) <= objTop );
		else if ( overDiv.offsetTop >= ( objTop + objHeight ) );
		else if ( overDiv.offsetLeft >= ( objLeft + objWidth ) );
		else if ( obj.style.visibility = "visible" ){
			hiddenObjects.push(obj);
			obj.style.visibility = "hidden";
		}
	}	
}

function unhideElements(){
	for ( var i = 0; i < hiddenObjects.length; i++ ){
		hiddenObjects[i].style.visibility = "visible";
	}
	hiddenObjects = new Array();
}


function getElementPosition(element){
	var objectTop = element.offsetTop;
	var objectLeft = element.offsetLeft;
	var objectParent = element.offsetParent;
	while( objectParent.tagName.toUpperCase() != "BODY" ){
		objectTop += objectParent.offsetTop;
		objectLeft += objectParent.offsetLeft;
		objectParent = objectParent.offsetParent;
	}
	return [objectTop,objectLeft];
}