var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)

var version4 = (navigator.appVersion.charAt(0) == "4");
var popupHandle;
var hide  = true;
document.onmousemove = getMouseXY;



var tempX = 0
var tempY = 0
var oldrow = 't0'
var crntclr = ''
var hvractive = 0
var menuskin = "skin1";
var display_url = 0;
var delay = 0;
var target = 'self';
var headlinePos = 0;
var urls = new Array();
var items = new Array();
var showhl = 0;

function evalobject(O,W){
	var o,w,s,t;
	if (!O){alert('Mangler objektreferanse');}
	else{
	o=eval(O);
	if (!W){
		w=window.open()}
	else
	{w=W}
	
	w.document.write('Enumerating: '+O+'<br>');
	for (c in o) {
		try{
		t=typeof(o[c]);
		t='object'==t||'array'==t;
		s=' <b>'+O+'.'+c+' </b> = ';
		if(t)
			s+=' <a href=javascript:window.opener.evalobject("'+O+'.'+c+'",window)>';
			s+=o[c];
			if(t) 
				s+=' </a>';
				s+=' <br>\n';
				w.document.write(s)
			}
			catch(evalobject){}
		}
	w.document.close();
	w.focus()
	}
}


function requestdelete(stractionondelete)
{

	if (CanIDelete() == true)
		{
		window.parent.location=stractionondelete;
		
		}

}

function CanIDelete(){
	var name = confirm("Klikk OK knappen for å slette denne forekomsten\nmed tilhørende registrerte opplysninger");
	return name;
}

function RequestTestMsg(){
	var name = confirm("Klikk OK knappen for å sende til alle mottakere\neller avbryt for å sende en testmelding til deg selv");
	return name;
}

function showhide(obj, refobjid)
{
	var x = document.getElementById(refobjid);
	hide = !hide;
	x.style.visibility = (hide) ? 'hidden' : 'visible';
	setLyr(obj,refobjid);
}

function setLyr(obj,lyr)
{
	var coors = findPos(obj);
	// if (lyr == 'testP') coors[1] -= 50;
	var x = document.getElementById(lyr);
	x.style.top = coors[1] + 'px';
	x.style.left = coors[0] + 'px';
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}


function Len(str)
/***
        IN: str - the string whose length we are interested in

        RETVAL: The number of characters in the string
***/
{  return String(str).length;  }


function Mid(str, start, len)
        /***
                IN: str - the string we are LEFTing
                    start - our string's starting position (0 based!!)
                    len - how many characters from start we want to get

                RETVAL: The substring from start to start+len
        ***/
        {
                // Make sure start and len are within proper bounds
                if (start < 0 || len < 0) return "";

                var iEnd, iLen = String(str).length;
                if (start + len > iLen)
                        iEnd = iLen;
                else
                        iEnd = start + len;

                return String(str).substring(start,iEnd);
        }

function StringExists(strSearch, charSearchFor)
{

	if (strSearch.match(charSearchFor)==charSearchFor)
		{
		return -1
		}
	return 0

}


	
function InStr(strSearch, charSearchFor)
/*
InStr(strSearch, charSearchFor) : Returns the first location a substring (SearchForStr)
                           was found in the string str.  (If the character is not
                           found, -1 is returned.)
                           
Requires use of:
	Mid function
	Len function
*/
{
	for (i=0; i < Len(strSearch); i++)
	{
	    if (charSearchFor == Mid(strSearch, i, 1))
	    {
			return i;
	    }
	}
	return -1;
}


function enableordisable(frmSkjema, btnToEnable, chkBoxValue)
{
var btn = frmSkjema.item(btnToEnable)
var chkbx = frmSkjema.item(chkBoxValue)
	if (chkbx.checked = true)
		{
			btn.disabled = false
		}
	else
		{
			btn.disabled = true
		}
}

function isjavascripthere()
{
	alert('I´m here, and ready!');
}
function opennewwin(strurl,dlgwith,dlgheight)
{


	if ((tempY + dlgheight) > screen.availHeight){tempY = (screen.availHeight - (dlgheight + 20)) }
	if ((tempX + dlgwith) > screen.availWidth){tempX = (screen.availWidth - (dlgwith + 20)) }  

	displayPopup(2,strurl,'sekvenspopup',dlgheight,dlgwith,(version4 ? event : null))

}

function closeallwin()
{
	if (null != popupHandle)
	{
		if(false == popupHandle.closed)
		{
			popupHandle.close()
		}
	}
}


