﻿var AppPath = "http://www.pharmascalabis.com/"

$(document).ready(function() {
    $(".divSubMenuLeft").hide();
    //$(".divSubMenuLeft:not(:first)").hide();
    $(".divItemMenuLeft a").click(function() {
        $(".divSubMenuLeft:visible").slideUp("slow");
        $(this).parent().next().slideDown("slow");
        return false;
    });

    $(".btnNewsletter").click(function() {
    subscribeNewsletter($(".txtNewsletter").val());
    });
});

function subscribeNewsletter(strMailNewsletter) {
    $.ajax({
        url: AppPath + "subscribeNewsletter.ashx?strEmail=" + strMailNewsletter + "&id=" + get0100Random(),
        success: function(data, textStatus) {
            alert(data);

        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
        alert("Ocorreu um erro, por favor tente mais tarde.");
        }
    });
}

function get0100Random() {
    return Math.floor(Math.random() * 101);
}

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(AppPath + '/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(AppPath + 'vbv.aspx', 'vbv', 'width=' + wWidth + ',height=' + wHeight + ',top=' + wTop + ',left=' + wLeft);
}

function res(control) {
    control.value = control.value.replace(/([^0-9])/g, "");
}