﻿function OnChangeDatePicker(e) {
    window.location.replace(replaceQueryString(location.href, 'date', $.telerik.formatString('{0:M/d/yyyy h:mm:ss tt}', e.value)));
}

function OnChangeYTVDropdown(e) {
    window.location.replace(replaceQueryString(location.href, 'isytv', e.value));
}

function OnChangeCountryDropdown(e) {
    window.location.replace(replaceQueryString(location.href, 'country', e.value));
}

function replaceQueryString(url, param, value) {
    var hashMatch = new RegExp("#.*?", "i");
    var hash = "";
    if (url.match(hashMatch)) {
        hash = url.substring(url.indexOf("#"));
        url = url.substring(0, url.indexOf("#"));
    }

    var re = new RegExp("([?|&])" + param + "=.*?(&|$)", "i");
    if (url.match(re)) {
        return url.replace(re, '$1' + param + "=" + value + '$2') + hash;
    } else if (url.indexOf("?") == -1) {
        return url + '?' + param + "=" + value + hash;
    } else {
        return url + '&' + param + "=" + value + hash;
    }
}


