function validateMail(str)
{
	if(!str){
		return false;
	}
	if( /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(str) ){
		return true;
	}
	return false;
}


$(document).ready(function(){
	var $liMenuMais = $("#div_mais");
	$liMenuMais.bind("mouseover",function(event){
		$("#DropMenu").stop();
		$("#DropMenu").css({
			"left" : $liMenuMais.offset().left -40,
			"top" : $liMenuMais.offset().top + $liMenuMais.outerHeight(false),
			"height": 0,
			"overflow": "hidden"
		});
	
		var $tmp = $("#DropMenu").clone().css({"position" : "absolute", "z-index" : "-999", "display" : "block", "height" : "auto"}).insertAfter("#DropMenu");
		var h = $tmp.outerHeight(false);
		$tmp.remove();
		$("#DropMenu").show().animate({ "height" : h }, 800);
	});
	$liMenuMais.add("#DropMenu").bind("mouseout",function(event){
		if($(event.relatedTarget).closest("#DropMenu").length == 0){
			$("#DropMenu").stop();
			$("#DropMenu").animate({"height" : 0 }, 400,function(){
			$("#DropMenu").hide()
			});
		};
	});
	
});


function get_mais(){
	var m=document.getElementById("div_mais");
	var d=document.getElementById("Dropmenu_selecionado");
	if (d){
		m.className = "menu_mais_ativado";
		//alert("mais");
	}	
}


function ValidaIntegra()
{
	if (document.getElementById("campo_usuario_caixa_integra").value == 'Digite seu login...')
	{
		jAlert('Por favor digite o login.','AVISO',function(){
			document.getElementById('campo_usuario_caixa_integra').focus();
		});
		return false;
	}
	if (document.getElementById("campo_senha_caixa_integra").value == '******')
	{	
		jAlert('Por favor digite sua Senha.','AVISO',function(){
			document.getElementById('campo_senha_caixa_integra').focus();
		});
		return false;
	}
	return true;
}

function ValidaPainel()
{
	if (document.getElementById("painel_email").value == 'Digite seu e-mail...')
	{
		jAlert('Por favor digite o E-mail corretamente.','AVISO',function(){
			document.getElementById('painel_email').focus();
		});
		return false;
	}
	if (document.getElementById("painel_password").value == '******')
	{	
		jAlert('Por favor digite sua Senha','AVISO',function(){
			document.getElementById('painel_password').focus();
		});
		return false;
	}
	return true;
}

function validaNewsLetter(){
	if(!validateMail(document.getElementById('campo_texto_caixa_newsletter').value)){
		jAlert('Favor preencher o campo E-mail corretamente.','AVISO',function(){
			document.getElementById('campo_texto_caixa_newsletter').focus();
		});
	}
	else{
		sendNewsletter();
	}
}
function sendNewsletter(){
	document.formNewsLetter.submit();
	jAlert('Informações enviadas com sucesso!','AVISO',function(){
			document.getElementById('campo_texto_caixa_newsletter').value = '';
	});
}

function validaApoiadorForm(){
	var nomeCampo = new Array();
	if(document.getElementById('nome').value == ''){
	
		jAlert('Favor preencher o campo Nome corretamente.','AVISO',function(){
			document.getElementById('nome').focus();
		});
		
	}
	else if(!validateMail(document.getElementById('idName').value)){
	//else if(document.getElementById('idName').value == ""){
		jAlert('Favor preencher o campo E-mail corretamente.','AVISO',function(){
			document.getElementById('idName').focus();
		});
	}
	else if(document.getElementById('tel').value == ''){
		jAlert('Favor preencher o campo Telefone corretamente.','AVISO',function(){
			document.getElementById('tel').focus();
		});
		
	}
	
	else{
		
		sendContato();
		
	}
}

function runLogin(){
	$("#formLogin").hide();
	$("#box").hide();
	$("#imgLoginFixo").click(function(){
		$("#formLogin").height($(document).height()+5).width($(window).width());
		$("#box").css("align", "center").css("margin-top", "-"+($("#box").height()/2)+"px").css("margin-left", "-"+($("#box").width()/2)+"px");
		$("#box").show();
		$("#formLogin").show();
		$('html,body').animate({scrollTop: 0}, 1000);
	});
}

function clearFields(){
    document.getElementById('nome').value = '';
    document.getElementById('idName').value = '';
    document.getElementById('tel').value = '';
    document.getElementById('msg').value = '';
}

$(function(){
	$("#tel").mask('(99) 9999-9999');
});
function muda_cor(){
	$("#texto_jusbrasilAtualiza_item span").css("color", "rgb(0, 0, 0)");
}
	
 
$(function urlSite(){
	//pega a url e coloca na variavel url
	var url = window.location;
	//converte em String
	url = url.toString()
	//converte em um array separando pelos (.)
	url = url.split("//");
	url = url[1].split("/");
	url = url[0];
	$("#url_site").html("<a class='site_contato' href=http://"+url+"><span>"+url+"</span></a>");
});


function box(){
	if(!($.browser.msie && $.browser.version == 7)){
		$('.box').fadeIn(); 
		
	}
	else{
		$('#texto_home').hide(); 
		$('#texto_home3').slideDown();	
	}
	
}
	
$(document).ready(function(){
	if($.browser.msie && $.browser.version == 6){
		//alert("IE6!");
	    $("#alert").show();
	    $("html").css({"background-image":"none","background-color":"#cccccc"});
	    $("body").css({"background-image":"none","background-color":"#cccccc"});
	    $("#body").hide();
	    $("#body").hide();
	}
});

$(document).ready(function(){
	runLogin();
	$(".descritivo_endereco_principal").before("<br>");
	$('#combo_caixa_busca').selectbox();
	get_mais();
	if(!$.browser.msie || ($.browser.msie && $.browser.version !=7)){
		$("body").css("display", "none");
		$("body").css("overflow-y", "scroll");
	    $("body").fadeIn(500);
		$("a.transition").click(function(event){
			event.preventDefault();
			linkLocation = this.href;
			$("body").fadeOut(300, redirectPage);		
		});
		function redirectPage() {
			window.location = linkLocation;
		}
	}
		Shadowbox.init({
		overlayOpacity: 0.8,
		displayCounter: false
	});	
	
	$('#accordion').easyAccordion({ 
						autoStart: false, 
						slideInterval: 3000
	}); 
	
	tooltip();
    imagePreview();
    screenshotPreview();
 		
});




