function validateMail(str)
{
	if(!str){
		return false;
	}
	if( /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(str) ){
		return true;
	}
	return false;
}
/*
*	All png images must be a child of a span tag with class = "clearPng"

if(navigator.userAgent.toLowerCase().indexOf("msie 6") != -1){
	$(function(){
		$('.clearPng').pngFix();
	});
}
*/
function BrowserCheck() {
var uA = new String(navigator.userAgent);
if(uA.match(/firefox/gi)){
this.app = "Firefox";
}
else if(uA.match(/chrome/gi)){
this.app = "Chrome";
}
else if(uA.match(/safari/gi)){
this.app = "Safari";
}
else if(uA.match(/opera/gi)){
this.app = "Opera";
}
else if(uA.match(/msie/gi)){
this.app = "Internet Explorer";
}
else{
this.app = navigator.appName;
}

this.ns = (this.app=="Netscape" && this.v>=4);
this.firefox = this.app == "Firefox";
this.chrome = this.app == "Chrome";
this.safari = this.app == "Safari";
this.opera = this.app == "Opera";
this.ie = this.app == "Internet Explorer";
this.unknown = !(this.ns || this.firefox || this.chrome || this.safari || this.opera || this.ie);

var version = new String(navigator.appVersion);
if (this.ie){
var vs = navigator.appVersion.substring(navigator.appVersion.indexOf('MSIE'));
this.v = parseInt(vs.substring(5,vs.indexOf(';')));
}
else if(!this.unknown){
var toMatch = (this.safari ? "Version" : this.app) + "/";
var idx = version.indexOf(toMatch) + toMatch.length;
this.v = parseFloat(version.substring(idx,version.indexOf(' ',idx)));
}
else{
this.v = parseInt(version);
}

this.toString = function(){
return this.app + " versão " + this.v;
}
var tipo_browser = this.app + this.v;
//alert(tipo_broser);
}

var browser = new BrowserCheck();
//alert(browser);

$(document).ready(function(){
	// verifica posição da frase de efeito e corrige se estiver errada
	
	if($('.frase').height() > 30){
		$('#frasePosicionamento').css('margin-top', '-70px');
	}
	
	var $liMenuMais = $("#div_mais");
	$liMenuMais.bind("mouseover",function(event){
		$("#DropMenu").stop();
		$("#DropMenu").css({
			"left" : $liMenuMais.offset().left -50,
			"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 == 0)
	{
		jAlert('O campo usuário  é obrigatório.','AVISO',function(){
			document.getElementById('campo_usuario_caixa_integra').focus();
		});
		return false;
	}
	if (document.getElementById("campo_senha_caixa_integra").value == 0)
	{	
		jAlert('O campo senha é obrigatório.','AVISO',function(){
			document.getElementById('campo_senha_caixa_integra').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 () {
            var tabContainers = $('div.tabs > div');
            tabContainers.hide().filter(':first').show();
            
            $('div.tabs ul.tabNavigation a').click(function () {
                    tabContainers.hide();
                    tabContainers.filter(this.hash).show();
                    $('div.tabs ul.tabNavigation a').removeClass('selected');
                    $(this).addClass('selected');
                    return false;
            }).filter(':first').click();
    });
 
$(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>");
});




