var QB ={ "countries": [ { "0":"Belgium", "1": [ { "0":"Bruges", "1":"2" } ] }, { "0":"England", "1": [ { "0":"The Thames", "1":"19" }, { "0":"Norfolk Broads", "1":"3" } ] }, { "0":"France", "1": [ { "0":"Camargue", "1":"9" }, { "0":"Alsace-Lorraine", "1":"4" }, { "0":"Burgundy", "1":"6" }, { "0":"Midi", "1":"15" }, { "0":"Loire / Nivernais", "1":"7" }, { "0":"Loire Valley", "1":"18" }, { "0":"Aquitaine", "1":"16" }, { "0":"Brittany", "1":"5" }, { "0":"Lot", "1":"8" }, { "0":"Charente", "1":"17" } ] }, { "0":"Germany", "1": [ { "0":"Berlin", "1":"10" } ] }, { "0":"Holland", "1": [ { "0":"Holland", "1":"11" } ] }, { "0":"Ireland", "1": [ { "0":"Ireland", "1":"12" } ] }, { "0":"Italy", "1": [ { "0":"Venice", "1":"13" } ] }, { "0":"Scotland", "1": [ { "0":"Scotland", "1":"14" } ] } ], "cruises": [ { "0":"2", "1":"349", "2":"Gent - Gent", "3":"3" }, { "0":"2", "1":"350", "2":"Gent - Nieuwpoort", "3":"7" }, { "0":"2", "1":"351", "2":"Nieuwpoort - Gent", "3":"7" }, { "0":"2", "1":"154", "2":"Nieuwpoort - Nieuwpoort", "3":"3" }, { "0":"19", "1":"309", "2":"Benson - Benson", "3":"3" }, { "0":"19", "1":"333", "2":"Benson - Chertsey", "3":"7" }, { "0":"19", "1":"330", "2":"Chertsey - Benson", "3":"7" }, { "0":"19", "1":"331", "2":"Chertsey - Chertsey", "3":"3" }, { "0":"3", "1":"159", "2":"Horning - Horning", "3":"3" }, { "0":"9", "1":"129", "2":"Beaucaire - Beaucaire", "3":"3" }, { "0":"9", "1":"130", "2":"Beaucaire - Port Cassafières", "3":"7" }, { "0":"4", "1":"305", "2":"Boofzheim - Boofzheim", "3":"3" }, { "0":"4", "1":"306", "2":"Boofzheim - Hesse", "3":"7" }, { "0":"6", "1":"139", "2":"Branges - Branges", "3":"3" }, { "0":"6", "1":"140", "2":"Branges - Gray", "3":"7" }, { "0":"6", "1":"289", "2":"Branges - St-Jean-de-Losne", "3":"7" }, { "0":"15", "1":"265", "2":"Castelnaudary - Castelnaudary", "3":"3" }, { "0":"15", "1":"131", "2":"Castelnaudary - Homps", "3":"7" }, { "0":"15", "1":"266", "2":"Castelnaudary - Port Cassafières", "3":"7" }, { "0":"15", "1":"267", "2":"Castelnaudary - Trèbes", "3":"3" }, { "0":"7", "1":"145", "2":"Châtel Censoir - Châtel Censoir", "3":"3" }, { "0":"7", "1":"146", "2":"Châtel Censoir - Migennes", "3":"7" }, { "0":"18", "1":"148", "2":"Châtillon-sur-Loire - Châtillon-sur-Loire", "3":"3" }, { "0":"18", "1":"150", "2":"Châtillon-sur-Loire - Decize", "3":"7" }, { "0":"18", "1":"149", "2":"Châtillon-sur-Loire - Migennes", "3":"10" }, { "0":"16", "1":"277", "2":"Condom - Le Mas d'Agenais", "3":"7" }, { "0":"16", "1":"278", "2":"Condom - Montauban", "3":"14" }, { "0":"18", "1":"298", "2":"Decize - Châtillon-sur-Loire", "3":"7" }, { "0":"7", "1":"337", "2":"Decize - Decize", "3":"3" }, { "0":"18", "1":"296", "2":"Decize - Decize", "3":"3" }, { "0":"7", "1":"297", "2":"Decize - Tannay", "3":"7" }, { "0":"5", "1":"286", "2":"Dinan - Messac", "3":"7" }, { "0":"8", "1":"282", "2":"Douelle - Douelle", "3":"3" }, { "0":"6", "1":"293", "2":"Fontenoy-le-Château - Fontenoy-le-Château", "3":"3" }, { "0":"6", "1":"141", "2":"Fontenoy-le-Château - Gray", "3":"7" }, { "0":"6", "1":"294", "2":"Fontenoy-le-Château - St-Jean-de-Losne", "3":"7" }, { "0":"6", "1":"138", "2":"Gray - Branges", "3":"7" }, { "0":"6", "1":"288", "2":"Gray - Fontenoy-le-Château", "3":"7" }, { "0":"6", "1":"137", "2":"Gray - Gray", "3":"3" }, { "0":"4", "1":"303", "2":"Hesse - Boofzheim", "3":"7" }, { "0":"4", "1":"302", "2":"Hesse - Hesse", "3":"3" }, { "0":"4", "1":"304", "2":"Hesse - Saarbrücken", "3":"7" }, { "0":"15", "1":"126", "2":"Homps - Castelnaudary", "3":"7" }, { "0":"15", "1":"124", "2":"Homps - Homps", "3":"3" }, { "0":"15", "1":"125", "2":"Homps - Port Cassafières", "3":"7" }, { "0":"17", "1":"287", "2":"Jarnac - Jarnac", "3":"3" }, { "0":"16", "1":"274", "2":"Le Mas d'Agenais - Condom", "3":"7" }, { "0":"16", "1":"273", "2":"Le Mas d'Agenais - Le Mas d'Agenais", "3":"3" }, { "0":"16", "1":"275", "2":"Le Mas d'Agenais - Montauban", "3":"7" }, { "0":"5", "1":"284", "2":"Messac - Dinan", "3":"7" }, { "0":"5", "1":"283", "2":"Messac - Messac", "3":"3" }, { "0":"5", "1":"135", "2":"Messac - Nort-sur-Erdre", "3":"7" }, { "0":"7", "1":"144", "2":"Migennes - Châtel Censoir", "3":"7" }, { "0":"18", "1":"143", "2":"Migennes - Châtillon-sur-Loire", "3":"10" }, { "0":"7", "1":"142", "2":"Migennes - Migennes", "3":"3" }, { "0":"7", "1":"295", "2":"Migennes - Tannay", "3":"7" }, { "0":"16", "1":"281", "2":"Montauban - Condom", "3":"14" }, { "0":"16", "1":"279", "2":"Montauban - Montauban", "3":"3" }, { "0":"16", "1":"280", "2":"Montauban - Le Mas d'Agenais", "3":"7" }, { "0":"15", "1":"127", "2":"Narbonne - Narbonne", "3":"3" }, { "0":"15", "1":"128", "2":"Narbonne - Trèbes", "3":"7" }, { "0":"5", "1":"134", "2":"Nort-sur-Erdre - Messac", "3":"7" }, { "0":"5", "1":"133", "2":"Nort-sur-Erdre - Nort-sur-Erdre", "3":"3" }, { "0":"9", "1":"270", "2":"Port Cassafières - Beaucaire", "3":"7" }, { "0":"15", "1":"269", "2":"Port Cassafières - Castelnaudary", "3":"7" }, { "0":"15", "1":"132", "2":"Port Cassafières - Homps", "3":"7" }, { "0":"9", "1":"268", "2":"Port Cassafières - Port Cassafières", "3":"3" }, { "0":"15", "1":"313", "2":"Port Cassafières - Port Cassafières", "3":"3" }, { "0":"4", "1":"308", "2":"Saarbrücken - Hesse", "3":"7" }, { "0":"4", "1":"307", "2":"Saarbrücken - Saarbrücken", "3":"3" }, { "0":"9", "1":"272", "2":"St Gilles - Port Cassafières", "3":"7" }, { "0":"9", "1":"271", "2":"St Gilles - St Gilles", "3":"3" }, { "0":"6", "1":"292", "2":"St-Jean-de-Losne - Branges", "3":"7" }, { "0":"6", "1":"290", "2":"St-Jean-de-Losne - St-Jean-de-Losne", "3":"3" }, { "0":"6", "1":"291", "2":"St-Jean-de-Losne - Fontenoy-le-Château", "3":"7" }, { "0":"7", "1":"300", "2":"Tannay - Decize", "3":"7" }, { "0":"7", "1":"301", "2":"Tannay - Migennes", "3":"7" }, { "0":"7", "1":"299", "2":"Tannay - Tannay", "3":"3" }, { "0":"15", "1":"264", "2":"Trèbes - Castelnaudary", "3":"4" }, { "0":"15", "1":"123", "2":"Trèbes - Narbonne", "3":"7" }, { "0":"15", "1":"122", "2":"Trèbes - Trèbes", "3":"3" }, { "0":"10", "1":"311", "2":"Jabel - Jabel", "3":"3" }, { "0":"10", "1":"312", "2":"Jabel - Marina Wolfsbruch", "3":"3" }, { "0":"10", "1":"310", "2":"Marina Wolfsbruch - Jabel", "3":"3" }, { "0":"10", "1":"170", "2":"Marina Wolfsbruch - Marina Wolfsbruch", "3":"3" }, { "0":"10", "1":"171", "2":"Marina Wolfsbruch - Potsdam", "3":"7" }, { "0":"10", "1":"173", "2":"Potsdam - Marina Wolfsbruch", "3":"7" }, { "0":"10", "1":"172", "2":"Potsdam - Potsdam", "3":"3" }, { "0":"11", "1":"155", "2":"Sneek - Sneek", "3":"3" }, { "0":"11", "1":"156", "2":"Sneek - Strand Horst", "3":"7" }, { "0":"11", "1":"158", "2":"Strand Horst - Sneek", "3":"7" }, { "0":"11", "1":"157", "2":"Strand Horst - Strand Horst", "3":"3" }, { "0":"12", "1":"162", "2":"Belturbet - Belturbet", "3":"3" }, { "0":"12", "1":"161", "2":"Belturbet - Carrick-on-Shannon", "3":"7" }, { "0":"12", "1":"163", "2":"Belturbet - Portumna", "3":"10" }, { "0":"12", "1":"169", "2":"Carrick-on-Shannon - Belturbet", "3":"7" }, { "0":"12", "1":"168", "2":"Carrick-on-Shannon - Carrick-on-Shannon", "3":"3" }, { "0":"12", "1":"167", "2":"Carrick-on-Shannon - Portumna", "3":"7" }, { "0":"12", "1":"164", "2":"Portumna - Belturbet", "3":"10" }, { "0":"12", "1":"165", "2":"Portumna - Carrick-on-Shannon", "3":"7" }, { "0":"12", "1":"166", "2":"Portumna - Portumna", "3":"3" }, { "0":"13", "1":"344", "2":"Casale - Casale", "3":"3" }, { "0":"13", "1":"177", "2":"Casale - Porto Levante", "3":"7" }, { "0":"13", "1":"175", "2":"Porto Levante - Casale", "3":"7" }, { "0":"13", "1":"174", "2":"Porto Levante - Porto Levante", "3":"3" }, { "0":"14", "1":"160", "2":"Laggan - Laggan", "3":"3" }]}

