document.write("<link href=\"Css/Fix.css\" rel=\"stylesheet\" type=\"text/css\" />");

var cor1 = "#EFEFEF";
var cor2 = "#ffffff";

function validacaoFaleConosco()
{
   if( $("#ctl00_ContentPlaceHolder1_txtNome").attr("value") == "" )
   {
        alert("O campo \"Seu Nome \" &eacute; de preenchimento obrigat&oacute;rio.");
        return false;
   }
   
   if( $("#ctl00_ContentPlaceHolder1_txtEmail").attr("value") == "" )
   {
        alert("O campo \"Seu Email \" &eacute; de preenchimento obrigat&oacute;rio.");
        return false;
   }
   
   var reEmail = /^[\w-]+(\.[\w-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/; 

   if(!reEmail.test($("#ctl00_ContentPlaceHolder1_txtEmail").attr("value")))
   {        
        alert("O e-mail não é v&aacute;lido.");
        return false;
   }   
   
   if( $("#ctl00_ContentPlaceHolder1_txtMensagem").attr("value") == "" )
   {
        alert("O campo \"Mensagem \" &eacute; de preenchimento obrigat&oacute;rio.");
        return false;
   }
   
   return true;
}



function fazerAoCarregar()
{

    $(":text").css("background-color",cor1);
    $("textarea").css("background-color",cor1);
    $("select").css("background-color",cor1);
    
    $(":text").keyup(
        function()
        {
            if($(this).attr("value") == "")
            {  
                $(this).css("background-color",cor1); 
            }
            else
            {   
                $(this).css("background-color",cor2);     
            }
        }    
    );        
    
    $("textarea").keyup(
        function()
        {
            if($(this).attr("value") == "")
            {  
                $(this).css("background-color",cor1); 
            }
            else
            {   
                $(this).css("background-color",cor2);     
            }
        }    
    );    
    
    $("select").change(
        function()
        {
            if($(this).attr("value") == "0")
            {  
                $(this).css("background-color",cor1); 
            }
            else
            {   
                $(this).css("background-color",cor2);     
            }
        }    
    );   
    
    
    /*
    $("select.preencher").change(
        function()
        {
            if(this.se.length > 0)
            {
                this.$("option:selected").removeClass("preencher");
            }
            else
            {
                this.addClass("preencher");            
            }
        }    
    );
    */
    
    
    $(".showfake").removeClass("showfake");
    var itensdemenu = document.getElementById("menu").getElementsByTagName("li");	
	
	for(var i=0; i<itensdemenu.length; i++)
	{		    
	    if(itensdemenu[i].className == "menu")
	    {        
	        if(itensdemenu[i].getElementsByTagName("ul")[0] != null)
	        {
	            itensdemenu[i].getElementsByTagName("p")[0].onmouseover = abreMenu;	
	            itensdemenu[i].getElementsByTagName("div")[0].onmouseout = fechaMenuDIV;
	            itensdemenu[i].onmouseover = abreMenu2;	   
	            itensdemenu[i].onmouseout = fechaMenuLI;      
	            itensdemenu[i].getElementsByTagName("a")[0].onfocus = abreMenuA;	
				
	            var lismenu = itensdemenu[i].getElementsByTagName("ul")[0].getElementsByTagName("li");
	        }			
			
	    }
	}
	
	if(document.getElementById("destaques")!= null)
	{	
	    $("#destaques").find(".shadow").css("z-index","8");	
		var destaques = document.getElementById("destaques");
		
		destaques.onmouseover = function()
		{
		    hideMenu();
		    $("#destaques").find("h3").css("z-index","20");
		    $("#destaques").find(".shadow").css("z-index","8");	
		}		
		destaques.onmouseout = function()
		{
		    $("#destaques").find("h3").css("z-index","9");	
		    $("#destaques").find(".shadow").css("z-index","8");			
		}		
		
		var randomnumber = Math.floor(Math.random() * destaques.getElementsByTagName("li").length);

        $(destaques).prepend("<div class=\"destaques_navegacao\"><span class=\"anterior\">anterior</span> | <span class=\"proximo\">pr&oacute;ximo</span></div>");
        $(".destaques_navegacao").hide();
        
        
		for(var i=0; i<destaques.getElementsByTagName("li").length; i++)
		{
	        $(destaques.getElementsByTagName("li")[i]).find("p,h3").clone().addClass("shadow").css("opacity", 0.2).appendTo(destaques.getElementsByTagName("li")[i]);
			$(".shadow").find("a").css("color","#000");		
				
			$(destaques.getElementsByTagName("li")[i]).find("p,h3").hide();
			$(destaques.getElementsByTagName("li")[i]).hide();
			
			if(i == randomnumber)
			{
				$(destaques.getElementsByTagName("li")[i]).fadeIn("slow", function()
				    {				    
				        $(destaques.getElementsByTagName("li")[i]).find("p,h3").fadeIn("fast", function()
				            {
				                $(".destaques_navegacao").slideDown("fast");
				            }
				        );
				    }
				);
			}
		}	
		   

		$(".anterior").click( 
		    function ()
		    { 
                $(".destaques_navegacao").hide();
		    	var todos = $("#destaques").find("li");
		    	var atual = $("#destaques").find("li:visible");	
		    	var todosSize = $("#destaques").find("li").size();
		    	var atualIndex = todos.index(atual);
		    	var anteriorIndex;
		    	var anterior;
		    	
		    	if(atualIndex > 0)
		    	{
		    	    anteriorIndex = atualIndex-1;
		    	    anterior = todos.eq(anteriorIndex); 
                    anterior.find("p,h3").hide();
		    	    anterior.show();		  
		    	      	   
		    	    atual.find("p,h3").fadeOut("fast",function()
		    	        {
		    	            atual.fadeOut("slow", function()
		    	                {
		    	                    anterior.find("p,h3").fadeIn("fast", function()
		    	                        {
		    	                            atual.hide();	
                                            $(".destaques_navegacao").slideDown("fast");	    	                    
		    	                        }
		    	                    );                         
		    	                }
		    	            );
		    	        }
		    	    );
		    	}
		    	else
		    	{
		    	    anteriorIndex = todosSize-1;
		    	    anterior = todos.eq(anteriorIndex);
                    anterior.find("p,h3").hide();
                    		    	    
		    	    atual.find("p,h3").fadeOut("fast",function()
		    	        {
		    	            anterior.fadeIn("slow", function()
		    	                {
		    	                    anterior.find("p,h3").fadeIn("fast",function()
		    	                        {
		    	                            atual.hide();		    	                            
                                            $(".destaques_navegacao").slideDown("fast"); 	
		    	                        }
		    	                    );
		    	                }
		    	            );
		    	        }
		    	    )		    	    		    	    
		    	}		    		    			    	
		    } 
        ); 	
		
		$(".proximo").click( 
		    function ()
		    { 
                $(".destaques_navegacao").hide();
		    	var todos = $("#destaques").find("li");
		    	var atual = $("#destaques").find("li:visible");	
		    	var todosSize = $("#destaques").find("li").size();
		    	var atualIndex = todos.index(atual);
		    	var proximoIndex;
		    	var proximo;
		    	
		    	if(atualIndex < todosSize-1)
		    	{
		    	    proximoIndex = atualIndex+1;
                    proximo = todos.eq(proximoIndex);
                    proximo.find("p,h3").hide();
                    
                    atual.find("p,h3").fadeOut("fast", function()
                        {
		    	            proximo.fadeIn("slow", function()
		    	                {
		    	                    proximo.find("p,h3").fadeIn("fast", function()
		    	                        {  
		    	                            atual.hide();	                 
                                            $(".destaques_navegacao").slideDown("fast"); 	
		    	                        }
		    	                    )
		    	                }
		    	            );                     
                        }
                    );


		    	}
		    	else
		    	{
		    	    proximoIndex = 0;
                    proximo = todos.eq(proximoIndex);
                    proximo.find("p,h3").hide();	
		    	    proximo.show();
                    	    	    
                    atual.find("p,h3").fadeOut("fast", function()
                        {
        		    	    atual.fadeOut("slow", function()
        		    	        {
        		    	            proximo.find("p,h3").fadeIn("fast",function()
        		    	                {   
		    	                            atual.hide();	         	                  
                                            $(".destaques_navegacao").slideDown("fast");	 
        		    	                }
        		    	            );
        		    	        }
        		    	    );                            
                        }
                    );
		    	}   			    	
		    } 
        ); 
		
	}    
	
	resize();	
	
    if($(".formulario")[0] != null)
    {         
        $("form").submit( 
            function(){
                return validacaoFaleConosco();
            }        
        );
    }
}

function abreMenu()
{
    hideMenu();  
    var subMenu = this.parentNode.getElementsByTagName("div");
    
	for(var i=0; i<subMenu.length; i++)
	{
	    if(subMenu[i].className == "hide")
	    {
	        subMenu[i].className = "show";
	    }
	}    	
}

function removeClassFake()
{    
    $(this).removeClass("showfake");
}

function abreMenuA()
{
    hideMenu();    
    var subMenu = this.parentNode.parentNode.getElementsByTagName("div");
    
	for(var i=0; i<subMenu.length; i++)
	{
	    if(subMenu[i].className == "hide")
	    {
	        subMenu[i].className = "show";
	    }
	}    	
}

function abreMenu2()
{
    hideMenu();    
    var subMenu = this.getElementsByTagName("div");
    
	for(var i=0; i<subMenu.length; i++)
	{
	    if(subMenu[i].className == "hide")
	    {
	        subMenu[i].className = "show";
	    }
	}    	
}

function fechaMenuLI()
{ 
    var subMenu = this.getElementsByTagName("div")[0];
    subMenu.className = "hide";
}

function fechaMenuDIV()
{   
    this.className = "hide";
}

function resize()
{	
    document.getElementsByTagName("body")[0].className = "";
    document.getElementsByTagName("html")[0].className = "";
}

function hideMenu()
{
    $(".menu").find("div:first").removeClass("show");
    $(".menu").find("div:first").addClass("hide");  
}

window.onload = fazerAoCarregar;
window.onresize = resize;

/*
function fechaMenuLI2()
{ 
    var subMenu = this.parentNode.parentNode.parentNode.parentNode.parentNode.getElementsByTagName("div")[0];
    subMenu.className = "hide";
}
*/