<script type="text/javascript">
var versions = {{theme_version_selector}}
var pagename = '{{pagename}}'
var stable = 'v{{theme_stable}}'

function vfnav() {
    if ( pagename=='index' ) {
        pn = ''
    }
    else {
        pn = pagename
    }

    v = $(this).children("option:selected").attr('value')

    if ( (v==0) || (v==stable) ) {
        uri = '/manual/' + pn
    }
    else {
        uri = '/' + v + '/' + pn
    }
    window.location.href= uri;
}

$(document).ready(function(){
    $("#vn").html(function(){
        s=$("<select/>");
        o='<option/>';

        $.each(versions,function(index, version) {
            if ( version.v==stable ) {
                dv=true;
            }
            $(o,{value:version.v,text: version.t}).appendTo(s);
        });

        if ( dv==false ) {
            $(o, {value:0,text:'(stable)'}).appendTo(s);
        }
        return(s);
    });

    $("#vn select").bind('change', vfnav);
    $('#vn select').val('v{{version|e}}');
});
</script>
