
////////////////////////////////////////////////////////////////////////////////////////////

function ChangeBGOver(id,picture)
{
	document.getElementById(id).setAttribute("background",''+picture+'')
	document.getElementById(id).className = 'hovedmeny_over';	
}

function ChangeBGOut(id,picture)
{
	document.getElementById(id).setAttribute("background",''+picture+'')
	document.getElementById(id).className = 'hovedmeny';	
}

function Navigate(side)
{
	window.location.href = side;
}



































////////////////////////////////////////////////////////////////////////////////////////////

// Finner sidens størrelse
function getPageSize()
{
	var xScroll, yScroll;	
	if (window.innerHeight && window.scrollMaxY)
	{	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	}
	else if (document.body.scrollHeight > document.body.offsetHeight)
	{
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	}
	else
	{
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
		
	var windowWidth, windowHeight;
	if (self.innerHeight)
	{
		if(document.documentElement.clientWidth)
		{
			windowWidth = document.documentElement.clientWidth; 
		}
		else
		{
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;

	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}
	else if (document.body)
	{
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	if(yScroll < windowHeight)
	{
		pageHeight = windowHeight;
	}
	else
	{ 
		pageHeight = yScroll;
	}
	if(xScroll < windowWidth)
	{
		pageWidth = xScroll;		
	}
	else
	{
		pageWidth = windowWidth;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

// Finner hvor du befinner deg på siden (scrolling)
function getPageScroll()
{
	var xScroll, yScroll;
	if (self.pageYOffset)
	{
		yScroll = self.pageYOffset;
		xScroll = self.pageXOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
	{
		yScroll = document.documentElement.scrollTop;
		xScroll = document.documentElement.scrollLeft;
	}
	else if (document.body)
	{
		yScroll = document.body.scrollTop;
		xScroll = document.body.scrollLeft;	
	}
	arrayPageScroll = new Array(xScroll,yScroll) 
	return arrayPageScroll;
}

// Finner hvor du befinner deg på siden (x = left - y = top)
function getPageXY(e)
{
	if (window.event)
	{
		xPage = event.clientX;
		yPage = event.clientY;
	}
	else if (e.which)
	{
		xPage = e.clientX;
		yPage = e.clientX;
	}
	arrayPageXY = new Array(xPage,yPage) 
	return arrayPageXY;
}

///// HTTP-Request /////////////////////////////////////////////////////////////////////////

function ShowHjelp(e,side,id,dato,mode,left,top,frame)
{
	var arrayPageScroll = getPageScroll();
	var xScroll = arrayPageScroll[0];
	var yScroll = arrayPageScroll[1];
	var arrayPageXY = getPageXY(e);
	var left = arrayPageXY[0] + xScroll;
	var top = arrayPageXY[1] + yScroll;
	if (left > 600)
	{
		document.getElementById('vishttprequest').style.top = top;
		document.getElementById('vishttprequest').style.left = left + 20;		
		document.all['vishttprequest'].style.visibility = "visible";
		SendRequest(side,id,dato,mode,left,top)
	}
	else
	{
		document.getElementById('vishttprequest').style.top = top;
		document.getElementById('vishttprequest').style.left = left + 20;
		document.all['vishttprequest'].style.visibility = "visible";
		SendRequest(side,id,dato,mode,left,top)
	}
}

function HideHTTPRequest()
{
	document.all['vishttprequest'].style.visibility = "hidden";
	document.getElementById("soekres").innerHTML = '';
}

///// Portal ///////////////////////////////////////////////////////////////////////////////

function view_address(email)
{
	if (email != "")
	{
		address_to_replace = document.getElementById("main_email").firstChild;
		real_address = address_to_replace.nodeValue.replace("[at]", "@");
		address_to_replace.nodeValue = real_address;
		address_to_replace.parentNode.setAttribute("href", "mailto:"+real_address);
	}
}

//// Admin //////////////////////////////////////////////////////////////////////////////////

// Setter URL på IFrame
function ShowIFrame(side,width,height,left,top)
{
	document.getElementById("innhold").setAttribute("src",''+side+'')	
	setTimeout("ShowIFrame1('"+width+"','"+height+"','"+left+"','"+top+"');",1000);
}

// Skjuler loading og viser IFrame
function ShowIFrame1(width,height,left,top)
{
	document.getElementById("visiframe").style.visibility = "visible";
	document.getElementById("visiframe").style.left = left;	
	document.getElementById("visiframe").style.top = top;
 	document.getElementById("innhold").style.width = width;
 	document.getElementById("innhold").style.height = height;
}

function HideIFrame()
{
	document.getElementById("visiframe").style.visibility = "hidden";
}

////////////////////////////////////////////////////////////////////////////////////////////

function Validate(e,Tegn)
{
	if (window.event)
	{
		var keychar = e.keyCode
		var browser = "ie";
	}
	else if (e.which)
	{
		var keychar = e.which
		var browser = "nn";
	}
	var c = String.fromCharCode(keychar)
	var cl = c.toLowerCase();
	if (Tegn.indexOf(cl) >= 0) 
	{
		return true;
	}
	else 
	{
		if (browser == "ie") 
		{
			var tekst = document.getElementById("hjelptekst");
			tekst.firstChild.nodeValue = "Du har brukt et ugyldig tegn.";			
			event.returnValue = false;
		}
		else if (browser == "nn")
		{
			var tekst = document.getElementById("hjelptekst");
			tekst.firstChild.nodeValue = "Du har brukt et ugyldig tegn.";
			e.preventDefault();
		}
	}
}
