$.validator.addMethod(
    "dateSK",
    function(value, element) {
        var check = false;
        var re = /^\d{1,2}\.\d{1,2}\.\d{4}$/;
        if (re.test(value)){
            var adata = value.split('.');
            var dd = parseInt(adata[0], 10);
            var mm = parseInt(adata[1], 10);
            var yyyy = parseInt(adata[2], 10);
            var xdata = new Date(yyyy, mm-1, dd);
            check = ( xdata.getFullYear() == yyyy )&&( xdata.getMonth () == mm - 1 )&&( xdata.getDate() == dd )
        } else
            check = false;
        return this.optional(element) || check;
    },
    "Please enter a correct date"
);

$.sal = function(cookieName) {
    var cookie = $.cookie(cookieName);
    var items = cookie ? cookie.split(/,/) : new Array();

    if (!Array.indexOf) {
        Array.prototype.indexOf = function(obj) {
            for (var i = 0; i < this.length; i++) {
                if (this[i] == obj) { return i; }
            }
            return -1;
        }
    }

    return {
        "processItem": function(div, speed) {
            var index = items.indexOf(div);
            $("#" + div).slideToggle(speed, function() {
                if ($("#" + div).is(":visible")) {
                    if (index == -1) { items.push(div) };
                }
                else {
                    if (index != -1) { items.splice(index, 1); };
                }
                $.cookie(cookieName, items);
            });
        },
        "displayItem": function(div) {
            if (items.indexOf(div) != -1) {
                $("#" + div).css("display", "block");
            }
        },
        "clear": function() {
            $.cookie(cookieName, null);
            items = new Array();
        }
    }
}("sal");


$.extend({
  getUrlVars: function(){
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
  },
  getUrlVar: function(name){
    //replace slash with "\/"
    if ($.getUrlVars()[name] == undefined) return null;
    return $.getUrlVars()[name].replace(/\//gi, "\\/");
  }
});

//$.sal.clear();