function imgselect(strurl)
{

	var dlgwith = 755
	var dlgheight = 385
	
	if ((tempY + dlgheight) > screen.availHeight){tempY = (screen.availHeight - (dlgheight + 20)) }
	if ((tempX + dlgwith) > screen.availWidth){tempX = (screen.availWidth - (dlgwith + 20)) }  
	
	displayPopup(1,strurl,'image',dlgheight,dlgwith,(version4 ? event : null))

	// displayDialog(1,strurl,'image',dlgheight,dlgwith,(version4 ? event : null))

}

function popupdisplay(strurl)
{

	var dlgwith = 700
	var dlgheight = 500
	
	if ((tempY + dlgheight) > screen.availHeight){tempY = (screen.availHeight - (dlgheight + 20)) }
	if ((tempX + dlgwith) > screen.availWidth){tempX = (screen.availWidth - (dlgwith + 20)) }  

	displayPopup(2,strurl,'sendpw',dlgheight,dlgwith,(version4 ? event : null))
	}

function systempopupwindow(strurl, dlgwith, dlgheight)
{
	
	if ((tempY + dlgheight) > screen.availHeight){tempY = (screen.availHeight - (dlgheight + 20)) }
	if ((tempX + dlgwith) > screen.availWidth){tempX = (screen.availWidth - (dlgwith + 20)) }  

	displayPopup(2,strurl,'javaclientcoded',dlgheight,dlgwith,(version4 ? event : null))
	}

function passworddisplay()
{

	var dlgwith = 330
	var dlgheight = 200
	
	if ((tempY + dlgheight) > screen.availHeight){tempY = (screen.availHeight - (dlgheight + 20)) }
	if ((tempX + dlgwith) > screen.availWidth){tempX = (screen.availWidth - (dlgwith + 20)) }  

	displayPopup(1,'sendmepw.asp','sendpw',dlgheight,dlgwith,(version4 ? event : null))
	}

function confirmdelete(strmsg)
{
		if (strmsg != null)
			{
			var name = confirm(strmsg)
			}
			else
			var name = confirm("Klikk OK knappen for å slette denne forekomsten")
			
		if (name == true)
			{
			return true;
			
			}
		else
		return false;
}



function checkrequired(which) 
{
var pass=true;

if (document.images) 
	{
	for (i=0;i<which.length;i++) 
	{
	var tempobj=which.elements[i];
	
		if (((tempobj.type=="text"||tempobj.type=="textarea")&&	tempobj.value=='' || tempobj.value=='Dette feltet mangler opplysninger')||(tempobj.type.toString().charAt(0)=="s"&& tempobj.selectedIndex==0)) 
		{
			pass=false;
			break;
         }
     }
	}
	if (!pass) {
	shortFieldName=tempobj.title;
	alert("Feltet "+shortFieldName+" mangler opplysninger.");
	tempobj.value='Dette feltet mangler opplysninger';
	tempobj.focus();
	tempobj.select();
	return false;
	}
	else
	return true;
}

	
function frmSubmit(vrAction, vrFormName)
{

	var editor = document.forms(vrFormName)
	var editItem = document.forms(vrFormName).item("action")
	editItem.value = vrAction
	if (vrAction != '1')
	{
		editor.submit()
	}
	else
	{
		var name = confirm("Klikk OK knappen for å slette denne forekomsten")
		if (name == true)
			{
			editor.submit()
			
			}
	}
}

function editdisplay(strscript, srcfld) {

	var dlgwith = 800
	var dlgheight = 650
	
	if ((tempY + dlgheight) > screen.availHeight){tempY = (screen.availHeight - (dlgheight + 20)) }
	if ((tempX + dlgwith) > screen.availWidth){tempX = (screen.availWidth - (dlgwith + 20)) }  
	
	// 
	// window.open(strscript + "?source=" + srcfld, "editor","left=" + tempX + ",top=" + tempY + ",height=" + dlgheight + ",width=" + dlgwith + ",scrollbars=no")
	// window.open(strscript, "editor","left=" + tempX + ",top=" + tempY + ",height=" + dlgheight + ",width=" + dlgwith + ",scrollbars=no")
	
	//displayDialog(1, strscript + "?source=" + srcfld,'editor',dlgheight,dlgwith,(version4 ? event : null))
	displayDialog(1, strscript ,'editor',dlgheight,dlgwith,(version4 ? event : null))
	}


