	// cookie_expire
	var $cookie_expire = new Date();
	$cookie_expire.setMilliseconds($cookie_expire.getMilliseconds()+(60*60*24*90*1000));
	$cookie_expire = $cookie_expire.toGMTString();
	// cookie_domain
	var $cookie_domain = '.' + location.host;
	$pos_dot = location.host.lastIndexOf('.');
	if ($pos_dot != -1) {
		$pos_dot = location.host.lastIndexOf('.', $pos_dot - 1);
		if ($pos_dot != -1) {
			var $cookie_domain = location.host.substring($pos_dot, location.host.length);
		}
	}

	//if (top.location != self.location) {
		//top.location.href = self.location;
	//}

	if (location.host.indexOf('eksperten.dk') != -1) {
		window.onerror = null;
	}

	function get_id ($id) {
		if (document.all && document.getElementById) {
			return document.all($id);
		} else if (!document.all && document.getElementById) {
			return document.getElementById($id);
		} else {
			return false;
		}
	}

	function box_click ($id) {
		if (($bcontent = get_id($id+'c')) && ($img = get_id($id+'i'))) {
			$bcontent = $bcontent.style;
		} else {
			return false;
		}
		if ($bcontent.visibility == 'hidden') {
			$bcontent.display = '';
			$bcontent.visibility = 'visible';
			$img.src = '/media/1030_156.gif';
			set_cookie('box['+$id+']',1,$cookie_expire,'/',$cookie_domain);
		} else {
			$bcontent.display = 'none';
			$bcontent.visibility = 'hidden';
			$img.src = "/media/1030_156.gif";
			set_cookie('box['+$id+']',0,$cookie_expire,'/',$cookie_domain);
		}
	}

	function get_cookie ($name) {
		var $start = document.cookie.indexOf($name + '=');
		var $len = $start + $name.length + 1;
		if ((!$start) && ($name != document.cookie.substring(0, $name.length))) {
			return null;
		}
		if ($start == -1) {
			return null;
		}
		var $end = document.cookie.indexOf(';', $len);
		if ($end == -1) {
			$end = document.cookie.length;
		}
		return unescape(document.cookie.substring($len, $end));
	}

	function set_cookie ($name, $value, $expires, $path, $domain, $secure) {
		document.cookie = $name + '=' + escape($value) + (($expires) ? '; expires=' + $expires : '') + (($path) ? '; path=' + $path : '') + (($domain) ? '; domain=' + $domain : '') + (($secure) ? '; secure' : '');
	}

	function set_browser_width () {
		$browser_width = (window.innerWidth || document.body.clientWidth) - 16;
		if (get_cookie('browser_width') != $browser_width) {
			set_cookie('browser_width', $browser_width, '', '/', $cookie_domain);
		}
		return $browser_width;
	}

	function init () {
		// browser_width
		$browser_width = set_browser_width();
		$id_table = get_id('table_main');
		$id_content = get_id('content');
		if ($id_table && $id_content && ($browser_width < $WIDTH_MAIN)) {
			$id_table.style.width = $browser_width + 'px';
			$id_content.style.width = $browser_width - (4 + 20 + 300 + 20) + 'px';
		}
		// hide art banner?
		if (($id = get_id('artbanner')) && $id.style.offsetHeight < 200) {
			$id.style.display = 'none';
			$id.style.visibility = 'hidden';
		}
		// reposition menu
		position_menu();
		oM.construct(1);
		//
		mozilla_workaround();
	}
	window.onresize = init;

	var $artbanner_force_hide = false;
	function artbanner_control ($show, $force) {
		if ($id = get_id('artbanner')) {
			if ($show && !$artbanner_force_hide) {
				$id.style.display = '';
				$id.style.visibility = 'visible';
			} else {
				$id.style.display = 'none';
				$id.style.visibility = 'hidden';
			}
		}
		if ($force) {
			$artbanner_force_hide = true;
		}
	}

	function get_xy ($obj) {
		var $rd = {x:0, y:0};
		do {
			$rd.x += parseInt($obj.offsetLeft);
			$rd.y += parseInt($obj.offsetTop);
			$obj = $obj.offsetParent;
		} while ($obj);
		return $rd;
	}

	var $current_rid, $current_username, $tid;

	function post_tools ($rid, $username, $pos) {
		window.clearTimeout($tid);
		if ($id = get_id('qtools')) {
			$item = $id.style;
		} else {	// !IE5 && !NS6
			document.location.href = '/bruger.phtml?navn='+escape($username);
			return false;
		}
		if ($current_rid == $rid) {
			$item.display = 'none';
			$item.visibility = 'hidden';
			$current_rid = -1;
		} else {
			$item.display = 'inline';
			$item.visibility = 'visible';
			var $obj = get_id('rid'+$rid);
			$obj_xy = get_xy($obj);
			if ($rid) {
				$item.left = $obj_xy.x + 'px';
				$item.top = $obj_xy.y + 15 + 'px';
			} else {
				if (document.all && document.getElementById) {
					$item.left = $pos.x - 250;
				} else {
					$item.left = $pos.pageX - 250;
				}
				$item.top = $obj_xy.y + 16;
			}
			$current_rid = $rid;
			$current_username = $username;
			$tid = window.setTimeout('post_tools('+$rid+',0,0)', 30000);
		}
		return false;
	}

	function post_tools_action ($action, $xtra) {
		switch ($action) {
			case 0 :	// show userinfo
				document.location.href = '/bruger.phtml?navn='+escape($current_username);
				break;
			case 1 :	// hide rid
				document.location.href = '/ignorer.phtml?rid='+$current_rid+'&goto='+self.location+'#'+$current_rid;
				break;
			case 2 :	// local hide user
				document.location.href = '/ignorer.phtml?rid='+$current_rid+'&brugernavn='+escape($current_username)+'&goto='+self.location+'#'+$current_rid;
				break;
			case 3 :	// global hide user
				document.location.href = '/ignorer.phtml?global=1&brugernavn='+escape($current_username)+'&goto='+self.location+'#'+$current_rid;
				break;
			case 4 :	// show rid
				document.location.href = '/ignorer.phtml?show_rid='+$xtra+'&goto='+self.location+'#'+$xtra;
				break;
			case 5 :	// show user
				document.location.href = '/ignorer.phtml?show_username='+$xtra+'&goto='+self.location;
				break;
			case 6 :	// disable post
				document.location.href = '/coadmin/post_disable.phtml?rid='+$current_rid;
				break;
			case 7 :	// karma
				document.location.href = '/karma.phtml?username='+escape($current_username);
				break;
			case 8 :	// anmeld
				document.location.href = '/support/report.phtml?rid='+$current_rid;
				break;
		}
	}

	function spmlist () {
		set_cookie("status_1",(document.forms["qlist_form"].status_1.checked)?"on":"off",$cookie_expire,"/",$cookie_domain);
		set_cookie("status_2",(document.forms["qlist_form"].status_2.checked)?"on":"off",$cookie_expire,"/",$cookie_domain);
		set_cookie("status_3",(document.forms["qlist_form"].status_3.checked)?"on":"off",$cookie_expire,"/",$cookie_domain);
		set_cookie("status_4",(document.forms["qlist_form"].status_4.checked)?"on":"off",$cookie_expire,"/",$cookie_domain);
	}

	function catmap ($catid) {
		if ($catid) {
			if (!document.forms['fedit']) {
				top.location.href = '/kat/' + $catid;
				return true;
			}
			//$obj = fedit.catid;
			$obj = document.forms['fedit'].catid;
			for (var $i = 0; $i < $obj.options.length; $i++) {
				if ($obj.options[$i].value == $catid) {
					$obj.options[$i].selected = true;
					catdesc();
					return true;
				}
			}
		} else {
			$height = (screen.height > 480) ? 600 : 450;
			$catmap = window.open('/catmap.phtml','catmap','width=500,height=' + $height + ',location=no,menubar=no,toolbar=no,scrollbars=yes,resizable=yes,top=100,left=30');
			$catmap.focus();
		}
	}

	var $catdesc_current;
	function catdesc () {
		$obj = document.forms['fedit'].catid;
		$catid = $obj.options[$obj.selectedIndex].value;
		if ($id = get_id('c' + $catid + 'desc')) {
			if ($catdesc_current != null) {
				$catdesc_current.style.display = 'none';
				$catdesc_current.style.visibility = 'hidden';
			}
			$catdesc_current = $id;
			$id.style.display = 'block';
			$id.style.visibility = 'visible';
			if ($id = get_id('catdesc-warn')) {
				$id.style.display = 'block';
				$id.style.visibility = 'visible';
			}
		}
	}

	function chart () {
		document.write('<img src="http://cluster.chart.dk/reghit.asp?website_id=81655&secID=' + Math.random()*10000000 + '&ref=' + escape(document.referrer) + '" width="1" height="1" alt="" />');
	}

	function freetxt () {
		if (($id = get_id('freetxt')) && ($img = get_id('freetxt_arrow'))) {
			if ($id.style.display == 'none') {
				$id.style.visibility = 'visible';
				$id.style.display = 'block';
				$img.src = "/img/arrow-down.gif";
				//
				$id = get_id('qlist_search_normal_sort');
				$id.style.visibility = 'hidden';
				$id.style.display = 'none';
				//
				set_cookie('freetxt',1,$cookie_expire,'/',$cookie_domain);
				//
				if (($id = get_id('userpart')) && $id.style.display != 'none') {
					userpart();
				}
			} else {
				$id.style.visibility = 'hidden';
				$id.style.display = 'none';
				$img.src = "/img/arrow-right.gif";
				//
				$id = get_id('qlist_search_normal_sort');
				$id.style.visibility = 'visible';
				$id.style.display = 'block';
				//
				set_cookie('freetxt',0,$cookie_expire,'/',$cookie_domain);
			}
		}
	}

	function userpart () {
		if (($id = get_id('userpart')) && ($img = get_id('userpart_arrow'))) {
			if ($id.style.display == 'none') {
				$id.style.visibility = 'visible';
				$id.style.display = 'block';
				$img.src = "/img/arrow-down.gif";
				set_cookie('userpart',1,$cookie_expire,'/',$cookie_domain);
				// hide freetext?
				if (($id = get_id('freetxt')) && $id.style.display != 'none') {
					freetxt();
				}
			} else {
				$id.style.visibility = 'hidden';
				$id.style.display = 'none';
				$img.src = "/img/arrow-right.gif";
				set_cookie('userpart',0,$cookie_expire,'/',$cookie_domain);
				// drop value
				document.forms['qlist_form'].spm_creator.value = '';
				document.forms['qlist_form'].spm_part.value = '';
				document.forms['qlist_form'].spm_answer.value = '';
			}
		}
	}

	function checkbox_click ($id, $form) {
		eval('$obj = document.forms["' + $form + '"].' + $id + ';');
		if ($obj.disabled) {
			return false;
		}
		$obj.checked = $obj.checked ? false : true;
	}

	function section_link () {
		return ($section == 2) ? 'artikler' : 'spm';
	}

	function highlight ($src, $id) {
		if ($src.style.backgroundColor != 'lightgrey') {
			$src.style.backgroundColor = 'lightgrey';
		} else {
			$src.style.backgroundColor = 'white';
		}
		if ($user_logged_in) {
			var $fid = document.forms['fexp'].rselected;
			var $value = ' ' + $id + ' ';
			if ($fid.value.indexOf($value) != -1) {
				var $re = new RegExp($value);
				$fid.value = $fid.value.replace($re, '');
			} else {
				$fid.value = $fid.value + $value;
			}
		}

	}

	function mozilla_workaround () {
		// bug: http://bugzilla.mozilla.org/show_bug.cgi?id=262109
		if (navigator.userAgent.indexOf('Gecko') == -1 || (document.location.href.indexOf('/spm/') == -1 && document.location.href.indexOf('/artikler/') == -1)) {
			return;
		}
		for ($n = 0; $s = document.styleSheets[$n]; ++$n) {
			$s.disabled = true;
			$s.disabled = false;
		}
	}

	function report_abuse () {
		if (!$user_logged_in) {
			alert('Du skal være logget ind.');
		}
		var $fid = document.forms['fexp'].rselected;
		document.location.href = '/support/report.phtml?refs=' + escape($fid.value);
	}

