﻿$(document).ready(function () {



    InitDialogs();







    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

    function EndRequestHandler(sender, args) {

        InitDialogs();

    };

});

function InitDialogs() {



    $('.extraInfo').click(function (event) {

        var type = $(this).attr('lang');
        //        $("#dialog-extraInfo").dialog('option', 'position', [event.clientX, event.clientY]);
        $.ajax({
            type: "POST",

            url: "GetCentralData.asmx/GetExtraInfo",
            data: "{'type' : '" + type + "' }",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (msg) {
                if (msg.d["Error"] == "") {
                    $(".jqmAlertContent").html(msg.d["Value"]);


                    return false;
                }
                else {

                    return false;
                }
            }
        });

    });


    // select + reference "triggering element" -- will pass to $.jqm()
    var triggers = $('a.extraInfo');

    // NOTE; we could have used document.getElementById(), or selected
    //  multiple elemets with $(..selector..) and passed the trigger
    //  as a jQuery object. OR, just include the string '#ex3btrigger' 
    //  as the trigger parameter (as typically demonstrated).

    //  NOTE; we supply a target for the ajax return. This allows us
    //   to keep the structure of the alert window. An element can 
    //   also be passed (see the documentation) as target.

    $('#ex3b').jqm({
        trigger: triggers,
        ajax: 'examples/3b.html',
        target: 'div.jqmAlertContent',
        overlay: 0
    });

    // Close Button Highlighting. IE doesn't support :hover. Surprise?
    if ($.browser.msie) {
        $('div.jqmAlert .jqmClose')
  .hover(
    function () { $(this).addClass('jqmCloseHover'); },
    function () { $(this).removeClass('jqmCloseHover'); });
    }



    //    $("#dialog-extraInfo").dialog('destroy');

    //    $("#dialog-extraInfo").dialog({
    //        autoOpen: false,
    //        modal: false,
    //        resizable: false,
    //        disabled: true
    //    });

    //    $('.extraInfo').click(function (event) {

    //        var type = $(this).attr('lang');
    ////        $("#dialog-extraInfo").dialog('option', 'position', [event.clientX, event.clientY]);
    //        $.ajax({
    //            type: "POST",

    //            url: "GetCentralData.asmx/GetExtraInfo",
    //            data: "{'type' : '" + type + "' }",
    //            contentType: "application/json; charset=utf-8",
    //            dataType: "json",
    //            success: function (msg) {
    //                if (msg.d["Error"] == "") {
    //                    $("#lblExtraInfoPopUp").html(msg.d["Value"]);

    //                    $("#dialog-extraInfo").dialog('open');
    //                    return false;
    //                }
    //                else {
    //                    $("#dialog-extraInfo").dialog('close');
    //                    return false;
    //                }
    //            }
    //        });

    //    });
};
