function pobierz_pojemnosci(modelid){
 plik = "http://"+location.host+"/scripts/osa/pobierz_pojemnosci.php?q="+modelid;
 element = document.getElementById("lista-pojemnosci");

 xml = null;
 element.innerHTML="Pojemność: ";
 try{
  xml = new ActiveXObject("Microsoft.XMLHTTP"); // IE
 }catch(e){
  try {
   xml = new XMLHttpRequest(); // Mozilla/FireFox/Opera
  }catch(e){
   xml = null;
  }
 }
 if(xml != null){
  xml.onreadystatechange = function(){
   if(xml.readyState==4){
    element.innerHTML += "<select name=\"pojemnosc\" class=\"form2\" style=\"vertical-align:middle\"><option value=\"0\">wszystkie</option>"+xml.responseText+"</select>";
   }
  }
  xml.open("GET", plik, true);
  xml.send(null);

 }
 return false;
}

function pobierz_roczniki(modelid,bid,engineid){
 plik = "http://"+location.host+"/scripts/osa/xx_pobierz_roczniki.php?q="+bid+"&q3="+modelid+"&q2="+engineid;
 element = document.getElementById("lista-lat");

 xml = null;
 element.innerHTML="";
 try{
  xml = new ActiveXObject("Microsoft.XMLHTTP"); // IE
 }catch(e){
  try {
   xml = new XMLHttpRequest(); // Mozilla/FireFox/Opera
  }catch(e){
   xml = null;
  }
 }
 if(xml != null){
  xml.onreadystatechange = function(){
   if(xml.readyState==4){
    element.innerHTML = xml.responseText;
   }
  }
  xml.open("GET", plik, true);
  xml.send(null);

 }
 return false;
}


function przelacz(modelid,pojemnosc){
 if(document.getElementById){
  element1 = document.getElementById('proste');
  element2 = document.getElementById('zaawansowane');
  element3 = document.getElementById('pro-zaw');
  if(element1.style.display==''){
   element1.style.display ='none';
   element2.style.display ='';
   element3.innerHTML = '&laquo; szukanie pełne';
   if(pojemnosc=='') pobierz_pojemnosci(modelid);
  }else{
   element1.style.display = '';
   element2.style.display = 'none';
   element3.innerHTML = 'szukanie uproszczone &raquo;';
  }
 }
}