function showdialog(strscript, dlgwith,dlgheight) {

	
	if ((tempY + dlgheight) > screen.availHeight){tempY = (screen.availHeight - (dlgheight + 20)) }
	if ((tempX + dlgwith) > screen.availWidth){tempX = (screen.availWidth - (dlgwith + 20)) }  
	

	displayDialog(2, strscript,'windialog',dlgheight,dlgwith,(version4 ? event : null))
	}


function caldisplay(strscript, srcfld, srcCSS) {

	var dlgwith = 170
	var dlgheight = 170
	
	if ((tempY + dlgheight) > screen.availHeight){tempY = (screen.availHeight - (dlgheight + 20)) }
	if ((tempX + dlgwith) > screen.availWidth){tempX = (screen.availWidth - (dlgwith + 20)) }  
	
	// window.open("/common/dtepicker.asp?source=" + srcfld, "calendar","left=" + tempX + ",top=" + tempY + ",height=" + dlgheight + ",width=" + dlgwith + ",scrollbars=no")
	displayPopup(1, strscript + "?source=" + srcfld + "&css=" + srcCSS,'calendar',dlgheight,dlgwith,(version4 ? event : null))
	}

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  

  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0} 
  return true
}
function EnableNewPage() {


}

function GotoNewPage(NewPage) {


}
function IsIE() 
{
	
	if (navigator.userAgent.indexOf('MSIE')>-1)
		return true;
	else
		return false;
}

function SA_DisplayErr(ErrMsg) {
	DisplayErr(ErrMsg);
	//alert(ErrMsg);
}
    
function DisplayErr(ErrMsg) {
    var strErrMsg = '<table class="ErrMsg"><tr><td><img src=/images/critical_error.gif" border=0></td><td>' + ErrMsg + '</td></tr></table>'
	if (IsIE()) {
		document.all("divErrMsg").innerHTML = strErrMsg;
	}
	else {
		alert(ErrMsg);
	}
}
function closePopup() {
if(popupHandle != null && !popupHandle.closed) popupHandle.close()
}


function didparentgetfocus(myname, parentname){
alert("didparentgetfocus");

}

function displayPopup(position,url,name,height,width,evnt)
{
// Nannette Thacker http://www.shiningstar.net
// position=1 POPUP: makes screen display up and/or left,
//    down and/or right
// depending on where cursor falls and size of window to open
// position=2 CENTER: makes screen fall in center

var properties = "titlebar=0,status=no,toolbar=no,location=0,height="+height
properties = properties+",width="+width

var brwsertype
var leftprop, topprop, screenX, screenY, cursorX, cursorY, padAmt

if(navigator.appName == "Microsoft Internet Explorer")
{
	screenY = document.body.offsetHeight
	screenX = window.screen.availWidth
	brwsertype = "msie"
}
else
{ // Navigator coordinates
//		screenY = window.outerHeight
//		screenX = window.outerWidth
	// change made 3/16/01 to work with Netscape:
		rwsertype = "nonmsie"
		screenY = screen.height;
		screenX = screen.width;
}

if(position == 1)	// if POPUP not CENTER
{
	cursorX = evnt.screenX
	cursorY = evnt.screenY
	padAmtX = 10
	padAmtY = 10
	
	if((cursorY + height + padAmtY) > screenY)	
	// make sizes a negative number to move left/up
	{
		padAmtY = (-30) + (height*-1);	
		// if up or to left, make 30 as padding amount
	}
	if((cursorX + width + padAmtX) > screenX)
	{
		padAmtX = (-30) + (width*-1);	
		// if up or to left, make 30 as padding amount
	}

	if(navigator.appName == "Microsoft Internet Explorer")
	{
		leftprop = cursorX + padAmtX
		topprop = cursorY + padAmtY
	}
	else
	{ // adjust Netscape coordinates for scrolling
		leftprop = (cursorX - pageXOffset + padAmtX)
		topprop = (cursorY - pageYOffset + padAmtY)
	}
}
else	// CENTER
{
	leftvar = (screenX - width) / 2
	rightvar = (screenY - height) / 2
		
	if(navigator.appName == "Microsoft Internet Explorer")
	{
		leftprop = leftvar
		topprop = rightvar
	}
	else
	{ // adjust Netscape coordinates for scrolling
		leftprop = (leftvar - pageXOffset)
		topprop = (rightvar - pageYOffset)
	}
}

if(evnt != null)
{
properties = properties+",left="+leftprop
properties = properties+",top="+topprop


}
closePopup()

popupHandle = open(url,name,properties)

}


