
alert('test');

      	  var v=[];
      	  var n=[];
          var a=[];
          var c=[];
 function chaas(b) {
       a=b.split(':::');
       a[1]=a[1].replace(/ Ls/, '');
      if (v.length>0){


	    for(i=0; i<(v.length); i++) {
	    z=1;

	      if(a[1] < (v[i]*1)){
	      	  for(k=(v.length); k>i; k--) {
	      		 //alert(k);
	      		 v[k]=v[k-1];
	      		 n[k]=n[k-1]
	      		 c[k]=c[k-1];
	      		 }

	          v[i]=a[1];
	          n[i]=a[0];
	          c[i]=a[2];
	          z=2;
	      	  break;
	      	  //a=9999;
	      }
	   }
	   if(z==1) { v[i]=a[1]; n[i]=a[0]; c[i]=a[2];}


    }else{


    	v[0]=a[1];
    	n[0]=a[0];
    	c[0]=a[2];

    }

          viewaas();

   }

   function viewaas() {
   	for(i=0; i<(v.length); i++) {
     // alert(v[i]);
      if(isNaN(v[i])) {
      document.getElementById('a'+i).innerHTML=v[i];
      }else{
   	  document.getElementById('a'+i).innerHTML=v[i]+' Ls';
   	  document.getElementById('c'+i).innerHTML=c[i];
   	  }
   	  document.getElementById('b'+i).innerHTML=n[i];

    }
   }
	 function getXmlHttp(){
  var xmlhttp;
  try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
      xmlhttp = false;
    }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
    xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}





 function getBalva(reg_nr,VRegCertNr,WorkingTime,RegPlace){


    var xmlhttp = getXmlHttp()
  xmlhttp.open("GET", "/components/com_octa/_ajax/balva_ajax.php?reg_nr="+reg_nr+"&VRegCertNr="+VRegCertNr+"&WorkingTime="+WorkingTime+"&RegPlace="+RegPlace+"&l="+Math.random(), true);
  xmlhttp.onreadystatechange = function() {
  if (xmlhttp.readyState == 4) {
     if(xmlhttp.status == 200) {
     // alert(xmlhttp.responseText);
        //++++++++++++++++++++++++++++++++++++++
         chaas('<img src="files/logo_balva.gif" width="118" height="24">:::'+xmlhttp.responseText+':::<a href="index.php?option=com_octatest&task=regf&aas=balva"><?=$bay_lang;?></a>');
     //  document.getElementById('a1').innerHTML=xmlhttp.responseText;
          //++++++++++++++++++++++++++++++++++++
         }
    }
  };
  xmlhttp.send(null);
  }

 function getBaltikums(reg_nr,VRegCertNr,WorkingTime){

  var xmlhttp1 = getXmlHttp()
  xmlhttp1.open("GET", "/components/com_octa/_ajax/baltikums_ajax.php?reg_nr="+reg_nr+"&VRegCertNr="+VRegCertNr+"&WorkingTime="+WorkingTime+"&l="+Math.random(), true);
  xmlhttp1.onreadystatechange = function() {
  if (xmlhttp1.readyState == 4) {
     if(xmlhttp1.status == 200) {
     // alert(xmlhttp1.responseText);
        //++++++++++++++++++++++++++++++++++++++
         chaas('<img src="files/logo_baltikums.gif" width="118" height="36">:::'+xmlhttp1.responseText+':::<a href="index.php?option=com_octatest&task=regf&aas=baltikums"><?=$bay_lang;?></a>');
    //   document.getElementById('a2').innerHTML=xmlhttp1.responseText;
          //++++++++++++++++++++++++++++++++++++
         }
    }
  };
  xmlhttp1.send(null);
  }

 function getBan(reg_nr,VRegCertNr,WorkingTime){
  var xmlhttp2 = getXmlHttp()
  xmlhttp2.open("GET", "/components/com_octa/_ajax/ban_ajax.php?reg_nr="+reg_nr+"&VRegCertNr="+VRegCertNr+"&WorkingTime="+WorkingTime+"&l="+Math.random(), true);
  xmlhttp2.onreadystatechange = function() {
  if (xmlhttp2.readyState == 4) {
     if(xmlhttp2.status == 200) {
     // alert(xmlhttp2.responseText);
        //++++++++++++++++++++++++++++++++++++++
          chaas('<img src="files/logo_ban.gif" width="129" height="37">:::'+xmlhttp2.responseText+':::<a href="index.php?option=com_octatest&task=regf&aas=ban"><?=$bay_lang;?></a>');
      // document.getElementById('a3').innerHTML=xmlhttp2.responseText;
          //++++++++++++++++++++++++++++++++++++
         }
    }
  };
  xmlhttp2.send(null);
  }

 function getGjensidige(reg_nr,VRegCertNr,WorkingTime){
  var xmlhttp4 = getXmlHttp()
  xmlhttp4.open("GET", "/components/com_octa/_ajax/gjensidige_ajax.php?reg_nr="+reg_nr+"&VRegCertNr="+VRegCertNr+"&WorkingTime="+WorkingTime+"&l="+Math.random(), true);
  xmlhttp4.onreadystatechange = function() {
  if (xmlhttp4.readyState == 4) {
     if(xmlhttp4.status == 200) {
     // alert(xmlhttp4.responseText);
        //++++++++++++++++++++++++++++++++++++++
          chaas('<img src="files/logo_gjensidige.gif" width="121" height="30">:::'+xmlhttp4.responseText+':::<a href="index.php?option=com_octatest&task=regf&aas=gjensidige"><?=$bay_lang;?></a>');
     //  document.getElementById('a4').innerHTML=xmlhttp4.responseText;
          //++++++++++++++++++++++++++++++++++++
         }
    }
  };
  xmlhttp4.send(null);
  }

 function getBTA(reg_nr,VRegCertNr,WorkingTime){
  var xmlhttp5 = getXmlHttp()
  xmlhttp5.open("GET", "/components/com_octa/_ajax/bta_ajax.php?reg_nr="+reg_nr+"&VRegCertNr="+VRegCertNr+"&WorkingTime="+WorkingTime+"&l="+Math.random(), true);
  xmlhttp5.onreadystatechange = function() {
  if (xmlhttp5.readyState == 4) {
     if(xmlhttp5.status == 200) {
     // alert(xmlhttp5.responseText);
        //++++++++++++++++++++++++++++++++++++++
          chaas('<img src="files/logo_bta.gif" width="85" height="32">:::'+xmlhttp5.responseText+':::<a href="https://www.e-polise.lv/epolicy/eocta/CalculatePrice.aspx?lng=LV&regnr=<? echo $_POST['reg_nr'];?>&certregnr=<? echo $_POST['VRegCertNr'];?>" target="_blank"><?=$bay_lang;?></a>');
       //document.getElementById('a5').innerHTML=xmlhttp5.responseText;
          //++++++++++++++++++++++++++++++++++++
         }
    }
  };
  xmlhttp5.send(null);
  }


 function getSeesam(reg_nr,VRegCertNr,WorkingTime){
  var xmlhttp6 = getXmlHttp()
  xmlhttp6.open("GET", "/components/com_octa/_ajax/seesam_ajax.php?reg_nr="+reg_nr+"&VRegCertNr="+VRegCertNr+"&WorkingTime="+WorkingTime+"&l="+Math.random(), true);
  xmlhttp6.onreadystatechange = function() {
  if (xmlhttp6.readyState == 4) {
     if(xmlhttp6.status == 200) {
     // alert(xmlhttp6.responseText);
        //++++++++++++++++++++++++++++++++++++++
          chaas('<img src="files/logo_seesam.gif" width="116" height="39">:::'+xmlhttp6.responseText+':::<a href="index.php?option=com_octatest&task=regf&aas=seesam"><?=$bay_lang;?></a>');
    //   document.getElementById('a6').innerHTML=xmlhttp6.responseText;
          //++++++++++++++++++++++++++++++++++++
         }
    }
  };
  xmlhttp6.send(null);
  }


 function getErgo(reg_nr,VRegCertNr,WorkingTime){

  var xmlhttp7 = getXmlHttp()
  xmlhttp7.open("GET", "/components/com_octa/_ajax/ergo_ajax.php?reg_nr="+reg_nr+"&VRegCertNr="+VRegCertNr+"&WorkingTime="+WorkingTime+"&l="+Math.random(), true);
  xmlhttp7.onreadystatechange = function() {
  if (xmlhttp7.readyState == 4) {
     if(xmlhttp7.status == 200) {
     // alert(xmlhttp7.responseText);
        //++++++++++++++++++++++++++++++++++++++
          chaas('<img src="files/logo_ergo.gif" width="86" height="31">:::'+xmlhttp7.responseText+':::<a href="index.php?option=com_octatest&task=regf&aas=ergo"><?=$bay_lang;?></a>');
      // document.getElementById('a7').innerHTML=xmlhttp7.responseText;
          //++++++++++++++++++++++++++++++++++++
         }
    }
  };
  xmlhttp7.send(null);
  }


 function getIF(reg_nr,VRegCertNr,WorkingTime){

  var xmlhttp7 = getXmlHttp()
  xmlhttp7.open("GET", "/components/com_octa/_ajax/if_ajax.php?reg_nr="+reg_nr+"&VRegCertNr="+VRegCertNr+"&WorkingTime="+WorkingTime+"&l="+Math.random(), true);
  xmlhttp7.onreadystatechange = function() {
  if (xmlhttp7.readyState == 4) {
     if(xmlhttp7.status == 200) {
     // alert(xmlhttp7.responseText);
        //++++++++++++++++++++++++++++++++++++++
          chaas('<img src="files/logo_if.gif" width="39" height="44">:::'+xmlhttp7.responseText+':::<a href="index.php?option=com_octatest&task=regf&aas=if"><?=$bay_lang;?></a>');
      // document.getElementById('a8').innerHTML=xmlhttp7.responseText;
          //++++++++++++++++++++++++++++++++++++
         }
    }
  };
  xmlhttp7.send(null);
  }

 function getBalta(reg_nr,VRegCertNr,WorkingTime){

  var xmlhttp8 = getXmlHttp()
  xmlhttp8.open("GET", "/components/com_octa/_ajax/balta_ajax.php?reg_nr="+reg_nr+"&VRegCertNr="+VRegCertNr+"&WorkingTime="+WorkingTime+"&l="+Math.random(), true);
  xmlhttp8.onreadystatechange = function() {
  if (xmlhttp8.readyState == 4) {
     if(xmlhttp8.status == 200) {
     // alert(xmlhttp8.responseText);
        //++++++++++++++++++++++++++++++++++++++
          chaas('<img src="files/logo_balta.gif" width="120" height="36">:::'+xmlhttp8.responseText+':::<a href="index.php?option=com_octatest&task=regf&aas=balta"><?=$bay_lang;?></a>');
      // document.getElementById('a8').innerHTML=xmlhttp8.responseText;
          //++++++++++++++++++++++++++++++++++++
         }
    }
  };
  xmlhttp8.send(null);
  }


  function getCSDD(reg_nr){

  var xmlhttp_csdd = getXmlHttp()
  xmlhttp_csdd.open("GET", "/components/com_octa/_ajax/csdd_ajax.php?reg_nr="+reg_nr+"&l="+Math.random(), true);
  xmlhttp_csdd.onreadystatechange = function() {
  if (xmlhttp_csdd.readyState == 4) {
     if(xmlhttp_csdd.status == 200) {
     // alert(xmlhttp_csdd.responseText);
        //++++++++++++++++++++++++++++++++++++++
       document.getElementById('a_csdd').innerHTML=xmlhttp_csdd.responseText;
          //++++++++++++++++++++++++++++++++++++
         }
    }
  };
  xmlhttp_csdd.send(null);
  }

 function getLTAB(reg_nr){

  var xmlhttp_ltab = getXmlHttp()
  xmlhttp_ltab.open("GET", "/components/com_octa/_ajax/ltab_ajax.php?reg_nr="+reg_nr+"&l="+Math.random(), true);
  xmlhttp_ltab.onreadystatechange = function() {
  if (xmlhttp_ltab.readyState == 4) {
     if(xmlhttp_ltab.status == 200) {
     // alert(xmlhttp_ltab.responseText);
        //++++++++++++++++++++++++++++++++++++++
       document.getElementById('a_ltab').innerHTML=xmlhttp_ltab.responseText;
          //++++++++++++++++++++++++++++++++++++
         }
    }
  };
  xmlhttp_ltab.send(null);
  }


 function getBMCLASS(reg_nr){

  var xmlhttp_bmclass = getXmlHttp()
  xmlhttp_bmclass.open("GET", "/components/com_octa/_ajax/bmclass_ajax.php?reg_nr="+reg_nr+"&l="+Math.random(), true);
  xmlhttp_bmclass.onreadystatechange = function() {
  if (xmlhttp_bmclass.readyState == 4) {
     if(xmlhttp_bmclass.status == 200) {
     // alert(xmlhttp_bmclass.responseText);
        //++++++++++++++++++++++++++++++++++++++
       document.getElementById('a_bmclass').innerHTML=xmlhttp_bmclass.responseText;
          //++++++++++++++++++++++++++++++++++++
         }
    }
  };
  xmlhttp_bmclass.send(null);
  }


