﻿$(document).ready(function() {
    var filterVal = $.query.get('pagesize');
    $("#pagesize").val(filterVal);
    var sort = $.query.get('sortorder');
    $("#sortby").val(sort)
});

function SetUrl(pagesize) {
    var fullUrl = window.location;
    if (fullUrl.toString().indexOf("?") == -1 && fullUrl.toString().indexOf("pagesize") == -1) {
        fullUrl = fullUrl + "?pagesize=" + pagesize;
        window.location.href = fullUrl;
        $("#pagesize").val(pagesize);

    }
    else if (fullUrl.toString().indexOf("?") > -1 && fullUrl.toString().indexOf("pagesize") > -1) {
        var url = location.search;
        url = $.query.set('pagesize', pagesize);
        cleanUrl = location.protocol + "//" + location.host + location.pathname;
        window.location.href = cleanUrl + url;
        $("#pagesize").val(pagesize);
    }
    else if (fullUrl.toString().indexOf("?") > -1 && fullUrl.toString().indexOf("pagesize") == -1) {
        var url = location.search;
        url = $.query.set('pagesize', pagesize);
        cleanUrl = location.protocol + "//" + location.host + location.pathname;
        window.location.href = cleanUrl + url;
        $("#pagesize").val(pagesize);
    }
}

function SetSortOrder(sortorder) {
    var fullUrl = window.location;
    if (fullUrl.toString().indexOf("?") == -1 && fullUrl.toString().indexOf("sortorder") == -1) {
        fullUrl = fullUrl + "?sortorder=" + sortorder;
        window.location.href = fullUrl;
        $("#sortby").val(sortorder);

    }
    else if (fullUrl.toString().indexOf("?") > -1 && fullUrl.toString().indexOf("sortorder") > -1) {
        var url = location.search;
        url = $.query.set('sortorder', sortorder);
        cleanUrl = location.protocol + "//" + location.host + location.pathname;
        window.location.href = cleanUrl + url;
        $("#sortby").val(sortorder);
    }
    else if (fullUrl.toString().indexOf("?") > -1 && fullUrl.toString().indexOf("sortorder") == -1) {
        var url = location.search;
        url = $.query.set('sortorder', sortorder);
        cleanUrl = location.protocol + "//" + location.host + location.pathname;
        window.location.href = cleanUrl + url;
        $("#sortby").val(sortorder);
    }
}


function showMapPanel(name) {

    $("#" + name).show();
}

function hideMapPanel(name) {

    $("#" + name).hide();
}
