var myimages = new Array();
window.onload = function()
{
	//Sett riktig størrelse på overlegg
	pageDim = getPageSizeWithScroll();
   //document.getElementById('overlegg').style.height = pageDim[1] + "px";
	//document.getElementById('overlegg2').style.height = pageDim[1] + "px";
	av_height = getWinHeight();
	if( pageDim[1] > av_height )
		av_height = pageDim[1];
   document.getElementById('overlegg').style.height = av_height + "px";
	document.getElementById('overlegg2').style.height = av_height + "px";

	initPage();
}

function contact_search( reg )
{
   document.getElementById('overlegg').style.display='';
	document.getElementById('sok_resultat').style.display='';
	xajax_contact_search(reg);
}

function search( sok )
{
	var sok = sok.replace(/(<([^>]+)>)/ig,"");
	if( !sok.match('eller artikler'));
	if( sok.length > 2 )
	{
		//alert( sok );
		document.getElementById('overlegg').style.display='';
		document.getElementById('sok_resultat').style.display='';
		xajax_search(sok);
	}
}


function preloading()
{
	for (x=0; x<preloading.arguments.length; x++)
	{
		myimages[x] = new Image();
		myimages[x].src = preloading.arguments[x];
	}
}


function getWinHeight() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return myHeight;
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
}

function getPageSizeWithScroll(){
	if (window.innerHeight && window.scrollMaxY) {// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
		xWithScroll = window.innerWidth + window.scrollMaxX;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yWithScroll = document.body.scrollHeight;
		xWithScroll = document.body.scrollWidth;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.offsetHeight;
		xWithScroll = document.body.offsetWidth;
  	}
	arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);
	//alert( 'The height is ' + yWithScroll + ' and the width is ' + xWithScroll );
	return arrayPageSizeWithScroll;
}

function openFilListe( ressurs_id )
{
	var ressursLinjeNavn = "ressurs_linje_" + ressurs_id;
	var filListeNavn 		= "fil_liste_" + ressurs_id;
	var filListeId = document.getElementById(filListeNavn);
	var content = filListeId.innerHTML;
	if( content == "" )
		xajax_visFilListe( ressurs_id, ressursLinjeNavn, filListeNavn )
	else
	{
		document.getElementById(ressursLinjeNavn).className = "ressursLinje";
		filListeId.innerHTML = "";
	}
}

function bigImage(art_id,id)
{
	document.getElementById('overlegg2').style.display='';
	document.getElementById('popHolder').style.display='';
	xajax_bigImage(art_id,id);
}



function hideOverlegg()
{
	xajax_resetPops();
	if( document.getElementById('overlegg').style.display=='' )
	{
		document.getElementById('overlegg').style.display='none';
		document.getElementById('sok_resultat').style.display='none';
		document.getElementById('sokFelt').value='Søk i ansatte, skoler eller artikler';
	}
	if( document.getElementById('overlegg2').style.display=='' )
	{
       if( b = document.getElementById('overlegg2') )
			b.style.display='none';
         if( p = document.getElementById('popHolder') )
			p.style.display='none';
		 //new Effect.Fade('popHolder', {duration:0.4,queue: 'front'});
	}
}

function popup(url, name, width, height)
{
	settings="fullscreen=no,toolbar=no,location=no,directories=no,"+
	"status=no,menubar=yes,scrollbars=yes,"+
	"resizable=no,width="+width+",height="+height+",left=10,top=10";
	MyNewWindow=window.open(url,name,settings);
}

loadingNyhet = function()
{
	nyhetsBoks = document.getElementById('front_nyhetsDetalj');
	if( !nyhetsBoks )
		nyhetsBoks = document.getElementById('norge_nyhetsDetalj');
	nyhetsBoks.innerHTML = '<div align=\"center\" style=\"position:relative;top:150px;\"><img src=\"design/gfx/ajax-loader.gif\" border=\"0\">';
}