﻿// variáveis determinantes de browsers
var isN4 = (document.layers) ? true : false;
var isIE = (document.all) ? true : false;
var isDOM = (document.getElementById && !document.all) ? true : false;
var enter = true;

function MM_swapImgRestore() //v3.0
{ 
    var i, x, a = document.MM_sr; 
    for(i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) 
        x.src = x.oSrc;
}

function MM_preloadImages() //v3.0
{
    var d = document; 
    if (d.images)
    { 
        if (!d.MM_p) 
            d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; 
        for(i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0)
            { 
                d.MM_p[j] = new Image; 
                d.MM_p[j++].src = a[i];
            }
    }
}

function MM_findObj(n, d) //v4.01
{
    var p, i, x;  
    if (!d) 
        d = document; 
    if ((p = n.indexOf("?")) > 0 && parent.frames.length) 
    {
        d = parent.frames[n.substring(p + 1)].document; 
        n = n.substring(0,p);
    }
    if(!(x = d[n]) && d.all) 
        x = d.all[n]; 
    for (i = 0; !x && i < d.forms.length; i++) 
        x = d.forms[i][n];
    for(i = 0; !x && d.layers && i < d.layers.length; i++) 
        x = MM_findObj(n, d.layers[i].document);
    if(!x && d.getElementById) 
        x = d.getElementById(n); 
    
    return x;
}

function MM_swapImage() //v3.0
{
    var i, j = 0, x, a = MM_swapImage.arguments; 
    document.MM_sr = new Array; 
    for(i = 0;i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null)
        {
            document.MM_sr[j++] = x; 
            if(!x.oSrc) 
                x.oSrc = x.src; 
            x.src = a[i + 2];
        }
}

/// <summary>
/// Formata um campo telefone
/// </summary>
/// <param name="p_oPhoneField">Campo a ser formatado</param>
/// <param name="p_oEvent">Evento disparado</param>
function PhoneFieldFormat(p_oPhoneField, p_oEvent) 
{
    if (this.NumberKeyPressedValidate(p_oEvent) != false)
        return this.FieldFormat(p_oPhoneField, '0000-0000', p_oEvent); 
}

/// <summary>
/// Formata um campo RG
/// </summary>
/// <param name="p_oField">Campo a ser formatado</param>
/// <param name="p_sMask">Evento disparado</param>
function RgFieldFormat(p_oRgField, p_oEvent) 
{ 
    if (this.NumberKeyPressedValidate(p_oEvent) != false)
        return this.FieldFormat(p_oRgField, '00.000.000-0', p_oEvent);  
}

/// <summary>
/// Formata um campo CPF
/// </summary>
/// <param name="p_oField">Campo a ser formatado</param>
/// <param name="p_sMask">Evento disparado</param>
function CpfFieldFormat(p_oCpfField, p_oEvent) 
{ 
    if (this.NumberKeyPressedValidate(p_oEvent) != false)
        return this.FieldFormat(p_oCpfField, '000.000.000-00', p_oEvent);  
}

/// <summary>
/// Formata um campo CNPJ
/// </summary>
/// <param name="p_oField">Campo a ser formatado</param>
/// <param name="p_sMask">Evento disparado</param>
function CnpjFieldFormat(p_oCnpjField, p_oEvent) 
{
    if (this.NumberKeyPressedValidate(p_oEvent) != false)
        return this.FieldFormat(p_oCnpjField, '00.000.000/0000-00', p_oEvent);
}

/// <summary>
/// Formata um campo de acordo com uma máscara
/// </summary>
/// <param name="p_oField">Campo a ser formatado</param>
/// <param name="p_sMask">Máscara a ser aplicada no campo</param>
function FieldFormat(p_oField, p_sMask) 
{
    var l_sFieldNewText = "";
    var l_sOnlyNumbersField = "";
    var l_iMaskLength = 0;
    var l_iFieldPosition = 0;
    var l_bMask;
    l_oSpecialCharacters = /\-|\.|\/|\(|\)| /g;
    l_sOnlyNumbersField = p_oField.value.toString().replace(l_oSpecialCharacters, "");
    l_iMaskLength = l_sOnlyNumbersField.length;;

    for (l_iCount = 0; l_iCount <= l_iMaskLength; l_iCount++) 
    {
        l_bMask = ((p_sMask.charAt(l_iCount) == "-") || (p_sMask.charAt(l_iCount) == ".")
                    || (p_sMask.charAt(l_iCount) == "/"));
        l_bMask = l_bMask || ((p_sMask.charAt(l_iCount) == "(")
                  || (p_sMask.charAt(l_iCount) == ")") || (p_sMask.charAt(l_iCount) == " "));
                            
        if (l_bMask) 
        {
            l_sFieldNewText += p_sMask.charAt(l_iCount);
            l_iMaskLength++;
        }
        else 
        {
            l_sFieldNewText += l_sOnlyNumbersField.charAt(l_iFieldPosition);
            l_iFieldPosition++;
        }           
    }    
    p_oField.value = l_sFieldNewText;
    return true;
}

/// <summary>
/// Muda o foco entre dois campos
/// </summary>
/// <param name="p_nuLimit">Número de dígitos para a mudança de foco</param>
/// <param name="p_oField1">Campo que perderá o foco</param>
/// <param name="p_oField2">Campo que será focado</param>
function FieldChange(p_nuLimit, p_oField1, p_oField2)
{
    if (p_oField1.value.length >= p_nuLimit)
        p_oField2.focus();
}

/// <summary>
/// Verifica a tecla pressionada, e valida se é numérica
/// </summary>
/// <param name="p_oEvent">Evento disparado</param>
/// <returns>Caso a tecla pressionada não seja numérica, retorna false</returns>
function NumberKeyPressedValidate(p_oEvent)
{
    var l_oEvent = p_oEvent || window.event;
    var l_okeyPressed = l_oEvent.charCode || l_oEvent.keyCode || l_oEvent.which || 0;
    if (((l_okeyPressed > 47 && l_okeyPressed < 58) || (l_okeyPressed > 95 && l_okeyPressed < 106)) == false)
        return false;
}

/// <summary>
/// Muda a classe CSS de um determinado objeto
/// </summary>
/// <param name="p_oObject">Objeto cuja classe CSS será alterada</param>
/// <param name="p_sCssClass">Classe CSS a ser aplicada</param>
function ChangeObjectCssClass(p_oObject, p_sCssClass)
{
    p_oObject.attributes["class"].value = p_sCssClass;
}

/// <summary>
/// Muda a estrutura da página de clientes de acordo com o tipo de cliente selecionado
/// </summary>
/// <param name="p_sCustomerType">Tipo de cliente selecionado</param>
/// <param name="p_oPhysicalPerson">Objeto ('div' ou 'table') referente ao tipo de pessoa física</param>
/// <param name="p_oJuridicalPerson">Objeto ('div' ou 'table') referente ao tipo de pessoa jurídica</param>
function LayoutChangeByCustomerType(p_sCustomerType, p_oPhysicalPerson, p_oJuridicalPerson)
{
    if (p_sCustomerType == 'F')
    {
        this.ChangeObjectCssClass(p_oJuridicalPerson, "invisiblediv");
        this.ChangeObjectCssClass(p_oPhysicalPerson, "visiblediv");         
    }
    else
    {
        this.ChangeObjectCssClass(p_oJuridicalPerson, "visiblediv");
        this.ChangeObjectCssClass(p_oPhysicalPerson, "invisiblediv");
    }
}

