
function call(url){
	script = document.createElement( 'script' );
	script.src = url;
	document.getElementsByTagName( 'head' )[0].appendChild( script );
}

function _gel(id){return document.getElementById(id);}

function prompt2(str,val,f, v1, v2, v3, v4, v5){
	var w = document.body.clientWidth;
	var h = document.body.clientHeight;
	var scrollT = document.body.scrollTop;
	
	var d = document.createElement("DIV");
	d.id = "alert2div";
	d.innerHTML = "<form onsubmit='"+f+"(_gel(\"prompt2str\").value"+(v1 != undefined ? ", \""+v1+"\"" : "")+(v2 != undefined ? ", \""+v2+"\"" : "")+(v3 != undefined ? ", \""+v3+"\"" : "")+(v4 != undefined ? ", \""+v4+"\"" : "")+(v5 != undefined ? ", \""+v5+"\"" : "")+");prompt2Close();'>"+str+"<br><input type='text' size=48 id='prompt2str' value='"+val+"'> <input type='submit' value='OK'> <input type='button' value='Avbryt' onclick='prompt2Close();'></form>";
	d.style.position = "absolute";
	d.style.left = "100px";
	d.style.top = "100px";
	d.style.border = "2px solid #999";
	d.style.padding = "10px";
	d.style.backgroundColor = "#efefef";
	document.getElementsByTagName("BODY")[0].appendChild(d);
	var w2 = d.offsetWidth;
	var h2 = d.offsetHeight;
	d.style.top = (h/2 - h2 + scrollT)+"px";
	d.style.left = (w/2 - w2/2)+"px";
	_gel("prompt2str").select();
	_gel("prompt2str").focus();
}

function prompt2Close(){
	var d = _gel("alert2div");
	d.parentNode.removeChild(d);
}

var expDays = 30;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function SetCookie (name, value) {  
var argv = SetCookie.arguments;  
var argc = SetCookie.arguments.length;  
var expires = (argc > 2) ? argv[2] : null;  
var path = (argc > 3) ? argv[3] : null;  
var domain = (argc > 4) ? argv[4] : null;  
var secure = (argc > 5) ? argv[5] : false;  
document.cookie = name + "=" + escape (value) + 
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
((path == null) ? "" : ("; path=" + path)) +  
((domain == null) ? "" : ("; domain=" + domain)) +    
((secure == true) ? "; secure" : "");
}


function getCookieVal (offset) {  
	var endstr = document.cookie.indexOf (";", offset);  
	if (endstr == -1)    
	endstr = document.cookie.length;  
	return unescape(document.cookie.substring(offset, endstr));
	}

function GetCookie (name) {  
var arg = name + "=";  
var alen = arg.length;  
var clen = document.cookie.length;  
var i = 0;  
while (i < clen) {    
var j = i + alen;    
if (document.cookie.substring(i, j) == arg)      
return getCookieVal (j);    
i = document.cookie.indexOf(" ", i) + 1;    
if (i == 0) break;   
}  
return null;
}


function centerWin(url, w, h, scroll){
	if(scroll == undefined){scroll = "yes";}
	var l = (screen.width - w) / 2;
	var t = (screen.height - h) / 2;
	window.open(url, "", "top="+t+", left="+l+", height="+h+", width="+w+", scrollbars="+scroll);
}



function call2(url, id){
	var myConn = new XHConn();
	if(id){
		var ret = function (oXML) {if(_gel(id)){_gel(id).innerHTML = oXML.responseText;}};
	}else{
		var ret = function (oXML) {eval(oXML.responseText);};
	}
	var c = "";
	var a = url.split("?"); 
	if(a[1]){
		var b = a[1].split("&");

		for(var x=0;x<b.length;x++){
			var d = b[x].split("=");
			c += (c != "" ? "&" : "")+d[0]+"="+escape(d[1]);
		}
	}else{
		var c = "";
	}
	myConn.connect(a[0], "GET", c, ret);
}

function XHConn(){
	var xmlhttp;
	try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
	catch(e){try{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
	catch(e){try{ xmlhttp = new XMLHttpRequest(); }
	catch(e){xmlhttp = false; }}}
	if(!xmlhttp) return null;
	this.connect = function(sURL, sMethod, sVars, fnDone){
		if (!xmlhttp) return false;
		sMethod = sMethod.toUpperCase();
		try {
			if (sMethod == "GET"){
				xmlhttp.open(sMethod, sURL+"?"+sVars, true);
				sVars = "";
			}else{
				xmlhttp.open(sMethod, sURL, true);
				xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
				xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			}
			xmlhttp.onreadystatechange = function(){ if (xmlhttp.readyState == 4) { fnDone(xmlhttp);}};
			xmlhttp.send(sVars);
		}
		catch(z) { return false; }
		return true;
	}
	return this;
}

function formSubmit(frm) {
	
	var qs = '';
	for(e=0;e<frm.elements.length;e++) {
		if(frm.elements[e].name!='') {
			if(frm.elements[e].type.toUpperCase() == "CHECKBOX"){
				if(!frm.elements[e].checked){continue;}
			}else if(frm.elements[e].type.toUpperCase() == "RADIO"){
				if(!frm.elements[e].checked){continue;}
			}
			qs+=(qs=='')?'':'&';
			qs+=frm.elements[e].name+'='+escape(frm.elements[e].value);
		}
	}
	var m = !frm.method ? "GET" : frm.method;
	for(var x=0;x<frm.attributes.length;x++){
		if(frm.attributes[x].name.toUpperCase() == "ACTION"){
			var a = frm.attributes[x].value;
			break;
		}
	}
	var myConn = new XHConn();
	var ret = function (oXML){eval(oXML.responseText);};
	myConn.connect(a, m, qs, ret);
	return false;
}

function print_page(){
	_gel("header").style.display = "none";
	_gel("print_header").style.display = "block";
	_gel("mainmenu").style.display = "none";
	window.print();
	setTimeout('_gel("print_header").style.display = "none";_gel("header").style.display = "block";_gel("mainmenu").style.display = "block";', 1000);
	
}