function displayDialog(position,url,name,height,width,evnt)
{
// Nannette Thacker http://www.shiningstar.net
// position=1 POPUP: makes screen display up and/or left,
//    down and/or right
// depending on where cursor falls and size of window to open
// position=2 CENTER: makes screen fall in center

// var properties = "titlebar=0,status=no,toolbar=no,location=0,height="+height
// properties = properties+",width="+width

var properties = "help:no;status:no;scroll:no;dialogHide:no;resizable:no;center:no;dialogHeight:"+height
properties = properties+"px;dialogWidth:"+width+"px"



var brwsertype
var leftprop, topprop, screenX, screenY, cursorX, cursorY, padAmt

if(navigator.appName == "Microsoft Internet Explorer")
{
	screenY = document.body.offsetHeight
	screenX = window.screen.availWidth
	brwsertype = "msie"
}
else
{ // Navigator coordinates
//		screenY = window.outerHeight
//		screenX = window.outerWidth
	// change made 3/16/01 to work with Netscape:
		brwsertype = "nonmsie"
		screenY = screen.height;
		screenX = screen.width;
}

if(position == 1)	// if POPUP not CENTER
{
	cursorX = evnt.screenX
	cursorY = evnt.screenY
	padAmtX = 10
	padAmtY = 10
	
	if((cursorY + height + padAmtY) > screenY)	
	// make sizes a negative number to move left/up
	{
		padAmtY = (-30) + (height*-1);	
		// if up or to left, make 30 as padding amount
	}
	if((cursorX + width + padAmtX) > screenX)
	{
		padAmtX = (-30) + (width*-1);	
		// if up or to left, make 30 as padding amount
	}

	if(navigator.appName == "Microsoft Internet Explorer")
	{
		leftprop = cursorX + padAmtX
		topprop = cursorY + padAmtY
	}
	else
	{ // adjust Netscape coordinates for scrolling
		leftprop = (cursorX - pageXOffset + padAmtX)
		topprop = (cursorY - pageYOffset + padAmtY)
	}
}
else	// CENTER
{
	leftvar = (screenX - width) / 2
	rightvar = (screenY - height) / 2
		
	if(navigator.appName == "Microsoft Internet Explorer")
	{
		leftprop = leftvar
		topprop = rightvar
	}
	else
	{ // adjust Netscape coordinates for scrolling
		leftprop = (leftvar - pageXOffset)
		topprop = (rightvar - pageYOffset)
	}
}

if(evnt != null)
{
// properties = properties+",left="+leftprop
// properties = properties+",top="+topprop

properties = properties+";dialogLeft:"+leftprop
properties = properties+";dialogTop:"+topprop

}
closePopup()

popupHandle = window.showModalDialog(url,window,properties)

}



function textCounter(field,maxlimit) {

// onKeyDown="textCounter(document.saveline.strComments,255)" onKeyUp="textCounter(document.saveline.strComments,255)"
if (field.value.length > maxlimit)
field.value = field.value.substring(0, maxlimit)
}

function setdate(field) {
// onKeyDown="setdate(document.saveline.strComments)" onKeyUp="setdate(document.saveline.strComments)"
var date = new Date();
var year = date.getYear();
var month = date.getMonth() + 1;
var day = date.getDate();
if (day < 10){
	day = '0' + day
}

if (month < 10){
month = '0' + month
}

field.value = day + "." + month + "." + year

}

function setTodayDate()
{
	var code;
	var strDate;
	var date = new Date();
	var d  = date.getDate();
	var day = (d < 10) ? '0' + d : d;
	var m = date.getMonth() + 1;
	var month = (m < 10) ? '0' + m : m;
	var yy = date.getYear();
	var year = (yy < 1000) ? yy + 1900 : yy;

	
	strDate = day + "." + month + "." + year	
	
	if (event.keyCode == 68) 
	{
	event.srcElement.value = strDate;
	}
	
}

function submitdefinedform(frmForm,setvalue){
var selfrm = document.forms(frmForm)

selfrm.handleaction.value = setvalue;
//document.forms.clsEdit.flipp.value = "<%=strCrntFlipp%>";
selfrm.submit();
}

function checkboxrequired(frmForm, btntolock) 
{
var pass=false;

var which = document.forms(frmForm);
var cmbBtn = which.item(btntolock);
var count = which.elements.length

cmbBtn.disabled=false;

	for (i=0;i<count;i++) 
	{
		var tempobj=which.elements[i];
		
		if ((tempobj.type=="checkbox") && (tempobj.checked==false)) 
		{
			cmbBtn.disabled=true;
			break;
         }
     }
}




