﻿function getModels()
{
    var ddModels = document.getElementById('ddModels')
    var brand = document.getElementById('ddBrands').value;
    var dt = Communicar.Web.diagrameMontaj.GetModels(brand).value;

    ddModels.length = 0; 
    
    opt = document.createElement('option');
    opt = document.createElement('option');
    opt.text = " -- " + "Alegeti" + " -- ";
    opt.value = "0";
    
    try
    {
        ddModels.add(opt,null);

    }
    catch(ex)
    {
        ddModels.add(opt);
    }
    
    if(dt==null || brand == 0)
        return ;    
   
    for(i = 0; i< dt.length;i++)
    {
        opt = document.createElement('option');
        opt.text = dt[i]["Name"];
        opt.value = dt[i]["ID"];
        opt.selected = (dt[i]["ID"]==$("hModel").value) ? true : false;
        
        try
        {
            ddModels.add(opt,null);

        }
        catch(ex)
        {
            ddModels.add(opt);
        }
    }
}

function getDocuments()
{
    var brand = document.getElementById('ddBrands').value;
    var model = document.getElementById('ddModels').value;
    var categ = document.getElementById('hCategory').value;
    
    if(!isNaN(brand) && brand > 0 && !isNaN(model) && brand > 0 /*&& !isNaN(categ) && categ > 0*/)
    {
        document.location.href="diagrameMontaj.aspx?pID=0&cID="+categ+"&sID=1"+"&brand="+brand+"&model="+model;
    }
}


