var d = document;

function pageInit() {
	solve_captcha();
	fixLayoutHeights();
	updShadowHeights();
	$(window).resize(updShadowHeights); // on window resize, do this
}

function fixLayoutHeights() {
	var divs = new Array("tre_kol1_venstre","tre_kol1_midten","tre_kol1_hoyre"); //list of DIV ids
	var h = 0;
	for (i = 0; i < divs.length; i++) {
		if (!d.getElementById(divs[i])) continue;
		if (d.getElementById(divs[i]).offsetHeight > h) {
			h = d.getElementById(divs[i]).offsetHeight;
			//alert(h);
		}
	}

	for (i = 0; i < divs.length; i++) {
		if (!d.getElementById(divs[i])) continue;
		d.getElementById(divs[i]).style.height = h +"px"; //set the height of all divs to the tallest
	}
}

function updShadowHeights() {
	if ($(window).height() > $('#wrap').height()) {
		$('#wrap').height($(window).height());
	}

	$('#shadowl').height($('#wrap').height());
	$('#shadowr').height($('#wrap').height());
}

function setMainBoxWidth(width) {
	d.getElementById('main').style.width = width;
}

function random_password(length) {
	if (length == null) length = 8;
	var a = 'abcdefghijklmnopqrstuvwxyz0123456789';
	var pass = '';
	for (var i = 0; i <= length; i++) {
		pass = pass + a.substr(Math.round(35*Math.random()),1);
	}
	return pass;
}

function solve_captcha() {
	var antispam = d.getElementById('antispam');
	if (antispam) {
		antispam.value = 'hurra';
	}
	var captcha = d.getElementById('captcha');
	if (captcha) {
		captcha.style.display = 'none';
	}
}