function changeDuration()
        {
            for( k=0;k<QB.cruises.length; k++ )
            {
                if( QB.cruises[k][1] == this.value )
                {
                    //dur_start = duration_opts.indexOf( QB.cruises[k][3] );
                    //alert( duration_opts );
                    for( m=0;m<duration_opts.length; m++ )
                    {
                        //alert( m+":"+QB.cruises[k][3] );
                        if( duration_opts[m] == QB.cruises[k][3] )
                        {
                            dur_start = m;
                        }
                    }
                    //alert( duration_dd.innerHTML );
                    duration_dd.innerHTML = "";
                    for( kk=dur_start; kk<duration_opts.length; kk++ )
                    {
                        duration_option = document.createElement( "option" );
                        duration_option.setAttribute( "value", duration_opts[kk] );
                        duration_option_text = document.createTextNode( duration_opts[kk] );
                        duration_option.appendChild( duration_option_text );
                        duration_dd.appendChild( duration_option );
                    }
                }
            }
        }



    function populateQBForm()
    {
        if( !document.getElementById( "qbregion" ) ) {  return false; }
        var region_dd = document.getElementById( "qbregion" );
        var route_dd = document.getElementById( "qbroute" );
        var duration_dd = document.getElementById( "qbduration" );
        var duration_opts = Array( '2','3','4','5','7','10','11','14' );
        for( i=0; i<QB.countries.length; i++ )
        {
            var region_group = document.createElement( "optgroup" );
            region_group.setAttribute( "label", QB.countries[i][0] );
            for( ii=0;ii<QB.countries[i][1].length;ii++ )
            {
                var region_option = document.createElement( "option" );
                region_option.setAttribute( "value", QB.countries[i][1][ii][1] );
                var region_name = document.createTextNode( QB.countries[i][1][ii][0]);
                region_option.appendChild( region_name );
                region_group.appendChild( region_option );
            }
            region_dd.appendChild( region_group );
        }
        region_dd.onchange = function()
        {
            route_dd.innerHTML = "<option value=\"null\">Please Select...</option>";
            for( j=0; j<QB.cruises.length; j++ )
            {
                if( QB.cruises[j][0] == this.value )
                {
                    var cruise_option = document.createElement( "option" );
                    cruise_option.setAttribute( "value", QB.cruises[j][1] );
                    var cruise_option_text = document.createTextNode( QB.cruises[j][2]);
                    cruise_option.appendChild( cruise_option_text );
                    route_dd.appendChild( cruise_option );
                }
            }
            // Need to set duration, as IE6's onChange doesn't appear to be triggered by JS
            for( k=0;k<QB.cruises.length; k++ )
            {
                if( QB.cruises[k][1] == route_dd.value )
                {
                    //dur_start = duration_opts.indexOf( QB.cruises[k][3] );
                    //alert( duration_opts );
                    for( m=0;m<duration_opts.length; m++ )
                    {
                        //alert( m+":"+QB.cruises[k][3] );
                        if( duration_opts[m] == QB.cruises[k][3] )
                        {
                            dur_start = m;
                        }
                    }
                    //alert( duration_dd.innerHTML );
                    duration_dd.innerHTML = "";
                    for( kk=dur_start; kk<duration_opts.length; kk++ )
                    {
                        duration_option = document.createElement( "option" );
                        duration_option.setAttribute( "value", duration_opts[kk] );
                        duration_option_text = document.createTextNode( duration_opts[kk] );
                        duration_option.appendChild( duration_option_text );
                        duration_dd.appendChild( duration_option );
                    }
                }
            }

        }
        route_dd.onchange = function()
        {
            for( k=0;k<QB.cruises.length; k++ )
            {
                if( QB.cruises[k][1] == this.value )
                {
                    //dur_start = duration_opts.indexOf( QB.cruises[k][3] );
                    //alert( duration_opts );
                    for( m=0;m<duration_opts.length; m++ )
                    {
                        //alert( m+":"+QB.cruises[k][3] );
                        if( duration_opts[m] == QB.cruises[k][3] )
                        {
                            dur_start = m;
                        }
                    }
                    //alert( duration_dd.innerHTML );
                    duration_dd.innerHTML = "";
                    for( kk=dur_start; kk<duration_opts.length; kk++ )
                    {
                        duration_option = document.createElement( "option" );
                        duration_option.setAttribute( "value", duration_opts[kk] );
                        duration_option_text = document.createTextNode( duration_opts[kk] );
                        duration_option.appendChild( duration_option_text );
                        duration_dd.appendChild( duration_option );
                    }
                }
            }
        }
    }
    addLoadEvent( populateQBForm );