﻿// Fixes dialog under combobox in IE6
$.ui.dialog.defaults.bgiframe = true;

function initializeRequestHandler(sender, args) {
    // Disables control which causes partial post-back
    //if ($get(args._postBackElement.id) != null)
    //    $get(args._postBackElement.id).disabled = true;
    blockPage();
}

// This function will handle the end request event
function endRequestHandler(sender, args) {

    if (args.get_error() != undefined) {
        var errorMessage;
        if (args.get_response().get_statusCode() == '200') {
            errorMessage = args.get_error().message;
        }
        else {
            // Error occurred somewhere other than the server page.
            errorMessage = 'An unspecified error occurred. ';
        }
        args.set_errorHandled(true);

        //Shows message
        alert(errorMessage);
    }

    SetInputFormStyle();

    // Enables control which causes partial post-back
    //if ($get(sender._postBackSettings.sourceElement.id) != null)
    //    $get(sender._postBackSettings.sourceElement.id).disabled = false;
    unblockPage();
}

$(document).ready(function() {

    //jQuery.noConflict();
    SetInputFormStyle();

    // Handles partial post-back
    Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(initializeRequestHandler);
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler);
});

function SetInputFormStyle() {
//    // ****************************************
//    // *Style for table of formMain class*
//    // ****************************************
//    var col1 = $("table.formMain td:first-child");
//    var col2 = $("table.formMain td:nth-child(2)");
//    var col3 = $("table.formMain td:nth-child(3)");
//    $(col2).addClass("mainContentColumn");

    // ****************************************
    // *Style for table of formOneColumn class*
    // ****************************************
    var col1 = $("table.formOneColumn td:first-child");
    var col2 = $("table.formOneColumn td:nth-child(2)");
    $(col1).addClass("formLabelColumn");
    $(col2).addClass("formInputColumn");
}