/// <summary>
/// Dá um check em todos os controles checkbox de um formulário
/// </summary>
function CheckAllBox()
{
	var l_oForm = null;
	var l_oCheckbox = null;
	
	if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) 
		l_oForm = document.aspnetForm;
	else
	    l_oForm = document.forms["aspnetForm"];
	
	for(l_iCount = 0; l_iCount < l_oForm.elements.length; l_iCount++)
	{
		if (l_oForm.elements[l_iCount].type == "checkbox")
	    {
		    l_oCheckbox = theform.elements[i];
			l_oCheckbox.checked = true;
		}
	}
}

/// <summary>
/// Abre o popup de zoom de imagem de produto
/// </summary>
/// <param name="p_sUrl">URL de zoom de imagem de produto</param>
function OpenProductZoomPopUp(p_sUrl)
{
    window.open(p_sUrl, "ProductZoom", "toolbar=no,status=no,menubar=no,scrollbars=no,resizeable=no,top=100,left=50,width=450,height=500");
}

/// <summary>
/// Abre o popup de indicação de produto
/// </summary>
/// <param name="p_sUrl">URL de indicação de produto</param>
function OpenProductIndicationPopUp(p_sUrl)
{
    window.open(p_sUrl, "ProductIndication", "toolbar=no,status=no,menubar=no,scrollbars=no,resizeable=no,top=100,left=50,width=450,height=550");
}

function OpenProductZipCodePopUp(p_sUrl)
{
    window.open(p_sUrl, "ZipCode", "toolbar=no,status=no,menubar=no,scrollbars=no,resizeable=no,top=100,left=50,width=520,height=450");
}

function OpenProductShippingDatePopUp(p_sUrl)
{
    window.open(p_sUrl, "ShippingDate", "toolbar=no,status=no,menubar=no,scrollbars=no,resizeable=no,top=100,left=50,width=450 ,height=300");
}

function OpenCepVerify()
{
    window.open("zipcodepopup.aspx", "CEP", "toolbar=no,status=no,menubar=no,scrollbars=no,resizeable=no,top=100,left=50,width=380,height=400");
}

/// <summary>
/// Cria um grupo de radiobuttons dentro de um repeater
/// </summary>
/// <param name="p_sRadioButtonRegionId">ID do objeto (div, table, etc) que contém os objetos radiobutton</param>
/// <param name="p_oClickedRadioButton">Objeto radiobutton clicado</param>
function SetRepeaterRadioButtonGroup(p_sRadioButtonRegionId, p_oClickedRadioButton)
{
    var l_oRadioButton = null;
    var l_oRegionElement = null;
        
    $(function() {
        l_oRadioButton = $("#" + p_sRadioButtonRegionId + " :radio");
        for(l_iCount = 0; l_iCount < l_oRadioButton.length; l_iCount++)
            l_oRadioButton[l_iCount].checked = false;
            
        p_oClickedRadioButton.checked = true;
    });
}

function PaymentSubmit()
{
    document.forms['paymentForm'].submit();
}

$(document).ready(function() {
    //var path = $('#ctl00_hdnImagesPath').val();
    var path = $('.footer :hidden').val();

    if (path != null) {
        $('img.imagens_internas').each(function(i) {
            $(this).attr("src", path + $(this).attr('src'));
        });
    }
});

