﻿// JScript File

//IE6 Hover Functionality

function ShowInvalidPageDiv() 
{   
    blnValidate = true;
    
    if (typeof (Page_ClientValidate) == 'function') 
    {
        blnValidate=Page_ClientValidate('Group');        
            
        if (blnValidate != true) 
        {
            CloseOrOpenDiv(false);
            document.getElementById('ctl00_cphError_lblError').style.display = 'none';
            document.getElementById('ctl00_cphError_lblError').style.visibility = 'hidden'; 
        }
        else 
        {
            CloseOrOpenDiv(true);
        }
        
        return blnValidate;
    }

}
function ShowInvalidPageDivCreditCard() {
    blnValidate = true;

    if (typeof (Page_ClientValidate) == 'function') 
    {
        blnValidate = Page_ClientValidate('CreditCard');         
        
        if (blnValidate != true ) {
            CloseOrOpenDivCreditCard(false);
            document.getElementById('ctl00_cphError_lblError').style.display = 'none';
            document.getElementById('ctl00_cphError_lblError').style.visibility = 'hidden';
        }
        else {
            CloseOrOpenDivCreditCard(true);
        }

        return blnValidate;
    }

}
function ShowInvalidPageDivACH() {
    blnValidate = true;

    if (typeof (Page_ClientValidate) == 'function') {
        blnValidate = Page_ClientValidate('ACH');

        if (blnValidate != true ) {
            CloseOrOpenDivAch(false);
            document.getElementById('ctl00_cphError_lblError').style.display = 'none';
            document.getElementById('ctl00_cphError_lblError').style.visibility = 'hidden';
        }
        else {
            CloseOrOpenDivAch(true);
        }

        return blnValidate;
    }

}
function ShowInvalidPageDivResend() {
    blnValidate = true;

    if (typeof (Page_ClientValidate) == 'function') {
        blnValidate = Page_ClientValidate('GroupReSend');

        if (blnValidate != true) {
            CloseOrOpenDivResend(false);
            document.getElementById('ctl00_cphError_lblError').style.display = 'none';
            document.getElementById('ctl00_cphError_lblError').style.visibility = 'hidden';
        }
        else {
            CloseOrOpenDivResend(true);
        }

        return blnValidate;
    }

}
function ShowInvalidPageDivMaster() {
    blnValidate = true;

    if (typeof (Page_ClientValidate) == 'function') {
        blnValidate=Page_ClientValidate('GroupMaster');
        

        if (blnValidate != true) {
            CloseOrOpenDivMaster(false);
            document.getElementById('ctl00_lblErrorMaster').style.display = 'none';
            document.getElementById('ctl00_lblErrorMaster').style.visibility = 'hidden';
        }
        else {
            CloseOrOpenDivMaster(true);
        }

        return blnValidate;
    }

}
function CloseOrOpenDiv(blnClose) 
{
    if (blnClose == true) 
    {
        document.getElementById('ctl00_ContainerErrorDiv').style.display = 'none';
        document.getElementById('ctl00_ContainerErrorDiv').style.visibility = 'hidden';
        document.getElementById('ctl00_cphError_vSumGroup').style.display = 'none';
        document.getElementById('ctl00_cphError_vSumGroup').style.visibility = 'hidden';
    }
    else 
    {
        document.getElementById('ctl00_ContainerErrorDiv').style.display = 'block';
        document.getElementById('ctl00_ContainerErrorDiv').style.visibility = 'visible';
        document.getElementById('ctl00_cphError_vSumGroup').style.display = 'block';
        document.getElementById('ctl00_cphError_vSumGroup').style.visibility = 'visible';        
    }
    
    return false;
}
function CloseOrOpenDivResend(blnClose) {
    if (blnClose == true) {
        document.getElementById('ctl00_ContainerErrorDiv').style.display = 'none';
        document.getElementById('ctl00_ContainerErrorDiv').style.visibility = 'hidden';
        document.getElementById('ctl00_cphError_vSumGroup2').style.display = 'none';
        document.getElementById('ctl00_cphError_vSumGroup2').style.visibility = 'hidden';
    }
    else {
        document.getElementById('ctl00_ContainerErrorDiv').style.display = 'block';
        document.getElementById('ctl00_ContainerErrorDiv').style.visibility = 'visible';
        document.getElementById('ctl00_cphError_vSumGroup2').style.display = 'block';
        document.getElementById('ctl00_cphError_vSumGroup2').style.visibility = 'visible';
    }

    return false;
}
function CloseDivAllSum() {

    document.getElementById('ctl00_ContainerErrorDiv').style.display = 'none';
    document.getElementById('ctl00_ContainerErrorDiv').style.visibility = 'hidden';
    document.getElementById('ctl00_cphError_vSumCreditCard').style.display = 'none';
    document.getElementById('ctl00_cphError_vSumCreditCard').style.visibility = 'hidden';
    document.getElementById('ctl00_cphError_vSumAch').style.display = 'none';
    document.getElementById('ctl00_cphError_vSumAch').style.visibility = 'hidden';

    return false;
}
function CloseDivAllResend() {

    document.getElementById('ctl00_ContainerErrorDiv').style.display = 'none';
    document.getElementById('ctl00_ContainerErrorDiv').style.visibility = 'hidden';
    document.getElementById('ctl00_cphError_vSumGroup').style.display = 'none';
    document.getElementById('ctl00_cphError_vSumGroup').style.visibility = 'hidden';
    document.getElementById('ctl00_cphError_vSumGroup2').style.display = 'none';
    document.getElementById('ctl00_cphError_vSumGroup2').style.visibility = 'hidden';

    return false;
}

