<!--//

var speed        = 4;
var increment    = 2;
var incrementNS4 = 5; // for slower NS4 browsers

var is_NS = navigator.appName=="Netscape";
var is_Ver = parseInt(navigator.appVersion);
var is_NS4 = is_NS&&is_Ver>=4&&is_Ver<5;
var is_NS5up = is_NS&&is_Ver>=5;
var IE = window.document.all; // IE 4x
var NN = window.document.layers; //NN 4x
var IENN = window.document.getElementById; // IE 5x and N6x
var isN6 = false; //N6 true or false to make difrense betwen IE5 and N6..


var agt = navigator.userAgent.toLowerCase(); // convert all characters to lowercase to simplify testing 
var isWin = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
var isMac = (agt.indexOf("mac")!=-1);


var coll="";
var styleObj="";

if (navigator.appName == 'Netscape') 
{
  	if (navigator.appVersion.charAt(0) == "5")
  	{
		isN6 = true;// N6x
	}
}	
if (is_NS4) {
	increment = incrementNS4;
	Lq = "document.layers.";
	Sq = "";
} else {
	Lq = "document.all.";
	Sq = ".style";
}

if (IENN)
{
	coll = "getElementById('";
	styleObj = "').style";
}
else if(IE)
{
	coll = "all('";
	styleObj = "').style"
}
else if(NN)
{
	coll = "layers['";
	styleObj = "']";
}
else
{
	document.location.href= strFile;
}

// call the handleResize function if the window is resized in NN
if (NN)
{
	window.captureEvents(Event.RESIZE);
	window.onresize = handleResize;
}

function BesamGetTop(strLayer)
{
	var intTop
	intTop = document.getElementById(strLayer).offsetTop;
	if (isN6)
		intTop = intTop + 6
	else
	{
	if (isMac)
		intTop = intTop - 4
	}
	return intTop
}
function BesamGetLeft(strLayer)
{
	var intLeft
	intLeft = document.getElementById(strLayer).offsetLeft;
	if (isN6)
		intLeft = intLeft + 6
	else
	{
	if (isMac)
		intLeft = intLeft - 2
	}
	return intLeft
}

/*
-----------------------------------------
function handleResize()
-----------------------------------------
Desc:	reload the page, specialy used to
		fix the resize bugg i NN   		
Arg:	
Ret:	false
-----------------------------------------
*/
function handleResize()
{
	window.document.location.reload();
	return false
}

/*
-----------------------------------------
function getObj(strLayer)
-----------------------------------------
Desc:	Return a object reference to 
		the layer. Works for IE 4x, IE5x,
		NN4x, NN6x  		
Arg:	strLayer = the name of the layer.
Ret:	Object Reference
-----------------------------------------
*/
function getObj(strLayer)
{
	var objRef;
	if(typeof strLayer == "string")
	{
		return objRef = eval("window.document." + coll  + strLayer  + styleObj);
	}
	else
	{
		return objRef = strLayer
	}
	
}
/*
-----------------------------------------
function hideLayer(strLayer)
-----------------------------------------
Desc:	hide the specific layer works in
		IE 4x, IE5x, NN4x, NN6x
Arg:	strLayer = the name of the layer
		to hide.
Ret:	none.
-----------------------------------------
*/
function hideLayer(strLayer)
{
	var objRef = getObj(strLayer);
	if(IE || IENN)
	{
		objRef.visibility = "hidden";
	}
	else if(NN)
	{
		objRef.visibility = "hide";
	}
}
/*
-----------------------------------------
function showLayer(strLayer)
-----------------------------------------
Desc:	show the specific layer works in
		IE 4x, IE5x, NN4x, NN6x
Arg:	strLayer = the name of the layer
		to show.
Ret:	none.
-----------------------------------------
*/
function showLayer(strLayer)
{
	var objRef = getObj(strLayer);
	if(IE || IENN)
	{
		objRef.visibility = "visible";
	}
	else if(NN)
	{
		objRef.visibility = "show";
	}
}
/*
-----------------------------------------
function writeToLayer(strLayer, strText)
-----------------------------------------
Desc:	write content to the specific 
		layer works in IE 4x, IE5x, NN4x
		NN6x
Arg:	strLayer = the name of the layer
		to write in.
		strText = the string to be writen
		to the layer
Ret:	none.
-----------------------------------------
*/
function writeToLayer(strLayer,strText)
{
	if(IENN)
	{
		window.document.getElementById(strLayer).innerHTML = strText;
	}
	else if(IE)
	{
		IE[strLayer].innerHTML = strText;
	}
	else if(NN)
	{
		objRef = getObj(strLayer);
		objRef.document.open();
		objRef.document.write(strText);
		objRef.document.close();
	}
}
/*
-----------------------------------------
function moveLayerTo(strLayer, intX, intY)
-----------------------------------------
Desc:	Move the specefic layer to the 
		x and y cordinats. Works for 
		IE 4x, IE5x, NN4x, NN6x  		
Arg:	strLayer = the name of the layer.
		intX = pixels from left
		intY = pixels from top
Ret:	none
-----------------------------------------
*/
function moveLayerTo(strLayer, intX, intY)
{
	var objRef = getObj(strLayer);
	objRef.top = intY;
	objRef.left = intX;

}
/*
-----------------------------------------
function setZIndex(strLayer, intZ)
-----------------------------------------
Desc:	Setting the z-order of the layer
		IE 4x, IE5x, NN4x, NN6x  		
Arg:	strLayer = the name of the layer.
		intZ = the index number to set
Ret:	none
-----------------------------------------
*/
function setZIndex(strLayer, intZ)
{
	var objRef = getObj(strLayer);
	objRef.zIndex = intZ;
}
/*
-----------------------------------------
function setBGColor(strLayer, strColor)
-----------------------------------------
Desc:	Setting the background color of
		the layer. works in IE 4x, IE5x,
		NN4x, NN6x  		
Arg:	strLayer = the name of the layer.
		strColor = colorName or RGB
Ret:	none
-----------------------------------------
*/
function setBGColor(strLayer, strColor)
{
	var objRef = getObj(strLayer);
	if (NN)
	{
		objRef.bgColor = strColor;
	}
	else 
	{
		objRef.backgroundColor = strColor;
	}
}

