	function clear_Form(obj, text) {
		if( obj.value == "Finn en medarbeider") {
			obj.value="";
		}
	}
	function gid(id) {
		return document.getElementById(id);
	}
	function skjulMedRes() {
		setTimeout('gid("medarb_res").style.visibility="hidden"', 500);
	}
	function medSok(obj) {
		if( obj.value.length > 1) { // se etter et ord som starter på denne/disse bokstavene i databasen
			if( window.XMLHttpRequest ) {
				xmlhttp = new XMLHttpRequest();
			}
			else {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			xmlhttp.onreadystatechange=function() {
				if( xmlhttp.readyState==4) {
					gid("medarb_res").style.visibility="visible";
					gid("medarb_res").innerHTML=xmlhttp.responseText;
				}
			}
			xmlhttp.open("GET", "http://www.radioharstad.no/medarb_res.php?q="+obj.value, true);
			xmlhttp.send();
		}
	}
	/* Created by: Paul Tuckey | http://tuckey.org/ Modified by: EZboy yuriy.demchenko at gmail.com */
	function countLines(strtocount, cols) {
	  var hard_lines = 1;
	  var last = 0;
	  while ( true ) {
		last = strtocount.indexOf("\n", last+1);
		hard_lines ++;
		if ( last == -1 ) break;
	  }
	  var soft_lines = Math.round(strtocount.length / (cols-1));
	  var hard = eval("hard_lines  " + unescape("%3e") + "soft_lines;");
	  if ( hard ) soft_lines = hard_lines;
	  return soft_lines;
	}
	
	// Multiple onload function created by: Simon Willison http://simon.incutio.com/archive/2004/05/26/addLoadEvent
	function addLoadEvent(func) {
	  var oldonload = window.onload;
	  if (typeof window.onload != 'function') {
		window.onload = func;
	  } else {
		window.onload = function() {
		  if (oldonload) {
			oldonload();
		  }
		  func();
		}
	  }
	}

	addLoadEvent(function() {
	  clear_Form(this);
	});
	


	var i = -1;
	$(document).keydown(function(e){
		if( e.keyCode != 40 && e.keyCode != 38 && e.keyCode != 13 ) {
			i = -1;
		}
		$('#medarb_res a div').removeClass('rh_sok_pil');
		if( e.keyCode == 13 ) {
			window.location = $('#medarb_res a').eq(i).attr('href');
		} else if( e.keyCode == 40 ) { // pil ned
			i++;
			if( i == $('#medarb_res a').size() ) {
				i = 0;
			}
			
		} else if( e.keyCode == 38 ) { // pil opp
			i--;
			if( i == -1 || i == -2 ) {
				i = $('#medarb_res a').size()-1;
			}
		}
		$('#medarb_res a div').eq(i).addClass('rh_sok_pil');
	});

