function ChType(typ)
{
    if(typ=='')
    {
        $("dproducer").innerHTML='<select><option value="">Не указано место</select>'
        return;
    }
    var params=$H({type:typ, ctype:$('ctype').value}).toQueryString(); 
    new Ajax.Request("/includes/ajax/maugli.php",{method:"post",parameters: params, onSuccess:this.onChType.bind(this)});
} 
function onChType(tr)
{
    $("dproducer").innerHTML=tr.responseText;
}
function ChProd(mmm)
{
    var typ=document.forms['ser'].pro[document.forms['ser'].pro.selectedIndex].value;
    //alert(mmm+' - '+typ);
    if(mmm=='')
    {
        $("dmodel").innerHTML='<select class="sel" name="model" style="width:187px;   background-color: #ffffff;"><option value="">Все модели</select>'
        return;
    }
    if(typ=='')
    {
        $("dmodel").innerHTML='<select><option value="">Не указано место</select>'
        return;
    }
    var params=$H({type:typ, producer:mmm, ctype:$('ctype').value}).toQueryString(); 
    new Ajax.Request("/includes/ajax/maugli.php",{method:"post",parameters: params, onSuccess:this.onChProd.bind(this)});
} 
function onChProd(tr)
{
    $("dmodel").innerHTML=tr.responseText;
}
function Search()
{
    var sel1= document.forms['ser'].location;
    var sel2= document.forms['ser'].producer;
    var sel3= document.forms['ser'].model;
	var loc;
	if (sel2.selectedIndex==0)
		return;
	switch (sel1.selectedIndex)
	{
		case 1:
			loc = '/autoshow/?mode=producer&producer='+sel2[sel2.selectedIndex].value;
		break;
		case 2:
			loc = '/notice/?producer='+sel2[sel2.selectedIndex].value;
		break;
		default:
			return;
	}
	if (sel3.selectedIndex>0)
		loc += '&model='+sel3[sel3.selectedIndex].value;
	if ($('ctype').value>0)
		loc += '&type='+$('ctype').value;
	window.location = loc;
}

function ChF(num)
{
    var sel1= document.forms['ser'].location;
    var sel2= document.forms['ser'].producer;
    var sel3= document.forms['ser'].model;
    sel1.selectedIndex=sel2.selectedIndex=sel3.selectedIndex=0;
	removeAllOptions(sel2);
	removeAllOptions(sel3);
   var TextAr=Array('Все автомобили','Легковые','Микроавтобусы','Грузовые','Другое');
   for(var i=1; i<6; ++i)
   {
        if(i==num)
        {
            $('f'+i).style.backgroundColor="#EFEEEE";
            $('f'+i).innerHTML=TextAr[i-1];
            if(i!=1)
                document.forms['ser'].ctype.value=i-1;
            else
                document.forms['ser'].ctype.value='';
        }else
        {
            $('f'+i).style.backgroundColor="#fff";
            $('f'+i).innerHTML='<a href="javascript:void(0)" onclick="ChF('+i+')" class="px14">'+TextAr[i-1]+'</a>';
        }
   }
}
