$(document).ready(function (){

jQuery.event.add(window, "load", resizeFrame);
jQuery.event.add(window, "resize", resizeFrame);

function resizeFrame(){var h = $(window).height();$("#bgconteudoss").css("height", h-250);}

$('#menu a.menu')
	.css( {backgroundPosition: "0 40px"} )
	.mouseover(function(){
		$(this).stop().animate(
			{backgroundPosition:"(0 0)"}, 
			{duration:300})
		})
	.mouseout(function(){
		$(this).stop().animate(
			{backgroundPosition:"(0 40px)"}, 
			{duration:300})
		})
	.click(function(){
		//changeContent("empresa");
	});

$('ul#nav > li').hover(function() {
	if($.browser.msie) {
		$('ul', this).css('top',$(this).position().top + $(this).height());
		$('ul', this).css('left',$(this).position().left);
	}
	$('ul:first', this).show();
	$('ul:first', this).css('z-index',12);
  },
  function() {
    $('ul:first', this).hide();
  });
  $('ul#nav li li').hover(function() {
    $('ul:first', this).each(function() {
      $(this).css('top', $(this).parent().position().top );
      $(this).css('left', $(this).parent().position().left + $(this).parent().width() );
       $(this).show();
    });
  },
  function() {
    $('ul:first', this).hide();
  });


changeContent = function(esq, dir) {
	var lang = $("#lang").val();
	if (esq) {
		if (esq != "empty") {
			$("#lconteudos").load("/pvcstar/views/centro/"+lang+"_"+esq).hide().fadeIn('fast');
		}
	}
	if (dir) {
		$("#rconteudos").fadeOut('fast');
		if (dir != "empty") {
			$("#rconteudos").load("/pvcstar/views/lateral/"+lang+"_"+dir).hide().fadeIn('fast');
		}
	}
}

changeLang = function(q) {
	var url = document.location.href;
	url=url.replace('pt',q);
	url=url.replace('fr',q);
	url=url.replace('en',q);
	
	window.location = url;
}

/*VERIFICAR URL*/
checkURL();

	$('#submenu a').click(function (e){
		checkURL(this.hash);
	});

	setInterval("checkURL()",250);
});

var lasturl="";
function checkURL(hash)
{
	if(!hash) hash=window.location.hash;

	if(hash != lasturl)
	{
		lasturl=hash;
		loadPage(hash);
	}
}

function loadPage(url)
{
	url=url.replace('#','');
	changeContent(url+'.php', url+'.php');
}
