﻿//var AppPath = "http://server2.ibt.pt/testesnet2/brell/";
//var AppPathSSL = "https://server2.ibt.pt/testesnet2/brell/";
var AppPath = "http://www.brell.pt/";
var AppPathSSL = "https://www.brell.pt/";

var AppPathOrSSL = AppPath;

function ChangeTheme(theme) {
    var cssid = document.getElementsByTagName("link");
    var css = '';
    for (var i = 0; i < cssid.length; i++) {
        if (cssid[i].type == 'text/css') // search only css link
        {
            if (cssid[i].href.indexOf("App_Themes") >= 0) {
                cssid[i].href = "App_Themes/" + theme + "/css/styles.css";

                css = cssid[i].href;
            }
        }
    }

    //document.getElementById('magicFrame').src = 'ChangeThemeHidden.aspx?theme=' + theme;
    $.ajax({
        url: AppPathOrSSL + "ajax/changeTheme.ashx?theme=" + theme,
        success: function(data, textStatus) {
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
        }
    });

    strTheme = theme;

}

function getCart() {
    try {
        $.ajax({
            url: AppPathOrSSL + "ajax/getCart.ashx?id=" + get0100Random(),
            success: function(data, textStatus) {
                if (data != "") {
                    var arrOrder = String(data).split(";");
                    $("#spanCCItems").text(arrOrder[0]);
                    $("#spanCCEuros").text(arrOrder[1]);
                }
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
            }
        });
    } catch (ex) { }
}

var strTheme = "";

