
	   function ajaxGetPage(containerid, url)
		{
			var xmlHttp;
			var ajaxreturn = 0;
			dokument = document.getElementById(containerid);
	                dokument.innerHTML = "<font color=\"green\"><b>Nahrávam dáta...</b></font>";

			try
			{
				// Firefox, Opera 8.0+, Safari
				xmlHttp=new XMLHttpRequest();
			}
			catch (e)
			{
				// Internet Explorer
				try
				{
					xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch (e)
				{
					try
					{
						xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
					}
					catch (e)
					{
						alert("Your browser does not support AJAX!");
						return false;
					}
				}
			}
			xmlHttp.onreadystatechange=function()
			{
				if(xmlHttp.readyState==4 && xmlHttp.status == 200)
				{
					document.getElementById(containerid).innerHTML = xmlHttp.responseText;
				}
			}

			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
		}



	   function getOkresy()
	   {
	   	   var select=document.getElementById('kraje');
	   	   var id_okr=select.options[select.selectedIndex].value;
		   if (id_okr!="")
	   	   	   ajaxGetPage('td_okresy', 'ajax/mesta.php?what=okresy&id=' + id_okr);
	   }

       function getMesta()
	   {
	   	   var select=document.getElementById('okresy');
	   	   var id_okr=select.options[select.selectedIndex].value;
		   if (id_okr!="")
	   	   	   ajaxGetPage('td_mesta', 'ajax/mesta.php?what=mestaf&id=' + id_okr);
	   }

		function getFirmy()
		{
			var select=document.getElementById('mesta');
			var id_mest=select.options[select.selectedIndex].value;
			select=document.getElementById('id_sluzby');
			var id_sluz=select.options[select.selectedIndex].value;
			if (id_mest!="")
				ajaxGetPage('td_firmy', 'ajax/mesta.php?what=firmy&mest=' + id_mest + '&sluz=' + id_sluz);
		}

		function getTemplateBoxes()
		{
			var select=document.getElementById('id_sluzby');
			var id_sluz=select.options[select.selectedIndex].value;
			var select2=document.getElementById('id_firmy');
			var id_firm=select2.options[select2.selectedIndex].value;
			
            if (id_sluz!="" && id_firm != "")
				ajaxGetPage('template', 'ajax/template_boxes.php?id_sluzby=' + id_sluz + '&id_firmy=' + id_firm);
		}
		
		function getFirmaBoxes()
		{
			var select=document.getElementById('id_sluzby');
			var id_sluz=select.options[select.selectedIndex].value;
			var select2=document.getElementById('mesta');
            var id_mesta=select2.options[select2.selectedIndex].value;
			if (id_sluz!="0" && id_mesta!="")
				ajaxGetPage('td_sluzby', 'ajax/firma_boxes.php?id_sluzby=' + id_sluz + '&id_mesta=' + id_mesta);
		}

		function checkSubmit()
		{
            
            typ_boxu = document.getElementById('typ_boxu').value;
            if (typ_boxu < 0)
			{
			     alert('Nemožno pokračovať, neboli korektne vybraté všetky položky.');
                 hodnota = false;
			}
			else
			{
			     hodnota = true;
			}
            return hodnota;

		}
		
		function getOkresyLeft()
	   {
	   	   var select=document.getElementById('lmkraje');
	   	   var id_okr=select.options[select.selectedIndex].value;
		   if (id_okr!="")
	   	   	   ajaxGetPage('lm_okresy', 'ajax/mesta.php?what=lmokresy&id=' + id_okr);
	   }

       function getMestaLeft()
	   {
	   	   var select=document.getElementById('lmokresy');
	   	   var id_okr=select.options[select.selectedIndex].value;
		   if (id_okr!="")
	   	   	   ajaxGetPage('lm_mesta', 'ajax/mesta.php?what=lmmesta&id=' + id_okr);
	   }
	   
	   function getSluzby()
		{
			var select=document.getElementById('pobocka');
			var id_pobocky=select.options[select.selectedIndex].value;

			if (id_pobocky != "")
				ajaxGetPage('td_sluzby', 'ajax/sluzby.php?what=sluzby&id=' + id_pobocky);
		}
		
		function getTypAuta()
        	{
        	   	   var select=document.getElementById('znacka');
        	   	   var id_okr=select.options[select.selectedIndex].value;
        		   if (id_okr!= '')
			dokument = document.getElementById('typ_auta_td');
			dokument.innerHTML = "<font color=\"green\"><b>Nahrávam dáta...</b></font>";
					   
        	   	   	   ajaxGetPage('typ_auta_td', 'ajax/auta.php?what=typ&znacka=' + id_okr);
        	}
      
      function getTemplateBoxesFirma()
		{
			//alert('aa');
            
            var select=document.getElementById('id_sluzby');
			var id_sluz=select.options[select.selectedIndex].value;
			//alert(id_sluz);
            
            if (id_sluz != 0)
			{
               
               //loading = document.getElementById('template');
               //loading.innerHtml = 'Moment, sťahujem informácie.';
	            dokument = document.getElementById('template');
		            dokument.innerHTML = "<font color=\"green\"><b>Nahrávam dáta...</b></font>";
			    
				ajaxGetPage('template', 'ajax/template_boxes.php?id_sluzby=' + id_sluz);
			}
			
			
		} 


    
    
