
jQuery(window).load(function(){

if(window.location.search != '' ){
	//alert('nada no search');
	var frame = window.location.search.slice(7);
	//alert(frame);
	if(frame != '-1' && frame != ''){
	if(document.getElementById('pagina_interna').src){ document.getElementById('pagina_interna').src= frame + '?frame=true'; }
	if(document.getElementById('pagina_interna').data){ document.getElementById('pagina_interna').data= frame + '?frame=true'; }
	}
}

});
	
jQuery(document).ready(function(){
	//console.log(jQuery('#home').outerWidth());
	//console.log(screen.width);
	if(screen.width > 1290){
		var margin = Math.round((screen.width - 1276)/2);
		var width = jQuery('#conteudo').width() + margin;
		jQuery('#conteudo').width(width + 'px');
		jQuery('#conteudo').css("margin-left",margin);
		jQuery('#home').css("margin-right",margin);
	}
	if(screen.width <= 1024){ jQuery('html,body,#pseudo_body').scrollLeft(150); }
	
	jQuery('a[rel]').click(function(){
		if(document.getElementById('globo_interna').mexe){
			var rel = jQuery(this).attr("rel");
			document.getElementById('globo_interna').mexe(rel);
		}
	});
	
	jQuery('#ok_newsletter').click(function(){
	
		var nome   = jQuery('#nome_newsletter').val();
		var email  = jQuery('#email_newsletter').val();
		var idioma = jQuery('#idioma_newsletter').val();
		
		if(nome == '' || email == '' || idioma == ''){
			
			alert('Por favor preencha os campos');
			return false;

		}

		var dados = 'nome_newsletter=' + nome + '&email_newsletter=' + email + '&idioma_newsletter=' + idioma;

		jQuery.ajax({
			
			type: "POST",
			url:  "newsletter.php",
			data: dados,
			error: function(){
			
				alert('Ocorreu um erro ao efetuar o cadastro, por favor tente novamente');
				return false;
			
			},
			success: function(msg){
			
				var msg = jQuery.trim(msg);

				switch(msg){
				
					case 'erro':
						alert('Ocorreu um erro ao efetuar o cadastro, por favor tente novamente');
						return false;
						break;
						
					case 'ja_cadastrado':
						alert('O seu email ja consta na nossa base de dados');
						return false;
						break;
						
					case 'sucesso':
						alert('Cadastro efetuado com sucesso');
						return false;
						break;
					
				}

			}
			
		});	
		
		return false;
	
	});
	
	
	jQuery("ul#menu_ul li").hover(function(){
		jQuery(this).css("background-color","#8aafc0");
		if(jQuery(this).attr("id") == "menu_home"){ jQuery("#menu").css("background-position","left bottom") }
		if(jQuery(this).attr("id") == "menu_contato"){ jQuery("ul#menu_ul").css("background-position","right bottom") }
	},function(){
		jQuery(this).css("background-color","#a5cbdc");
		if(jQuery(this).attr("id") == "menu_home"){ jQuery("#menu").css("background-position","left top") }
		if(jQuery(this).attr("id") == "menu_contato"){ jQuery("ul#menu_ul").css("background-position","right top") }
	});
	//daria pra juntar essas duas (a de cima e a de baixo)
	jQuery("ul#menu_ul li.menu_parent").hover(function(){
		jQuery(this).children("ul").css('display','block');
	},function(){
		jQuery(this).children("ul").css('display','none');
	});
	
	jQuery('a[rel]').click(function() {
		$target = jQuery('#interna');
		var targetOffset = jQuery("#pseudo_body").length && $target.position().left || $target.offset().left; //- 95;
		if(screen.width <= 1024){ targetOffset += 85; }
		var copyLeft = targetOffset + 560;
		var signLeft = targetOffset + 964;
		jQuery('#copyright').animate({left: copyLeft + 'px'},{duration: 2000,easing: 'swing'});
		jQuery('#signature').animate({left: signLeft + 'px'},{duration: 2000,easing: 'swing'});
		jQuery('html,body,#pseudo_body').animate({scrollLeft: targetOffset},{duration: 2000,easing: 'swing'});
		return false;
	});
	
	jQuery('li#menu_home a').click(function() {
		var targetOffset = jQuery('#home').offset().left; //- 95;
		if(screen.width <= 1024){ targetOffset += 150; }
		jQuery('#copyright').animate({left: '560px'},{duration: 2000,easing: 'swing'});
		jQuery('#signature').animate({left: '964px'},{duration: 2000,easing: 'swing'});
		jQuery('html,body,#pseudo_body').animate({scrollLeft: targetOffset},{duration: 2000,easing: 'swing'});
		return false;
	});

	jQuery('#home #esquerda #newsletter a#abre_popup').click(function() {
		jQuery('#home #esquerda #newsletter #popup_newsletter').show('slow');
		return false;
	});
	
	jQuery('#home #esquerda #newsletter #popup_newsletter a#fecha_popup').click(function() {
		jQuery('#home #esquerda #newsletter #popup_newsletter').hide('slow');
		return false;
	});
	
	jQuery("a#signature").hover(function(){

		jQuery(this).children("img").fadeIn("medium");
		
	},function(){

		jQuery(this).children("img").fadeOut("medium");

	});

});