$(document).ready(function() {
    getCart();
    try {
        if (ssl) {
            AppPathOrSSL = AppPathSSL

        }
    } catch (ex) { }

    try {
        switch (menu) {
            case "menuSolucoes":
                $('#menuSolucoes').css("background-position", "-422px 0px");
                break;
            case "menuLoja":
                $('#menuLoja').css("background-position", "-263px 0px");
                break;
            case "menuCores":
                $('#menuCores').css("background-position", "-144px 0px");
                break;
            case "menuProdutos":
                $('#menuProdutos').css("background-position", "left 0px");
                break;
        }

    } catch (ex) { }

    var strCorActiva;
    if (strTheme == "") { strTheme = 'brl06' }
    if (strTheme == 'brl06') { strCorActiva = '#4a54a4' }
    if (strTheme == 'brl36') { strCorActiva = '#a61c58' }
    if (strTheme == 'brl22') { strCorActiva = '#ef3f44' }
    if (strTheme == 'brl44') { strCorActiva = '#659830' }


    $('#divFlash').flash(
        {
            src: 'swf/brellHome.swf',
            width: 970,
            height: 398,
            wmode: 'transparent',
            flashvars: {
                strDefault: strTheme,
                strFotoBrl36_1: AppPathOrSSL + 'img/moldura1.jpg',
                strFotoBrl36_2: AppPathOrSSL + 'img/moldura1_2.jpg',
                strFotoBrl36_3: AppPathOrSSL + 'img/moldura1_3.jpg',
                strFotoBrl06_1: AppPathOrSSL + 'img/moldura3.jpg',
                strFotoBrl06_2: AppPathOrSSL + 'img/moldura3_2.jpg',
                strFotoBrl06_3: AppPathOrSSL + 'img/moldura3_3.jpg',
                strFotoBrl44_1: AppPathOrSSL + 'img/moldura4.jpg',
                strFotoBrl44_2: AppPathOrSSL + 'img/moldura4_2.jpg',
                strFotoBrl44_3: AppPathOrSSL + 'img/moldura4_3.jpg',
                strFotoBrl22_1: AppPathOrSSL + 'img/moldura2.jpg',
                strFotoBrl22_2: AppPathOrSSL + 'img/moldura2_2.jpg',
                strFotoBrl22_3: AppPathOrSSL + 'img/moldura2_3.jpg',
                strLataBrl22: AppPathOrSSL + 'img/lataSilk.png',
                strLataBrl44: AppPathOrSSL + 'img/lataDoree.png',
                strLataBrl06: AppPathOrSSL + 'img/lataMatt.png',
                strLataBrl36: AppPathOrSSL + 'img/lataAqua.png'

            }
        },
        { version: 8 }
    );

    $('#divLoving').hover(
      function() {
          $('#divNuvemLoving').animate({ "marginTop": "132px" }, "slow");
      },
      function() {
          $('#divNuvemLoving').animate({ "marginTop": "142px" }, "slow");
      }
    );

    $('#divQuiet').hover(
      function() {
          $('#divNuvemQuiet').animate({ "marginTop": "132px" }, "slow");
      },
      function() {
          $('#divNuvemQuiet').animate({ "marginTop": "142px" }, "slow");
      }
    );

    $('#divNature').hover(
      function() {
          $('#divNuvemNature').animate({ "marginTop": "132px" }, "slow");
      },
      function() {
          $('#divNuvemNature').animate({ "marginTop": "142px" }, "slow");
      }
    );

    $('#divTeen').hover(
      function() {
          $('#divNuvemTeen').animate({ "marginTop": "132px" }, "slow");
      },
      function() {
          $('#divNuvemTeen').animate({ "marginTop": "142px" }, "slow");
      }
    );

    $('#divLoving').click(function() {
        $('#divLovingOFF').fadeOut("slow");
        $('#divQuietOFF').fadeIn("slow");
        $('#divNatureOFF').fadeIn("slow");
        $('#divTeenOFF').fadeIn("slow");

        $('#divNuvemLoving').fadeTo("slow", 1);
        $('#divNuvemQuiet').fadeTo("slow", 0.33);
        $('#divNuvemNature').fadeTo("slow", 0.33);
        $('#divNuvemTeen').fadeTo("slow", 0.33);

        $('#divSonhosText').css("display", "none");
        $('#divCoresLoving').fadeIn("slow");
        $('#divCoresQuiet').css("display", "none");
        $('#divCoresNature').css("display", "none");
        $('#divCoresTeen').css("display", "none");

        //        $('#divSonhosText').fadeOut("slow");
        //        $('#divCoresLoving').fadeIn("slow");
        //        $('#divCoresQuiet').fadeOut("slow");
        //        $('#divCoresNature').fadeOut("slow");
        //        $('#divCoresTeen').fadeOut("slow");
    });

    $('#divQuiet').click(function() {
        $('#divLovingOFF').fadeIn("slow");
        $('#divQuietOFF').fadeOut("slow");
        $('#divNatureOFF').fadeIn("slow");
        $('#divTeenOFF').fadeIn("slow");

        $('#divNuvemLoving').fadeTo("slow", 0.33);
        $('#divNuvemQuiet').fadeTo("slow", 1);
        $('#divNuvemNature').fadeTo("slow", 0.33);
        $('#divNuvemTeen').fadeTo("slow", 0.33);

        $('#divSonhosText').css("display", "none");
        $('#divCoresLoving').css("display", "none");
        $('#divCoresQuiet').fadeIn("slow");
        $('#divCoresNature').css("display", "none");
        $('#divCoresTeen').css("display", "none");
    });

    $('#divNature').click(function() {
        $('#divLovingOFF').fadeIn("slow");
        $('#divQuietOFF').fadeIn("slow");
        $('#divNatureOFF').fadeOut("slow");
        $('#divTeenOFF').fadeIn("slow");

        $('#divNuvemLoving').fadeTo("slow", 0.33);
        $('#divNuvemQuiet').fadeTo("slow", 0.33);
        $('#divNuvemNature').fadeTo("slow", 1);
        $('#divNuvemTeen').fadeTo("slow", 0.33);

        $('#divSonhosText').css("display", "none");
        $('#divCoresLoving').css("display", "none");
        $('#divCoresQuiet').css("display", "none");
        $('#divCoresNature').fadeIn("slow");
        $('#divCoresTeen').css("display", "none");
    });

    $('#divTeen').click(function() {
        $('#divLovingOFF').fadeIn("slow");
        $('#divQuietOFF').fadeIn("slow");
        $('#divNatureOFF').fadeIn("slow");
        $('#divTeenOFF').fadeOut("slow");

        $('#divNuvemLoving').fadeTo("slow", 0.33);
        $('#divNuvemQuiet').fadeTo("slow", 0.33);
        $('#divNuvemNature').fadeTo("slow", 0.33);
        $('#divNuvemTeen').fadeTo("slow", 1);

        $('#divSonhosText').css("display", "none");
        $('#divCoresLoving').css("display", "none");
        $('#divCoresQuiet').css("display", "none");
        $('#divCoresNature').css("display", "none");
        $('#divCoresTeen').fadeIn("slow");
    });


    $(".aCor").hover(
    function() {
        $("#divTextCores").text($(this).attr("title"));
    }
    ,
    function() {
        $("#divTextCores").text("");
    }
    )

    $('#divVerPaletaCores').click(function() {
        $('#divDreams').fadeOut("fast", function() { $('#divPaleta').fadeIn("slow"); $('#divTextsPaleta').fadeIn("slow"); $('#divTitlePaleta').fadeIn("slow"); });
        $("#aCatalogoCompleto").removeClass("linkMenuLeft")
        $("#aCatalogoCompleto").addClass("linkMenuLeftSelected");
        $("#aCatalogoAmbientes").removeClass("linkMenuLeftSelected")
        $("#aCatalogoAmbientes").addClass("linkMenuLeft");
    });

    $('#divVerUniversosCor').click(function() {
        $('#divPaleta').fadeOut("fast", function() { $('#divDreams').fadeIn("slow"); });
        $("#aCatalogoAmbientes").removeClass("linkMenuLeft")
        $("#aCatalogoAmbientes").addClass("linkMenuLeftSelected");
        $("#aCatalogoCompleto").removeClass("linkMenuLeftSelected")
        $("#aCatalogoCompleto").addClass("linkMenuLeft");
    });

    $(".divCorPaletaCompleta").hover(
    function() {
        $("#divTextoPaletaCompleta" + $(this).attr("id")).css("display", "block");
    }
    ,
    function() {
        $("#divTextoPaletaCompleta" + $(this).attr("id")).css("display", "none");
    }
    )

    $('#divTitle').flash(
        {
            src: AppPathOrSSL + 'swf/helveticaNeueBoldCondensedFont.swf',
            wmode: 'transparent',
            flashvars: {
                css: [
                    '* { color: ' + strCorActiva + ';  font-size:18px; }',
                    'a { color: ' + strCorActiva + '; text-decoration: none;  font-size:18px; }',
                    'a:hover { color: ' + strCorActiva + ';  font-size:18px; }'
                ].join(' ')
            }
        },
        { version: 8 },
        function(htmlOptions) {
            htmlOptions.flashvars.txt = this.innerHTML;
            this.innerHTML = '<div>' + this.innerHTML + '</div>';
            var $alt = $(this.firstChild);
            htmlOptions.height = $alt.height();
            htmlOptions.width = $alt.width();
            $alt.addClass('alt');
            $(this)
                .addClass('flash-replaced')
                .prepend($.fn.flash.transform(htmlOptions));
        }
    );

    $('#divEscolhaSonho,#divTitlePaleta').flash(
        {
            src: AppPathOrSSL + 'swf/helveticaNeueLightCondensedFont.swf',
            wmode: 'transparent',
            flashvars: {
                css: [
                    '* { color: ' + strCorActiva + ';  font-size:18px; }',
                    'a { color: ' + strCorActiva + '; text-decoration: none;  font-size:18px; }',
                    'a:hover { color: ' + strCorActiva + ';  font-size:18px; }'
                ].join(' ')
            }
        },
        { version: 8 },
        function(htmlOptions) {
            htmlOptions.flashvars.txt = this.innerHTML;
            this.innerHTML = '<div>' + this.innerHTML + '</div>';
            var $alt = $(this.firstChild);
            htmlOptions.height = $alt.height();
            htmlOptions.width = $alt.width();
            $alt.addClass('alt');
            $(this)
                .addClass('flash-replaced')
                .prepend($.fn.flash.transform(htmlOptions));
        }
    );

    //        $('#divTitlePaleta').flash(
    //        {
    //            src: AppPath + 'swf/helveticaNeueLightCondensedFont.swf',
    //            wmode: 'transparent',
    //            flashvars: {
    //                css: [
    //                    '* { color: ' + strCorActiva + ';  font-size:18px; }',
    //                    'a { color: ' + strCorActiva + '; text-decoration: none;  font-size:18px; }',
    //                    'a:hover { color: ' + strCorActiva + ';  font-size:18px; }'
    //                ].join(' ')
    //            }
    //        },
    //        { version: 8 },
    //        function(htmlOptions) {
    //            htmlOptions.flashvars.txt = this.innerHTML;
    //            this.innerHTML = '<div>' + this.innerHTML + '</div>';
    //            var $alt = $(this.firstChild);
    //            htmlOptions.height = $alt.height();
    //            htmlOptions.width = $alt.width();
    //            $alt.addClass('alt');
    //            $(this)
    //                .addClass('flash-replaced')
    //                .prepend($.fn.flash.transform(htmlOptions));
    //        }
    //    );

    ////        $('#divVerPaletaCores,#divVerUniversosCor').flash(
    ////        {
    ////            src: AppPath + 'swf/helveticaNeueMediumCondensedFont.swf',
    ////            wmode: 'transparent',
    ////            flashvars: {
    ////                css: [
    ////                    '* { color: ' + strCorActiva + ';  font-size:16px; cursor: pointer; }',
    ////                    'a { color: ' + strCorActiva + '; text-decoration: none;  font-size:16px; cursor: pointer; }',
    ////                    'a:hover { color: ' + strCorActiva + ';  font-size:16px; cursor: pointer; }'
    ////                ].join(' ')
    ////            }
    ////        },
    ////        { version: 8 },
    ////        function(htmlOptions) {
    ////            htmlOptions.flashvars.txt = this.innerHTML;
    ////            this.innerHTML = '<div>' + this.innerHTML + '</div>';
    ////            var $alt = $(this.firstChild);
    ////            htmlOptions.height = $alt.height();
    ////            htmlOptions.width = $alt.width();
    ////            $alt.addClass('alt');
    ////            $(this)
    ////                .addClass('flash-replaced')
    ////                .prepend($.fn.flash.transform(htmlOptions));
    ////        }
    ////    );

    //        $('#divVerUniversosCor').flash(
    //        {
    //            src: AppPath + 'swf/helveticaNeueMediumCondensedFont.swf',
    //            wmode: 'transparent',
    //            flashvars: {
    //                css: [
    //                    '* { color: ' + strCorActiva + ';  font-size:18px; }',
    //                    'a { color: ' + strCorActiva + '; text-decoration: none;  font-size:18px; }',
    //                    'a:hover { color: ' + strCorActiva + ';  font-size:18px; }'
    //                ].join(' ')
    //            }
    //        },
    //        { version: 8 },
    //        function(htmlOptions) {
    //            htmlOptions.flashvars.txt = this.innerHTML;
    //            this.innerHTML = '<div>' + this.innerHTML + '</div>';
    //            var $alt = $(this.firstChild);
    //            htmlOptions.height = $alt.height();
    //            htmlOptions.width = $alt.width();
    //            $alt.addClass('alt');
    //            $(this)
    //                .addClass('flash-replaced')
    //                .prepend($.fn.flash.transform(htmlOptions));
    //        }
    //    );
    //if (navigator.appName != 'Microsoft Internet Explorer') {
    //                $('.menuLeft').flash(
    //                    {
    //                        src: AppPathOrSSL + 'swf/helveticaNeueMediumCondensedFont.swf',
    //                        wmode: 'transparent',
    //                        flashvars: {
    //                            css: [
    //                                '* { color: ' + strCorActiva + ';  font-size:14px; }',
    //                                'a { color: ' + strCorActiva + '; text-decoration: none;  font-size:14px; }',
    //                            //'a:hover { color: ' + strCorActiva + ';  font-size:14px; }'
    //                                'a:hover { color: #000000;  font-size:14px; }'
    //                            ].join(' ')
    //                        }
    //                    },
    //                    { version: 8 },
    //                    function(htmlOptions) {
    //                        htmlOptions.flashvars.txt = this.innerHTML;
    //                        this.innerHTML = '<div>' + this.innerHTML + '</div>';
    //                        var $alt = $(this.firstChild);
    //                        htmlOptions.height = $alt.height();
    //                        htmlOptions.width = $alt.width();
    //                        $alt.addClass('alt');
    //                        $(this)
    //                            .addClass('flash-replaced')
    //                            .prepend($.fn.flash.transform(htmlOptions));
    //                    }
    //                );
    //}
    try {
        $('#' + divCoresToShow).css("display", "none");
        $('#' + divLinkCoresToShow).removeClass("linkMenuLeft")
        $('#' + divLinkCoresToShow).addClass("linkMenuLeftSelected");

    } catch (ex) { }

    $('.aCor').tooltip({
        delay: 0,
        showURL: false
    })

    try {
        var strBT = $(".divOK").attr('bt');
        $(".divOK").dialog({ modal: true, autoOpen: false, closeOnEscape: false, minHeight: 50, resizable: false, show: 'drop', hide: 'drop', buttons: { "Ok": function() { $(this).dialog("close"); }, strBT: function() { redirect(AppPath + "cart.aspx"); } } });

        $("button:contains('strBT')").html(strBT);

        $(".divERROR").dialog({ modal: true, autoOpen: false, closeOnEscape: false, minHeight: 50, resizable: false, show: 'drop', hide: 'drop', buttons: { "Ok": function() { $(this).dialog("close"); } } });
    } catch (ex) { }

    $('.imgAdicionar').click(function() {

        var optionSelectedLitros = ""
        if ($("option[selected='selected']:eq(0)").length > 0) {
            optionSelectedLitros = $("option[selected='selected']:eq(0)").attr('value');
        } else if ($("option[selected='true']:eq(0)").length > 0) {
            optionSelectedLitros = $("option[selected='true']:eq(0)").attr('value');
        }
        var optionSelectedCores = ""
        if ($("option[selected='selected']:eq(1)").length > 0) {
            optionSelectedCores = $("option[selected='selected']:eq(1)").attr('value');
        } else if ($("option[selected='true']:eq(1)").length > 0) {
            optionSelectedCores = $("option[selected='true']:eq(1)").attr('value');
        }
        var optionSelectedBrancoCor = ""
        if ($("input[type='radio'][checked='checked']").length > 0) {
            optionSelectedBrancoCor = $("input[type='radio'][checked='checked']").attr('value');
        } else if ($("input[type='radio'][checked='true']").length > 0) {
            optionSelectedBrancoCor = $("input[type='radio'][checked='true']").attr('value');
        }

        var CorForte = ""
        try {
            CorForte = strCorForte;
        } catch (ex) { }

        $.ajax({
            url: AppPathOrSSL + "ajax/addCart.ashx?idProduct=" + $(this).attr('idProduct') + "&litros=" + optionSelectedLitros + "&brancocor=" + optionSelectedBrancoCor + "&cor=" + optionSelectedCores + "&corForte=" + CorForte + "&id=" + get0100Random(),
            success: function(data, textStatus) {
                $(".divOK").dialog('open');
                getCart();
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                $(".divERROR").dialog('open');
            }
        });
    });

    $('.txtPesquisa').watermark('Pesquisa');

    setTiposTinta();


    $("#selectEspaco").change(function() {
        setTiposTinta();
        getLitros()
    }).change();

    $("#selectTipoTinta").change(function() {
        setTinta();
        getLitros();
    }).change();

    $("#selectTinta").change(function() {
        getLitros();
        getImgLataTinta();
    }).change();

    $("#txtArea").keyup(function() {
        $(this).val($(this).val().replace(/([^0-9])/g, ""));
        getLitros();
    });

    $("#txtPortas").keyup(function() {
        $(this).val($(this).val().replace(/([^0-9])/g, ""));
        getLitros();
    });

    $("#txtJanelas").keyup(function() {
        $(this).val($(this).val().replace(/([^0-9])/g, ""));
        getLitros();
    });

});