function showmenuie5(selectedmenu) {
var evnt = (version4 ? event : null)
var crntmnu = document.getElementById(selectedmenu)
var height = crntmnu.offsetHeight
var width = crntmnu.offsetWidth
var position = 1

var leftprop, topprop, screenX, screenY, cursorX, cursorY, padAmt

	if(navigator.appName == "Microsoft Internet Explorer")
	{
		screenY = document.body.offsetHeight
		screenX = window.screen.availWidth
	}
	else
	{ 
		screenY = screen.height;
		screenX = screen.width;
	}
	
	if(position == 1)	// if POPUP not CENTER
	{
		cursorX = evnt.screenX
		cursorY = evnt.screenY
		padAmtX = 10
		padAmtY = 10
		
		if((cursorY + height + padAmtY) > screenY)	
		// make sizes a negative number to move left/up
		{
			padAmtY = (-30) + (height*-1);	
			// if up or to left, make 30 as padding amount
		}
		if((cursorX + width + padAmtX) > screenX)
		{
			padAmtX = (-30) + (width*-1);	
			// if up or to left, make 30 as padding amount
		}
	
		if(navigator.appName == "Microsoft Internet Explorer")
		{
			leftprop = cursorX + padAmtX
			topprop = cursorY + padAmtY
		}
		else
		{ // adjust Netscape coordinates for scrolling
			leftprop = (cursorX - pageXOffset + padAmtX)
			topprop = (cursorY - pageYOffset + padAmtY)
		}
	}


	crntmnu.style.top = document.body.scrollTop + event.clientY  - 200; 
	crntmnu.style.left =  document.body.scrollLeft + event.clientX  - 200; 
	crntmnu.style.visibility = "visible";
return false;
}

function showdivlmnt(elementid, ajustY, ajustX) {
var evnt = (version4 ? event : null)
var crntmnu = document.getElementById(elementid)
var height = crntmnu.offsetHeight
var width = crntmnu.offsetWidth
var position = 1

var leftprop, topprop, screenX, screenY, cursorX, cursorY, padAmt

	if(navigator.appName == "Microsoft Internet Explorer")
	{
		screenY = document.body.offsetHeight
		screenX = window.screen.availWidth
	}
	else
	{ 
		screenY = screen.height;
		screenX = screen.width;
	}
	
	if(position == 1)	// if POPUP not CENTER
	{
		cursorX = evnt.screenX
		cursorY = evnt.screenY
		padAmtX = 10
		padAmtY = 10
		
		if((cursorY + height + padAmtY) > screenY)	
		// make sizes a negative number to move left/up
		{
			padAmtY = (-30) + (height*-1);	
			// if up or to left, make 30 as padding amount
		}
		if((cursorX + width + padAmtX) > screenX)
		{
			padAmtX = (-30) + (width*-1);	
			// if up or to left, make 30 as padding amount
		}
	
		if(navigator.appName == "Microsoft Internet Explorer")
		{
			leftprop = cursorX + padAmtX
			topprop = cursorY + padAmtY
		}
		else
		{ // adjust Netscape coordinates for scrolling
			leftprop = (cursorX - pageXOffset + padAmtX)
			topprop = (cursorY - pageYOffset + padAmtY)
		}
	}


	crntmnu.style.top = document.body.scrollTop + event.clientY + ajustY ; 
	crntmnu.style.left =  document.body.scrollLeft + event.clientX + ajustX; 
	crntmnu.style.visibility = "visible";


return false;
}

function hidemenu(selmenu) {
var mnutohide = document.getElementById(selmenu)
mnutohide.style.visibility = "hidden";

}

function loctest(){
	alert('test');
}

function addLoadEvent(func, params) {

  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func(params);
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func(params);
    }
  }
}


function showme(elmntToShow, elmntToHide){

	var ets = document.getElementById(elmntToShow);
	var eth = document.getElementById(elmntToHide);
	ets.style.fontWeight='bold';
	document.getElementById('general_' + elmntToShow).style.display='block';
	eth.style.fontWeight='normal';
	document.getElementById('general_' + elmntToHide).style.display='none';
}


function removeselfromlistitem(optionboxid){
	var opt = document.getElementById(optionboxid);
	var idx = 0;
	for (idx=0;idx<=opt.length;idx++)
		{
			if (opt.options[idx]!=null){
				if (opt.options[idx].value==0){
					opt.options[idx]=null
				}			
			}
		}
	

}