function CloseOrOpenDivCreditCard(blnClose) {
    if (blnClose == true) {
        document.getElementById('ctl00_ContainerErrorDiv').style.display = 'none';
        document.getElementById('ctl00_ContainerErrorDiv').style.visibility = 'hidden';
        document.getElementById('ctl00_cphError_vSumCreditCard').style.display = 'none';
        document.getElementById('ctl00_cphError_vSumCreditCard').style.visibility = 'hidden';
    }
    else {
        document.getElementById('ctl00_ContainerErrorDiv').style.display = 'block';
        document.getElementById('ctl00_ContainerErrorDiv').style.visibility = 'visible';
        document.getElementById('ctl00_cphError_vSumCreditCard').style.display = 'block';
        document.getElementById('ctl00_cphError_vSumCreditCard').style.visibility = 'visible';
    }

    return false;
}
function CloseOrOpenDivAch(blnClose) {
    if (blnClose == true) {
        document.getElementById('ctl00_ContainerErrorDiv').style.display = 'none';
        document.getElementById('ctl00_ContainerErrorDiv').style.visibility = 'hidden';
        document.getElementById('ctl00_cphError_vSumAch').style.display = 'none';
        document.getElementById('ctl00_cphError_vSumAch').style.visibility = 'hidden';
    }
    else {
        document.getElementById('ctl00_ContainerErrorDiv').style.display = 'block';
        document.getElementById('ctl00_ContainerErrorDiv').style.visibility = 'visible';
        document.getElementById('ctl00_cphError_vSumAch').style.display = 'block';
        document.getElementById('ctl00_cphError_vSumAch').style.visibility = 'visible';
    }

    return false;
}
function CloseOrOpenDivMaster(blnClose) {
    if (blnClose == true) {
        document.getElementById('ctl00_ContainerErrorDivMaster').style.display = 'none';
        document.getElementById('ctl00_ContainerErrorDivMaster').style.visibility = 'hidden';
        document.getElementById('ctl00_vSumGroupMaster').style.display = 'none';
        document.getElementById('ctl00_vSumGroupMaster').style.visibility = 'hidden';
    }
    else {
        document.getElementById('ctl00_ContainerErrorDivMaster').style.display = 'block';
        document.getElementById('ctl00_ContainerErrorDivMaster').style.visibility = 'visible';
        document.getElementById('ctl00_vSumGroupMaster').style.display = 'block';
        document.getElementById('ctl00_vSumGroupMaster').style.visibility = 'visible';
    }

    return false;
}