$(function() {
    $.fn.SetTabsAction = function() {
        var l_arrProductDetailTitle = $("#divOffersBoxHeaderTabs > div");
        var l_arrProductDetailBody = $(".divOffersBoxContent > div");
        var l_arrParameters = arguments[0] || {};
        var l_oClickedDiv = l_arrParameters.p_oClickedDiv;

        $(l_arrProductDetailBody).removeClass("visiblediv");
        $(l_arrProductDetailBody).removeClass("invisiblediv");
        for (i = 0; i < l_arrProductDetailTitle.length; i++) 
        {
            $($(l_arrProductDetailTitle[i]).children(0)[0]).removeClass("divOffersBoxHeaderOpenedLeft");
            $($(l_arrProductDetailTitle[i]).children(0)[1]).removeClass("divOffersBoxHeaderOpenedCenter");
            $($(l_arrProductDetailTitle[i]).children(0)[2]).removeClass("divOffersBoxHeaderOpenedRight");
            $($(l_arrProductDetailTitle[i]).children(0)[0]).removeClass("divOffersBoxHeaderClosedLeft");
            $($(l_arrProductDetailTitle[i]).children(0)[1]).removeClass("divOffersBoxHeaderClosedCenter");
            $($(l_arrProductDetailTitle[i]).children(0)[2]).removeClass("divOffersBoxHeaderClosedRight");
        }
        for (i = 0; i < l_arrProductDetailTitle.length; i++) 
        {
            if (l_arrProductDetailTitle[i] == l_oClickedDiv) 
            {
                $(l_arrProductDetailBody[i]).addClass("visiblediv");
                $($(l_arrProductDetailTitle[i]).children(0)[0]).addClass("divOffersBoxHeaderOpenedLeft");
                $($(l_arrProductDetailTitle[i]).children(0)[1]).addClass("divOffersBoxHeaderOpenedCenter");
                $($(l_arrProductDetailTitle[i]).children(0)[2]).addClass("divOffersBoxHeaderOpenedRight");
            }
            else 
            {
                $(l_arrProductDetailBody[i]).addClass("invisiblediv");
                $($(l_arrProductDetailTitle[i]).children(0)[0]).addClass("divOffersBoxHeaderClosedLeft");
                $($(l_arrProductDetailTitle[i]).children(0)[1]).addClass("divOffersBoxHeaderClosedCenter");
                $($(l_arrProductDetailTitle[i]).children(0)[2]).addClass("divOffersBoxHeaderClosedRight");
            }
        }
        i = 0;
    };

    $.fn.ShowHideEvaluationSection = function() {
        if ($("#divComments").hasClass("invisiblediv")) {
            $("#divComments").removeClass("invisiblediv");
            $("#divComments").addClass("visiblediv");

            $("#divComments").css("top", String($("#lnkProductEvaluation").position().top + 5) + "px");
            $("#divComments").css("left", String($("#lnkProductEvaluation").position().left - 37) + "px");
        }
        else {
            $("#divComments").removeClass("visiblediv");
            $("#divComments").addClass("invisiblediv");
        }
    };
    
    $.fn.ShowPinkArrow = function() {
        var l_arrProductUl = $("#divNavigationHistoryContent ul");
        var l_iCurrentIndex = $(l_arrProductUl).index($("#divNavigationHistoryContent ul:[class*=selected]"));
        
        if(l_iCurrentIndex < 0)
        {
            $("#divLeftNavHistory").removeClass("visiblediv");
            $("#divLeftNavHistory").addClass("invisiblediv");
            
            $("#divRightNavHistory").removeClass("visiblediv");
            $("#divRightNavHistory").addClass("invisiblediv");
         }
         else
         {
            $("#divLeftNavHistory").removeClass("invisiblediv");
            $("#divLeftNavHistory").addClass("visiblediv");
            
            $("#divRightNavHistory").removeClass("invisiblediv");
            $("#divRightNavHistory").addClass("visiblediv");     
         } 
    };

    $.fn.ChangeNavHistoryCarrousel = function() {
        var l_arrParameters = arguments[0] || {};
        var l_sDirection = l_arrParameters.Direction;
        var l_arrNavigationHistoryContent = $("#divNavigationHistory > div");
        var l_arrProductUl = $("#divNavigationHistoryContent ul");
        var l_iUlCount = l_arrProductUl.length - 1;
        var l_iCurrentIndex = $(l_arrProductUl).index($("#divNavigationHistoryContent ul:[class*=selected]"));

        if (l_sDirection == "left") {
            if (l_iCurrentIndex > 0) {
                $($("#divNavigationHistoryContent ul")[l_iCurrentIndex]).removeClass("selected");
                $($("#divNavhistoryPaging ul")[l_iCurrentIndex]).removeClass("verdana_12_rosa");
                $($("#divNavhistoryPaging ul")[l_iCurrentIndex]).addClass("verdana_12_cinza_escuro2");
                l_iCurrentIndex--;

                $($("#divNavigationHistoryContent ul")[l_iCurrentIndex]).addClass("selected");
                $($("#divNavhistoryPaging ul")[l_iCurrentIndex]).removeClass("verdana_12_cinza_escuro2");
                $($("#divNavhistoryPaging ul")[l_iCurrentIndex]).addClass("verdana_12_rosa");
            }
            else {
                $($("#divNavigationHistoryContent ul")[0]).removeClass("selected");
                $($("#divNavhistoryPaging ul")[l_iCurrentIndex]).removeClass("verdana_12_rosa");
                $($("#divNavhistoryPaging ul")[l_iCurrentIndex]).addClass("verdana_12_cinza_escuro2");
                l_iCurrentIndex = l_iUlCount;

                $($("#divNavigationHistoryContent ul")[l_iCurrentIndex]).addClass("selected");
                $($("#divNavhistoryPaging ul")[l_iCurrentIndex]).removeClass("verdana_12_cinza_escuro2");
                $($("#divNavhistoryPaging ul")[l_iCurrentIndex]).addClass("verdana_12_rosa");
            }
        }
        else if (l_sDirection == "right") {
            if (l_iCurrentIndex < l_iUlCount) {
                $($("#divNavigationHistoryContent ul")[l_iCurrentIndex]).removeClass("selected");
                $($("#divNavhistoryPaging ul")[l_iCurrentIndex]).removeClass("verdana_12_rosa");
                $($("#divNavhistoryPaging ul")[l_iCurrentIndex]).addClass("verdana_12_cinza_escuro2");
                l_iCurrentIndex++;

                $($("#divNavigationHistoryContent ul")[l_iCurrentIndex]).addClass("selected");
                $($("#divNavhistoryPaging ul")[l_iCurrentIndex]).removeClass("verdana_12_cinza_escuro2");
                $($("#divNavhistoryPaging ul")[l_iCurrentIndex]).addClass("verdana_12_rosa");
            }
            else {
                $($("#divNavigationHistoryContent ul")[l_iUlCount]).removeClass("selected");
                $($("#divNavhistoryPaging ul")[l_iCurrentIndex]).removeClass("verdana_12_rosa");
                $($("#divNavhistoryPaging ul")[l_iCurrentIndex]).addClass("verdana_12_cinza_escuro2");
                l_iCurrentIndex = 0;

                $($("#divNavigationHistoryContent ul")[l_iCurrentIndex]).addClass("selected");
                $($("#divNavhistoryPaging ul")[l_iCurrentIndex]).removeClass("verdana_12_cinza_escuro2");
                $($("#divNavhistoryPaging ul")[l_iCurrentIndex]).addClass("verdana_12_rosa");
            }
        }
        else {
            for (l_iCount = 0; l_iCount <= l_iUlCount; l_iCount++) {
                if (l_iCount == l_iCurrentIndex)
                    $("#divNavhistoryPaging").append("<ul id=\"ulIndice" + l_iCount + "\"" +
                                                     " class=\"float_left verdana_12_rosa\"" +
                                                     " style=\"margin:0px; padding-left:3px;\">" +
                                                     "<span>" + (l_iCount + 1) + "</span></ul>");
                else
                    $("#divNavhistoryPaging").append("<ul id=\"ulIndice" + l_iCount + "\"" +
                                                     " class=\"float_left verdana_12_cinza_escuro2\"" +
                                                     " style=\"margin:0px; padding-left:3px;\">" +
                                                     "<span>" + (l_iCount + 1) + "</span></ul>");
            }

            for (l_iCount = 0; l_iCount <= l_iUlCount; l_iCount++) {
                $("#ulIndice" + String(l_iCount)).click(function() {
                    var l_arrNavigationHistoryContent = $("#divNavigationHistory > div");
                    var l_arrProductUl = $("#divNavigationHistoryContent ul");
                    var l_iUlCount = l_arrProductUl.length - 1;

                    var l_arrIndiceUl = $("#divNavhistoryPaging ul");
                    var l_iUlIndiceCount = l_arrIndiceUl.length - 1;

                    var l_iCurrentIndex = $(l_arrIndiceUl).index($("#divNavhistoryPaging ul:[class*=verdana_12_rosa]"));

                    $($("#divNavigationHistoryContent ul")[l_iCurrentIndex]).removeClass("selected");
                    $($("#divNavhistoryPaging ul")[l_iCurrentIndex]).removeClass("verdana_12_rosa");
                    $($("#divNavhistoryPaging ul")[l_iCurrentIndex]).addClass("verdana_12_cinza_escuro2");
                    l_iCurrentIndex = $(l_arrIndiceUl).index($(this));

                    $($("#divNavigationHistoryContent ul")[l_iCurrentIndex]).addClass("selected");
                    $($("#divNavhistoryPaging ul")[l_iCurrentIndex]).removeClass("verdana_12_cinza_escuro2");
                    $($("#divNavhistoryPaging ul")[l_iCurrentIndex]).addClass("verdana_12_rosa");

                    $(l_arrNavigationHistoryContent).removeClass("visiblediv");
                    $(l_arrNavigationHistoryContent).removeClass("invisiblediv");
                    for (l_iCount = 0; l_iCount < l_arrProductUl.length; l_iCount++) {
                        if (l_iCount == l_iCurrentIndex)
                            $(l_arrNavigationHistoryContent[l_iCount]).addClass("visiblediv");
                        else
                            $(l_arrNavigationHistoryContent[l_iCount]).addClass("invisiblediv");
                    }
                });
            }
        }

        $(l_arrNavigationHistoryContent).removeClass("visiblediv");
        $(l_arrNavigationHistoryContent).removeClass("invisiblediv");
        for (l_iCount = 0; l_iCount < l_arrProductUl.length; l_iCount++) {
            if (l_iCount == l_iCurrentIndex)
                $(l_arrNavigationHistoryContent[l_iCount]).addClass("visiblediv");
            else
                $(l_arrNavigationHistoryContent[l_iCount]).addClass("invisiblediv");
        }
    };

    $.fn.ChangeOffersControlCarrousel = function() {
        var l_arrParameters = arguments[0] || {};
        var l_sDirection = l_arrParameters.Direction;
        var l_arrOffersControlContent = $("#divOffersControl > div");
        var l_arrProductUl = $("#divOffersControlContent ul");
        var l_iUlCount = l_arrProductUl.length - 1;
        var l_iCurrentIndex = $(l_arrProductUl).index($("#divOffersControlContent ul:[class*=selected]"));

        if (l_sDirection == "left") 
        {
            if (l_iCurrentIndex > 0) 
            {
                $($("#divOffersControlContent ul")[l_iCurrentIndex]).removeClass("selected");
                l_iCurrentIndex--;
                $($("#divOffersControlContent ul")[l_iCurrentIndex]).addClass("selected");
            }
            else 
            {
                $($("#divOffersControlContent ul")[0]).removeClass("selected");
                l_iCurrentIndex = l_iUlCount;
                $($("#divOffersControlContent ul")[l_iCurrentIndex]).addClass("selected");
            }
        }
        else if (l_sDirection == "right") 
        {
            if (l_iCurrentIndex < l_iUlCount) 
            {
                $($("#divOffersControlContent ul")[l_iCurrentIndex]).removeClass("selected");
                l_iCurrentIndex++;
                $($("#divOffersControlContent ul")[l_iCurrentIndex]).addClass("selected");
            }
            else 
            {
                $($("#divOffersControlContent ul")[l_iUlCount]).removeClass("selected");
                l_iCurrentIndex = 0;
                $($("#divOffersControlContent ul")[l_iCurrentIndex]).addClass("selected");
            }
        }
        else 
        {
            for (l_iCount = 0; l_iCount <= l_iUlCount; l_iCount++) 
            {
                $("#ulIndice" + String(l_iCount)).click(function() {
                    var l_arrOffersControlContent = $("#divOffersControl > div");
                    var l_arrProductUl = $("#divOffersControlContent ul");
                    var l_iUlCount = l_arrProductUl.length - 1;
                    var l_arrIndiceUl = $("#divNavhistoryPaging ul");
                    var l_iUlIndiceCount = l_arrIndiceUl.length - 1;
                    var l_iCurrentIndex = $(l_arrIndiceUl).index($("#divNavhistoryPaging ul:[class*=verdana_12_rosa]"));

                    $($("#divOffersControlContent ul")[l_iCurrentIndex]).removeClass("selected");
                    l_iCurrentIndex = $(l_arrIndiceUl).index($(this));
                    $($("#divOffersControlContent ul")[l_iCurrentIndex]).addClass("selected");
                    $(l_arrOffersControlContent).removeClass("visiblediv");
                    $(l_arrOffersControlContent).removeClass("invisiblediv");
                    
                    for (l_iCount = 0; l_iCount < l_arrProductUl.length; l_iCount++) 
                    {
                        if (l_iCount == l_iCurrentIndex)
                            $(l_arrOffersControlContent[l_iCount]).addClass("visiblediv");
                        else
                            $(l_arrOffersControlContent[l_iCount]).addClass("invisiblediv");
                    }
                });
            }
        }

        $(l_arrOffersControlContent).removeClass("visiblediv");
        $(l_arrOffersControlContent).removeClass("invisiblediv");
        for (l_iCount = 0; l_iCount < l_arrProductUl.length; l_iCount++) 
        {
            if (l_iCount == l_iCurrentIndex)
                $(l_arrOffersControlContent[l_iCount]).addClass("visiblediv");
            else
                $(l_arrOffersControlContent[l_iCount]).addClass("invisiblediv");
        }
    };

    // Atribui o nome da página atual à variável "_sPageName"
    $.fn.GetPageName = function() {
        var l_sPath = window.location.pathname;
        this._sPageName = l_sPath.substring(l_sPath.lastIndexOf('/') + 1).toLowerCase();
    };

    $.fn.SetHomeLogoBack = function() {
        $("#Image73").mouseout(function() {
            MM_swapImgRestore();
        });
        $("#Image73").mouseover(function() {
            MM_swapImage('Image73', '', 'images/logo_2.gif', 1);
        });
    };

    // prepara a busca avançada para aparecer em forma de div flutuante
    $.fn.PrepareAdvancedSearchPopUp = function() {
        $("#spnOpenSearch").css("cursor", "pointer");
        $("#spnOpenSearch").css("cursor", "hand");
        $("#spnOpenSearch").click(function() {
            $("#AdvancedSearchPopUp").toggle(500);
            
            if($("#AdvancedSearchPopUp").hasClass("active"))
            {
                $("#AdvancedSearchPopUp").removeClass("active");                
                
                $("#divAdvSearchTabCenter").removeClass("bg_busca_avancada_centro_aberta");                                
                $("#divAdvSearchTabLeft").removeClass("bg_busca_avancada_esq_aberta");
                $("#divAdvSearchTabRight").removeClass("bg_busca_avancada_dir_aberta");
                
                $("#divAdvSearchTabCenter").addClass("bg_busca_avancada_centro_fechada");
                $("#divAdvSearchTabLeft").addClass("bg_busca_avancada_esq_fechada");               
                $("#divAdvSearchTabRight").addClass("bg_busca_avancada_dir_fechada");                              
                
                $("#spnOpenSearch").removeClass("verdana_12_rosa");
                $("#spnOpenSearch").addClass("verdana_12_cinza_escuro");
            }
            else
            {
                $("#AdvancedSearchPopUp").addClass("active");
                
                $("#divAdvSearchTabCenter").addClass("bg_busca_avancada_centro_aberta");
                $("#divAdvSearchTabLeft").addClass("bg_busca_avancada_esq_aberta");
                $("#divAdvSearchTabRight").addClass("bg_busca_avancada_dir_aberta");
                
                $("#divAdvSearchTabCenter").removeClass("bg_busca_avancada_centro_fechada");
                $("#divAdvSearchTabLeft").removeClass("bg_busca_avancada_esq_fechada");                
                $("#divAdvSearchTabRight").removeClass("bg_busca_avancada_dir_fechada");  
                                
                $("#spnOpenSearch").removeClass("verdana_12_cinza_escuro");
                $("#spnOpenSearch").addClass("verdana_12_rosa");
            }
            
            $("#AdvancedSearchPopUpItems").jScrollPane({ width:530, height:200, border:0,borderTopScrollArrow:"solid #D2D4D5 1",borderBottomScrollArrow:"solid #D2D4D5 1" });
        });
    }

    $.fn.Page_Load = function() {
        $.fn.GetPageName();
        
        if (this._sPageName != "default.aspx" && this._sPageName != "")
            $.fn.SetHomeLogoBack();
        
        if (this._sPageName == "product.aspx" || this._sPageName == "default.aspx" ||
            this._sPageName == "dept.aspx" || this._sPageName == "" ||
            this._sPageName.toUpperCase().indexOf("_P.ASPX") != -1 ||
            this._sPageName.toUpperCase().indexOf("_D.ASPX") != -1) {
            $("#divOffersBoxHeaderTabs > div").click(function() {
                $.fn.SetTabsAction({ p_oClickedDiv: $(this)[0] });
            });
            
            if (this._sPageName == "product.aspx" || this._sPageName.toUpperCase().indexOf("_P.ASPX") != -1) {
                $("#lnkProductEvaluation, #aEvaluationClose").click(function() {
                    $.fn.ShowHideEvaluationSection();
                });
                
                $(".divPerfumeWithImg").css("height", "50px");
                $(".divPerfumeWithImg > .float_left").css("height", "50px");
                $(".divPerfumeWithImg > .float_left > div").css("height", "50px");
                $(".divPerfumeWithImg > .float_left > .divGroupDescription").css("height", "30px");
                $(".divPerfumeWithImg > .float_left > .divGroupDescription").css("padding-top", "20px");
                $(".divPerfumeWithImg > .divAvailable").css("height", "50px");
                $(".divPerfumeWithImg > .divAvailable > .float_left").css("height", "27px");
                $(".divPerfumeWithImg > .divAvailable > .float_left").css("padding-top", "23px");
                $(".divPerfumeWithImg > .divAvailable > .float_right").css("height", "30px");
                $(".divPerfumeWithImg > .divAvailable > .float_right").css("padding-top", "20px");
                
                $(".divPerfumeWithImg > .divUnavailable").css("height", "50px");
                $(".divPerfumeWithImg > .divUnavailable > .divRemindMePerfume").css("height", "27px");
                $(".divPerfumeWithImg > .divUnavailable > .divRemindMePerfume").css("padding-top", "23px");
                $(".divPerfumeWithImg > .divUnavailable > .float_right").css("height", "33px");
                $(".divPerfumeWithImg > .divUnavailable > .float_right").css("padding-top", "17px");
                
                $(".divPerfumeWithImg > .divUnavailable > .divRemindMeFormPerfume").css("height", "27px");
                $(".divPerfumeWithImg > .divUnavailable > .divRemindMeFormPerfume").css("padding-top", "23px");
            }      
        }

        if (this._sPageName == "listgroup.aspx")
            $(".box:eq(" + String($(".box").length - 1) + ")").css("border-bottom", "none");

        if (this._sPageName == "searchresults.aspx" || this._sPageName == "dept.aspx" || this._sPageName.toUpperCase().indexOf("_D.ASPX") != -1) {
            $.fn.PrepareAdvancedSearchPopUp();
        }
        
        if (this._sPageName == "payment.aspx")
            $.fn.BlockCaracters();
    };

    var isCtrl = false;
    $(".txtCreditCard").keyup(function (e) {
        if(e.which == 17) 
            isCtrl = false;
    })
        
    $(".txtCreditCard").keydown(function (e) {
        if(e.which == 17) 
            isCtrl = true;
    });
        
    $.fn.BlockCaracters = function() {
        $(".txtCreditCard").keypress(function(e) {
            if (((e.which < 65 || e.which > 90) 
                && (e.which < 97 || e.which > 122)) && e.which != 32)
                e.preventDefault();
        });
    };

    $.fn.SearchLengthValidate = function() {
        var l_sKeyword = "";
        l_sKeyword = $(".jSearchTextBox")[0].value.trim();
        
        if (l_sKeyword.length < 3)
        {
            window.alert("Por favor, digite pelo menos três caracteres em sua busca.");
            return false;
        }
        else
            return true;
    };

    $.fn.GiftDescriptionView = function() {
        $("#aGiftProduct").attr("href", "#aGiftTab");
    };
    
    $("#aGiftProduct").click(function() {
        if ($(".divGiftTab").length > 0)
            $.fn.SetTabsAction({ p_oClickedDiv: $(".divGiftTab")[0] });
    });
    
    $("#aDescription").click(function() {
        if ($(".divDescriptionTab").length > 0)
            $.fn.SetTabsAction({ p_oClickedDiv: $(".divDescriptionTab")[0] });
    });

    var _sPageName = "";
    var l_iFooterTotalWidth = 0;
    l_iFooterTotalWidth = $(".divBoxFooter").width();
    $(".divBoxFooterLine").css("width", String(l_iFooterTotalWidth - 16.3) + "px");

    $.fn.Page_Load();
    
    /*$(".jSearchTextBox").autocomplete({
        source: function(request, response) {
            $.ajax({
                url: "SearchAutoComplete.asmx/ShowSearchResults",
                data: "{ strKeyword: '" + request.term + "', intItemsPerSearch: 5, idCatalog: 1, idProfile: 1, idPriceTable: 1 }",
                dataType: "json",
                type: "POST",
                contentType: "application/json; charset=utf-8",
                dataFilter: function(data) { return data; },
                success: function(data) { 
                            response($.map(data.d, function(item) {
                                                        return { value: item.DsCompleteName
                                                         }
                                            })
                            )},
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                           alert(textStatus + " " + errorThrown);
                       }
            });
        },
        minLength: 2,
        select: function(event, ui) {         
            window.location = ui.item.url;
        }
    });*/

    $(".jSearchTextBox").autocomplete({
        source: function(request, response) {
                    $.ajax({url: "SearchAutoComplete.asmx/ShowSearchResults",
                            data: "{ strKeyword: '" + request.term + "', intItemsPerSearch: 10, idCatalog: 1, idProfile: 1, idPriceTable: 1 }",
                            dataType: "json",
                            type: "POST",
                            contentType: "application/json; charset=utf-8",
                            dataFilter: function(data) { return data; },
                            success: function(data) { 
                                        response($.map(data.d, function(item) {
                                                                return { value: item.DsCompleteName, url: item.DsProductUrl }
                                                                })
                                        )},
                            error: function(XMLHttpRequest, textStatus, errorThrown) {
                                        //alert(textStatus + " " + errorThrown);
                                    }
                    });
        },
        minLength: 2,
        select: function(event, ui) {         
            window.location = ui.item.url;
        }
    });

    $("#imgNewAddress").click(function() {
        if ($("#tbNewAddress").hasClass("invisiblediv")) {
            $("#tbNewAddress").removeClass("invisiblediv");
            $("#tbNewAddress").addClass("visiblediv");
        }
        else {
            $("#tbNewAddress").removeClass("visiblediv");
            $("#tbNewAddress").addClass("invisiblediv");
        }
    });

    /*-- Zoom de Kit --*/
    $.fn.ShowHideKitZoom = function() {
        var l_arrParameters = arguments[0] || {};
        var l_fgShow = l_arrParameters.FgShow;
        var l_oFocusedDiv = l_arrParameters.FocusedDiv;
        var l_iCurrentIndex = 0;
        var l_arrColorZoom = [];
        l_iCurrentIndex = $(".divPerfumeItem").index(l_oFocusedDiv);

        if (l_fgShow == 1)
        {
            $($(".divPerfumeItem:eq(" + String(l_iCurrentIndex) + ") #divKitZoom")[0]).removeClass("invisiblediv");
            $($(".divPerfumeItem:eq(" + String(l_iCurrentIndex) + ") #divKitZoom")[0]).addClass("visiblediv");
        }
        else
        {
            $($(".divPerfumeItem:eq(" + String(l_iCurrentIndex) + ") #divKitZoom")[0]).removeClass("visiblediv");
            $($(".divPerfumeItem:eq(" + String(l_iCurrentIndex) + ") #divKitZoom")[0]).addClass("invisiblediv");
        }
    };
    
    $.fn.SetKitZoomPosition = function() {
        var l_arrParameters = arguments[0] || {};
        var l_oFocusedDiv = l_arrParameters.FocusedDiv;
        var l_iTopAux = 0;
        var l_iLeftAux = 0;
        var l_iCurrentIndex = 0;
        
        l_iCurrentIndex = $(".divPerfumeItem").index(l_oFocusedDiv);
        l_iTopAux = $($(".divPerfumeItem:eq(" + String(l_iCurrentIndex) + ") #divItemQty")[0]).position().top;
        if ($($(".divPerfumeItem:eq(" + String(l_iCurrentIndex) + ") div.divGroupDescription")).length != 0)
            l_iLeftAux = $($(".divPerfumeItem:eq(" + String(l_iCurrentIndex) + ") div.divGroupDescription")).position().left;

        $($(".divPerfumeItem:eq(" + String(l_iCurrentIndex) + ") #divKitZoom")[0]).css("top", String(l_iTopAux - 100) + "px");
        $($(".divPerfumeItem:eq(" + String(l_iCurrentIndex) + ") #divKitZoom")[0]).css("left", String(l_iLeftAux + 1) + "px");
    };
    
    $(".divPerfumeItem").each(function() {
        $.fn.SetKitZoomPosition({FocusedDiv:$(this)});
    });
    
    $(".divPerfumeItem").mouseover(function() {
        $.fn.ShowHideKitZoom({FgShow:1, FocusedDiv:$(this)});
    });
    
    $(".divPerfumeItem").mouseout(function() {
        $.fn.ShowHideKitZoom({FgShow:0, FocusedDiv:$(this)});
    });
    /*--    ----    ----    ----    --*/
    
    $(".divMakeupItem").mouseover(function() {
        var l_iCurrentIndex = 0;
        var l_arrColorZoom = [];
        l_iCurrentIndex = $(".divMakeupItem").index($(this));
        l_arrColorZoom = $("div#divColorZoom");

        $(this).css("background-color", "#EBEBEB");
        $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divColorZoom")[0]).removeClass("invisiblediv");
        $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divColorZoom")[0]).addClass("visiblediv");
    });

    $(".divMakeupItem").mouseout(function() {
        var l_iCurrentIndex = 0;
        var l_arrColorZoom = [];
        l_iCurrentIndex = $(".divMakeupItem").index($(this));
        l_arrColorZoom = $("div#divColorZoom");

        $(this).css("background-color", "#FFFFFF");
        $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divColorZoom")[0]).removeClass("visiblediv");
        $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divColorZoom")[0]).addClass("invisiblediv");
    });

    $(".divMakeupItem").each(function() {
        var l_iTopAux = 0;
        var l_iLeftAux = 0;
        var l_iCurrentIndex = 0;
        var l_sGroupDescription = "";
        var l_iWordLength = 0;
        
        l_iCurrentIndex = $(".divMakeupItem").index($(this));
        l_iTopAux = $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divItemQty")[0]).position().top;
        
        if ($($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") div#divItemInfo")).length != 0)
            l_iLeftAux = $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") div#divItemInfo")).position().left;

        $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divColorZoom")[0]).css("top", String(l_iTopAux - 25) + "px");
        $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divColorZoom")[0]).css("left", String(l_iLeftAux + 1) + "px");
        
        l_sGroupDescription = $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #spnGroupDescription")[0]).text().trim();
        l_iWordLength = l_sGroupDescription.length;
        if (l_iWordLength >= 24)
            $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divGroupDescriptionText")[0]).css("padding-top", "0px");
    });

    $(window).resize(function() {
        var l_iFooterTotalWidth = 0;
        l_iFooterTotalWidth = $(".divBoxFooter").width();
        
        $(".divBoxFooterLine").css("width", String(l_iFooterTotalWidth - 16.3) + "px");
        
        $(".divMakeupItem").mouseover(function() {
            var l_iCurrentIndex = 0;
            var l_arrColorZoom = [];
            l_iCurrentIndex = $(".divMakeupItem").index($(this));
            l_arrColorZoom = $("div#divColorZoom");

            $(this).css("background-color", "#EBEBEB");
            $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divColorZoom")[0]).removeClass("invisiblediv");
            $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divColorZoom")[0]).addClass("visiblediv");
        });

        $(".divMakeupItem").mouseout(function() {
            var l_iCurrentIndex = 0;
            var l_arrColorZoom = [];
            l_iCurrentIndex = $(".divMakeupItem").index($(this));
            l_arrColorZoom = $("div#divColorZoom");

            $(this).css("background-color", "#FFFFFF");
            $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divColorZoom")[0]).removeClass("visiblediv");
            $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divColorZoom")[0]).addClass("invisiblediv");
        });

        $(".divMakeupItem").each(function() {
            var l_iTopAux = 0;
            var l_iLeftAux = 0;
            var l_iCurrentIndex = 0;
            l_iCurrentIndex = $(".divMakeupItem").index($(this));
            l_iTopAux = $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divItemQty")[0]).position().top;
            
            if ($($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") div#divItemInfo")).length != 0)
                l_iLeftAux = $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") div#divItemInfo")).position().left;

            $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divColorZoom")[0]).css("top", String(l_iTopAux - 25) + "px");
            $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divColorZoom")[0]).css("left", String(l_iLeftAux + 1) + "px");
        });
        
        $(".divPerfumeItem").each(function() {
            $.fn.SetKitZoomPosition({FocusedDiv:$(this)});
        });
        
        $(".divPerfumeItem").mouseover(function() {
            $.fn.ShowHideKitZoom({FgShow:1, FocusedDiv:$(this)});
        });
        
        $(".divPerfumeItem").mouseout(function() {
            $.fn.ShowHideKitZoom({FgShow:0, FocusedDiv:$(this)});
        });
    });

	$('a.accordionAttend').click(function() {
		$('div.formularioAttend').slideToggle("slow");
	});    
    
	$('a.accordionRelationship').click(function() {
		$('div.formularioRelationship').slideToggle("slow");
	});
    
    jQuery.fn.extend({ 
        disableSelection : function() { 
                this.each(function() { 
                        this.onselectstart = function() { return false; }; 
                        this.unselectable = "on"; 
                        jQuery(this).css('-moz-user-select', 'none'); 
                }); 
        } 
     }); 

    $(".sRemindMePerfume").click(function() {
        var l_iCurrentIndex = 0;
        l_iCurrentIndex = $(".sRemindMePerfume").index($(this));
        
        $(".divRemindMePerfume:eq(" + String(l_iCurrentIndex) + ")").removeClass("visiblediv");
        $(".divRemindMePerfume:eq(" + String(l_iCurrentIndex) + ")").addClass("invisiblediv");
        $(".divRemindMeFormPerfume:eq(" + String(l_iCurrentIndex) + ")").removeClass("invisiblediv");
        $(".divRemindMeFormPerfume:eq(" + String(l_iCurrentIndex) + ")").addClass("visiblediv");
    });

    $(".sRemindMeMakeup").click(function() {
        var l_iCurrentIndex = 0;
        l_iCurrentIndex = $(".sRemindMeMakeup").index($(this));
        
        $(".divRemindMeMakeup:eq(" + String(l_iCurrentIndex) + ")").removeClass("visiblediv");
        $(".divRemindMeMakeup:eq(" + String(l_iCurrentIndex) + ")").addClass("invisiblediv");
        $(".divRemindMeFormMakeup:eq(" + String(l_iCurrentIndex) + ")").removeClass("invisiblediv");
        $(".divRemindMeFormMakeup:eq(" + String(l_iCurrentIndex) + ")").addClass("visiblediv");
    });
    
    $.fn.ChangeNavHistoryCarrousel({ Direction: "" });
    $("#imgLeftNavHistory").click(function() {
        $.fn.ChangeNavHistoryCarrousel({ Direction: "left" });
    });
    
    $("#imgRightNavHistory").click(function() {
        $.fn.ChangeNavHistoryCarrousel({ Direction: "right" });
    });

    $("#ctl00_ContentSite_ctlOffersControl_lvProducts_imgLeftOffersControl").click(function() {
        $.fn.ChangeOffersControlCarrousel({Direction: "left"});
    });

    $("#ctl00_ContentSite_ctlOffersControl_lvProducts_imgRightOffersControl").click(function() {
        $.fn.ChangeOffersControlCarrousel({Direction: "right"});
    });
    
    $("#aGiftProduct").click(function() {
        $.fn.GiftDescriptionView();
    });
    
    $.fn.ShowPinkArrow();
    
    $("#divNavigationTop").each(function() {
        var l_iPadding = 0;
        l_iPadding = (($("#divNavigationBottom").position().top - $("#divNavigationTop").position().top) / 2) - 5;
        
        if (l_iPadding > 10)
            $("#divNavigationClear").css("margin-top", String(l_iPadding) + "px");
        else
            $("#divNavigationClear").css("margin-top", "10px");
    });
    
    var l_oDivTabsBox = [];
    l_oDivTabsBox = $(".divOffersBoxContent .divOffersBoxProducts");
    if (l_oDivTabsBox.length == 0)
        $("#divOffersBox").addClass("invisiblediv");
    
    $.fn.SelectCheck = function(){
        var l_arrParameters = arguments[0] || {};
        var l_sDirection = l_arrParameters.idCheck; 
        var l_sDirectionAdd = l_arrParameters.idCheckAdd;
        var l_iCurrentIndex = 0;
        l_iCurrentIndex = $("#"+l_sDirection+" input").index(l_sDirectionAdd);
        
        $("#"+l_sDirection+" input:not(checked)").removeAttr("checked");
    };
    
    $(".jNumbersOnly").keydown(function(event) {
            // Permite apenas "backspace", "delete" e "enter"
            if (event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 13 || event.keyCode == 37 || event.keyCode == 39 ||
                (event.keyCode >= 48 && event.keyCode <= 57) ||
                (event.keyCode >= 96 && event.keyCode <= 105)) 
            {
                // let it happen, don't do anything
            }
            else {
                event.preventDefault();
                // Ensure that it is a number and stop the keypress
                /*if (event.keyCode < 48 || event.keyCode > 57 ) {
                    event.preventDefault(); 
                }*/   
            }
    });
    
    $("#divContact").click(function() {
        window.open("http://epocacosmeticos.neoassist.com/?action=new", "FaleConosco", "toolbar=no,status=no,menubar=no,scrollbars=no,resizeable=no,top=100,left=50,width=550,height=450");
    });
});

