function kalkulu (){
df=document.formo;

ind = df.lando.value;
 var kat = 0;
       var val =document.getElementById("valuto");
        var val1 =document.getElementById("valuto1");
         val.innerHTML = "&euro;";
          val1.innerHTML = "&euro;";

      
if (ind == "at" || ind == "be" || ind == "fi" || ind == "fr" || ind == "re" || ind == "nc" || ind == "de" || ind == "gb" || ind == "ca" ||
ind == "gr" || ind == "ie" || ind == "is" || ind == "it" || ind == "nl" || ind == "dk" || ind == "ch" ||
ind == "pt" || ind == "lu" ||  ind == "es" || ind == "sm" || ind == "li" ||  ind == "no" || ind == "se" ||
ind == "kr" || ind == "mt" || ind == "cy" || ind == "jp" || ind == "il" || ind == "gi" || ind == "us"
|| ind == "ad" || ind == "va" || ind == "au" || ind == "nz")
{
lando_kat = 0;

}
 
else {
  lando_kat = 1;
	}

var unua = new Array(160, 120,  200, 150, 80, 60, 120, 90);
var dua = new Array(200, 150, 250, 185, 100, 75, 150, 110);
var tria = new Array(240, 180, 300, 225, 120, 90, 180, 135);



var kat1 = 0;
var jaro = new Date();


if (jaro.getFullYear() == 2011) {
tabelo = unua;
}
else if (jaro.getFullYear() == 2012) {
if (jaro.getMonth() <= 2) {
tabelo = dua;
}
else {
tabelo = tria;
}
}
var kvo = 2;

    var ima = document.getElementById("im");
    var imkotizo = tabelo[lando_kat];
    	  ima.innerHTML = imkotizo + "&nbsp;&euro;";

    	   var neima = document.getElementById("neim");
    var neimkotizo = tabelo[lando_kat+kvo];
    	  neima.innerHTML = neimkotizo + "&nbsp;&euro;";

    	   var komita = document.getElementById("komit");
    var komkotizo = tabelo[lando_kat+kvo+kvo];
    	  komita.innerHTML = komkotizo + "&nbsp;&euro;";

    	     var raa = document.getElementById("ra");
    	      var raa1 = document.getElementById("ra1");
    	       var raa2 = document.getElementById("ra2");
if (df.kateg[0].checked){
var rakotizo = tabelo[lando_kat+(kvo*2)];
}
else {
 var rakotizo = tabelo[lando_kat+(kvo*3)];
 }
    	  raa.innerHTML = raa1.innerHTML = raa2.innerHTML = rakotizo + "&nbsp;&euro;";


var dap = 0;
if (df.kat[4].checked){
var dap = 0;
}
else if (df.kat[0].checked || df.kat[1].checked || df.kat[2].checked || df.kat[3].checked){
var dap = kvo*2;
}
 if (df.kat[0].checked && df.kateg[1].checked) {
 var dap = kvo;
 }

 var dp =document.getElementById("pagado");
 dp.style.display = 'block';
if (df.pago[0].checked || df.pago[1].checked || df.pago[2].checked) {
df.kotiz.value = 0;
dp.style.display = 'none';
}
else if (df.kateg[0].checked){
var kat1 = lando_kat + dap;
df.kotiz.value = tabelo[kat1];
}
else if (df.kateg[1].checked){
var kat1 = lando_kat + kvo + dap;
df.kotiz.value = tabelo[kat1];
}

else {
df.kotiz.value = "";
}

var kampoj = new Array(df.kotiz.value, df.donaco.value, df.iik.value,
df.blind.value, df.canuto.value, df.triamonda.value);
 var sumigo = 0;
for (i=0;i<kampoj.length;i++) {
var rep = parseInt(kampoj[i]);

	if (rep==rep) {
 sumigo = sumigo + rep;
}
}
  var sel =document.getElementById("sume");
 sel.innerHTML=sumigo;


}

 var url = "../alighoj/kontr.php?la=";

 function reenHTTP() {
  if (http.readyState == 4) {
         neplu();
    results = http.responseText;
     var el = document.getElementById("informo");
      var pel = document.getElementById("persone");
        var del = document.getElementById("datumoj");
        var kel = document.getElementById("kamp");

  if (results == 1) {
   pel.style.display = 'none';
     del.style.display = 'none';
   el.innerHTML = "Viaj personaj informoj jam estas registritaj &#265;e UEA, bv. plenigi nur la sekvajn kampojn";
   kel.value=results;
  }
  else if  (results == 0) {
  el.innerHTML = "Nekonata UEA-kodo a&#365; nekorekte elektita lando";
    pel.style.display = 'block';
    del.style.display = 'block';
     kel.value=results;
  }
  else if  (results == 2) {
  el.innerHTML = "Nekorekta kodo<br />&nbsp;";
  pel.style.display = 'block';
     del.style.display = 'block';
      kel.value=results;
  }

       }

}
function neplu() {
	 var el =	document.getElementById("informo");
	  var pel = document.getElementById("persone");
	      var del = document.getElementById("datumoj");
	       var kel = document.getElementById("kamp");
 	  el.innerHTML = "Bonvolu plenigi &#265;iujn kampojn markitajn per steleto *";
      pel.style.display = 'block';
         del.style.display = 'block';
          kel.value='';
}


 function vidu() {
 	var ku = document.formo.kodo.value;
 	if (ku.length ==6 && document.formo.lando.value !="ne indikita") {
 	kuo = ku + "_" + document.formo.lando.value;
  http.open("GET", url + escape(kuo), true);
  http.onreadystatechange = reenHTTP;
  http.send(null);
  } else {
  neplu();
  }
}
function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }

  return xmlhttp;
}
var http = getHTTPObject();

function validate_required(kampo,alerttxt)
{
with (kampo)
{
if (value==null)
  {alert(alerttxt);return false;}
else {return true}
}
}

function testu(thisform)
{
with (thisform)
{
if (validate_required(kotiz,"Bonvolu elekti kategorion")==false)
  {retadreso.focus();return false;}
  var tio = 0;
  var tu = document.formo.pago.length;
for(i=0;i<tu;i++) {
if (document.formo.pago[i].checked != false)
    {
     tio=1;
    }
}
 if (tio==0  || document.formo.pago[3].checked != false) {
     alert ("Bonvolu indiki KIEL vi pagos");
       return false;
        }

}
}

function kolorigu () {
	 var nel = document.getElementById("nekl");
	 var al = document.getElementById("apero");
	 if (document.formo.neKonLib.checked == true) {
	nel.style.color = '#FF5353';
	al.style.color = 'grey';
	document.formo.aperigo.checked = false;
	}   
	else if (document.formo.aperigo.checked == true) {
	nel.style.color = 'grey';
	al.style.color = '#FF5353';
	document.formo.neKonLib.checked = false;
	}
 else if (document.formo.neKonLib.checked == false && document.formo.aperigo.checked == false) {
	al.style.color = '#FF5353';
    nel.style.color = '#FF5353';
	document.formo.aperigo.checked = false;
	}

    }
