// auto scroll to content
$(window).unload(function() {
    var top = f_scrollTop();
    setCookie('window_scroll_top', top, 1);
})
$(function() {
    var top = getCookie('window_scroll_top');
    if (top)
    {
        $(document).scrollTop(top);
        //window.scrollBy(0, top);
    }
});
// get window scroll positions
function f_scrollLeft() {
    return f_filterResults (
        window.pageXOffset ? window.pageXOffset : 0,
        document.documentElement ? document.documentElement.scrollLeft : 0,
        document.body ? document.body.scrollLeft : 0
    );
}
function f_scrollTop() {
    return f_filterResults (
        window.pageYOffset ? window.pageYOffset : 0,
        document.documentElement ? document.documentElement.scrollTop : 0,
        document.body ? document.body.scrollTop : 0
    );
}
function f_filterResults(n_win, n_docel, n_body) {
    var n_result = n_win ? n_win : 0;
    if (n_docel && (!n_result || (n_result > n_docel)))
        n_result = n_docel;
    return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
/**
 * Set Cookie
 */
function setCookie(name, value, days)
{
    var expireDate = new Date();
    expireDate.setDate(expireDate.getDate() + parseInt(days));
    document.cookie = name + '=' + value + '; expires=' + expireDate.toGMTString() + '; path=/';
}
/**
 * Get Cookie
 */
function getCookie(name)
{
    var re = new RegExp(name + '=[^;]+', 'i');
    if (document.cookie.match(re))
    {
        return document.cookie.match(re)[0].split('=')[1];
    }
    return '';
}
