//dynamicpulldowns.php
//Copyright (c) 2008, 2009 Makeweb LIMITED
//www.justin-cook.com
//www.makeweb.co.nz

function fillLevel2(intStart) {
    var fLevel1 = document.pulldownsform.level1;
    var fLevel2 = document.pulldownsform.level2;
    var a = arItems;
    var b, c, d, intItem, intType;
var w = 'select';
    if ( intStart > 0 ) {
        for ( b = 0; b < a.length; b++ ) {
            if ( a[b][1] == intStart )
                intType = a[b][0];
        }

        for ( c = 0; c < fLevel1.length; c++ ) {
            if ( fLevel1.options[ c ].value == intType )
                fLevel1.selectedIndex = c;
        }
    }

    if ( intType == null )
        intType = fLevel1.options[ fLevel1.selectedIndex ].value;

    fLevel2.options.length = 0;

    for ( d = 0; d < a.length; d++ ) {
        if ( a[d][0] == intType )
            fLevel2.options[ fLevel2.options.length ] = new Option( a[d][2], a[d][1] );

        if ( a[d][1] == intStart )
            fLevel2.selectedIndex = fLevel2.options.length - 1;
    }
}
function fillLevel3(intStart) {
    var fLevel2 = document.pulldownsform.level2;
    var fLevel3 = document.pulldownsform.cPath;
    var a = arItems;
    var b, c, d, intItem, intType;

    if ( intStart > 0 ) {
        for ( b = 0; b < a.length; b++ ) {
            if ( a[b][1] == intStart )
                intType = a[b][0];
        }

        for ( c = 0; c < fLevel2.length; c++ ) {
            if ( fLevel2.options[ c ].value == intType )
                fLevel2.selectedIndex = c;
        }
    }

    if ( intType == null )
        intType = fLevel2.options[ fLevel2.selectedIndex ].value;

    fLevel3.options.length = 0;

    for ( d = 0; d < a.length; d++ ) {
        if ( a[d][0] == intType )
            fLevel3.options[ fLevel3.options.length ] = new Option( a[d][2], a[d][1] );

        if ( a[d][1] == intStart )
            fLevel3.selectedIndex = fLevel3.options.length - 1;
    }
}
