
//The Id of user control that is being loaded into Customers Central
var ucSubscriberDetailId = 'ctl00_eContent_ucSubscriberDetail';

function tabSubscriberDetails_ActiveTabChanged(sender, e) {
    var manageRecordingURL = window.location.href.split('WebSite')[0] + "WebSite/ManageRecording.aspx";
    var url = manageRecordingURL + "?TabIndex=" + sender.get_activeTabIndex() + "&PageUrl=" + window.location.href.split('?')[0] + "&TabId=tabSubscriberDetails";
    $.ajax({ url: url, cache: false });
}

function ResizeObject(height) {
    var host = document.getElementById("silverlightControlHost");
    if (document.documentElement.clientHeight < height) {
        host.style.height = height + "px";
    }
    else {
        host.style.height = document.documentElement.clientHeight.toString() + "px";
    }
}

function ClearHtmlContent() {
    var toClose = $('[id$=_imgClose]')[0];
    if (toClose) {
        __doPostBack($('[id$=_imgClose]').attr('name'));

    }
}

function HandleCreditCardUpdate() {
    $('[id$=_ibtnRefresh]').click();
}

function validateUKAlternatePhone()
{
    var altPhoneText = $('[id$=_pnAltPhone_m_txtPhoneNumber]')[0];
    var altPhoneAsterik = $('[id$=_spnAltPhoneValidationError]')[0];
    var ukRegEx = /^(((\+44\s?\d{4}|\(?0\d{4}\)?)\s?\d{3}\s?\d{3})|((\+44\s?\d{3}|\(?0\d{3}\)?)\s?\d{3}\s?\d{4})|((\+44\s?\d{2}|\(?0\d{2}\)?)\s?\d{4}\s?\d{4}))(\s?\#(\d{4}|\d{3}))?$/;
    
    if (altPhoneText != null
            && altPhoneText.value != ''
            && !altPhoneText.value.match(ukRegEx)) {
        alert($('[id$=_hdEnterValidPhoneNumber]').val()); //Please enter a valid alternate phone number');
        altPhoneText.focus();
        altPhoneAsterik.style.display = 'inline';
        return false;
    } else {
        
        return true;
    }
    
    return true;
}

function validateUSAlternatePhone() {

    var altPhoneText = $('[id$=_pnAltPhone_m_txtPhoneNumber]')[0];
    var altPhoneAsterik = $('[id$=_spnAltPhoneValidationError]')[0];
    if (altPhoneText != null
                && altPhoneText.value != ''
                && !altPhoneText.value.match(/[-\d]{12}/)) {
        alert($('[id$=_hdEnterValidPhoneNumber]').val()); //Please enter a valid alternate phone number');
        altPhoneText.focus();
        altPhoneAsterik.style.display = 'inline';
        return false;
    } else
        return true;
}

if (typeof (CustomerCentral) != 'undefined') {
    CustomerCentral[ucSubscriberDetailId] = new Object();

    CustomerCentral[ucSubscriberDetailId].Enabled = false;

    CustomerCentral[ucSubscriberDetailId].CollapseSearch = function () {
        var toClose = $find('CollapseFromSearchClick');
        if (toClose) {
            toClose._doClose();
        }
    };

    CustomerCentral[ucSubscriberDetailId].IsValidated = function () {
        return ($('[id$=_divCheckBox]')[0].style.backgroundImage == '') ? false : true;
    };

    CustomerCentral[ucSubscriberDetailId].SetCheckEnabled = function (isEnabled) {
        var hEnabled = $('[id$=_hidEnabled]')[0];

        if (isEnabled) {
            hEnabled.value = 'true';
        } else {
            hEnabled.value = 'false';
        }
    };

    CustomerCentral[ucSubscriberDetailId].CheckChange = function () {

        try {
            var hEnabled = $('[id$=_hidEnabled]')[0];

            if (!CustomerCentral[ucSubscriberDetailId].IsValidated()) {
                $(".ibtnHIPManager").removeAttr("disabled");
            }

            if (hEnabled.value.toLowerCase() != 'true') {
                return;
            }

            if (!CustomerCentral[ucSubscriberDetailId].IsValidated()) {
                CustomerCentral[ucSubscriberDetailId].SetEnabled(true, true);
                CustomerCentral[ucSubscriberDetailId].SetCheckEnabled(false);
                CustomerCentral.AddAutoNote($('[id$=_hdSubscriberDetailsViewed]').val());

            } else {
                CustomerCentral[ucSubscriberDetailId].SetEnabled(false, false);
            }
        } catch (e) {
            debugger;
        }

        return false;
    };

    CustomerCentral[ucSubscriberDetailId].SetEnabled = function (toSet, addAutoNote) {
        var checkbox = $('[id$=_divCheckBox]')[0];
        var hiddenServerUrl = $('[id$=_hidServerUrl]')[0];
        var altPhoneText = $('[id$=_pnAltPhone_m_txtPhoneNumber]')[0];
        var emailText = $('[id$=_tabSubscriberDetailsPanel1_txtEmail]')[0];
        var altPhoneLabel = $('[id$=_lblAltPhone]')[0];
        var emailLabel = $('[id$=_lblEmail]')[0];
        var btnEndCall = $('[id$=_btnEndCall]')[0];
        var alternateUserLabel = $('[id$=_lblAlternateUser]')[0];
        var alternateUserText = $('[id$=_txtAlternateUser]')[0];
        CustomerCentral.SetAllChildrenDisabled(document.getElementById('logo1'), true); // image header disable as link
        CustomerCentral.SetPanelsEnabled(toSet);
        if (emailText != null) {
            emailLabel.innerHTML = emailText.value;
        }
       
        if (altPhoneText != null) {
            altPhoneText.value = altPhoneLabel.innerText;
        }

        if (alternateUserText != null) {
            alternateUserText.value = alternateUserLabel.innerHTML;
        }

        if (toSet) {
            checkbox.style.backgroundImage = 'url(' + hiddenServerUrl.value + '/images/FancyForm/chk_on.png)';

            if (altPhoneText != null) {
                altPhoneText.style.display = 'inline';
                altPhoneLabel.style.display = 'none';
            }
            if (emailText != null) {
                emailText.style.display = 'inline';
                emailLabel.style.display = 'none';
            }
            if (alternateUserText != null) {
                alternateUserText.style.display = 'inline';
                alternateUserLabel.style.display = 'none';
            }

            CustomerCentral[ucSubscriberDetailId].ToggleButton($('[id$=_ibtnSave]').attr('id'), true);
            CustomerCentral[ucSubscriberDetailId].ToggleButton($('[id$=_ibtnUpdateCC]').attr('id'), true);
            CustomerCentral[ucSubscriberDetailId].ToggleButton($('[id$=_ibtnTerminateCC]').attr('id'), true);
            CustomerCentral[ucSubscriberDetailId].ToggleButton($('[id$=_ibtnTerminateCCSL]').attr('id'), true);
            CustomerCentral[ucSubscriberDetailId].ToggleButton($('[id$=_ibtnPaymentHistoryAndRefunds]').attr('id'), true);
            CustomerCentral[ucSubscriberDetailId].ToggleButton($('[id$=_ibtnNoteHistory]').attr('id'), true);
            CustomerCentral[ucSubscriberDetailId].ToggleButton($('[id$=_ibtnReactivateSubscriber]').attr('id'), true);
            CustomerCentral[ucSubscriberDetailId].ToggleButton($('[id$=_ibtnSubscriberHistory]').attr('id'), true);
            CustomerCentral[ucSubscriberDetailId].ToggleButton($('[id$=_ibtnTriplePlay]').attr('id'), true);
            CustomerCentral[ucSubscriberDetailId].ToggleButton($('[id$=_ibtnFinancing]').attr('id'), true);
            CustomerCentral[ucSubscriberDetailId].ToggleButton($('[id$=_ibtnManageDebitCard]').attr('id'), true);

            $('[id$=_hdEnabled]').val("1");
        } else {
            checkbox.style.backgroundImage = '';

            if (altPhoneText != null) {
                altPhoneText.style.display = 'none';
                altPhoneLabel.style.display = 'inline';
            }
            if (emailText != null) {
                emailText.style.display = 'none';
                emailLabel.style.display = 'inline';
            }
            if (alternateUserText != null) {
                alternateUserText.style.display = 'none';
                alternateUserLabel.style.display = 'inline';
            }

            CustomerCentral[ucSubscriberDetailId].ToggleButton($('[id$=_ibtnSave]').attr('id'), false);
            CustomerCentral[ucSubscriberDetailId].ToggleButton($('[id$=_ibtnUpdateCC]').attr('id'), true);
            CustomerCentral[ucSubscriberDetailId].ToggleButton($('[id$=_ibtnTerminateCC]').attr('id'), false);
            CustomerCentral[ucSubscriberDetailId].ToggleButton($('[id$=_ibtnTerminateCCSL]').attr('id'), false);
            CustomerCentral[ucSubscriberDetailId].ToggleButton($('[id$=_ibtnPaymentHistoryAndRefunds]').attr('id'), false);
            CustomerCentral[ucSubscriberDetailId].ToggleButton($('[id$=_ibtnNoteHistory]').attr('id'), false);
            CustomerCentral[ucSubscriberDetailId].ToggleButton($('[id$=_ibtnReactivateSubscriber]').attr('id'), true);
            CustomerCentral[ucSubscriberDetailId].ToggleButton($('[id$=_ibtnSubscriberHistory]').attr('id'), false);
            CustomerCentral[ucSubscriberDetailId].ToggleButton($('[id$=_ibtnTriplePlay]').attr('id'), false);
            CustomerCentral[ucSubscriberDetailId].ToggleButton($('[id$=_ibtnFinancing]').attr('id'), false);
            CustomerCentral[ucSubscriberDetailId].ToggleButton($('[id$=_ibtnManageDebitCard]').attr('id'), false);
            
        }

        $('[id$=_spnEmailValidationError]')[0].style.display = 'none';
        $('[id$=_spnAltPhoneValidationError]')[0].style.display = 'none';
        $('[id$=_spnAlternateUserValidationError]')[0].style.display = 'none';
    };

    CustomerCentral[ucSubscriberDetailId].Validate = function () {
        var altPhoneText = $('[id$=_pnAltPhone_m_txtPhoneNumber]')[0];
        var emailText = $('[id$=_tabSubscriberDetailsPanel1_txtEmail]')[0];
        var altPhoneValResult = true;
        var altPhoneAsterik = $('[id$=_spnAltPhoneValidationError]')[0];
        var emailAsterik = $('[id$=_spnEmailValidationError]')[0];
        
        
        if ($('[id$=_hdLocaleId]').val() == '2057')
        {
            
            altPhoneValResult = validateUKAlternatePhone();
        }
        else if ($('[id$=_hdLocaleId]').val() == '1033')
        {
            altPhoneValResult = validateUSAlternatePhone();
        }
        
        
        if (altPhoneValResult == false)
            return false;

        if (emailText != null
            && emailText.value != ''
            && !emailText.value.match(/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/)) {
            alert($('[id$=_hdEnterValidEmail]').val()); //'Please enter a valid email address');
            emailText.focus();
            emailAsterik.style.display = 'inline';
            return false;
        }

        emailAsterik.style.display = 'none';
        altPhoneAsterik.style.display = 'none';

        return true;
    };

    CustomerCentral[ucSubscriberDetailId].ibtnSave_Click = function () {

        var altPhnumber = $('[id$=_pnAltPhone_m_txtPhoneNumber]')[0];;
        var email = $('[id$=_tabSubscriberDetailsPanel1_txtEmail]')[0];
        var alternateUser = $('[id$=_txtAlternateUser]')[0];
        var initialSubscriber = $('[id$=_hdfInitialSubscriber]')[0];

        function OnSuccess(result) {
            try {
                if (result) {
                    var altPhoneLabel = $('[id$=_lblAltPhone]')[0];
                    var emailLabel = $('[id$=_lblEmail]')[0];
                    var alternateUserLabel = $('[id$=_lblAlternateUser]')[0];
                    var altPhoneText = $('[id$=_pnAltPhone_m_txtPhoneNumber]')[0];;
                    var emailText = $('[id$=_tabSubscriberDetailsPanel1_txtEmail]')[0];
                    var alternateUserText = $('[id$=_txtAlternateUser]')[0];
                    
                    $(altPhoneLabel).val(altPhnumber.value);
                    $(altPhoneText).val(altPhnumber.value);
                    $(emailText).val(email.value);
                    $(emailLabel).val(email.value);
                    $(alternateUserLabel).val(alternateUser.value);
                    $(alternateUserText).val(alternateUser.value);

                    alert($('[id$=_hdSubsInfoSavedSuccessfully]').val()); //'Subscriber Information Saved Successfully');
                    $('[id$=_ucSubscriberDetail_tblLoading]')[0].style.display = 'inline';
                    $('[id$=_tblLoading]').css("display", "");
                    //CustomerCentral.AddAutoNote($('[id$=_hdSubscriberContactInfo1]').val() + ' ' + emailText.value + ', '
                    //                              + $('[id$=_hdSubscriberContactInfo2]').val() + ' ' + altPhoneText.value + ', '
                    //                              + $('[id$=_hdSubscriberContactInfo3]').val() + ' ' + alternateUserText.value);
                    var divProgress = $('[id$=_ucSubscriberDetail_tblLoading]')[0];
                    divProgress.style.display = 'none';

                    $(altPhoneLabel).val(altPhnumber.value);
                    $(altPhoneText).val(altPhnumber.value);
                    $(emailText).val(email.value);
                    $(emailLabel).val(email.value);
                    $(alternateUserLabel).val(alternateUser.value);
                    $(alternateUserText).val(alternateUser.value);
                    //
                } else {
                    alert($('[id$=_hdSubsInfoNotSaved]').val()); //'Subscriber Information could not be saved');
                }
            } catch (e) {
                alert($('[id$=_hdExceptionOnSuccess]').val()); //'An exception happened OnSuccess');
            } finally {
                
            }
            return false;
        }

        function OnFailure(e) {
            try {
                alert($('[id$=_hdServerNotContactedSaveSubs]').val()); //'The server could not be contacted to save the subscriber data.');
            } catch (e) {
                alert($('[id$=_hdExceptionOnFailures]').val()); //'An exception happened OnFailure');
            } finally {
                divProgress.style.display = 'none';
            }
        }


        if (CustomerCentral[ucSubscriberDetailId].Validate()) {
            var divProgress = $('[id$=_ucSubscriberDetail_tblLoading]')[0];
            divProgress.style.display = 'inline';
            if (altPhnumber != null
                && email != null
                && alternateUser != null) {

                if (initialSubscriber.value === undefined || initialSubscriber.value === null || initialSubscriber.value.replace(/(^[\s]+|[\s]+$)/g, '') == '') {
                    initialSubscriber.value = 0;
                };

                CustomerCentral.SaveSubscriberContactInfo(altPhnumber.value, email.value, alternateUser.value, initialSubscriber.value,
                    OnSuccess, OnFailure);
            }
        }

        return false;
    };

    CustomerCentral[ucSubscriberDetailId].btnEndCall_Click = function () {
        var multiSelect = $('[id$=_lbxClosingCodes]')[0];
        var spnVal = $('[id$=_spnClosingCodeAsterik]')[0];
        var selectedIndexes = CustomerCentral[ucSubscriberDetailId].GetSelectedIndexes(multiSelect);

        // Need at least one to be selected
        if (selectedIndexes.length <= 0) {
            spnVal.style.display = 'inline';
            return false;
        }

        $('[id$=_tblEndCallLoading]')[0].style.display = 'inline';
        spnVal.style.display = 'none';
        return true;
    };

    CustomerCentral[ucSubscriberDetailId].btnUpdateCC_Clicked = function () {

        $('[id$=_ucSubscriberDetail_tblLoading]')[0].style.display = 'inline';
    };

    CustomerCentral[ucSubscriberDetailId].btnTerminateCC_Clicked = function () {

        $('[id$=_ucSubscriberDetail_tblLoading]')[0].style.display = 'inline';
    };

    CustomerCentral[ucSubscriberDetailId].btnRefresh_Click = function () {

        $('[id$=_ucSubscriberDetail_tblLoading]')[0].style.display = 'inline';
    };

    CustomerCentral[ucSubscriberDetailId].btnReactivateSubscriber_Click = function () {

        $('[id$=_ucSubscriberDetail_tblLoading]')[0].style.display = 'inline';
    };
    $('[id$=_btnAfterNoteUpdate]').click(function () {

        $('[id$=_ucSubscriberDetail_tblLoading]')[0].style.display = 'inline';
    });

    CustomerCentral[ucSubscriberDetailId].GetSelectedIndexes = function (mySelect) {
        var toRet = new Array();

        for (var i = 0; i < mySelect.options.length; i++) {
            if (mySelect.options[i].selected) {
                toRet[toRet.length] = i;
            }
        }

        return toRet;
    };

    CustomerCentral[ucSubscriberDetailId].ToggleButton = function (clientID, enable) {
        var hiddenServerUrl = $('[id$=_hidServerUrl]')[0];

        switch (clientID) {
            case $('[id$=_ibtnRefresh]').attr('id'):
                var iButtonRefresh = $('[id$=_ibtnRefresh]')[0];

                if (enable) {
                    iButtonRefresh.src = hiddenServerUrl.value + '/images/refresh.jpg';
                } else {
                    iButtonRefresh.src = hiddenServerUrl.value + '/images/refresh_disabled.jpg';
                }
                iButtonRefresh.disabled = !enable;
                break;
            case $('[id$=_ibtnEndCall]').attr('id'):
                var iButtonEndCall = $('[id$=_ibtnEndCall]')[0];

                if (enable) {
                    iButtonEndCall.src = hiddenServerUrl.value + '/images/EndCall.jpg';
                } else {
                    iButtonEndCall.src = hiddenServerUrl.value + '/images/EndCall_disabled.jpg';
                }
                iButtonEndCall.disabled = !enable;
                break;
            case $('[id$=_ibtnLookup]').attr('id'):
                var iButtonLookup = $('[id$=_ibtnLookup]')[0];

                if (enable) {
                    iButtonLookup.src = hiddenServerUrl.value + '/images/Magnifying-Glass-32x32.jpg';
                } else {
                    iButtonLookup.src = hiddenServerUrl.value + '/images/Magnifying-Glass-32x32_disabled.jpg';
                }
                iButtonLookup.disabled = !enable;
                break;
            case $('[id$=_ibtnSave]').attr('id'):
                var iButtonSave = $('[id$=_ibtnSave]');
                if (iButtonSave != null) {
                    if (enable) {
                        iButtonSave.src = hiddenServerUrl.value + '/images/disk.jpg';
                    } else {
                        iButtonSave.src = hiddenServerUrl.value + '/images/disk_disabled.jpg';
                    }
                    iButtonSave.disabled = !enable;
                }
                break;
            case $('[id$=_ibtnUpdateCC]').attr('id'):
                var iButtonUpdateCC = $('[id$=_ibtnUpdateCC]')[0];
                if (iButtonUpdateCC != null) {
                    if (enable) {
                        iButtonUpdateCC.src = hiddenServerUrl.value + '/images/credit-card.jpg';
                    } else {
                        iButtonUpdateCC.src = hiddenServerUrl.value + '/images/credit-card_disabled.jpg';
                    }
                    iButtonUpdateCC.disabled = !enable;
                }
                break;
            case $('[id$=_ibtnTerminateCC]').attr('id'):
                var ibtnTerminateCC = $('[id$=_ibtnTerminateCC]')[0];
                if (ibtnTerminateCC != null) {
                    if (enable) {
                        ibtnTerminateCC.src = hiddenServerUrl.value + '/images/cancelsubscriber.jpg';
                    } else {
                        ibtnTerminateCC.src = hiddenServerUrl.value + '/images/cancelsubscriber_disabled.jpg';
                    }
                    ibtnTerminateCC.disabled = !enable;
                }
                break;
            case $('[id$=_ibtnTerminateCCSL]').attr('id'):
                var ibtnTerminateCCSL = $('[id$=_ibtnTerminateCCSL]')[0];
                if (ibtnTerminateCCSL != null) {
                    if (enable) {
                        ibtnTerminateCCSL.src = hiddenServerUrl.value + '/images/cancelsubscriber.jpg';
                    } else {
                        ibtnTerminateCCSL.src = hiddenServerUrl.value + '/images/cancelsubscriber_disabled.jpg';
                    }
                    ibtnTerminateCCSL.disabled = !enable;
                }
                break;
            case $('[id$=_ibtnPaymentHistoryAndRefunds]').attr('id'):
                var ibtnPaymentHistoryAndRefunds = $('[id$=_ibtnPaymentHistoryAndRefunds]')[0];
                if (ibtnPaymentHistoryAndRefunds != null) {
                    if (enable) {
                        ibtnPaymentHistoryAndRefunds.src = hiddenServerUrl.value + '/images/payments_active.gif';
                    } else {
                        ibtnPaymentHistoryAndRefunds.src = hiddenServerUrl.value + '/images/payments_inactive.gif';
                    }
                    ibtnPaymentHistoryAndRefunds.disabled = !enable;
                }
                break;
            case $('[id$=_ibtnReactivateSubscriber]').attr('id'):
                var ibtnReactivateSubscriber = $('[id$=_ibtnReactivateSubscriber]')[0];
                if (ibtnReactivateSubscriber != null) {
                    if (enable) {
                        ibtnReactivateSubscriber.src = hiddenServerUrl.value + '/images/ReActivate02.png';
                    } else {
                        ibtnReactivateSubscriber.src = hiddenServerUrl.value + '/images/ReActivate02-Disabled.png';
                    }
                    ibtnReactivateSubscriber.disabled = !enable;
                }
                break;
            case $('[id$=_ibtnNoteHistory]').attr('id'):
                var ibtnNoteHistory = $('[id$=_ibtnNoteHistory]')[0];
                if (ibtnNoteHistory != null) {
                    if (enable) {
                        ibtnNoteHistory.src = hiddenServerUrl.value + '/images/notepad-icon-active.png';
                    } else {
                        ibtnNoteHistory.src = hiddenServerUrl.value + '/images/notepad-icon-inactive.png';
                    }
                    ibtnNoteHistory.disabled = !enable;
                }
                break;
            case $('[id$=_ibtnSubscriberHistory]').attr('id'):
                var ibtnSubscriberHistory = $('[id$=_ibtnSubscriberHistory]')[0];
                if (ibtnSubscriberHistory != null) {
                    if (enable) {
                        ibtnSubscriberHistory.src = hiddenServerUrl.value + '/images/subscriber_history_active.jpg';
                    } else {
                        ibtnSubscriberHistory.src = hiddenServerUrl.value + '/images/subscriber_history_active.jpg';
                    }
                    ibtnSubscriberHistory.disabled = !enable;
                }
                break;
            case $('[id$=_ibtnTriplePlay]').attr('id'):
                var ibtnTriplePlay = $('[id$=_ibtnTriplePlay]')[0];
                if (ibtnTriplePlay != null) {
                    if (enable) {
                        ibtnTriplePlay.src = hiddenServerUrl.value + '/images/tripleplay-icon-active.png';
                    } else {
                        ibtnTriplePlay.src = hiddenServerUrl.value + '/images/tripleplay-icon-inactive.png';
                    }
                    ibtnTriplePlay.disabled = !enable;
                }
                break;
            case $('[id$=_ibtnFinancing]').attr('id'):
                var ibtnFinancing = $('[id$=_ibtnFinancing]')[0];
                if (ibtnFinancing != null) {
                    if (enable) {
                        ibtnFinancing.src = hiddenServerUrl.value + '/images/Finance-Enabled.png';
                    } else {
                        ibtnFinancing.src = hiddenServerUrl.value + '/images/Finance-Disabled.png';
                    }
                    ibtnFinancing.disabled = !enable;
                }
                break;
            case $('[id$=_ibtnManageDebitCard]').attr('id'):
                var btnManageDebitCard = $('[id$=_ibtnManageDebitCard]')[0];
                if (btnManageDebitCard != null) {
                    if (enable) {
                        btnManageDebitCard.src = hiddenServerUrl.value + '/images/DollarSymbol.jpg';
                    } else {
                        btnManageDebitCard.src = hiddenServerUrl.value + '/images/DollarSymbolDisabled.jpg';
                    }
                    btnManageDebitCard.disabled = !enable;
                }
                break;
                
        }
    };
}

function onSilverlightError(sender, args) {
    var appSource = "";
    if (sender != null && sender != 0) {
        appSource = sender.getHost().Source;
    }

    var errorType = args.ErrorType;
    var iErrorCode = args.ErrorCode;

    if (errorType == "ImageError" || errorType == "MediaError") {
        return;
    }

    var errMsg = "Unhandled Error in Silverlight Application " + appSource + "\n";

    errMsg += "Code: " + iErrorCode + "    \n";
    errMsg += "Category: " + errorType + "       \n";
    errMsg += "Message: " + args.ErrorMessage + "     \n";

    if (errorType == "ParserError") {
        errMsg += "File: " + args.xamlFile + "     \n";
        errMsg += "Line: " + args.lineNumber + "     \n";
        errMsg += "Position: " + args.charPosition + "     \n";
    }
    else if (errorType == "RuntimeError") {
        if (args.lineNumber != 0) {
            errMsg += "Line: " + args.lineNumber + "     \n";
            errMsg += "Position: " + args.charPosition + "     \n";
        }
        errMsg += "MethodName: " + args.methodName + "     \n";
    }

    throw new Error(errMsg);
}

function showPaymentHistory() {
    if ($('[id$=_hdEnabled]').val() == 1) {
        $.colorbox({ iframe: true, href: "paymenthistory.aspx", title: $('[id$=_hdPaymentsRefundsHeader]').val(), width: "1100px", height: "600px", retinaImage: true, retinaUrl: true, overlayClose: false });
    }
}
function showNoteHistory(subscriberId) {
    if ($('[id$=_hdEnabled]').val() == 1) {
        $.colorbox({ iframe: true, href: "NotesHistory.aspx?subscriberId=" + subscriberId, title: $('[id$=_hdNoteHistoryHeader]').val(), width: "1100px", height: "600px", retinaImage: true, retinaUrl: true, overlayClose: false });
    }
    return false;
}

function showDepreciaition(subscriberId) {
    if ($('[id$=_hdEnabled]').val() == 1) {
        $.colorbox({ iframe: true, href: "DepreciationTable.aspx?subscriberId=" + subscriberId, title: $('[id$=_hdDepreciationTableHeader]').val(), width: "600px", height: "500px", retinaImage: true, retinaUrl: true, overlayClose: false });
    }
    return false;
}

function showSubscriberHistory() {
    if ($('[id$=_hdEnabled]').val() == 1) {
        $.colorbox({ iframe: true, href: "SubscriberHistory.aspx", title: $('[id$=_hdSubscriberHistoryHeader]').val(), width: "600px", height: "300px", retinaImage: true, retinaUrl: true, overlayClose: false });
    }
}

function showManageCreditCard() {

    CustomerCentral.PreventUpdateCreditCardInfoDuringMRC(OnSuccess);

    function OnSuccess(result)
    {
        if (result)
        {
            $.colorbox({ iframe: true, href: "PreventUpdateBillingInfo.aspx", title: $('[id$=_hdPreventUpdateBillingInfoHeader]').val(), width: "500px", height: "200px", retinaImage: true, retinaUrl: true, overlayClose: false });
        }
        else
            if ($('[id$=_hdEnabled]').val() == 1 && $('[id$=_ibtnManageCC]').attr('disabled') !== 'disabled')
            {
                $.colorbox({ iframe: true, href: "ManageCreditCard.aspx", title: $('[id$=_hdManageCreditCardHeader]').val(), width: "1100px", height: "600px", retinaImage: true, retinaUrl: true, overlayClose: false });
            }
    }
}

function showFinanceDetails(subscriberId, financePaymentUrl) {
    if ($('[id$=_hdEnabled]').val() == 1) {
        $.colorbox({ iframe: true, href: financePaymentUrl, title: $('Lease Details').val(), width: "600px", height: "400px", retinaImage: true, retinaUrl: true, overlayClose: false });
    }
}
