﻿
function GenerateCloseButton(sender, e) {
    // TO Close the Calendar Pop Up.
    if ($('#' + sender._id + "_ajax__calendar_close_button").length == 0) {

        $(sender._header).before("<div class='ajax__calendar_close_button' id=" + sender._id + "_ajax__calendar_close_button>&nbsp;</div>");

        $('#' + sender._id + "_ajax__calendar_close_button").bind("click", sender, function(e) {

            e.data.hide();

        });
    }
}

function hideValidator() {
       if ((AjaxControlToolkit.ValidatorCalloutBehavior._currentCallout != null) && (AjaxControlToolkit.ValidatorCalloutBehavior._currentCallout != 'undefined')) {
           AjaxControlToolkit.ValidatorCalloutBehavior._currentCallout.hide();
       }
}

function hidePreview() {
    hideValidator();
    self.parent.tb_remove();
}
function showUpdateProgressDialog() {
    $('#updateInProgressDiv').css({ "display": "block" });
    $("#openThickBox").trigger('click');
}
function hideUpdateProgressDialog() {
    $('#updateInProgressDiv').css({ "display": "none" });
}

//Following Function are Added By Pankaj Gohel
//This funcation are used to do ACTIVE-INACTIVE Funtionality.
function IsActiveImageFormatter(cellValue, options, rowObject) {
    //debugger;
    var imageHtml = "";

    if (cellValue == "")
        imageHtml = '<img src="../Images/spacer.gif"  alt="Pending Activation" height="25" width="75" />'; //'&nbsp;';
    else if (cellValue == "True" || cellValue == "Yes")
        imageHtml = '<img src="../Images/spacer.gif" class="act-ico" alt="Active" onclick="return toggleActivation(event,\'' + options.rowId + '\', this);" originalValue="' + cellValue + '" />';
    else if (cellValue == "False" || cellValue == "No")
        imageHtml = '<img src="../Images/spacer.gif" class="inact-ico" alt="InActive" onclick="return toggleActivation(event,\'' + options.rowId + '\', this);" originalValue="' + cellValue + '" />';
    else
        imageHtml = cellValue;

    options.colModel.editable = false;
    return imageHtml;
}
function PriceImageFormatter(cellValue, options, rowObject) {
    //debugger;
    var imageHtml = "";


    imageHtml = '<a href="javascript:void(0)" style="display:inline-block;cursor:default;"  />$' + cellValue;

    options.colModel.editable = false;
    return imageHtml;
}
function ViewOrderFormatter(cellValue, options, rowObject) {
    //debugger;
    var linkHref = "";


    linkHref = '<a title="" class="view-btn"   href="ViewOrderDetails.aspx?BookingId=' + cellValue + '"></a>';

    options.colModel.editable = false;
    return linkHref;
}
function CancelOrderFormatter(cellValue, options, rowObject) {
    //debugger;
    var linkHref = "";
    
    linkHref = '<a title="" class="cancel-btn" href="ReviewCancellation.aspx?BookingId=' + cellValue + '"></a>';

    options.colModel.editable = false;
    return linkHref;
}



function IsActiveUnImageFormatter(cellValue, options, cellObject) {
    //debugger;
    if (isToggleActivation) {
        options.colModel.editable = true
        options.colModel.edittype = 'checkbox';

        if ($($(cellObject).html()).attr("originalValue") != "") {
            if ($($(cellObject).html()).attr("originalValue") == "True" || $($(cellObject).html()).attr("originalValue") == "Yes")
                return "False";
            else
                return "True";
        }
        else
            return "&nbsp;";
    }
    else {
        options.colModel.editable = false
    }


}
var isToggleActivation = false;
function toggleActivation(evnt, RowId, obj) {
    //debugger;
    var e = (window.event) ? window.event : evnt;
    //alert($(e.srcElement).parents('table').attr('id'));
    var gridID = $(obj).parents('table').attr('id');
    isToggleActivation = true;

    //jQuery('#' + jQuery('#ActiveInactiveJQGrid').val()).editRow(RowId);
    //jQuery('#' + jQuery('#ActiveInactiveJQGrid').val()).saveRow(RowId);
    jQuery('#' + gridID).editRow(RowId);
    jQuery('#' + gridID).saveRow(RowId);

    var e = (window.event) ? window.event : evnt;
    e.cancelBubble = true;
    isToggleActivation = false;
    return false;
}


function CheckValidation(validationGroup) {
    if (typeof Page_ClientValidate != "undefined") {
        return Page_ClientValidate(validationGroup);
    }
    else {
        return true;
    }
}


//End changes
