window.name = 'mainwindow';

function set_target ( fname) {
	if (fname.clicktype[1].checked && mapclicked) {
		mapclicked = false;
		fname.action = "click_info.phtml"
		fname.target='infoaken';
	
//		window.open("","infoaken","height=350,width=370,resizable=0,scrollbars=yes,scrollbars=1,scrolling=yes")
		updatePopup(350,370, 'tyhi.html', 'infoaken', 'resizable=1,scrollbars=yes,scrollbars=1,scrolling=yes,')
	} else {
	      fname.action = "atlas.phtml"
	      fname.target = "";
	}
	return true;
}

  function set_mapclick ( vrtus) {
	mapclicked = vrtus;
  }

  // Teeme kindlaks , milline on kasutatav ekraanilahutus ...
  if(screen.width > 800) {
	var mapwidth = 1;
  } else {
	var mapwidth = 0;
  }
  var mapclicked = false;


var LastWindowOpened = "";

function closePopup() {

  if (LastWindowOpened != "") {
    if (eval("self." + LastWindowOpened)) {
      if (!(eval("self." + LastWindowOpened + ".closed"))) {
        eval ("self." + LastWindowOpened + ".close()");
      }
    }
  }
}



function openPopup(thisWidth,thisHeight,thisDocument,thisWindowName,windowtools) {

  OpenThisWindow = true;
  if (eval("self." + thisWindowName)){
    if (!(eval("self." + thisWindowName + ".closed"))) {
      eval ("self." + thisWindowName + ".focus()");
      OpenThisWindow = false;
    }
  }

  if (OpenThisWindow){
    if (LastWindowOpened != thisWindowName) {
      closePopup()
    }
     
    if (windowtools == null) {           
      var windowtools = "toolbar=0,location=0,directories=0,status=1,scrollbars=1,resizable=1,alwaysRaised=1,";
    }

    eval(thisWindowName + " = window.open(\"" + thisDocument + "\",\"" + thisWindowName + "\",\"" + windowtools + "width=" + thisWidth + ",height=" + thisHeight + ",top=10,left=10,screeny=25,screenx=50\")");
    LastWindowOpened = thisWindowName;
  }

}

function updatePopup(wWidth,wHeight,thisDocument,thisWindowName,windowtools) {

  OpenThisWindow = true;
  if (eval("self." + thisWindowName)){
    if (!(eval("self." + thisWindowName + ".closed"))) {
      eval ("self." + thisWindowName + ".focus()");
      eval ("self." + thisWindowName + ".location = \"" + thisDocument + "\"");
      OpenThisWindow = false;
    }
  }

  if (OpenThisWindow){
    if (LastWindowOpened != thisWindowName) {
      closePopup()
    }
                
    if (windowtools == null) {           
      var windowtools = "toolbar=0,location=0,directories=0,status=1,scrollbars=1,resizable=1,alwaysRaised=1,";
    }

    eval(thisWindowName + " = window.open(\"" + thisDocument + "\",\"" + thisWindowName + "\",\"" + windowtools + "width=" + wWidth + ",height=" + wHeight + ",top=10,left=10,screeny=25,screenx=50\")");
    LastWindowOpened = thisWindowName;
  }

}

function naitapl( kood) {
		window.location.href = 'atlas.phtml?menu_id=plan&plankood='+kood;
}