function ChangePaymentInfo() {
    if (document.getElementById('ctl00_cphMain_radACH').checked == true) {
        document.getElementById('PaymentHalfCreditCard').style.display = 'none';
        document.getElementById('PaymentHalfAch').style.display = '';
    }
    else {
        document.getElementById('PaymentHalfCreditCard').style.display = '';
        document.getElementById('PaymentHalfAch').style.display = 'none';    
    }
    
    return false;
}

// NetPresene JScript Examples

//Return Value from Dialog Page
function ReturnValue(strValue) {
    window.opener.document.getElementById('html_element_name').value = strValue;
    window.close()
    return false;
}

//Switch On/Off
function EnableSwitch(strSwitch) {
    if (strSwitch == '1') {
        document.getElementById('html_element_name').disabled = true;
        document.getElementById('html_element_name').style.display = 'none';
        document.getElementById('html_element_name').value = '';
        //Regular Expression Validators
        ValidatorEnable(document.getElementById('html_element_name'), false);
    }
    else if (strSwitch == '2') {
        document.getElementById('html_element_name').disabled = false;
        document.getElementById('html_element_name').style.display = '';
        //Regular Expression Validators
        ValidatorEnable(document.getElementById('html_element_name'), true);
    }
    else {
        document.getElementById('html_element_name').disabled = false;
        document.getElementById('html_element_name').style.display = '';
        //Regular Expression Validators
        ValidatorEnable(document.getElementById('html_element_name'), true);
    }
}

//Close Window
function CloseWindow() {
    window.close();
    return false;
}

//Transfer Values Control To Control
function TransferValues(strFrom, strTo) {
    document.getElementById(strTo).innerHTML = document.getElementById(strFrom).value;
}

