﻿$(document).ready(function(){

    $(".clsMainMenuContentHome a").hover(
           function() {
            /*$(this).next("em").animate({opacity: "show", top: "42", left:"5"}, "slow");*/
            $(this).next("em").animate({ opacity: "show", top: "42", left: "15" }, "slow");
        }, function() {
            $(this).next("em").animate({opacity: "hide", top: "42", left:"-13"}, "fast");
        });   
});

var lblnFirstTimeLogin = true;
var lblnFirstTimeMenuEmpresa = true;

function fnOpenLoginPanel()
{
    document.getElementById("divLogin").style.visibility = "visible";
    
    if(lblnFirstTimeLogin)
    {
        document.getElementById("divLogin").style.display = "none";
        lblnFirstTimeLogin = false;
    }
    
    $("#divLogin").slideToggle("slow").siblings("#divMenuEmpresa:visible").slideUp("slow");    
        
    //$("#divLogin").slideToggle("slow");
}

function fnOpenMenuEmpresa()
{
    document.getElementById("divMenuEmpresa").style.visibility = "visible";
    
    if(lblnFirstTimeMenuEmpresa)
    {
        document.getElementById("divMenuEmpresa").style.display = "none";
        lblnFirstTimeMenuEmpresa = false;
    }
      
    $("#divMenuEmpresa").slideToggle("slow").siblings("#divLogin:visible").slideUp("slow");     
    //$("#divMenuEmpresa").slideToggle("slow");
}

function fnOpenLanguagePanel()
{
    $(".clsDivLanguage").slideToggle("slow");
}

var scrollSpeed = 6;
var step = 1;
var current = -700;
var restartPosition = -270;
var init;

function fnPageLoad()
{
    $("#TopContainer").animate({opacity: "show"}, "slow");
    $("#MenuContainer").animate({opacity: "show"}, "slow");
    
    $("#divNews").animate({opacity: "show"}, "slow");
    	$(".clsNewsLettering").jCarouselLite({
		vertical: true,
		hoverPause:true,
		visible: 1,
		auto:2000,
		speed:1000
	});	
	
	//fnOpenHomePopup();
	
    setTimeout("startScrollBg()", 3000);
}

function startScrollBg()
{
   init = setInterval("scrollBg()", scrollSpeed);
}

function scrollBg()
{
	current += step;

	if (current == restartPosition)
		clearInterval(init);
    
	$('.divAll').css("background-position","0 " + current + "px");
}


function fnOpenHomePopup() 
{

    try
    {

        var scrolledX, scrolledY;
        if( self.pageYOffset ) {
          scrolledX = self.pageXOffset;
          scrolledY = self.pageYOffset;
        } else if( document.documentElement && document.documentElement.scrollTop ) {
          scrolledX = document.documentElement.scrollLeft;
          scrolledY = document.documentElement.scrollTop;
        } else if( document.body ) {
          scrolledX = document.body.scrollLeft;
          scrolledY = document.body.scrollTop;
        }

      // Determine the coordinates of the center of the page

        var centerX, centerY;
        if( self.innerHeight ) {
          centerX = self.innerWidth;
          centerY = self.innerHeight;
        } else if( document.documentElement && document.documentElement.clientHeight ) {
          centerX = document.documentElement.clientWidth;
          centerY = document.documentElement.clientHeight;
        } else if( document.body ) {
          centerX = document.body.clientWidth;
          centerY = document.body.clientHeight;
        }   

      
      var leftOffset = scrolledX + (centerX - 723) / 2;
      var topOffset = scrolledY + (centerY - 325) / 2;
    
      document.getElementById("divHomePopup").style.top = topOffset + "px";
      document.getElementById("divHomePopup").style.left = leftOffset + "px";
      //document.getElementById("divHomePopup").style.display = "block";
      document.getElementById("divHomePopup").style.zIndex = "10000";
      
      $("#divHomePopup").animate({opacity: "show"}, "slow");
      
   }
   catch(e)
   {
       alert("Erro: " + e);
   }
}

function fnCloseHomePopup()
{
    document.getElementById("divHomePopup").style.display = "none"
}


setTimeout("fnPageLoad()", 1000);