function highlightie5() {

if (event.srcElement.className == "menuitems") {

event.srcElement.style.backgroundColor = "gray";

event.srcElement.style.color = "black";

if (display_url)

window.status = event.srcElement.url;

   }

}

function lowlightie5() {

if (event.srcElement.className == "menuitems") {

event.srcElement.style.backgroundColor = "";

event.srcElement.style.color = "black";

window.status = "";

   }

}

function jumptoie5() {

if (event.srcElement.className == "menuitems") {

if (event.srcElement.getAttribute("target") != null)

window.open(event.srcElement.url, event.srcElement.getAttribute("target"));

else

window.location = event.srcElement.url;

   }

}


var persistclose=0 //set to 0 or 1. 1 means once the bar is manually closed, it will remain closed for browser session
var startX = 0 //set x offset of bar in pixels
var startY = 85 //set y offset of bar in pixels
var verticalpos="fromtop" //enter "fromtop" or "frombottom"

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function closebar(){
if (persistclose)
document.cookie="remainclosed=1"
document.getElementById("meny").style.visibility="hidden"
}

function staticbar(){
	barheight=document.getElementById("meny").offsetHeight
	var ns = (navigator.appName.indexOf("Netscape") != -1) || window.opera;
	var d = document;
	function ml(id){
		var el=d.getElementById(id);
		if (!persistclose || persistclose && get_cookie("remainclosed")=="")
		el.style.visibility="visible"
		if(d.layers)el.style=el;
		el.sP=function(x,y){this.style.left=x+"px";this.style.top=y+"px";};
		el.x = startX;
		if (verticalpos=="fromtop")
		el.y = startY;
		else{
		el.y = ns ? pageYOffset + innerHeight : iecompattest().scrollTop + iecompattest().clientHeight;
		el.y -= startY;
		}
		return el;
	}
	window.stayTopLeft=function(){
		if (verticalpos=="fromtop"){
		var pY = ns ? pageYOffset : iecompattest().scrollTop;
		ftlObj.y += (pY + startY - ftlObj.y)/8;
		}
		else{
		var pY = ns ? pageYOffset + innerHeight - barheight: iecompattest().scrollTop + iecompattest().clientHeight - barheight;
		ftlObj.y += (pY - startY - ftlObj.y)/8;
		}
		ftlObj.sP(ftlObj.x, ftlObj.y);
		setTimeout("stayTopLeft()", 15);
	}
	ftlObj = ml("meny");
	stayTopLeft();
}

//Function to hover item
function overItem(iconItem) {
	iconItem.style.backgroundColor='#CCCCCC';
}

//Function to moving off item
function outItem(iconItem) {
	iconItem.style.backgroundColor='#FFFFFF';
}



function showiframe(selectedmenu, movetop, moveleft) {
var evnt = (version4 ? event : null)
var crntmnu = document.getElementById(selectedmenu)
var height = crntmnu.offsetHeight
var width = crntmnu.offsetWidth
var position = 1
// window.status='Høyde: ' + height + ' Bredde:' + width; 
var leftprop, topprop, screenX, screenY, cursorX, cursorY, padAmt

	if(navigator.appName == "Microsoft Internet Explorer")
	{
		screenY = document.body.offsetHeight;
		screenX = window.screen.availWidth;
	}
	else
	{ 
		screenY = screen.height;
		screenX = screen.width;
	}
	
	if(position == 1)	// if POPUP not CENTER
	{
		cursorX = evnt.screenX;
		cursorY = evnt.screenY;
		padAmtX = 10;
		padAmtY = 10;
		
		if((cursorY + height + padAmtY) > screenY)	
		// make sizes a negative number to move left/up
		{
			padAmtY = (-30) + (height*-1);	
			// if up or to left, make 30 as padding amount
		}
		if((cursorX + width + padAmtX) > screenX)
		{
			padAmtX = (-30) + (width*-1);	
			// if up or to left, make 30 as padding amount
		}
	
		if(navigator.appName == "Microsoft Internet Explorer")
		{
			leftprop = cursorX + padAmtX;
			topprop = cursorY + padAmtY;
		}
		else
		{ // adjust Netscape coordinates for scrolling
			leftprop = (cursorX - pageXOffset + padAmtX);
			topprop = (cursorY - pageYOffset + padAmtY);
		}
	}


	crntmnu.style.top = document.body.scrollTop + event.clientY - movetop; 
	crntmnu.style.left =  document.body.scrollLeft + event.clientX  - moveleft; 
	crntmnu.style.visibility = "visible";


return false;
}

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}