/*
-----------------------------------------
function getObjLeft(strLayer)
-----------------------------------------
Desc:	get the position from left in 
		pixels. works in IE 4x, IE5x,
		NN4x, NN6x
		OBS! this attribute must in some
		browsers (IE5x and N6x) been set
		before you can read it. You can
		do this in to ways,
		set the left attribute in a init()
		function onLoad, or you have to  
		set the style attribute in the tag
		instead of setting it as a id in a 
		"style" tag.   		

Arg:	strLayer = the name of the layer.
Ret:	integer how many pixels from left
-----------------------------------------
*/
function getObjLeft(strLayer)
{
	var objRef = getObj(strLayer);
	if (NN)
	{
		return objRef.left;
	}
	else if (IENN)
	{
		return parseInt(objRef.left);
	}
	else if (IE)
	{
		return parseInt(objRef.pixelLeft);
	}
}
/*
-----------------------------------------
function getObjTop(strLayer)
-----------------------------------------
Desc:	get the position from top in 
		pixels. works in IE 4x, IE5x,
		NN4x, NN6x
		OBS! this attribute must in some
		browsers (IE5x and N6x) been set
		before you can read it. You can
		do this in to ways,
		set the left attribute in a init()
		function onLoad, or you have to  
		set the style attribute in the tag
		instead of setting it as a id in a 
		<style> tag.   		

Arg:	strLayer = the name of the layer.
Ret:	integer how many pixels from top
-----------------------------------------
*/
function getObjTop(strLayer)
{
	var objRef = getObj(strLayer);
	if (NN)
	{
		return objRef.top
	}
	else if(IENN)
	{
		return parseInt(objRef.top);
	}
	else if (IE)
	{
		return parseInt(objRef.pixelTop);
	}
}
/*
-----------------------------------------
function getObjOffsetLeft(strLayer)
-----------------------------------------
Desc:	get the position from left in 
		pixels. works in IE 4x, IE5x,
		NN4x, NN6x
		OBS! this attribute must in some
		browsers (IE5x and N6x) been set
		before you can read it. You can
		do this in to ways,
		set the left attribute in a init()
		function onLoad, or you have to  
		set the style attribute in the tag
		instead of setting it as a id in a 
		"style" tag.   		

Arg:	strLayer = the name of the layer.
Ret:	integer how many pixels from left
-----------------------------------------
*/
function getObjOffsetLeft(strLayer)
{
	var objRef = getObj(strLayer);
	if (NN)
	{
		return objRef.offsetLeft;
	}
	else if (IENN)
	{
		return parseInt(objRef.offsetLeft);
	}
	else if (IE)
	{
		return parseInt(objRef.offsetLeft);
	}
}
/*
-----------------------------------------
function getObjOffsetTop(strLayer)
-----------------------------------------
Desc:	get the position from top in 
		pixels. works in IE 4x, IE5x,
		NN4x, NN6x
		OBS! this attribute must in some
		browsers (IE5x and N6x) been set
		before you can read it. You can
		do this in to ways,
		set the left attribute in a init()
		function onLoad, or you have to  
		set the style attribute in the tag
		instead of setting it as a id in a 
		<style> tag.   		

Arg:	strLayer = the name of the layer.
Ret:	integer how many pixels from top
-----------------------------------------
*/
function getObjOffsetTop(strLayer)
{
	var objRef = getObj(strLayer);
	if (NN)
	{
		return objRef.offsetTop
	}
	else if(IENN)
	{
		return parseInt(objRef.offsetTop);
	}
	else if (IE)
	{
		return parseInt(objRef.offsetTop);
	}
}

