/*-------------------------------------------------------------------------------------

* Lembrar de limpar snippets que não forem usados no projeto!

------------------------------------------------------------------------------------ */

$(function(){
	
	// Stuff
	$('#content *:last-child').css({ marginBottom: '0' });

	// Popups
	$('a').popLinks();

	// Scrolls internos
	$('.scroll-short, .scroll-wide').jScrollPane({ animateTo: true, animateInterval: 50, animateStep: 3, scrollbarWidth: 18 });
	$('#navbar-intern.oq a').click(function(){
		var destinationSelector = $(this).attr('rel');
		$('.scroll-short').each(function(){
			this.scrollTo(destinationSelector);
		});
		return false;
	});

	// Menu hover para o IE6
	if ($.browser.msie && parseInt($.browser.version) < 7) {  
		$('.sub').mouseover(
			function() {
				$(this).children('ul').addClass('active');
			}).mouseout(
			function() {
				$(this).children('ul').removeClass('active');
		});
	}

	// Validação do contato
	var formContato = $('#form-contato');
	
	if (formContato.length > 0) {
		
		var formContainer = $('#form-contato-error');
		
		$('#form-contato').validate({
			rules: {
				nome: 'required',
				telfixo: 'required',
				mensagem: 'required',
				email: { required: true, email: true }
			},
			messages: {
				nome: 'Por favor digite seu Nome;',
				telfixo: 'Por favor digite o seu Telefone Fixo;',
				mensagem: 'Por favor digite sua Mensagem;',
				email: { required: 'Por favor digite seu E-mail;', email: 'Por favor digite um E-mail valido;' }
			}
		});
		$('#fc-telf, #fc-telc').mask('(99) 9999-9999',{ placeholder: '' });
	};


});


// Fix Inline Block property for Firefox (Only FF2!) ----------------------------------
$.fn.fixInlineBlock = function() {
	if ($.browser.mozilla) {
		return this.css('display','-moz-inline-box');
	}
};

// Pop Links (Ex.: rel='popup|200|200') -----------------------------------------------
$.fn.popLinks = function() {
	$(this).each(function(){
		var tgt = $(this).attr('href');
		var rel = $(this).attr('rel');
		if(rel) {
			var relsplit = rel.split('|',3);
			if(relsplit[0] == 'externa') {
				$(this).attr('target','_blank');
			} else if (relsplit[0] == 'popup') {
				$(this).click(function(){
					var pHeight = relsplit[1];
					var pWidth  = relsplit[2];
					var wHeight = $(window).height();
					var wWidth  = $(window).width();
					var pTop    = (wHeight-pHeight)/2;
					var pCenter = (wWidth-pWidth)/2;
					new_window  = window.open(tgt,'popup','width='+pWidth+',height='+pHeight+',location=no,toolbar=no,scrollbars=no,menubar=no,top='+pTop+',left='+pCenter+'');
					return false;
				});
			}
		}
	});
};