
$(document).ready(function() {

  $("#searchbutton").click(function() {
    document.location.href = '/?alttemplate=search&search=' + $("#searchtext").val();
  });

  $("#searchbuttona").click(function() {
    document.location.href = '/?alttemplate=search&search=' + $("#searchtexta").val();
  });

  $("#select-county").change(function() {
    document.location.href = $("#select-county").val();
  });

  $("#select-line").change(function() {
    document.location.href = $("#select-line").val();
  });

  $("#box-annonser").click(function() {
//    alert('skjul');
  });

  $("#searchtext").keypress(function(e) {

    var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;

    if(key == 13) {
      $("#searchbutton").click();
      return false;
    }
  });

  $("#searchtexta").keypress(function(e) {

    var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;

    if(key == 13) {
      $("#searchbuttona").click();
      return false;
    }
  });

});



function writemap(address,number,zip,city)
{
	document.write("<iframe src='http://app.fleximap.com/tunmedia/mapimage.aspx?gate=" + address + "&husnr=" + number + "&postnr=" + zip + "&post=" + city + "&iw=250&ih=250&sc=500000&img=4' style='border:0' border='0' height='260' width='260'></iframe>");
}

	function openMediaWindow(url,width,height) {
	var availheight=((screen.availHeight-height)/2);
	var availwidth=((screen.availWidth-width)/2);
	winStats='resizable=no,toolbar=no,status=no,location=no,directories=no,menubar=no,';
	winStats+='scrollbars=no,width='+width+',height='+height;
	if (navigator.appName.indexOf("Microsoft")>=0) {
		winStats+=',left='+availwidth+',top='+availheight;
	}else{
		winStats+=',screenX='+availwidth+',screenY='+availheight;
	}
	floater=window.open(url,"",winStats)
}