var vck={
 tip: '1,0,0',
 ma: '1,0,0',
 md: '1,0,0',
 car: '1,0,0',
 combustibil: '1,0,0',
 cc: '3,5,1',
 cutie: '1,0,0',
 km: '0,8,1',
 pri: '1,0,0',
 inm: '1,0,0',
 pret: '1,8,1',
 text:'5,0,0',
 textziar:'5,0,0'
}

function formtxtziar(force){
r='';
v=dgn('ma');r+='Vând '+v;
v=dgn('md');r+=' '+v;
v=dgn('vr');if(v!=''){r+=' '+v};
v=dgn('car').toLowerCase();if(v!=''){r+=', '+v};
v=dgn('combustibil').toLowerCase();if(v!=''){r+=', '+v};
v=dgn('cc');if(v!=''){r+=', '+sepmii(v)+'cc'};
v=dgn('cutie').toLowerCase();if(v!=''){r+=', cutie '+v};
v=dgn('km');if(v!=''){r+=', '+sepmii(v)+' km'};
v=dgn('pri');r+=', an '+v;
v=dgn('inm').toLowerCase().replace(/ro/,'RO');r+=', '+v;
v=dgn('taxa');if((v!='')&&(v!='0')){r+=', taxă '+sepmii(v)+' Euro'};
v=dgn('pret');r+=', preț '+sepmii(v)+' Euro';
t=document.getElementsByName('textziar')[0];if((t.value=='')||force){t.value=r;}
}

function ajfc(m,s){var xmlHttp;try{xmlHttp=new XMLHttpRequest();}catch(e){try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){return false;}}}
xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4){procajfc(m,s,xmlHttp.responseText);}}
xmlHttp.open("POST","ajf.asp",true);
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-2");
s=enc(s);
xmlHttp.send('m=auto_'+m+'&'+s);
}
function procajfc(m,s,r){
qs(s);
switch(m){
 case 'lac':{
  document.getElementById('tr_km').childNodes[0].innerHTML='Km parcurși';
  var d='none'
  if (r.length>95){d='';}
  tip=document.getElementById('tip').value;
  document.getElementById('f'+qsParam['c']).innerHTML=r;
  switch(qsParam['c']){
   case 'ma':{
   document.getElementById('fma').style.display=d;
   document.getElementById('fmd').style.display='none';
   document.getElementById('tr_car').className='dispno';
   if (init) {lac('md')}
   pas2();
   break}
   case 'md':{
   document.getElementById('fma').style.display='';
   document.getElementById('fmd').style.display=d;
   document.getElementById('tr_car').className='dispno';
   if (init) {caro()}
   if ((d!='none')&&(tip=='3')){
    pas2();ma=document.getElementById('ma').value;
    if ((ma=='Utilaj')||(ma=='Vehicul agricol')||(ma=='Motostivuitor')) {
    document.getElementById('tr_km').childNodes[0].innerHTML='Ore de funcționare';
    }
   }
   break}
  }
  break}
 case 'caro':{
  if (r.length>0){d='disp'}else{d='dispno'}
  document.getElementById('fcar').innerHTML=r;
  document.getElementById('tr_car').className=d;
  init=false;
  break}
 case 'form2':{
  document.getElementById('pas2').innerHTML=r;
  break}
 case 'presearch':{
  if (parseInt(r)>0){
  document.location='auto.asp?'+create_request_string(document.getElementById('search'));
  }else{
  rl='rss.asp?m=2&'+create_request_string(document.getElementById('search'));
  document.getElementById('btnsearch').className='disp';
  document.getElementById('sload').innerHTML='Nu sunt rezultate pentru această căutare!<br> Abonați-vă la RSS pentru a afla noutăți <a href="'+rl+'"><img src="img/nrss.gif"></a> <a href="ajutor.asp?id=2">află mai multe</a>.';}
  break}
 default: {break}
  }
}

function lac(c){
fldsrc();
tip=document.getElementById('tip').value;
if(c=='ma'){sel=sma;ma='';}else{sel=smd;ma=document.getElementById('ma').value;}
ajfc('lac','c='+c+'&tip='+tip+'&ma='+ma+'&sel='+sel);
}

function fldsrc(){
stip=parseInt(document.getElementById('tip').value);
if (stip==4){dd='no';}else{dd=''}
document.getElementById('tr_combustibil').className='disp'+dd;
document.getElementById('tr_cc').className='disp'+dd;
document.getElementById('tr_km').className='disp'+dd;
if ((stip==2)||(stip==4)){dd='no';}else{dd=''}
document.getElementById('tr_cutie').className='disp'+dd;
}

function caro(){
tip=parseInt(document.getElementById('tip').value);
if (tip==1){
 ma=document.getElementById('ma').value;
 md=document.getElementById('md').value;
 ajfc('caro','ma='+ma+'&md='+md+'&sel='+scar);
}
}

function pas2(){
if (document.getElementById('pas2')!=undefined){
loading('pas2');
tip=document.getElementById('tip').value;
ajfc('form2','id='+document.getElementById('f_id').value+'&tip='+tip+'&ma='+ma);}
}

function chinm(){
if (document.getElementById('inm').value=='Înmatriculabilă'){d=''}else{d='no';}
document.getElementById('span_taxa').className='disp'+d;
}

function presearch(){
if ((document.getElementsByName('judet')[0].value=='')&&(document.getElementsByName('tip')[0].value==0)){return null;}
document.getElementById('btnsearch').className='dispno';loading('sload');a=create_request_string(document.getElementById('search'));ajfc('presearch',a);
}