Shadowbox.init({
	overlayColor: "#FFF",
	overlayOpacity: 1,
	displayCounter: false,
	onOpen: function(element) {
		// Move a navegação pra dentro da barra superior (de título)
		jQuery('#sb-nav').appendTo('#sb-title');
	}
});

(function($) {
	$(document).ready(function() {
		// Adiciona o marcador na 1º item do menu
		$('.container .TabMenu li:first').addClass("selector");
		
		// Efeito de hover em cada item do menu
		$('.container .TabMenu li').hover(
			function() { $(this).addClass("hovering"); },
			function() { $(this).removeClass("hovering"); }
		);
		
		$('a', 'div.home div.col-2 p.outros').hover(
			function() { $('div.tooltip[class*=' + $(this).attr('class') + ']', 'div.home div.col-2').stop().fadeTo('normal', 1); },
			function() { $('div.tooltip[class*=' + $(this).attr('class') + ']', 'div.home div.col-2').clearQueue().fadeOut(); }
		);
		
		// Clique em cada item do menu
		$('.container .TabMenu li').click(function(e) {
			//e.preventDefault();
			
			$li = $(this);
			
			// Se for o item atual, cancela
			if ($(this).hasClass('selector')) return false;
			
			// Largura do primeiro item
			largura = $(".TabContent:first").outerWidth(true);
			
			left = $(this).index() * largura * -1;
			
			// Executa a animação
			$(".AllTabs").animate({
				'left': left
			}, 600, 'swing' ,function() {
				// Troca o item do menu
				$('.container .TabMenu li.selector').removeClass('selector');
				$li.addClass('selector');
				
				// Esconde os créditos
				if ($('.container .TabMenu li.selector').index() != 0) {
					$('div.apoio:has(div.creditos)').fadeOut('normal', function() {
						// Se estiver nos catalogos, mostra o flash
						if ($('.container .TabMenu li.selector').index() == 2) {
							$('div.getflash').fadeIn();
						} else {
							$('div.getflash').fadeOut();							
						}
					});
				} else {
					$('div.getflash').fadeOut('normal', function() {
						$('div.apoio:has(div.creditos):hidden').fadeIn();
					});
				}
			});			
		});

		// Executa o clique no item do menu que tem a ancora da URL
		var url = document.location.toString();
		if (url.match('#')) {
			ancora = '#' + url.split('#')[1];
			$('.TabMenu li a[href="' + ancora + '"]').parent().click();
		}
		
		
		// ========================
		
		$('.videos .video').hover(
			function() {
				$('div.tooltip', this).fadeIn();
			},
			function() {
				$('div.tooltip', this).fadeOut();
			}
		);
		
		// ========================
		
		// Limpa os inputs com o clique
		$('input[type="text"],textarea').each(function () {
			$(this).data('value', $(this).val());
			$(this).focus(function() {
				if ($(this).val() == $(this).data('value'))
					$(this).val('');
			}).blur(function() {
				if ($(this).val() == '')
					$(this).val($(this).data('value'));			
			});
		});
		// Limpa os inputs com o submit do form
		$('form').submit(function() {
			$('input[type="text"],textarea', this).each(function () {
				if ($(this).val() == $(this).data('value'))
					$(this).val('');
			});
		});
		
		// ========================
		
		$('#ContatoEnviarForm').validate({
			errorElement: 'div',
			rules:
			{
				'data[Contato][nome]': { required: true },
				'data[Contato][email]': { required: true, email: true },
				'data[Contato][assunto]': { required: true },
				'data[Contato][mensagem]': { required: true }
			},
			messages: 
			{
				'data[Contato][nome]': 
				{
					required: 'Preencha o seu nome' 
				},
				'data[Contato][email]': 
				{
					required: 'Preencha o seu e-mail',
					email: 'Insira um e-mail com formato válido' 
				},
				'data[Contato][assunto]': 
				{
					required: 'Preencha o assunto da mensagem'
				},
				'data[Contato][mensagem]': 
				{
					required: 'Preencha a sua mensagem'
				}
			},
			submitHandler: function(form) {
				$(form).ajaxSubmit({
					target: 'span.mensagem'
				});
			}
		});
	});
})(jQuery);

/*
*/