function checktimefield(ctrlField){
    if(!IsValidTime(ctrlField.value) && (ctrlField.value!='')) {
      ctrlField.style.color = '#FF0000';
      alert("'" + ctrlField.value + "', kan ikke brukes som klokkeslett!");
      ctrlField.value='';
      ctrlField.focus();
      ctrlField.style.color = '';
      return false;
    }
	return true;
}

function IsValidTime(timeStr) {
	var timePat = /^(\d{1,2}):(\d{2})(:(\d{2}))?(\s?(AM|am|PM|pm))?$/;
	var matchArray = timeStr.match(timePat);
	if (matchArray == null) {
		return false;
	}
	
	hour = matchArray[1];
	minute = matchArray[2];
	second = matchArray[4];
	ampm = matchArray[6];
	
	if (second=="") { second = null; }
	if (ampm=="") { ampm = null }
	if (hour < 0  || hour > 23) {
		return false;
	}
	if  (hour > 12 && ampm != null) {
		return false;
	}
	if (minute<0 || minute > 59) {
		return false;
	}
	if (second != null && (second < 0 || second > 59)) {
		return false;
	}
	return true;
}

if (document.getElementById)
{
	function makeHyperlink(position)
	{
		if (showhl!=0){
			var hyperlink = "<a href=\"" + urls[position] + "\" target=\"" + linktarget + "\">" + items[position] + "</a>";
		}
		else
		{
			var hyperlink = items[position];
		}
		return hyperlink;

			
	}
	
	function replaceHTML(position)
	{
		document.getElementById("headline").innerHTML = makeHyperlink(position);
		if(position == (urls.length - 1)) {
			headlinePos = 0;
		} else {
			headlinePos++;
		}
	}	
	
	function writeHeadlines(strTagId)
	{
		document.writeln(precedingHTML + makeHyperlink(headlinePos) + followingHTML);
		headlinePos++;
		setInterval('replaceHTML(headlinePos)', delay);
	}
}  	

function countDownToRefresh(tick)    
	{    
	if (tick == 0)        
		{        
			// window.location.href="<%=NwPge%>";        
			return;        
		}    
	var time = "";    
	var minute = Math.floor(tick / 60);    
	if (minute < 10)        
	{        
		time += "0";        
	}    
	time += minute + ":";    
	var second = tick % 60;    
	if (second < 10)        
	{        
		time += "0";        
	}    
	time += second;    
	window.clock.innerText = time;    
	--tick;    
	var command = "countDownToRefresh(" + tick + ")";    
	window.setTimeout(command,1000);    
	}

function waitPreloadPage(itmParent) 
{ 
var PrepPage;	

	if (itmParent!=null){
		PrepPage = itmParent.document.getElementById('prepage');
	}
	else
	{
		if (document.getElementById){
			PrepPage = document.getElementById('prepage');
			}
			else
			{
				if (document.layers){ //NS4
				PrepPage = document.prepage;

			}
			else { //IE4
				PrepPage = document.all.prepage;

			}
		}
	
	}
	if (document.getElementById){
		PrepPage.style.visibility='hidden';
		}
		else
		{
			if (document.layers){ //NS4
			PrepPage.visibility = 'hidden';
		}
		else { //IE4
			PrepPage.style.visibility = 'hidden';
		}
	}
}

function waitPreloadParentPage() 
{ 
	if (parent.document.getElementById){
		parent.document.getElementById('prepage').style.visibility='hidden';
		}
		else
		{
			if (parent.document.layers){ //NS4
			parent.document.prepage.visibility = 'hidden';
		}
		else { //IE4
			parent.document.all.prepage.style.visibility = 'hidden';
		}
	}
}

