var    NS4 = (document.layers) ? 1 : 0;
var    IE4 = (document.all) ? 1 : 0;
var   ver4 = (NS4 || IE4) ? 1 : 0;
var   ver5 = (document.getElementById) ? 1 : 0;
var  isMac = (navigator.appVersion.indexOf("Mac") != -1) ? 1 : 0;
var isMenu = (NS4 || IE4) ? 1 : 0;


function karttaclick(hy) {
  document.kform.alue.value=hy;
  if ( submitQuery(hy) ) 
     {
     document.kform.submit();		
     }    
}

function showByEvent(tget,x,y,e,firstLine,secondLine) {

  // Offsetit
  x = 10;
  y = 5;

  if (document.layers && document.layers[tget]) {
    changeContent(tget, firstLine,secondLine);


    //Netscape
    if ((e.x + x+15 + document.layers[tget].clip.width) > (window.pageXOffset + window.innerWidth)){
        x = 0 - e.x + window.pageXOffset + window.innerWidth - document.layers[tget].clip.width - 15;
    } 
     
    if ((e.y + y+10 + document.layers[tget].clip.height) > (window.pageYOffset + window.innerHeight)){
        y = 0 - e.y + window.pageYOffset + window.innerHeight - document.layers[tget].clip.height - 15;
    }
    			 
    document.layers[tget].left = e.x + x;
    document.layers[tget].top = e.y + y;
    document.layers[tget].visibility = 'visible';
    
  } else if (document.all) {
    //MSIE   
    document.all[tget].innerHTML = "<table class='yellowtable'><tr><td><div class='tttext'><b>"+ firstLine+"</b><br>"+secondLine+"</div></td></tr></table>"
    
    if ( ver5 ) {
       if ((window.event.x + x +  document.all[tget].offsetWidth) > (document.body.clientWidth + document.body.scrollLeft)){
         px = (document.body.clientWidth + document.body.scrollLeft) - document.all[tget].offsetWidth - x;
       } else {
         px = window.event.x + x;
       }
       px =  px + document.body.scrollLeft;
    } else {
       if ( (window.event.x + x + document.all[tget].clientWidth) > (document.body.clientWidth + document.body.scrollLeft) ) {
       	  px = document.body.clientWidth + document.body.scrollLeft - document.all[tget].clientWidth;
       } else {
          px = window.event.x;
       }
    }

    if ( ver5 ) {
       if ((window.event.y + y + document.all[tget].offsetHeight) > (document.body.clientHeight + document.body.scrollTop)){
          py = (document.body.clientHeight + document.body.scrollTop) - document.all[tget].offsetHeight - y;
       } else {
          py = window.event.y + y;
       }
       py = py   + document.body.scrollTop;
    } else {
       if ((window.event.y + y + document.all[tget].clientHeight) > (document.body.clientHeight + document.body.scrollTop)){
          py = (document.body.clientHeight + document.body.scrollTop) - document.all[tget].clientHeight - y;
       } else {
          py = window.event.y + y;
       }
    }
        
    document.all[tget].style.posLeft = px;
    document.all[tget].style.posTop = py;
    document.all[tget].style.visibility = 'visible';
    
  }    	
}

function hide(tget) {
  if (document.layers && document.layers[tget]) {
    document.layers[tget].visibility = 'hidden';
  } else if (document.all) {
    document.all[tget].style.visibility = 'hidden';
  }
}

// Netscapea varten.
function changeContent(tget, firstLine,secondLine) {
  document.layers[tget].document.write( "<table class='yellowtable'><tr><td><div class='tttext'><b>"+ firstLine+"</b><br>"+secondLine+"</div></td></tr></table>" );
  document.layers[tget].document.close()
}
