$(document).ready(function() {
	/* cria bordas arredondadas */
	$("head").prepend('<style>.rounded {  position:relative; } .lt, .lb, .rt, .rb, .lthome, .lbhome, .rthome, .rbhome { position:absolute; z-index:1;display:block;text-indent:-9999px; height:10px;width:10px; background-repeat:no-repeat; } .lt, .lthome { left:0; top:0; background-position:left top; } .lb, .lbhome { left:0; bottom:0; background-position:left bottom; } .rt, .rthome { right:0; top:0; background-position:right top; }.rb, .rbhome {right:0; bottom:0; background-position:right bottom; }</style>');
	$(".rounded").append('<span class="lt"></span><span class="rt" /><span class="rb" /><span class="lb" />');
	$(".roundedForm").append('<span class="lthome"></span><span class="rthome" /><span class="rbhome" /><span class="lbhome" />');
    $(".rodape").append('<span class="rb">&nbsp;</span><span class="lb">&nbsp;</span>');
    
	/* abas de navegacao internas */
	var itemsAbas = $(".lst_menu_detalhes_produto dd a");
		itemsAbas.click(function() {
		var css = $(this).attr("class").split(' ');
		$(".detales_produto_content .content").hide();
		$("." + css[1]).show();
		$.each(itemsAbas, function(index, item) {
			var current = $(item).attr("class");
			$(item).attr("class", current.replace("-on", "-off"));
		});
		$(this).attr("class", css.join(" ").replace("-off", "-on"));
		return false;
    });
    
    /* MENU */
    var menuPrincipal = $("dl#header_menu_category dd a");
    menuPrincipal.hover(
        function() {
            $(this).parent().children("ul").css("display", "block");
            var classLink = $(this).parent().children("a").attr("class");
            $(this).addClass(classLink + "_on");
       //     $(this).css("background-position", "0 -33px");
        },
        function() {
            $(this).parent().children("ul").css("display", "none");
            listaClass = $(this).attr('class').split('_');
            $(this).removeClass();
            $(this).addClass(listaClass[0]);
       //     $(this).css("background-position", "0px 0px");
        }
    );
    var menuPrincipalUl = $("dl#header_menu_category dd ul");
    menuPrincipalUl.hover(
        function() {
            $(this).css("display", "block");
            var classLink = $(this).parent().children("a").attr("class");
            $(this).parent().children("a").addClass(classLink + "_on");
             //$(this).parent().children("a").css("background-position", "0 -33px");
        },
        function() {
			$(this).css("display", "none");
            $(this).parent().children("ul").css("display", "none");
            listaClass = $(this).parent().children("a").attr('class').split('_');
            $(this).parent().children("a").removeClass();
            $(this).parent().children("a").addClass(listaClass[0]);
            // $(this).parent().children("a").css("background-position", "0px 0px");
        }
    );
    
    $(".campo").addClass("idleField");
	$(".campo").focus(function() {
		$(this).removeClass("idleField").addClass("focusField");
		if (this.value == this.defaultValue){ 
			this.value = '';
		}
		if(this.value != this.defaultValue){
			this.select();
		}
	});
	$(".campo").blur(function() {
		$(this).removeClass("focusField").addClass("idleField");
		if ($.trim(this.value) == ''){
			this.value = (this.defaultValue ? this.defaultValue : '');
		}
	});
	
	
	//Calcula a maior Elemento par Ajustar os Produtos da Home e Vitrines
	var maxheight = 0;
	
    jQuery('.ofertas_semana_vitrine_container .lstProdutos li').each(function(){
        if(maxheight < jQuery(this).height())
        {
            maxheight = jQuery(this).height();
        }
    });  

    jQuery('.ofertas_semana_vitrine_container .lstProdutos li').css("height", maxheight);
    
    maxheight = 0;
    
    jQuery('.ofertas_container .lstProdutos li').each(function(){
        if(maxheight < jQuery(this).height())
        {
            maxheight = jQuery(this).height();
        }
    });  

    jQuery('.ofertas_container .lstProdutos li').css("height", maxheight);
    
    maxheight = 0;
    
    jQuery('.lancamentos_container .lstProdutos li').each(function(){
        if(maxheight < jQuery(this).height())
        {
            maxheight = jQuery(this).height();
        }
    });  

    jQuery('.lancamentos_container .lstProdutos li').css("height", maxheight);
    
     jQuery('.tagList  li').css("height", "auto");
    	
});
