var http_request = false;

function makePOSTRequest(url, parameters) {
	http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			// set type accordingly to anticipated content type
			//http_request.overrideMimeType('text/xml');
		http_request.overrideMimeType('text/html');
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
		try {
			http_request = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {}
		}
	}
	if (!http_request) {
		alert('Cannot create XMLHTTP instance');
		return false;
	}

	http_request.onreadystatechange = alertContents;
	http_request.open('GET', url, true);
	http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http_request.setRequestHeader("Content-length", parameters.length);
	http_request.setRequestHeader("Connection", "close");
	http_request.send(parameters);
}

function alertContents() {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			result = http_request.responseText;
			document.getElementById('UNID').value = trim(result);
		} else {
			alert('There was a problem with the request.');
		}
	}
}


function postForm() {
	
	var katalog = '';
	
	if((document.getElementById("tomtJa").checked) == true){
		harTomt = 'Ja';
	}else{
		harTomt = 'Nei';
	}
	
	if((document.getElementById("huskatalog").checked) == true){
		katalog = 'Hus';
		if((document.getElementById("hyttekatalog").checked) == true){
			katalog = 'Hus og Fritid';
		}
	}else{
		if((document.getElementById("hyttekatalog").checked) == true){
			katalog = 'Fritid';
		}
	}
	

	var poststr = "Navn=" + encodeURI( document.getElementById("navn").value );
	poststr = poststr + "&Email=" + encodeURI( document.getElementById("epost").value );
	poststr = poststr + "&Telefon=" + encodeURI( document.getElementById("telefon").value );
	poststr = poststr + "&Adresse=" + encodeURI( document.getElementById("adresse").value );
	poststr = poststr + "&Postnr=" + encodeURI( document.getElementById("postnr").value );
	poststr = poststr + "&Poststed=" + encodeURI( document.getElementById("sted").value );
	poststr = poststr + "&Kommentar=" + encodeURI( document.getElementById("kommentar").value );
	poststr = poststr + "&Fylke=" + encodeURI( document.getElementById("tempfeltFylke").value );
	poststr = poststr + "&Kommune=" + encodeURI( document.getElementById("tempfelt").value );
	poststr = poststr + "&dispKommune=" + encodeURI( document.getElementById("tempfelt").value );
	poststr = poststr + "&Byggemnd=" + encodeURI( document.getElementById("maaned").value );
	poststr = poststr + "&ByggeAar=" + encodeURI( document.getElementById("aarstall").value );
	poststr = poststr + "&Tomt=" + encodeURI(harTomt);
	poststr = poststr + "&Kjennskap=" + encodeURI( document.getElementById("viteom").value );
	poststr = poststr + "&Katalog=" + encodeURI(katalog);
	
	var URL = "http://extranet.novoconsult.no/web/forhandler.nsf/orderform?openagent"
	makePOSTRequest(URL, poststr)
	
	//alert(poststr);

	
}


