//declare globals to build object reference
var whichDom = "", styleObj = ""
var isNav4, isNav6, isIE, isMAC
var isBrand = navigator.appName
var agt = navigator.userAgent.toLowerCase()
var navVer = parseInt(navigator.appVersion)

isNav4 = (isBrand == "Netscape" && navVer < 5) ? true : false
isNav6 = (isBrand == "Netscape" && navVer >= 5) ? true : false

isNav46 = ((isBrand == "Netscape") && (parseFloat(navigator.appVersion) >=
parseFloat(4.6)) && (parseFloat(navigator.appVersion) < parseFloat(4.7))) ?
true : false
isNav47 = ((isBrand == "Netscape") && (parseFloat(navigator.appVersion) >=
parseFloat(4.7))) ? true : false

isIE = ((agt.indexOf("msie") != -1) && (parseInt(navVer) >= 4)) ? true :
false
isMAC = (agt.indexOf("mac") != -1) ? true : false

//construct object reference
var doc = document
var layers = doc.layers
var all = doc.all

if (layers) {
whichDom = '["'
styleObj = '"]'
} else if (all) {
whichDom = ".all."
styleObj = ".style"
} else {
whichDom = '.getElementById("'
styleObj = '").style'
}

function setObject(obj) {
var theObj
if (typeof obj == "string")
theObj = eval("document" + whichDom + obj + styleObj)
else
theObj = obj
return theObj
}

function setObject2(obj) {
	var theObj
	if (typeof obj == "string") {
		tmp = "document" + whichDom + obj + styleObj
		tmp = tmp.replace('.style', '')
		theObj = eval(tmp)
	} else
		theObj = obj
	return theObj
}

if (isNav6) {
// visible = 'block';
visible = '';
hidden = 'none';
} else if (document.all) {
visible = '';
hidden = 'none';
}


var close_obj, open_obj, tmp_height=100,start_closing=false, running=false;
function showrec(id,img, src1, src2, alink) {
	if (running == true)
		return;
		
	running = true;
	
	menu = 'id_' + id;
	img = img;
	var theObj = setObject2(menu);
	
	img_id = String('img_' + id);
	
	//Ändra - till +
	as = document.getElementsByTagName('a');
	for (i=0;i<as.length;i++) {
		tmp = as.item(i);
		if (tmp.className == 'menu2a')
			tmp.innerHTML = tmp.innerHTML.replace('-&nbsp;&nbsp;&nbsp;', '+&nbsp;&nbsp;');
	}
	
	//Öppnä rätt fält
	open_obj = theObj;
	
	//Dölj alla fält
	divs = document.getElementsByTagName('div');
	for (i=0;i<divs.length;i++) {
		tmp = divs.item(i);
		if (tmp.id.indexOf('id_') == 0)
			CloseMenu(tmp); //tmp.style.display = hidden;
	}
	
	if (start_closing == false)
		OpenMenu();
	
	//Ändra plustecken
	alink.innerHTML = alink.innerHTML.replace('+&nbsp;&nbsp;', '-&nbsp;&nbsp&nbsp;');
	
	/*//theObj.display = visible;
	if (img != ''){
		re = /pl/gi;
		document[img_id].src = document[img_id].src.replace(re, 'min');
	}*/
}

function CloseMenu(obj) {
	//obj.style.display = hidden;
	if (obj.style.display == visible) {
		obj.style.overflow = 'hidden';
		obj.style.pixelHeight = tmp_height;
		close_obj = obj;
		tmp = close_obj.innerHTML.split('<DIV');
		tmp_height = (tmp.length-1) * 20;
		CloseMenuStart();
		start_closing = true;
	}
}

function CloseMenuStart() {
	if (close_obj.style.pixelHeight > 0) {
		move = Math.ceil(close_obj.style.pixelHeight * 0.2);
		close_obj.style.pixelHeight = (close_obj.style.pixelHeight - move);
		setTimeout("CloseMenuStart()", 10);
	} else {
		close_obj.style.display = hidden;
		OpenMenu();
	}
}

function OpenMenu() {
	open_obj.style.display = visible;
	open_obj.style.pixelHeight = 1;
	open_obj.style.overflow = 'hidden';
	tmp = open_obj.innerHTML.split('<DIV');
	tmp_height = (tmp.length-1) * 20;
	OpenMenuStart();
}

function OpenMenuStart() {
	if (open_obj.style.pixelHeight < tmp_height) {
		move = Math.ceil(open_obj.style.pixelHeight * 0.2);
		open_obj.style.pixelHeight = (open_obj.style.pixelHeight + move);
		setTimeout("OpenMenuStart()", 10);
	} else {
		//open_obj.style.pixelHeight = 'auto';
		open_obj.style.overflow = 'visible';
		running = false;
	}
}
