﻿$(document).ready(function () {
    //Ask ASP.NET what culture we prefer, because we stuck it in a meta tag
    var data = $("meta[name='accept-language']").attr("content")

    //Tell jQuery to figure it out also on the client side.
    Globalize.culture(data);

    //Tell the validator, for example,
    // that we want numbers parsed a certain way!
    //    $.validator.methods.number = function (value, element) {
    //        if ($.global.parseFloat(value)) {
    //            return true;
    //        }
    //        return false;
    //    }
    //    alert("1");
    //    //Fix the range to use globalized methods
    //    jQuery.extend(jQuery.validator.methods, {
    //        range: function (value, element, param) {
    //            //Use the Globalization plugin to parse the value
    //            var val = $.global.parseFloat(value);
    //            return this.optional(element) || (val >= param[0] && val <= param[1]);
    //        }
    //    });
    //Setup datepickers if we don't support it natively!
    if (!Modernizr.inputtypes.date) {
        if (Globalize.culture().name != 'en-us' && Globalize.culture().name != 'en') {

            var datepickerScriptFile = "/Scripts/cultures/globalize.culture." + $Globalize.culture().name + ".js";
            //Now, load the date picker support for this language 
            // and set the defaults for a localized calendar
            $.getScript(datepickerScriptFile, function () {
                $.datepicker.setDefaults($.datepicker.regional[Globalize.culture().name]);
            });
        }
        $("input[type='datetime']").datepicker();
        $("input[type='date']").datepicker();
    }

});
