function changeSeria() {

    producer=document.getElementById('ffproducer').value;


    if(producer.length!=0)  {

        $.post("/view/js/ff.php", {load:'seria',producer: ""+producer+""}, function(data,textStatus){
            if(data.length > 0) {
//alert (data);
                 eval(data);
                 document.getElementById('ffseria').innerHTML = "";
                 var option = document.createElement("option");
                 var optionText = document.createTextNode("[серия]");
                 option.appendChild(optionText);
                 option.value=0;
                 document.getElementById('ffseria').appendChild(option);

                 for(var i in res) {       
                    var option = document.createElement("option");
                    var optionText = document.createTextNode(res[i]['title']);
                    option.appendChild(optionText);
                    option.setAttribute("value",i);
				    document.getElementById('ffseria').appendChild(option);
                 }

                 // обнуляем заничение моделей
                 document.getElementById('ffmodel').innerHTML = "";
                 var option = document.createElement("option");
                 var optionText = document.createTextNode("[модель]");
                 option.appendChild(optionText);
                 option.value=0;
                 document.getElementById('ffmodel').appendChild(option);
              
            }  
        });
    } 

    return false;

}

function changeModel() {

    seria=document.getElementById('ffseria').value;


    if(seria.length!=0)  {

        $.post("/view/js/ff.php", {load:'model',seria: ""+seria+""}, function(data,textStatus){
            if(data.length > 0) {
//alert (data);
                 eval(data);
                 document.getElementById('ffmodel').innerHTML = "";
                 var option = document.createElement("option");
                 var optionText = document.createTextNode("[модель]");
                 option.appendChild(optionText);
                 option.value=0;
                 document.getElementById('ffmodel').appendChild(option);

                 for(var i in res) {       
                    var option = document.createElement("option");
                    var optionText = document.createTextNode(res[i]['title']);
                    option.appendChild(optionText);
                    option.setAttribute("value",i);
				    document.getElementById('ffmodel').appendChild(option);
                 }

            }  
        });
    } 

    return false;

}

function changeProducer() {

    type=document.getElementById('acc_type').value;


    if(type.length!=0)  {

        $.post("/view/js/ff.php", {load:'producer',type: ""+type+""}, function(data,textStatus){
            if(data.length > 0) {
                 eval(data);
                 document.getElementById('acc_producer').innerHTML = "";
                 var option = document.createElement("option");
                 var optionText = document.createTextNode("[производитель]");
                 option.appendChild(optionText);
                 option.value=0;
                 document.getElementById('acc_producer').appendChild(option);

                 for(var i in res) {       
                    var option = document.createElement("option");
                    var optionText = document.createTextNode(res[i]['title']);
                    option.appendChild(optionText);
                    option.setAttribute("value",i);
				    document.getElementById('acc_producer').appendChild(option);
                 }

            }  
        });
    } 

    return false;

}

function redirectUrl() {
    producer=document.getElementById('ffproducer').value;
    seria=document.getElementById('ffseria').value;
    model=document.getElementById('ffmodel').value;
    parentId=document.getElementById('ffparent').value;
    pageId=document.getElementById('ffpageid').value;

    if(producer!=0)  {
        $.post("/view/js/ff.php", {load:'redirect',producer: ""+producer+"",parent: ""+parentId+"",pageId:""+pageId+""}, function(data,textStatus){
            if(data.length > 0) {
//        alert(data);
              window.location = data+"?producer="+producer+"&seria="+seria+"&model="+model;
            } else {
              alert ("К сожалению, ничего не найдено.");
            }  
        });
    } else {
      alert("Пожалуйста, выберите производителя.");
    }

    return false;

}


function redirectUrl2() {
    producer=document.getElementById('acc_producer').value;

    if(producer!=0)  {
        $.post("/view/js/ff.php", {load:'redirect2',producer: ""+producer+""}, function(data,textStatus){
            if(data.length > 0) {
  //      alert(data);
         window.location = data;
            }  
        });
    } else {
      alert("Пожалуйста, выберите все поля.");
    }

    return false;

}
