page = function( current ) {
    document.location.search = '?page=' + current;
}

function addslashes(str) {
str=str.replace(/\\/g,'\\\\');
str=str.replace(/\'/g,'\\\'');
str=str.replace(/\"/g,'\\"');
str=str.replace(/\0/g,'\\0');
return str;
}

function storyChanged( url ) {
    $("#stories > li > a").removeClass( "on" );
    $( "a[id=" + url + "]" ).addClass( "on" );
    url = document.location.protocol + "//" + document.location.hostname + document.location.pathname + "/item?url=" + url;
    $("#votes_content").load( url + " #item" );
}

function storyPageChanged( current ) {
    url = document.location.protocol + "//" + document.location.hostname + document.location.pathname + "?page=" + current;
    $("#stories").load( url + " #stories > *" );
    $(".pager").load( url + " .pager >*" );
    
    $("#stories > li > a").click( function() {
       storyChanged( this.id );
    });
}

$(document).ready(
    function() {
        $("#stories > li > a").click( function() {
           storyChanged( this.id );
        });
    }
);