function makeEndOfURL(p, u, k, a)
{
	var kom = new Array();	
	var xf = document.xform;
	var hashtext = "";
	
	kom[1] = "silnik";
	kom[2] = "skrzynia-i-biegow";
	kom[3] = "uklad-jezdny";
	kom[4] = "widocznosc";
	kom[5] = "ergonomia";
	kom[6] = "wentylacja-i-ogrzewanie";
	kom[7] = "przestrzen-w-aucie";
	kom[8] = "wyciszenie";
	kom[9] = "ekonomicznosc";
	kom[10] = "niezawodnosc-drobiazgi";
	kom[11] = "niezawodnosc-usterki";
	kom[12] = "caloksztalt";
	kom[13] = "stosunek-jakosc-cena";
	kom[14] = "co-pozytywnie-zaskoczylo";
	kom[15] = "uciazliwe-usterki";
	
	if(xf.komentarze[xf.komentarze.selectedIndex].value==12 && xf.yearfromto[xf.yearfromto.selectedIndex].value==0 && xf.trybopinii[xf.trybopinii.selectedIndex].value==1 && p==1 && xf.przebieg[xf.przebieg.selectedIndex].value==0 )
	{
		var xurl = location.href;		
		xurl = xurl.substring(0,xurl.lastIndexOf('/')+1);		
		if(k.length)	xurl += k.substring(0,k.length-1);
		window.location = xurl;		
		return true;		
	}
	
	if(a>0)
		xf.komentarze[xf.komentarze.selectedIndex].value = a;
	
	if(xf.komentarze[xf.komentarze.selectedIndex].value<14 || u==0)
	{
		if(xf.trybopinii[xf.trybopinii.selectedIndex].value==1)
			hashtext = kom[xf.komentarze[xf.komentarze.selectedIndex].value];				
		else			
			hashtext = 'chronologicznie'+'-'+kom[xf.komentarze[xf.komentarze.selectedIndex].value];		
		if(xf.yearfromto[xf.yearfromto.selectedIndex].value!=0)
			hashtext += '-'+xf.yearfromto[xf.yearfromto.selectedIndex].value;							
	}		
	else 
	{
		if(xf.trybopinii[xf.trybopinii.selectedIndex].value==0)
			hashtext = 'chronologicznie';		
		
		if(xf.yearfromto[xf.yearfromto.selectedIndex].value!=0)
		{
			if(hashtext) hashtext += '-';
			hashtext += xf.yearfromto[xf.yearfromto.selectedIndex].value;							
		}		
	}	
		
	if(p>1) 
	{		
		if(hashtext) hashtext += '-';
		hashtext += p;
	}

	var przebieg=xf.przebieg[xf.przebieg.selectedIndex].value;

	if(przebieg>0)	
	{
		if(hashtext) 
		{ 
			hashtext += '-';
		    hashtext += 'przebieg-'+przebieg;
		}
		else
		{ 
			hashtext += '#';
		    hashtext += 'przebieg-'+przebieg;
		}
	}

	xf.action += hashtext;	
	xf.hashtxt.value = hashtext;
	xf.pagenr.value = p;	
	
	if(xf.komentarze[xf.komentarze.selectedIndex].value==14 && u>0)
	{
		if(hashtext) hashtext = '#'+hashtext;
		xf.action = k+'opinie-pozytywne'+hashtext;
	}
	else if(xf.komentarze[xf.komentarze.selectedIndex].value==15 && u>0)
	{
		if(hashtext) hashtext = '#'+hashtext;
		xf.action = k+'opinie-negatywne'+hashtext;
	}
	if(xf.komentarze[xf.komentarze.selectedIndex].value<14 && u==2)
	{
		if(hashtext) hashtext = '#'+hashtext;
		xf.action = k+'wszystkie-silniki'+hashtext;	
	}

	
	xf.submit();
	return true;
}

function makeEndOfURLOld(n)
{
	var kom = new Array();	
	var xf1 = document.crit1;
	var xf2 = document.crit2;
	var xf3 = document.crit3;
	
	kom[1] = "silnik";
	kom[2] = "skrzynia-i-biegow";
	kom[3] = "uklad-jezdny";
	kom[4] = "widocznosc";
	kom[5] = "ergonomia";
	kom[6] = "wentylacja-i-ogrzewanie";
	kom[7] = "przestrzen-w-aucie";
	kom[8] = "wyciszenie";
	kom[9] = "ekonomicznosc";
	kom[10] = "niezawodnosc-drobiazgi";
	kom[11] = "niezawodnosc-usterki";
	kom[12] = "caloksztalt";
	kom[13] = "stosunek-jakosc-cena";
	kom[14] = "co-pozytywnie-zaskoczylo";
	kom[15] = "uciazliwe-usterki";
	
	if(xf3.trybopinii[xf3.trybopinii.selectedIndex].value==1)
		hashtext = kom[xf1.komentarze[xf1.komentarze.selectedIndex].value];				
	else			
		hashtext = 'chronologicznie'+'-'+kom[xf1.komentarze[xf1.komentarze.selectedIndex].value];		
	if(xf2.yearfromto[xf2.yearfromto.selectedIndex].value!=0)
		hashtext += '-'+xf2.yearfromto[xf2.yearfromto.selectedIndex].value;						

	if(n==1)
		xf1.action += hashtext;
	else if(n==2)
		xf2.action += hashtext;	
	else if(n==3)
		xf3.action += hashtext;	
		
}