function ShowObjectPayment(idObj, type)
{
    if (isDOM)
    {
        document.getElementById('ctl00_ContentSite_ctlBasketPaymentControl_divPayment').className ='visiblediv';
        document.getElementById('ctl00_ContentSite_ctlBasketPaymentControl_divPayment2').className ='invisiblediv';
        document.getElementById('divPaymentMethod').className = 'visiblediv';
        if(type == 1)
        {
           if(idObj == 1) // Visa
           {
              document.getElementById('imgPaymentMethod').src ='images/ico_visa.gif';
              ShowObjectDropPayment(2);
           }
           else if(idObj == 3) // Dinners
           {
              document.getElementById('imgPaymentMethod').src ='images/ico_dinners.gif';
              ShowObjectDropPayment(4);
           }
           else if(idObj == 5)
           {
              document.getElementById('imgPaymentMethod').src ='images/ico_master.gif';
              ShowObjectDropPayment(5);
           }
        }
       if (type == 2)
       {
          document.getElementById('imgPaymentMethod').src ='images/ico_boleto.gif';
          document.getElementById('txtValueParcel').textContent = '';
       }
       if (type == 3)
       {
          document.getElementById('imgPaymentMethod').src ='images/ico_bradesco.gif';
          document.getElementById('txtValueParcel').textContent = 'Transferência Eletrônica Bradesco';
          document.getElementById('txtValueParcel').className = "verdana_9_cinza";
       }
       if (type == 6)
       {
          document.getElementById('imgPaymentMethod').src ='images/visa.gif';
          document.getElementById('txtValueParcel').textContent = 'Débito Automático';
          document.getElementById('txtValueParcel').className = "verdana_9_cinza";
       }
    }
    else if (isIE)
    { 
        document.all['ctl00_ContentSite_ctlBasketPaymentControl_divPayment'].className ='visiblediv';
        document.all['ctl00_ContentSite_ctlBasketPaymentControl_divPayment2'].className ='invisiblediv';
        document.all['divPaymentMethod'].className ='visiblediv';
        if(type == 1)
        {
           if(idObj == 1) // Visa
           {
              document.all('imgPaymentMethod').src ='images/ico_visa.gif';
              ShowObjectDropPayment(2);
           }
           else if(idObj == 3) // Dinners
           {
              document.all('imgPaymentMethod').src ='images/ico_dinners.gif';
              ShowObjectDropPayment(4);
           }
           else if(idObj == 5)
           {
              document.all('imgPaymentMethod').src ='images/ico_master.gif';
              ShowObjectDropPayment(5);
           }
        }
        if(type == 2)
        {
          document.all('imgPaymentMethod').src ='images/ico_boleto.gif';
          document.all('txtValueParcel').innerText = '';
        }
        if(type == 3) 
        {
          document.all('imgPaymentMethod').src ='images/ico_bradesco.gif';
          document.all('txtValueParcel').innerText = 'Transferência Eletrônica Bradesco';
           document.all('txtValueParcel').className = "verdana_9_cinza";
        } 
        if(type == 6) 
        {
          document.all('imgPaymentMethod').src ='images/visa.gif';
          document.all('txtValueParcel').innerText = 'Débito Automático Bradesco';
           document.all('txtValueParcel').className = "verdana_9_cinza";
        } 
    }
}

