













pestsByCrop={
"5":{}
,"9":{}
,"4":{}
,"7":{}
,"3":{}
,"1":{}
,"6":{}
,"2":{}
,"8":{}
};
pestsByCropCategory={
"6":{"23000153":"Gråskimmel"}
,"7":{"23000120":"Epleskurv"}
,"8":{}
,"9":{"23000207":"Kålfly"}
,"10":{"23000160":"Gulrotflue","23000697":"Håret engtege","23000206":"Kålfluer (liten & stor)","23000207":"Kålfly","23001057":"Liten kålflue","23000235":"Løkbladskimmel","23000288":"Salatbladskimmel"}
,"11":{"23000105":"Byggbrunflekk","23000249":"Grasmjøldogg","23000156":"Grå øyeflekk","23000173":"Hveteaksprikk","23000174":"Hvetebladprikk"}
,"12":{"23000207":"Kålfly"}
,"13":{"23000269":"Potettørråte"}
,"14":{}
,"15":{}
,"16":{}
,"17":{}
,"19":{}
};


var boxFirstOptionName ="-- Alle skadegj. --";

// Takes the cropId, finds the relevant pests, and displays them in the given select box
function displayPestsByCrop(sourceId, destinationId, pestId)
{
    var source = document.getElementById(sourceId);
    var cropId = source.options[source.selectedIndex].value;
    
    var destination = document.getElementById(destinationId);
    
    while(destination.options.length > 0)
    {
        destination.options[0] = null;
    }
    
    destination.appendChild(createOption("-1",boxFirstOptionName));
    
    var pestList = pestsByCrop[cropId];
    for(var i in pestList)
    {
        var option = createOption(i, pestList[i]);
        if(option.value == pestId)
            option.selected="selected";
        destination.appendChild(option);
    }
}


function displayPestsByCropCategory(sourceId, destinationId, pestId)
{
    var source = document.getElementById(sourceId);
    var cropCategoryId = source.options[source.selectedIndex].value;
    
    var destination = document.getElementById(destinationId);
    
    while(destination.options.length > 0)
    {
        destination.options[0] = null;
    }
    
    destination.appendChild(createOption("-1",boxFirstOptionName));
    
    var pestList = pestsByCropCategory[cropCategoryId];
    for(var i in pestList)
    {
        var option = createOption(i, pestList[i]);
        if(option.value == pestId)
            option.selected="selected";
        destination.appendChild(option);
    }
}


function createOption(value, name)
{
    var option = document.createElement("option");
    option.value=value;
    option.appendChild(document.createTextNode(name));
    return option;
}