hs.align = 'center';
hs.transitions = ['expand', 'crossfade'];
hs.outlineType = 'rounded-white';
hs.fadeInOut = true;
hs.headingEval = 'this.thumb.alt';

hs.addSlideshow({
	interval: 5000,
	repeat: false,
	useControls: true,
	fixedControls: 'fit',
	overlayOptions: {
		opacity: .75,
		position: 'bottom center',
		hideOnMouseOut: true
	}
});
function countChild(elem){
	return $(elem).size();
}
$(document).ready(function(){
	$(".overtext").overText();
	$("#header div a + a").click(function() {
		$("#downloads").addClass("show");
	});
	$("#downloads div span").click(function() {
		$("#downloads").removeClass("show");
	});
	$("#header div a:first-child").click(function() {
		$("#portal-atendimento").addClass("show");
	});
	$("#portal-atendimento div span").click(function() {
		$("#portal-atendimento").removeClass("show");
	});

	$("#phone").mask("(99)9999-9999");
	
	/* EBIS */
	$("#link").mouseover(function() {
		$("#ebis img").stop();
		$("#ebis img:first-child").animate({top:0, opacity: 0}, 250, function() {
			$(this).animate({top:15, opacity: 1}, 250);
			$("#ebis img + img").animate({top:35, opacity: 1}, 250);
		});
	});
	$("#link").mouseout(function() {
		$("#ebis img").stop();
		$("#ebis img + img").animate({top:45, opacity: 0}, 250);
		$("#ebis img:first-child").animate({top:0, opacity: 0}, 250, function() {
			$(this).animate({top:15, opacity: 1}, 250);
		});
	});
	$("#menu > li > a").mouseup(function() {
		$(this).focus();
		if( countChild($(this).parent().children()) > 2 ){
			$("#menu > li div > ul").stop();
			var j = $("#menu > li.show div > ul").height();
			$("#menu > li div > ul").animate({top:-j -30}, 350, function() {
				$("#menu > li > div").css("height", "0");
				$("#menu > li").removeClass("show");
			});
			var j = $(this).parent().children("div").children("ul").height();
			$(this).parent().children("div").children("ul").animate({top:-j -30}, 1, function() {
				$(this).parent().css("height", "auto");
				$(this).animate({top:0}, 350);
				$(this).parent().parent().addClass("show");
			});
		};
	});
	$("#menu > li > a").blur(function() {
		$("#menu > li div > ul").stop();
		var j = $("#menu > li.show div > ul").height();
		$("#menu > li div > ul").animate({top:0}, 350, function() {
			$("#menu > li div > ul").animate({top:-j -30}, 200, function() {
				$("#menu > li > div").css("height", "0");
				$("#menu > li").removeClass("show");
			});
		});
	});
});

function ExibeFlash(src, larg, alt, vars)
{
    var strHtml = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+ larg +'" height="'+ alt +'">';
    strHtml += '<param name="movie" value="'+ src +'" />'; 
    strHtml += '<param name="wmode" value="transparent" />'; 
    strHtml += '<param name="flashvars" value="'+ vars +'" />';
    strHtml += '<embed src="'+ src +'" wmode="transparent" flashvars="'+ vars +'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+ larg +'" height="'+ alt +'"></embed>';
    strHtml += '</object>';
    document.write(strHtml);
}

function validacao()
{
	mensagem = "";
	formulario = document.portal;
	
	if(formulario._USUARIO.value == "")
		mensagem += "Nome, ";
		
	if(formulario._SENHA.value == "")
		mensagem += "Senha, ";
			
				 
	if(mensagem != "")
	{
		document.getElementById('erroLogin').style.display = 'block';
		return false;
	}
	return true;	
}

function checkMail(mail){
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if(typeof(mail) == "string"){
        if(er.test(mail)){ return true; }
    }else if(typeof(mail) == "object"){
        if(er.test(mail.value)){ 
                    return true; 
                }
    }else{
        return false;
        }
	return false;	
}

function validacao2()
{
	mensagem = "";
	formulario = document.news;
	
	if(formulario.nome.value == "" || formulario.nome.value == "Nome:")
		mensagem += "Nome, ";
		
	if(formulario.email.value == "" || formulario.email.value == "E-mail:")
		mensagem += "E-mail, ";
			
				 
	if(mensagem == "")
    {
        if(checkMail(formulario.email.value))
        {
			return true;
        }
        else
        {
            document.getElementById('envioNews').style.display = 'block';
            return false;  
        }
    }
    else
    {
        document.getElementById('envioNews').style.display = 'block';
        return false;
    }

}