/*
-----------------------------------------
function moveLayer(strLayer, intX, intY)
-----------------------------------------
Desc:	Move the specefic layer  x and y 
		pixels from the curent position. 
		Works for IE 4x, IE5x, NN4x, NN6x  		
Arg:	strLayer = the name of the layer.
		intX = pixels to move in x cordinate
		intY = pixels to move in y cordinate
Ret:	none
-----------------------------------------
*/
function moveLayer(strLayer, intX, intY)
{
	var objRef = getObj(strLayer);
	var intCurentY = getObjTop(strLayer);
	var intCurentX = getObjLeft(strLayer);
	objRef.top = intCurentY + intY;
	objRef.left = intCurentX + intX;
}

/*
-----------------------------------------
function getObjHeight(strLayer)
-----------------------------------------
Desc:	gets the Height of the Layer
		IE 4x, IE5x, NN4x, NN6x
Arg:	strLayer = the name of the layer.
Ret:	integer (Height) in pixels
-----------------------------------------
*/
function getObjHeight(strLayer)
{
	var intHeight;
	if(IENN)
	{
		return intHeight = parseInt(document.getElementById(strLayer).offsetHeight);
	}
	else if(IE)
	{
		return intHeight = parseInt(document.all[strLayer].clientHeight);
	}
	else if(NN)
	{
		var objRef = getObj(strLayer);
		return intHeight = parseInt(objRef.clip.height);
	}
	
}

/*
-----------------------------------------
function getObjWidth(strLayer)
-----------------------------------------
Desc:	gets the Height of the Layer
		IE 4x, IE5x, NN4x, NN6x
Arg:	strLayer = the name of the layer.
Ret:	integer (Width) in pixels
-----------------------------------------
*/
function getObjWidth(strLayer)
{
	var intWidth;
	if(IENN)
	{
		return intWidth = parseInt(document.getElementById(strLayer).offsetWidth);
	}
	else if(IE)
	{
		return intWidth = parseInt(document.all[strLayer].clientWidth);
	}
	else if(NN)
	{
		return intWidth = parseInt(document.layers[strLayer].clip.width);
	}
}

/*
-----------------------------------------
function getWindowWidth()
-----------------------------------------
Desc:	Gets the Window Width
		IE 4x, IE5x, NN4x, NN6x
		Note: IE don have a property for 
		the window width so I had to take 
		the body width. This can do that 
		it is not the exakt pixels width
		in exploer.  
Arg:	
Ret:	integer: the WindowWidth
-----------------------------------------
*/
function getWindowWidth()
{
	if (NN)
	{
		return parseInt(window.innerWidth);
	}
	if (IE)
	{
		return parseInt(document.body.offsetWidth);
	}
	else if (IENN && isN6)
	{
		return parseInt(window.innerWidth);
	}
}

/*
-----------------------------------------
function getWindowHeight()
-----------------------------------------
Desc:	Gets the Windows Height
		IE 4x, IE5x, NN4x, NN6x
		Note: IE don have a property for 
		the window Height so I had to take 
		the body Height. This can do that 
		it is not the exakt pixels Height
		in exploer.  
Arg:	
Ret:	integer: the WindowHeight
-----------------------------------------
*/
function getWindowHeight()
{
	if (NN)
	{
		return parseInt(window.innerHeight);
	}
	if (IE)
	{
		return parseInt(document.body.offsetHeight);
	}
	else if (IENN && isN6)
	{
		return parseInt(window.innerHeight);
	}
}

