// Hatikka
// mikko/biomi.org


function resizeTextarea(field) {
// Lisää textarea-elementiin rivejä sitä mukaa kun lisää tekstiä kirjoitetaan.
// Sijoita trigger textarea-tagiin näin:
// onKeyUp="resizeTextarea(document.FORM-ID.TEXTAREA-ID)"

  var linel = field.getAttribute('cols');
  var textl = field.value.length;

  var lines = 1.2*(textl/linel);
  linesround = Math.round(lines);

  if (navigator.appName == "Microsoft Internet Explorer") {
    b = Math.round(0.5*lines);
    // if (b > 2) { Math.round(0.3*lines); } else { }
  }
  else {
    var b = 0; 
  }

  if (textl/linel < 1) {
    field.setAttribute("rows",1);
  }
  else {
     field.setAttribute("rows",linesround + b);
  }
}
//--------------------------------------------------- FUNCTION ENDS


function obsFocus() {
// Kohdistaa kursorin 
//  Suomalaisten havaintojen ja atlas-tallennuslomakkeella Provinssiin
//  Ulkomaisten havaintojen tallennuslomakkeella Maahan

  var strHref = window.location.href;

  if (strHref.indexOf("cou=fin") > -1 || strHref.indexOf("atl=atl") > -1) {
    document.forms[0].pro.focus()
  }
  else {
    document.forms[0].cou.focus()
  }
}

//--------------------------------------------------- FUNCTION ENDS

function date1Focus() {
// Kohdistaa kursorin päivämäärä-alku -kentään

  var strHref = window.location.href;
  document.forms[0].date1.focus()
}

//--------------------------------------------------- FUNCTION ENDS

var infoview

function infoviewer(theURL, widthset, heightset) {
	if (!widthset) {
		var widthset = 400
	}
	if (!heightset) {
		var heightset = 400
	}
	var properties = "toolbar=yes,scrollbars=yes,resizable=yes,width=" + widthset + ",height=" + heightset
	if (infoview && !infoview.closed)
		{
		infoview.location = theURL
		infoview.focus()
		}
	else
		{
		infoview = window.open(theURL,'infoviewer',properties)    
		}
}

//--------------------------------------------------- FUNCTION ENDS


function copycoord(to) {
  var temp = frames["ykj_mapframe"].document.getElementById("idtargetpoint").value;
  document.getElementById(to).value = temp;
} 

//--------------------------------------------------- FUNCTION ENDS

function clearcoord(to) {
  var temp = "";
  document.getElementById(to).value = temp;
} 

//--------------------------------------------------- FUNCTION ENDS

// Checkbox & ruksitaulu: Hyönteiskartoitus 81

function checkboxChange(boxid, trid) {
	if (document.getElementById(boxid).checked) {
	  document.getElementById(trid).className="tr-checked";
	}
	else {
	  document.getElementById(trid).className="tr-unchecked";
	}
}

//--------------------------------------------------- FUNCTION ENDS

function porvoo() {
  // onKeyUp: copy text from input and set link value

var kiint = document.getElementById("sit").value;
kiint1 = "http://pikkutikka.fmnh.helsinki.fi/vanhaporvoo/index.php?title=" + kiint;
kiint2 = "infoviewer('http://pikkutikka.fmnh.helsinki.fi/vanhaporvoo/index.php?title=" + kiint + "', 700, 500); return false;";

document.getElementById("porvoolink").setAttribute("href", kiint1);
document.getElementById("porvoolink").setAttribute("onclick", kiint2);

} 

//--------------------------------------------------- FUNCTION ENDS