swfobject.embedSWF("megazine/megazine.swf",        /* Path to the megazine.swf. You probably won't have to change this. */
			   "megazine_pt",                     /* Change this if you use another id for the div to display MegaZine. */
/* (1) */                  "1190",                          /* This is the WIDTH of the element used to display MegaZine. */
/* (2) */                  "630",                          /* This is the HEIGHT of the element used to display MegaZine. */
			   "9.0.115",                      /* Required Flash Player version. You probably won't have to change this. */
			   "swfobject/expressInstall.swf", /* Path to the expressInstall.swf to upgrade Flash Player. You probably won't have to change this. */
			   {
				   xmlFile : "megazine_pt.xml",   /* Used to pass the name of the xml file to use. Path is relative to the swf! */
				   maxScale : 1.0,             /* Maximum scaling factor when using liquid scaling. Default is 1.0, i.e. the book can not get bigger than it's 100% size. */
				   top: "90"                 /* Determines the height of the empty space above pages in pixels */
			   },
			   {
/* (3) */                      bgcolor : "#ffffff",        /* This is the background color used for the Flash element. */
/* (4) */                      wmode : "transparent",    /* Remove the // to enable transparency (show HTML background). Not recommended if using videos. */
				   allowFullscreen : "true"    /* Required for fullscreen mode. */
			   },
			   {id : "megazine_pt"});             /* Required for SWFAddress. */

swfobject.embedSWF("megazine/megazine.swf",        /* Path to the megazine.swf. You probably won't have to change this. */
			   "megazine_fr",                     /* Change this if you use another id for the div to display MegaZine. */
/* (1) */                  "1190",                          /* This is the WIDTH of the element used to display MegaZine. */
/* (2) */                  "630",                          /* This is the HEIGHT of the element used to display MegaZine. */
			   "9.0.115",                      /* Required Flash Player version. You probably won't have to change this. */
			   "swfobject/expressInstall.swf", /* Path to the expressInstall.swf to upgrade Flash Player. You probably won't have to change this. */
			   {
				   xmlFile : "megazine_fr.xml",   /* Used to pass the name of the xml file to use. Path is relative to the swf! */
				   maxScale : 1.0,             /* Maximum scaling factor when using liquid scaling. Default is 1.0, i.e. the book can not get bigger than it's 100% size. */
				   top: "90"                 /* Determines the height of the empty space above pages in pixels */
			   },
			   {
/* (3) */                      bgcolor : "#ffffff",        /* This is the background color used for the Flash element. */
/* (4) */                      wmode : "transparent",    /* Remove the // to enable transparency (show HTML background). Not recommended if using videos. */
				   allowFullscreen : "true"    /* Required for fullscreen mode. */
			   },
			   {id : "megazine_fr"});             /* Required for SWFAddress. */

swfobject.embedSWF("megazine/megazine.swf",        /* Path to the megazine.swf. You probably won't have to change this. */
			   "megazine_en",                     /* Change this if you use another id for the div to display MegaZine. */
/* (1) */                  "1190",                          /* This is the WIDTH of the element used to display MegaZine. */
/* (2) */                  "630",                          /* This is the HEIGHT of the element used to display MegaZine. */
			   "9.0.115",                      /* Required Flash Player version. You probably won't have to change this. */
			   "swfobject/expressInstall.swf", /* Path to the expressInstall.swf to upgrade Flash Player. You probably won't have to change this. */
			   {
				   xmlFile : "megazine_en.xml",   /* Used to pass the name of the xml file to use. Path is relative to the swf! */
				   maxScale : 1.0,             /* Maximum scaling factor when using liquid scaling. Default is 1.0, i.e. the book can not get bigger than it's 100% size. */
				   top: "90"                 /* Determines the height of the empty space above pages in pixels */
			   },
			   {
/* (3) */                      bgcolor : "#ffffff",        /* This is the background color used for the Flash element. */
/* (4) */                      wmode : "transparent",    /* Remove the // to enable transparency (show HTML background). Not recommended if using videos. */
				   allowFullscreen : "true"    /* Required for fullscreen mode. */
			   },
			   {id : "megazine_en"});             /* Required for SWFAddress. */


function clearForm(elementID) {
	if(document.getElementById(elementID).value == elementID ) {
		document.getElementById(elementID).value= "";
	}
}
function preencheForm(elementID){
	if(document.getElementById(elementID).value == '') {
		document.getElementById(elementID).value = elementID;
	}
}