function prepPreloadParentPage() 
{ 
	if (parent.document.getElementById){
		parent.document.getElementById('prepage').style.visibility='visible';
		}
		else
		{
			if (parent.document.layers){ //NS4
			parent.document.prepage.visibility = 'visible';
		}
		else { //IE4
			parent.document.all.prepage.style.visibility = 'visible';
		}
	}
}         

         
function prepPreloadPage() 
{ 
	if (document.getElementById){
		document.getElementById('prepage').style.visibility='visible';
		}
		else
		{
			if (document.layers){ //NS4
			document.prepage.visibility = 'visible';
		}
		else { //IE4
			document.all.prepage.style.visibility = 'visible';
		}
	}
}         
function countdown(year, month, day, hour, minute, format)
         {
         Today = new Date();
         Todays_Year = Today.getYear() - 2000;
         Todays_Month = Today.getMonth() + 1;                  
         
         //Convert both today's date and the target date into miliseconds.                           
         Todays_Date = (new Date(Todays_Year, Todays_Month, Today.getDate(), 
                                 Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime();                                 
         Target_Date = (new Date(year, month, day, hour, minute, 00)).getTime();                  
         
         //Find their difference, and convert that into seconds.                  
         Time_Left = Math.round((Target_Date - Todays_Date) / 1000);
         
         if(Time_Left < 0)
            Time_Left = 0;
         
         switch(format)
               {
               case 0:
                    //The simplest way to display the time left.
                    document.all.countdown.innerHTML = Time_Left + ' seconds';
                    break;
               case 1:
                    //More datailed.
                    days = Math.floor(Time_Left / (60 * 60 * 24));
                    Time_Left %= (60 * 60 * 24);
                    hours = Math.floor(Time_Left / (60 * 60));
                    Time_Left %= (60 * 60);
                    minutes = Math.floor(Time_Left / 60);
                    Time_Left %= 60;
                    seconds = Time_Left;
                    
                    dps = 's'; hps = 's'; mps = 's'; sps = 's';
                    //ps is short for plural suffix.
                    if(days == 1) dps ='';
                    if(hours == 1) hps ='';
                    if(minutes == 1) mps ='';
                    if(seconds == 1) sps ='';
                    
                    document.all.countdown.innerHTML = days + ' day' + dps + ' ';
                    document.all.countdown.innerHTML += hours + ' hour' + hps + ' ';
                    document.all.countdown.innerHTML += minutes + ' minute' + mps + ' and ';
                    document.all.countdown.innerHTML += seconds + ' second' + sps;
                    break;
               default: 
                    document.all.countdown.innerHTML = Time_Left + ' seconds';
               }
               
         //Recursive call, keeps the clock ticking.
         setTimeout('countdown(' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + format + ');', 1000);
         }

function detectPopupBlock(strAlertMsg) {
	var objChild;                           // Window
	var reWork = new RegExp('object','gi');	// Regular expression

	try {
		objChild = window.open('','child','width=5,height=5,status=no,resizable=yes'); 

		objChild.close();
	}
	catch(e) { }

	if(!reWork.test(String(objChild)))
		if(strAlertMsg!=''){
		alert(strAlertMsg);
		}else{
		return -1;
		}
}

function fbshre(urlToShare, faceBookTitle) 
{
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(urlToShare)+'&t='+encodeURIComponent(faceBookTitle),'sharer','toolbar=0,status=0,width=600,height=450');return false;
}

function countdown(yr,m,d, prefix){
	theyear=yr;themonth=m;theday=d
	var today=new Date()
	var todayy=today.getYear()
	if (todayy < 1000)
		todayy+=1900
		var todaym=today.getMonth()
		var todayd=today.getDate()
		var todayh=today.getHours()
		var todaymin=today.getMinutes()
		var todaysec=today.getSeconds()
		var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
		futurestring=montharray[m-1]+" "+d+", "+yr
		dd=Date.parse(futurestring)-Date.parse(todaystring)
		dday=Math.floor(dd/(60*60*1000*24)*1)
		dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
		dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
		dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
		if(dday==0&&dhour==0&&dmin==0&&dsec==1){
		cntarea.innerText=current
	
		return
	}
	else
		cntarea.innerText=prefix +" "+dday+ " dager, "+dhour+" timer, "+dmin+" minutter, og "+dsec+" sekund "+before
		setTimeout("countdown(theyear,themonth,theday,prefix)",1000)
}

function CommaToPunktaction(e) {
	var unicode = e.charCode ? e.charCode : e.keyCode;
	if (unicode==44) { 
		return (e.charCode ? e.charCode=46 : e.keyCode=46); 
	}
}

function WasEnterPressed(e) {
	var unicode = e.charCode ? e.charCode : e.keyCode;
	alert(unicode);
	if (unicode==13) { 
		// return true; 
	}
}

function numericInputOnly(inputfield) {
	var field = inputfield
	var valo = new String();
	var numere = "0123456789.,";
	var chars = field.value.split(""); 
	for (i = 0; i < chars.length; i++) {
	if (numere.indexOf(chars[i]) != -1) valo += chars[i];
	else{alert("Kun tall, komma og punktum er tillatt");}
	}
	if (field.value != valo) field.value = valo; 
}