//Currency Convertor
function ConverNumberToText() {
    TransferValues('ctl00_cphOne_txtAmount', 'ctl00_cphTwo_lblAmount');
    var strCurrency = document.getElementById('ctl00_cphOne_txtAmount').value;
    var arrCurrency = strCurrency.split("");
    var arrCurrencyTemp;
    var arrCurrencyDecimal;
    var strDecimalPosition;
    var arrNumbers = ['Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', ' Eight', ' Nine'];
    var arrTeens = ['Ten', 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen'];
    var arrTens = ['Zero', 'Ten', 'Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety'];
    var strCurrencyText = "";

    for (intCount = 0; intCount <= arrCurrency.length - 1; intCount++) {
        if (arrCurrency[intCount] == ".") {
            arrCurrencyTemp = strCurrency.split(".");
            arrCurrency = arrCurrencyTemp[0].split("");
            arrCurrencyDecimal = arrCurrencyTemp[1].split("");
            arrCurrencyDecimal.reverse();
        }
    }

    arrCurrency.reverse();

    for (intCount = arrCurrency.length - 1; intCount >= 0; intCount--) {
        switch (intCount) {
            case 8:
                strCurrencyText += arrNumbers[Number(arrCurrency[intCount])] + ' Hundred';
                break;
            case 7:
                if (Number(arrCurrency[intCount]) != 0) {
                    if (Number(arrCurrency[intCount]) == 1) {
                        strCurrencyText += ' ' + arrTeens[Number(arrCurrency[intCount - 1])];
                        break;
                    }
                    else {
                        strCurrencyText += ' ' + arrTens[Number(arrCurrency[intCount])];
                        break;
                    }
                }
                else {
                    break;
                }
            case 6:
                if (Number(arrCurrency[intCount]) != 0) {
                    strCurrencyText += ' ' + arrNumbers[Number(arrCurrency[intCount])] + ' Million';
                    break;
                }
                else {
                    strCurrencyText += ' Million';
                    break;
                }
            case 5:
                if (Number(arrCurrency[intCount]) != 0) {
                    strCurrencyText += ' ' + arrNumbers[Number(arrCurrency[intCount])] + ' Hundred';
                    break;
                }
                else {
                    break;
                }
            case 4:
                if (Number(arrCurrency[intCount]) != 0) {
                    if (Number(arrCurrency[intCount]) == 1) {
                        strCurrencyText += ' ' + arrTeens[Number(arrCurrency[intCount - 1])];
                        break;
                    }
                    else {
                        strCurrencyText += ' ' + arrTens[Number(arrCurrency[intCount])];
                        break;
                    }
                }
                else {
                    break;
                }
            case 3:
                if (Number(arrCurrency[intCount]) != 0) {
                    if (Number(arrCurrency[intCount + 1]) != 1) {
                        strCurrencyText += ' ' + arrNumbers[Number(arrCurrency[intCount])] + ' Thousand';
                        break;
                    }
                    else {
                        strCurrencyText += ' Thousand';
                        break;
                    }
                }
                else {
                    strCurrencyText += ' Thousand';
                    break;
                }
            case 2:
                if (Number(arrCurrency[intCount]) != 0) {
                    strCurrencyText += ' ' + arrNumbers[Number(arrCurrency[intCount])] + ' Hundred';
                    break;
                }
                else {
                    break;
                }
            case 1:
                if (Number(arrCurrency[intCount]) != 0) {
                    if (Number(arrCurrency[intCount]) == 1) {
                        strCurrencyText += ' ' + arrTeens[Number(arrCurrency[intCount - 1])];
                        break;
                    }
                    else {
                        strCurrencyText += ' ' + arrTens[Number(arrCurrency[intCount])];
                        break;
                    }
                }
                else {
                    break;
                }
            case 0:
                if (Number(arrCurrency[intCount]) != 0) {
                    if (Number(arrCurrency[intCount + 1]) != 1) {
                        strCurrencyText += ' ' + arrNumbers[Number(arrCurrency[intCount])];
                        break;
                    }
                    else {
                        break;
                    }
                }
                else {
                    break;
                }
            default:
                break;
        }
    }

    strCurrencyText += " Dollars";

    if (arrCurrencyDecimal != null) {
        if (arrCurrencyDecimal[0] != 0 || arrCurrencyDecimal[1] != 0) {
            if (arrCurrency != null) {
                strCurrencyText += " With";
            }

            for (intCount = arrCurrencyDecimal.length - 1; intCount >= 0; intCount--) {
                switch (intCount) {
                    case 1:
                        if (Number(arrCurrencyDecimal[intCount]) != 0) {
                            if (Number(arrCurrencyDecimal[intCount]) == 1) {
                                strCurrencyText += ' ' + arrTeens[Number(arrCurrencyDecimal[intCount - 1])];
                                break;
                            }
                            else {
                                strCurrencyText += ' ' + arrTens[Number(arrCurrencyDecimal[intCount])];
                                break;
                            }
                        }
                        else {
                            break;
                        }
                    case 0:
                        if (Number(arrCurrencyDecimal[intCount]) != 0) {
                            if (Number(arrCurrencyDecimal[intCount + 1]) != 1) {
                                strCurrencyText += ' ' + arrNumbers[Number(arrCurrencyDecimal[intCount])];
                                break;
                            }
                            else {
                                break;
                            }
                        }
                        else {
                            break;
                        }
                    default:
                        break;
                }
            }

            strCurrencyText += " Cents";
        }
    }
    document.getElementById('ctl00_cphTwo_lblAmountText').innerHTML = strCurrencyText;
    document.getElementById('ctl00_cphOne_hidCurrency').value = strCurrencyText;
}