function getImgLataTinta() {

    if ($("#selectTinta").attr("options").length > 0) {
        $.ajax({
            url: AppPathOrSSL + "ajax/getImgLataTinta.ashx?object=" + encodeURI($("#selectTinta").attr("options")[$("#selectTinta").attr("selectedIndex")].text) + "&id=" + get0100Random(),
            success: function(data, textStatus) {
                $("#divLata").empty();
                var template = [{
                    tagName: 'img',
                    src: data}];

                    $("#divLata").appendDom(template);

                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    //                    alert(textStatus);
                }
            });



            $.ajax({
                url: AppPathOrSSL + "ajax/getQuantidades.ashx?object=" + encodeURI($("#selectTinta").attr("options")[$("#selectTinta").attr("selectedIndex")].text) + "&id=" + get0100Random(),
                success: function(data, textStatus) {


                    $("#divDescricao").text("Rendimento: Aproximadamente " + $("#selectTinta").attr("options")[$("#selectTinta").attr("selectedIndex")].value + "  m²/Lt/demão")
                    var template = [{
                        tagName: 'br'}];

                        $("#divDescricao").appendDom(template);
                        $("#divDescricao").appendDom(template);

                        var template = [{
                            tagName: 'span',
                            innerHTML: 'Embalagens: ' + data}];

                            $("#divDescricao").appendDom(template);
                        },
                        error: function(XMLHttpRequest, textStatus, errorThrown) {
                            //                            alert(textStatus);
                        }
                    });


                }


            }

            function setTiposTinta() {
                try {
                    var strTintasInterior = new Array();
                    strTintasInterior[0] = "Tinta Plástica Mate";
                    strTintasInterior[1] = "Tinta Plástica Acetinada";
                    strTintasInterior[2] = "Esmalte Aquoso";
                    strTintasInterior[3] = "Primário Multiusos";

                    var strTintasExterior = new Array();
                    strTintasExterior[0] = "Tinta Plástica Mate";
                    strTintasExterior[1] = "Tinta Texturada";
                    strTintasExterior[2] = "Membrana Elástica";
                    strTintasExterior[3] = "Tinta Acrílica Pura";

                    var strTintas;
                    if ($("#selectEspaco").attr("options")[$("#selectEspaco").attr("selectedIndex")].text == "Interior") {
                        strTintas = strTintasInterior;
                    } else {
                        strTintas = strTintasExterior;
                    }

                    $("#selectTipoTinta").empty();
                    var x;
                    for (x in strTintas) {
                        var template = [{
                            tagName: 'option',
                            innerHTML: strTintas[x],
                            value: strTintas[x]}];

                            $("#selectTipoTinta").appendDom(template);

                        }
                        setTinta();
                    } catch (ex) { }
                }

                function setTinta() {
                    $.ajax({
                        url: AppPathOrSSL + "ajax/getTinta.ashx?strTipo=" + encodeURI($("#selectTipoTinta").attr("options")[$("#selectTipoTinta").attr("selectedIndex")].text) + "&id=" + get0100Random(),
                        success: function(data, textStatus) {
                            $("#selectTinta").empty();
                            var objArray = eval(data);
                            var m = 0;
                            for (m = 0; m < objArray.length; m++) {
                                var template = [{
                                    tagName: 'option',
                                    innerHTML: objArray[m].name,
                                    value: objArray[m].rendimento}];

                                    $("#selectTinta").appendDom(template);
                                }
                                getLitros();
                                getImgLataTinta();
                            },
                            error: function(XMLHttpRequest, textStatus, errorThrown) {
                                //                                alert(textStatus);
                            }
                        });

                    }

                    function get0100Random() {
                        return Math.floor(Math.random() * 101);
                    }

                    function getLitros() {
                        if ($("#selectTinta").attr("options").length > 0 && $("#txtArea").val() != "" && $("#txtPortas").val() != "" && $("#txtJanelas").val() != "") {
                            var decArea = $("#txtArea").val();
                            var intPortas = $("#txtPortas").val();
                            var intJanelas = $("#txtJanelas").val();

                            var decMetros = decArea - ((intPortas * 1.5) + (intJanelas * 1.5));

                            var decRendimento = $("#selectTinta").attr("options")[$("#selectTinta").attr("selectedIndex")].value.replace(",", ".");

                            var decLitros = (decMetros / decRendimento) * 1;

                            if (decLitros > 0) {
                                $("#txtLitros").val(decLitros.toFixed(1).toString() + "0");
                            } else {
                                $("#txtLitros").val("");
                            }
                        } else {
                            $("#txtLitros").val("");
                        }
                    }

                    function changeQty(control, action) {
                        var txtControl = document.getElementById(control);
                        var decTxtValue = parseInt(txtControl.value);

                        if (action == 0) {
                            if (decTxtValue > 0) {
                                if ((decTxtValue - 1) > 0) {
                                    txtControl.value = decTxtValue - 1;
                                }
                                else {
                                    txtControl.value = 1;
                                }
                            }
                        }
                        else {
                            txtControl.value = decTxtValue + 1;
                        }
                    }

                    function res(control) {
                        control.value = control.value.replace(/([^0-9])/g, "");
                    }

                    function redirect(url) {
                        window.location = url
                    }

                    function cvv() {
                        var wWidth = 400;
                        var wHeight = 350;
                        var wTop = (screen.availHeight - wHeight) / 2
                        var wLeft = (screen.availWidth - wWidth) / 2
                        var vbvWindow = window.open(AppPathOrSSL + '/cvv.htm', 'cvv', 'width=' + wWidth + ',height=' + wHeight + ',top=' + wTop + ',left=' + wLeft);
                    }

                    function vbv() {
                        var wWidth = 330;
                        var wHeight = 300;
                        var wTop = (screen.availHeight - wHeight) / 2
                        var wLeft = (screen.availWidth - wWidth) / 2
                        var vbvWindow = window.open(AppPathOrSSL + 'vbv.aspx', 'vbv', 'width=' + wWidth + ',height=' + wHeight + ',top=' + wTop + ',left=' + wLeft);
                    }

                    function noenter() {
                        return !(window.event && window.event.keyCode == 13);
                    }