function test_reg_nr() {
     emailRegExp = /([a-zA-Z0-9]){1,8}/;
     var err_mail="A/m numuru ievadiet bez atstarpem un stripinam!\n Piemers: AN1122";
     var err_mail1="Ievadiet pareizo A/m numuru!\n Piemers: AN1122";
     if(emailRegExp.test(document.getElementById("reg_nr").value)){

         emailRegExp = /([- ]){1,8}/;
         if(emailRegExp.test(document.getElementById("reg_nr").value)){
           // document.getElementById("reg_nr").style.border="1px solid red";
            alert(err_mail);
            return false;
          }
          return true;
     }else{
          alert(err_mail1);
          return false;
     }
}

function test_reg_cert() {
     emailRegExp = /([a-zA-Z0-9]){1,8}/;
     var err_mail="Tehniskas pases numuru ievadiet bez atstarpem un stripinam!\n Piemers: AD0001122";
     var err_mail1="Ievadiet pareizo tehniskas pases numuru!\n Piemers: AD0001122";
     if(emailRegExp.test(document.getElementById("VRegCertNr").value)){

         emailRegExp = /([- ]){1,8}/;
         if(emailRegExp.test(document.getElementById("VRegCertNr").value)){
           // document.getElementById("VRegCertNr").style.border="1px solid red";
            alert(err_mail);
            return false;
          }
          return true;
     }else{
          alert(err_mail1);
          return false;
     }
}
  function testform() {
       if(test_reg_nr()) {
         	if(test_reg_cert()) document.octa1.submit();
       	}

       //
  }