function menu(){
    $(".sub-menu").show();
    SubH = $(".sub-menu").height();
    SubT = -1*((SubH)+32);
    $(".sub-menu").css("position", "absolute");
	$(".sub-menu").css("left", "0");
    $(".sub-menu").css("top", SubT);
    $(".base-sub").css("height", (SubH)+32);
    $(".base-sub").css("display", "none");
}

$(document).ready(function(){
imgW = [];
imgH = [];

proW = [];
proH = [];

    $(".sub-menu").hide();
    setTimeout("menu()", 500);
	
	//$('.imagem img').load(function(){
	$('.imagem').each(function(i){
		imgW[i] = $('img', this).width();
		imgH[i] = $('img', this).height();
		$(this).css("width", imgW[i]);
		$(this).css("height", imgH[i]);
		$(this).hover(
		function(){
			$(this).css("width", imgW[i]-4);
			$(this).css("height", imgH[i]-4);
		},
		function(){
			$(this).css("width", imgW[i]);
			$(this).css("height", imgH[i]);
		})
	})
//})
	
    // ClearForm Login ***********************************************************************************************************************
    function clearForm(){
        swap_val=[];

        $('.box-login input').each(function(i){
            swap_val[i] = $(this).val();
            $(this).focus(function(){
                if($(this).val() == "senha"){
                    $(this).remove();
                    $('#labelSenha').append("<input type='password' type='text' name='senha' id='senha' title='senha' value='' tabindex='4' />");
                    clearForm();
                    $('#senha').focus();/*Necesário para o IE*/
                }
                if($(this).val() == swap_val[i]){
                    $(this).val("");
                }
            }).blur(function(){
                if($.trim($(this).val()) == "" && $(this).attr("id") == "senha"){
                    $(this).remove();
                    $('#labelSenha').append("<input type='text' type='text' id='senha' name='senha' title='senha' value='senha' tabindex='4' />");
                    clearForm();
                }
                if($.trim($(this).val()) == ""){
                    $(this).val(swap_val[i]);
                }
            })
        })
    }
    clearForm();
    // Login *********************************************************************************************************************************
    $(".box-login").fadeTo(0,0);
    $(".box-login").css("display", "none");
	$(".bt-over").hover(function(){
			$(".over", this).fadeToggle("slow", "easeOutExpo");
		})
	$(".pessoa").change(function(){
		if($(this).attr('id')=="fisica"){
			$(".tipoPessoa").html("<label for='CPF'></label><input type='text' id='CPF' value='CPF' tabindex='2' />");
			clearForm();
		}else{
			$(".tipoPessoa").html("<label for='CNPJ'></label><input type='text' id='CNPJ' value='CNPJ' tabindex='2' />");
			clearForm();
		}
		})
    $(".logar").toggle(
        function() {
			$(".restrito-over").fadeIn("slow", "easeOutExpo");
            $(".logar").addClass("restritoActive");
            $(".box-login").css("display", "block");
            $('.box-login').stop().animate(
            {
                opacity:1
            },{
                duration: 500,
                easing: 'easeOutExpo',
                complete:function(){
                    jQuery.each(jQuery.browser, function(i) {
                        if($.browser.msie){
                            $(this).css({
                                opacity:''
                            });
                        }
                    });
                }
            })
        },
        function() {
			$(".restrito-over").fadeOut("slow", "easeOutExpo");
            $(".logar").removeClass("restritoActive");
            $('.box-login').stop().animate(
            {
                opacity:0
            },{
                duration: 500,
                easing: 'easeOutExpo',
                complete:function(){
                    $(".box-login").css("display", "none");
                    jQuery.each(jQuery.browser, function(i) {
                        if($.browser.msie){
                            $(this).css({
                                opacity:''
                            });
                        }
                    });
                }
            });
        }
        );

    // Menu *********************************************************************************************************************************
    $(".produtos").hover(function(){
        $(".base-sub").css("display", "block");
        $(".base-sub").css("height", (SubH)+32);
        $('ul', this).stop().animate(
        {
            top:0
        },{
            easing: 'easeOutExpo',
            duration: 500
        });
    },
    function(){
        $('ul', this).stop().animate(
        {
            top:SubT
        },{
            easing: 'easeInOutExpo',
            duration: 800,
            complete:function(){
                $(".base-sub").css("display", "none");
            }
        });
    }
    );
	// SubMenu *********************************************************************************************************************************
		$('.menu-principal ul li .sub-menu li').hover(function(){
			$(this).stop().animate(
			{backgroundColor: "#0074bc", color:'#0074bc'}, {
				easing: 'easeOutExpo',
				duration: 500
				});
			$('a', this).stop().animate(
			{color: "#fff"}, {
				easing: 'easeOutExpo',
				duration: 500
				});
			},
		function(){
			$(this).stop().animate(
			{backgroundColor: "#def5fb"}, {
				easing: 'easeOutExpo',
				duration: 1000
				});
			$('a', this).stop().animate(
			{color: "#0074bc"}, {
				easing: 'easeOutExpo',
				duration: 500
				});
			}				
		)
    // Bordas Imagens ************************************************************************************************************************
	$(".imagem, #panes img, .fotos img, .box-conteudo-i, .box-produto").hover(function(){
		$(this).stop().animate({boxShadow: '0 0 10px #176e7e'}, 'fast');
	},function(){
		$(this).stop().animate({boxShadow: '0 0 5px #6ba8b3'}, 'fast');
		});
});
// Muda Cor da Tabela ************************************************************************************************************************
function corTabela(cor1, cor2){
	$('#caracteristicas tr').hover(function(){
		$(this).stop().animate(
		{backgroundColor: cor1}, {
			easing: 'easeOutExpo',
			duration: 500
			});
		},function(){
		$(this).stop().animate(
		{backgroundColor: cor2}, {
			easing: 'easeOutExpo',
			duration: 1000
			});
		})
	}
// Accordion ************************************************************************************************************************
function accordion(){
	    $('.accordion').click(function() {
        $(this).toggleClass("active").next().slideToggle('slow');
        	return false;
    	}).next().hide();
	}
// Scroll ************************************************************************************************************************	
function Scroll(){
	$('a[href*=#]').click(function() {
	 if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
	 && location.hostname == this.hostname) {
	   var $target = $(this.hash);
	   $target = $target.length && $target
	   || $('[name=' + this.hash.slice(1) +']');
	   if ($target.length) {
	  var targetOffset = $target.offset().top;
	  $('html,body')
		  .animate({scrollTop: targetOffset}, 700, 'easeOutExpo');
			return false;
		   }
		 }
		  });
}
// PreLoader ************************************************************************************************************************

(function($){
	var cache = [];
	$.preLoadImages = function(){
		var imageCount = arguments.length;
		for(var i=imageCount;i--;){
			var cacheImage = document.createElement('img');
			cacheImage.src = arguments[i];
			cache.push(cacheImage);
			}
		}
	})(jQuery)