/*
-----------------------------------------
function centerLayer(strLayer)
-----------------------------------------
Desc:	Center the specific layer
		IE 4x, IE5x, NN4x, NN6x
Arg:	strLayer = the name of the layer.
Ret:	none.
-----------------------------------------
*/
function centerLayer(strLayer)
{
	var intWindowWidth  = getWindowWidth();
	var intWindowHeight = getWindowHeight();
	var intLayerWidth   = getObjWidth(strLayer);
	var intLayerHeight  = getObjHeight(strLayer);
	var intX = (intWindowWidth/2)  - (intLayerWidth/2);
	var intY = (intWindowHeight/2) - (intLayerHeight/2);
	moveLayerTo(strLayer, intX, intY );
}


// for NS6 browsers
if (isN6) {increment = 4;}

// for Mac browsers
if (isMac) {increment = 4;}

window.aktivlayer = 0
window.visiblelayers = ''

function showdropdownmenulayer(objSource)
{
	//intmainleft = getObjOffsetLeft(maintable);
	//intmaintop = getObjOffsetTop(maintable);
	intmainleft = BesamGetLeft('maintable');
	intmaintop = BesamGetTop('maintable');
	//intmainleft = document.getElementById('maintable').offsetLeft;
	//intmaintop = document.getElementById('maintable').offsetTop;
	var intLeft=0;
	var intTop=0;

	if (objSource == 'spareparts')
	{
		intLeft = 34;
		 intTop = 80;
	}else if (objSource == 'close'){
		intLeft = 268;
		 intTop = 0;
	}


	//if (window.document.activeElement.id == objSource.id)
	//{
	//}
	moveLayerTo('dropmenu_'+objSource, intmainleft+1+110+intLeft, intTop+intmaintop);
	showLayer('dropmenu_'+objSource);
	moveLayerTo('controldropmenu_'+objSource, intmainleft+1+110+intLeft, intTop+intmaintop);
	showLayer('controldropmenu_'+objSource);
}

function showdropdownmenu(objSource, strpagename)
{
	if (window.mainmenutimer)
		window.clearTimeout(mainmenutimer);

	if (objSource.id != 'spareparts')
	{
		hideLayer('dropmenu_spareparts');
	}

	if (objSource.id != 'close')
	{
		hideLayer('dropmenu_close');
	}
	mainmenutimer = window.setTimeout("showdropdownmenulayer('" + objSource.id + "')", 250);
	objSource.src='/images_besam/sh_hl_'+strpagename+'_1.gif';
}

function showsecondarymenu(lngPageID, i)
{
	//intmainleft = getObjOffsetLeft(maintable);
	//intmaintop = getObjOffsetTop(maintable);
	//intmainleft = document.getElementById('maintable').offsetLeft;
	//intmaintop = document.getElementById('maintable').offsetTop;
	intmainleft = BesamGetLeft('maintable');
	intmaintop = BesamGetTop('maintable');

	if (isMac && !isN6)
		intmaintop = intmaintop - 101

	moveLayerTo('secondmenu_'+lngPageID, intmainleft+1+40+100+25, intmaintop+1+70+26+39+21+5+i*21);
	showLayer('secondmenu_'+lngPageID);
	window.visiblelayers = window.visiblelayers + lngPageID + ';'
}

function showsecondarymenutest(lngPageID, i, objSource, bShow)
{
	if (window.prevlayer)
	{
		var objRef2 = getObj('secondmenu_'+window.prevlayer);
		if (objRef2.visibility != 'hidden')
		{
			var objRef = getObj('sec_'+window.prevlayer);
			//if (glngSubMenuPageID != window.prevlayer)
			//{
				objRef.backgroundImage='url(/images_besam/navigation/sn_platta.gif)';
			//}
			//else
			//{
			//	objRef.backgroundImage='url(/images_besam/navigation/sn_platta_inaktiv.gif)';
			//}
		}
	}
	if (bShow)
	{
		window.aktivlayer = lngPageID;
		//objSource.background='/images_besam/navigation/sn_platta_inaktiv.gif';
		objSource.style.backgroundImage='url(/images_besam/navigation/sn_platta_svart_pil.gif)';
		//submenutimer = window.setTimeout("showsecondarymenutest2(" + lngPageID + ", " + i + ")", 100);
		showsecondarymenutest2(lngPageID, i);
	}
	else
	{
		drawMenu = ""
		objSource.style.backgroundImage='url(/images_besam/navigation/sn_platta_svart_pil.gif)';
		// hide all layers

		var strString = window.visiblelayers
		// Split at each ; character.
		ss = strString.split(";");

		for (j = 0; j < ss.length; j++)
		{
			if (ss[j] != '')
				hideLayer('secondmenu_'+ss[j]);
		}
	}
}