function ShowObjectDropPayment(idObject)
{
    if (isDOM)
    {
        var parcelSelect = document.getElementById('rbtParcelSelected,'+idObject);//seleciona o drop down de pardelas conforme a opção de pagto
        var index = parcelSelect.selectedIndex;//indice referente a quantidade de parcelas selecionada
        var selected_text = parcelSelect.options[index].text;// texto referente a quantidade de parcelas selecionadas
        
        document.getElementById('txtValueParcel').className ='';
        document.getElementById('txtValueParcel').textContent  = selected_text;
    }
    else if(isIE)
    {
        var parcelSelect = document.all['rbtParcelSelected,'+idObject];//seleciona o drop down de pardelas conforme a opção de pagto
        var index = parcelSelect.selectedIndex;//indice referente a quantidade de parcelas selecionada
        var selected_text = parcelSelect.options[index].text;// texto referente a quantidade de parcelas selecionadas
      
        document.getElementById('txtValueParcel').className ='';
        document.all['txtValueParcel'].innerText = selected_text;
    }
}

function ShowObjectDropPayment2(parcelSelect)
{   
    var index = parcelSelect.selectedIndex;//indice referente a quantidade de parcelas selecionada
    var selected_text = parcelSelect.options[index].text;// texto referente a quantidade de parcelas selecionadas
    
    if(isDOM)
    {
      document.getElementById('txtValueParcel').className ='';
      document.getElementById('txtValueParcel').textContent  = selected_text;
    }
    else if(isIE)
    {
       document.getElementById('txtValueParcel').className ='';
       document.all['txtValueParcel'].innerText = selected_text;
    }
}

