/* Minification failed. Returning unminified contents.
(60,1): run-time error CSS1019: Unexpected token, found '$'
(60,2): run-time error CSS1019: Unexpected token, found '('
(60,3): run-time error CSS1019: Unexpected token, found '"body"'
(60,9): run-time error CSS1019: Unexpected token, found ')'
(60,11): run-time error CSS1030: Expected identifier, found 'on('
(60,11): run-time error CSS1019: Unexpected token, found 'on('
(60,14): run-time error CSS1019: Unexpected token, found '"click"'
(60,21): run-time error CSS1019: Unexpected token, found ','
(60,23): run-time error CSS1019: Unexpected token, found '"#openHexRayFromDeformity, #openHexRayFromMounting"'
(60,74): run-time error CSS1019: Unexpected token, found ','
(60,85): run-time error CSS1031: Expected selector, found '('
(60,85): run-time error CSS1025: Expected comma or open brace, found '('
(86,2): run-time error CSS1019: Unexpected token, found ')'
(89,1): run-time error CSS1019: Unexpected token, found '$'
(89,2): run-time error CSS1019: Unexpected token, found '('
(89,3): run-time error CSS1019: Unexpected token, found '"body"'
(89,9): run-time error CSS1019: Unexpected token, found ')'
(89,11): run-time error CSS1030: Expected identifier, found 'on('
(89,11): run-time error CSS1019: Unexpected token, found 'on('
(89,14): run-time error CSS1019: Unexpected token, found '"click"'
(89,21): run-time error CSS1019: Unexpected token, found ','
(89,23): run-time error CSS1019: Unexpected token, found '"#openHexRayFromShow"'
(89,44): run-time error CSS1019: Unexpected token, found ','
(89,55): run-time error CSS1031: Expected selector, found '('
(89,55): run-time error CSS1025: Expected comma or open brace, found '('
(115,2): run-time error CSS1019: Unexpected token, found ')'
 */


//Ajax function to post data to hexray module from tlhex deformity section. Commented as new strategy to call hexray.
//$("body").on("click", "div.openHexRay", function (event) {

//    var formToPost = $("#deformityParameters");//Da parametrizzare quando aperto da mounting?
//    jQuery.validator.unobtrusive.parse(formToPost);
//    var isValid = CustomValidations();

//    if (formToPost.valid() && isValid) {//check client validation
//        var formSerialized = formToPost.serialize();
//        //to bypass the alert on redirect to hexray
//        window._isDirty = false;
//        formSerialized += "&GeneralInfo.FormChanged=" + $("#FormChanged").val() + "&GeneralInfo.PatientNumber=" + $("#PatientNumber").text() + "&GeneralInfo.CaseNumber=" + $("#CaseNumber").text() + "&GeneralInfo.CaseName=" + $("#CaseName").text();
//        $.blockUI(msgBlock);
//        $.ajax({
//            type: "POST",
//            url: "/HexRayIntegration/DeformityParameters", //Da parametrizzarre
//            data: formSerialized,
//            cache: false
//        }).success(function(dataSerialized) {

//            console.debug("Post on Integration Controller ok");
//            //Dynamic Redirect on the hexray view.
//            location.href = "http://"+window.location.host+"/HexRay/HexRay/Deformity?serializedData=" + dataSerialized.DeformityForHexRay;

//        }).error(function(msg) {
//            showAjaxErrors(ajaxExceptionMessage + " during opening Hex Ray Interface", msg);
//        });
//    }
//});

//Ajax function to call hexray controller in get passing caseid crypted from tlhex deformity section.
//$("body").on("click", "#openHexRayFromDeformity", function (event) {

//    var formToPost = $("#deformityParameters");//TODO Da parametrizzare quando aperto da mounting?
//    jQuery.validator.unobtrusive.parse(formToPost);
//    var isValid = CustomValidations();

//    if (formToPost.valid() && isValid) {//check client validation
//        //to bypass the alert on redirect to hexray
//        window._isDirty = false;
//        $.blockUI(msgBlock);
//        location.href = "http://" + window.location.host + "/HexRay/HexRay/DeformityHexRay?caseIdCrypted=" + $("#CaseIdCrypted").val();
//        //$.blockUI(msgBlock);
//        //$.ajax({
//        //    type: "GET",
//        //    url: "/HexRay/DeformityHexRay", //Da parametrizzarre
//        //    data: { caseIdCrypted: $("#CaseIdCrypted").val()},
//        //    cache: false
//        //}).success(function () {
//        //    console.debug("Post on Hex Ray Controller ok");
//        //}).error(function (msg) {
//        //    showAjaxErrors(ajaxExceptionMessage + " during opening Hex Ray Controller", msg);
//        //});
//    }
//});

//Ajax function to call hexray controller in get passing caseid crypted from tlhex deformity or mounting section.
$("body").on("click", "#openHexRayFromDeformity, #openHexRayFromMounting", function (event) {
    
    if ($(this).data("formselector")!=="")


        var formToPost = $($(this).data("formselector"));

    if(formToPost!==undefined){
    jQuery.validator.unobtrusive.parse(formToPost);
    var isValid = CustomValidations();
    }
    if (formToPost===undefined || (formToPost.valid() && isValid)) {//check client validation (only from deformity or mounting _ not show for customer care)
        //to bypass the alert on redirect to hexray
        window._isDirty = false;
        $.blockUI(msgBlock);
        var url = "https://" + window.location.host + "/HexRay/HexRay/" + $(this).data("actiontocall") + "?caseIdCrypted=" + ($("#CaseIdCrypted").val()!==undefined ? $("#CaseIdCrypted").val() : $("#CaseDataViewModel_CaseIdCrypted").val());

        //Manage landing tab to hexray depending on tab where the user save on hexray.
        if ($(this).data("actiontocall") === "MountingHexRay") {
            url += "&SelectedTab=mount&TabFromTlHex=mount";
        } else {
            url += "&SelectedTab=" + $("#TreatmentPlanInfo_HexRayTabType").val() + "&TabFromTlHex=Def";
        }

        location.href = url;
    }
});

//Ajax function to call hexray controller in get passing caseid crypted from tlhex deformity or mounting section.
$("body").on("click", "#openHexRayFromShow", function (event) {

  if ($(this).data("formselector") !== "")


    var formToPost = $($(this).data("formselector"));

  if (formToPost !== undefined) {
    jQuery.validator.unobtrusive.parse(formToPost);
    var isValid = CustomValidations();
  }
  if (formToPost === undefined || (formToPost.valid() && isValid)) {//check client validation (only from deformity or mounting _ not show for customer care)
    //to bypass the alert on redirect to hexray
    window._isDirty = false;
    $.blockUI(msgBlock);
    var url = "https://" + window.location.host + "/HexRay/HexRay/" + $(this).data("actiontocall") + "?readonly=true&caseIdCrypted=" + ($("#CaseIdCrypted").val() !== undefined ? $("#CaseIdCrypted").val() : $("#CaseDataViewModel_CaseIdCrypted").val());

    //Manage landing tab to hexray depending on tab where the user save on hexray.
    if ($(this).data("actiontocall") === "MountingHexRay") {
      url += "&SelectedTab=mount&TabFromTlHex=mount";
    } else {
      url += "&SelectedTab=" + $("#TreatmentPlanInfo_HexRayTabType").val() + "&TabFromTlHex=Def";
    }

    location.href = url;
  }
});