function showsecondarymenutest2(lngPageID, i)
{
	//intmainleft = getObjOffsetLeft(maintable);
	//intmaintop = getObjOffsetTop(maintable);
	//intmainleft = document.getElementById('maintable').offsetLeft;
	//intmaintop = document.getElementById('maintable').offsetTop;
	intmainleft = BesamGetLeft('maintable');
	intmaintop = BesamGetTop('maintable');

	var objRef = getObj('secondmenu_'+lngPageID);
	var objRef2 = getObj('menuIn');	
	if ((objRef.visibility == 'hidden') && (objRef2.visibility == 'hidden'))
	{
		var strString = window.visiblelayers
		// Split at each ; character.
		ss = strString.split(";");

		for (j = 0; j < ss.length; j++)
		{
			if (ss[j] != '')
				hideLayer('secondmenu_'+ss[j]);
		}

		//Visa menyn en nivå under valt alternativ
		i = i + 1

		moveLayerTo('menuIn', intmainleft+1+40+2, intmaintop+11+70+26+39+21+5+i*21);
		showLayer('menuIn');
		moveOnX(lngPageID, i, intmainleft+1+40, intmainleft+1+40+100+25);
	}
}

function cancelmove(lngPageID, objSource, bShow)
{	
	//if(submenutimer) clearTimeout(submenutimer)
	
	//if (window.aktivlayer != lngPageID)
	//{
		if (bShow)
		{
			var objRef = getObj('secondmenu_'+lngPageID);
			if (objRef.visibility == 'hidden')
			{
				//objSource.background='/images_besam/navigation/sn_platta_pil.gif';
				
				//if (glngSubMenuPageID != lngPageID)
				//{
					objSource.style.backgroundImage='url(/images_besam/navigation/sn_platta.gif)';
				//}
				//else
				//{
				//	objSource.style.backgroundImage='url(/images_besam/navigation/sn_platta_inaktiv.gif)';
				//}
			}
			window.prevlayer = lngPageID;
		}
		else
		{
			objSource.style.backgroundImage='url(/images_besam/navigation/sn_platta.gif)';
		}
		if(drawMenu) clearInterval(drawMenu);
		window.aktivlayer = 0
		var objRef2 = getObj('menuIn');
		if (objRef2.visibility != 'hidden')
			hideLayer('menuIn');
	//}
}

function moveOnX(lngPageID, i, MenuX, PosX) {
	if (window.drawMenu)
	{
		clearInterval(drawMenu);
		hideLayer('secondmenu_'+lngPageID);
	}
	if (MenuX < PosX)
	{
		MenuX = MenuX + increment;
		if (is_NS5up)
			{
			document.getElementById('menuIn').style.left = MenuX+"px";
			}
		else
			{
			eval(Lq+'menuIn'+Sq+'.left=MenuX');
			}
		drawMenu = setTimeout('moveOnX('+lngPageID+', '+i+', '+MenuX+', '+PosX+')',speed);
	}
	else
	{
		showsecondarymenu(lngPageID, i);
		hideLayer('menuIn');
	}
}

function moveOffX(lngPageID, i, MenuX, PosX) {
	if (MenuX > PosX) { 
		MenuX = MenuX - increment;
	if (is_NS5up) {
		document.getElementById('secondmenu_'+lngPageID).style.left = MenuX+"px";
	} else {
		eval(Lq+'secondmenu_'+lngPageID+Sq+'.left=MenuX');
	}
	setTimeout('moveOffX('+lngPageID+', '+i+', '+MenuX+', '+PosX+')',speed);
	   }
}

// Window opening
function openWin(url, width, height, left, top)
{
	var win = window.open(url, '_blank','resizable=no,scrollbars=no,status=0,directories=no,toolbar=no,menubar=no,left='+left+',top=100,width='+width+',height='+height);
}

// Window resize opening
function openResizeWin(url, width, height, left, top)
{
	var win = window.open(url, '_blank','resizable=yes,scrollbars=yes,status=0,directories=no,toolbar=no,menubar=no,left='+left+',top=100,width='+width+',height='+height);
}

// Window resize opening
function openResizeWinmenu(url, width, height, left, top)
{
	var win = window.open(url, '_blank','resizable=yes,scrollbars=yes,status=0,directories=no,toolbar=no,menubar=yes,left='+left+',top=100,width='+width+',height='+height);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}




//-->
