var d = document;
// !! AJAX LOAD PAGE !! //
	function makeRequest(url, type) {
		var httpRequest;
		if (window.XMLHttpRequest) { // Mozilla, Safari, and non-working IE7...
			httpRequest = new XMLHttpRequest();
			if (httpRequest.overrideMimeType) {
				httpRequest.overrideMimeType('text/xml');
			} else {
				// If IE7
				try {
					httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
				} 
				catch (e) {
					try {
						httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
					} 
					catch (e) {	}
				}
			}
		} 
		else if (window.ActiveXObject) { // IE
			try {
				httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
				//alert("Prøver xml2");
				} 
				catch (e) {
						   try {
								httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
							   } 
							 catch (e) { }
						  }
				 }
	
		if (!httpRequest) {
			alert('AJAX gir opp tilkobling. Nettleseren din mangler støtte for AJAX.');
			return false; 
		}
		httpRequest.onreadystatechange = function() { alertContents(httpRequest); };
		httpRequest.open('GET', url, true);
		httpRequest.send(null);
	
	}
	
	function alertContents(httpRequest) {
		if (httpRequest.readyState == 4) {
			if (httpRequest.status == 200) {
				gjorNoeMedHentetData(httpRequest.responseText, type);
			} else {
				alert('Beklager, ukjent feil har oppstått.');
			}
		}
	
	}
	
// !! FUNKSJON SOM BEHANDLER DATA //
	function gjorNoeMedHentetData(input, type) {
		if(type == "rediger") {
			d.getElementById('SP3_core_lastestatus').innerHTML = "bah";
		}
	}
	
function visSporring() {
	document.getElementById("sqlsporring").style.display = "block";
}

function visRad(visHva, liste) {
	rada = document.getElementById(liste + "_rad_" + visHva).style;
	knappen = document.getElementById("detaljKnapp_" + visHva);
	if(rada.display == "table-row") {
		rada.display = "none";
		knappen.innerHTML = '<img src="ikoner/pluss.png" border="0" alt="Vis detaljer" />';
	} else {
		rada.display = "table-row";
		knappen.innerHTML = '<img src="ikoner/minus.png" border="0" alt="Skjul detaljer" />';
	}
}

function byttRader(liste, fra, til) {
	TMP = d.getElementById("" + liste + fra).innerHTML;
	d.getElementById("" + liste + fra).innerHTML = d.getElementById("" + liste + til).innerHTML;
	d.getElementById("" + liste + til).innerHTML = TMP;
	//alert(TMP);
}

// !! !! !! GJØR OM TIL NYTT ILLUSTRASJONSBILDE !! !! !! //
function nyttIllBilde(id1, id2) {
	d.getElementById(id1).style.display = "block";
	d.getElementById(id2).style.display = "none";
}

function visNav($input) {
	d.getElementById("SP3_nav_hvor").innerHTML = $input;
}
function visMeny($input) {
	d.getElementById("SP3_post_meny").innerHTML = $input;
}
function TMCE_visBildeskjema(ting) {
	if(ting == "SP3_nybildeskjema") {
		d.getElementById("SP3_nybildeskjema").style.display = "";
		d.getElementById("SP3_bildeskjema").style.display = "none";
	}
}

var win=null;
function popUP(mypage,myname,w,h,pos,infocus){
if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}
settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no";win=window.open(mypage,myname,settings);
win.focus();}

var win=null;
function popUPnoscroll(mypage,myname,w,h,pos,infocus){
if(pos=="random"){myleft=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;mytop=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){myleft=(screen.width)?(screen.width-w)/2:100;mytop=(screen.height)?(screen.height-h)/2:100;}
else if((pos!='center' && pos!="random") || pos==null){myleft=0;mytop=20}
settings="width=" + w + ",height=" + h + ",top=" + mytop + ",left=" + myleft + ",scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no";win=window.open(mypage,myname,settings);
win.focus();}