function OpenPopupSecurity(url)
{
    window.open(url,'ProductRemember','toolbar=no,status=no,menubar=no,scrollbars=no,resizeable=no,top=100,left=50,width=446,height=464');
} 

function pageLoad(sender, args)
{
    if (args.get_isPartialLoad())
    {
        $(".divPerfumeWithImg").css("height", "50px");
        $(".divPerfumeWithImg > .float_left").css("height", "50px");
        $(".divPerfumeWithImg > .float_left > div").css("height", "50px");
        $(".divPerfumeWithImg > .float_left > .divGroupDescription").css("height", "30px");
        $(".divPerfumeWithImg > .float_left > .divGroupDescription").css("padding-top", "20px");
        $(".divPerfumeWithImg > .divAvailable").css("height", "50px");
        $(".divPerfumeWithImg > .divAvailable > .float_left").css("height", "27px");
        $(".divPerfumeWithImg > .divAvailable > .float_left").css("padding-top", "23px");
        $(".divPerfumeWithImg > .divAvailable > .float_right").css("height", "30px");
        $(".divPerfumeWithImg > .divAvailable > .float_right").css("padding-top", "20px");
        
        $(".divPerfumeWithImg > .divUnavailable").css("height", "50px");
        $(".divPerfumeWithImg > .divUnavailable > .divRemindMePerfume").css("height", "27px");
        $(".divPerfumeWithImg > .divUnavailable > .divRemindMePerfume").css("padding-top", "23px");
        $(".divPerfumeWithImg > .divUnavailable > .float_right").css("height", "33px");
        $(".divPerfumeWithImg > .divUnavailable > .float_right").css("padding-top", "17px");
        
        $(".divPerfumeWithImg > .divUnavailable > .divRemindMeFormPerfume").css("height", "27px");
        $(".divPerfumeWithImg > .divUnavailable > .divRemindMeFormPerfume").css("padding-top", "23px");
    
        $(".sRemindMePerfume").click(function() {
            var l_iCurrentIndex = 0;
            l_iCurrentIndex = $(".sRemindMePerfume").index($(this));
            
            $(".divRemindMePerfume:eq(" + String(l_iCurrentIndex) + ")").removeClass("visiblediv");
            $(".divRemindMePerfume:eq(" + String(l_iCurrentIndex) + ")").addClass("invisiblediv");
            $(".divRemindMeFormPerfume:eq(" + String(l_iCurrentIndex) + ")").removeClass("invisiblediv");
            $(".divRemindMeFormPerfume:eq(" + String(l_iCurrentIndex) + ")").addClass("visiblediv");
        });
        
        $(".sRemindMeMakeup").click(function() {
            var l_iCurrentIndex = 0;
            l_iCurrentIndex = $(".sRemindMeMakeup").index($(this));
            
            $(".divRemindMeMakeup:eq(" + String(l_iCurrentIndex) + ")").removeClass("visiblediv");
            $(".divRemindMeMakeup:eq(" + String(l_iCurrentIndex) + ")").addClass("invisiblediv");
            $(".divRemindMeFormMakeup:eq(" + String(l_iCurrentIndex) + ")").removeClass("invisiblediv");
            $(".divRemindMeFormMakeup:eq(" + String(l_iCurrentIndex) + ")").addClass("visiblediv");
        });
        
        $(".divMakeupItem").mouseover(function() {
            var l_iCurrentIndex = 0;
            var l_arrColorZoom = [];
            l_iCurrentIndex = $(".divMakeupItem").index($(this));
            l_arrColorZoom = $("div#divColorZoom");

            $(this).css("background-color", "#EBEBEB");
            $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divColorZoom")[0]).removeClass("invisiblediv");
            $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divColorZoom")[0]).addClass("visiblediv");
        });

        $(".divMakeupItem").mouseout(function() {
            var l_iCurrentIndex = 0;
            var l_arrColorZoom = [];
            l_iCurrentIndex = $(".divMakeupItem").index($(this));
            l_arrColorZoom = $("div#divColorZoom");

            $(this).css("background-color", "#FFFFFF");
            $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divColorZoom")[0]).removeClass("visiblediv");
            $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divColorZoom")[0]).addClass("invisiblediv");
        });

        $(".divMakeupItem").each(function() {
            var l_iTopAux = 0;
            var l_iLeftAux = 0;
            var l_iCurrentIndex = 0;
            l_iCurrentIndex = $(".divMakeupItem").index($(this));
            l_iTopAux = $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divItemQty")[0]).position().top;
            
            if ($($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") div#divItemInfo")).length != 0)
                l_iLeftAux = $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") div#divItemInfo")).position().left;

            $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divColorZoom")[0]).css("top", String(l_iTopAux - 25) + "px");
            $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divColorZoom")[0]).css("left", String(l_iLeftAux + 1) + "px");
            
            l_sGroupDescription = $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #spnGroupDescription")[0]).text().trim();
            l_iWordLength = l_sGroupDescription.length;
            if (l_iWordLength >= 24)
                $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divGroupDescriptionText")[0]).css("padding-top", "0px");
        });
    
        $(".divPerfumeItem").each(function() {
            $.fn.SetKitZoomPosition({FocusedDiv:$(this)});
        });
        
        $(".divPerfumeItem").mouseover(function() {
            $.fn.ShowHideKitZoom({FgShow:1, FocusedDiv:$(this)});
        });
        
        $(".divPerfumeItem").mouseout(function() {
            $.fn.ShowHideKitZoom({FgShow:0, FocusedDiv:$(this)});
        });
    
        $(window).resize(function() {
            var l_iFooterTotalWidth = 0;
            l_iFooterTotalWidth = $(".divBoxFooter").width();
            $(".divBoxFooterLine").css("width", String(l_iFooterTotalWidth - 16.3) + "px");
            
            $(".divMakeupItem").mouseover(function() {
                var l_iCurrentIndex = 0;
                var l_arrColorZoom = [];
                l_iCurrentIndex = $(".divMakeupItem").index($(this));
                l_arrColorZoom = $("div#divColorZoom");

                $(this).css("background-color", "#EBEBEB");
                $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divColorZoom")[0]).removeClass("invisiblediv");
                $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divColorZoom")[0]).addClass("visiblediv");
            });

            $(".divMakeupItem").mouseout(function() {
                var l_iCurrentIndex = 0;
                var l_arrColorZoom = [];
                l_iCurrentIndex = $(".divMakeupItem").index($(this));
                l_arrColorZoom = $("div#divColorZoom");

                $(this).css("background-color", "#FFFFFF");
                $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divColorZoom")[0]).removeClass("visiblediv");
                $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divColorZoom")[0]).addClass("invisiblediv");
            });

            $(".divMakeupItem").each(function() {
                var l_iTopAux = 0;
                var l_iLeftAux = 0;
                var l_iCurrentIndex = 0;
                l_iCurrentIndex = $(".divMakeupItem").index($(this));
                l_iTopAux = $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divItemQty")[0]).position().top;
                
                if ($($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") div#divItemInfo")).length != 0)
                    l_iLeftAux = $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") div#divItemInfo")).position().left;

                $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divColorZoom")[0]).css("top", String(l_iTopAux - 25) + "px");
                $($(".divMakeupItem:eq(" + String(l_iCurrentIndex) + ") #divColorZoom")[0]).css("left", String(l_iLeftAux + 1) + "px");
            });
        });
    }
}

var int_count = -1;
function SelectCheckAllBox(idcheck)
{    
    for(l_iCount = 0; l_iCount < 5; l_iCount++)
    {
        if(document.getElementById(idcheck+"_"+l_iCount).checked)
        {
            if(int_count > l_iCount)
            {
                int_count = l_iCount;
                break;
            }
        else
            int_count = l_iCount;
        }  
    }
  
    document.getElementById(idcheck + "_0").checked = false;
    document.getElementById(idcheck + "_1").checked = false;
    document.getElementById(idcheck + "_2").checked = false;
    document.getElementById(idcheck + "_3").checked = false;
    document.getElementById(idcheck + "_4").checked = false;
    document.getElementById(idcheck+"_" + int_count).checked = true;  
}
