/*
    por: M2BRNET (http://www.m2brnet.com)
\* ......................................................................................................................................... */

/*
	Namespace
\* ......................................................................................................................................... */

var M2 = function() {

	function inputValues(el,def) {

		var active_input   = '#383838',
			inactive_input = '#929292';

		return(el.each(function() {
			var el = $(this);
			el.css('color',inactive_input);
			el.val(def).focus(function() {
				if(el.val() == def) {
					el.val("").css('color',active_input);
				}
				el.blur(function() {
					if(el.val() == "") {
						el.val(def).css('color',inactive_input);
					}
				});
			});
		}));
	}

	function Tabs(el) {

		var tabContainers = $('.tab-content .tabs',el),
			tabNav        = $('.tab-nav a',el);

		$(tabNav).click(function () {
			tabContainers.hide().filter(this.hash).show();
			$(tabNav).removeClass('active');
			$(this).addClass('active');
			return false;
		}).filter(':first').click();
	}

	return {
		Init: function(){
			M2.SetInputValues('keyword','Digite aqui o que deseja buscar...');
			M2.SetInputValues('frm-news-email','Digite o seu email...');
			M2.External();
		},
		SetInputValues: function(el,def){
			var el = $("#"+el);
			if (el.length > 0 && def != '') {
				inputValues(el,def);
			}
		},
		SetTabs: function(el) {
			var el = $("#"+el);
			if (el.length > 0) {
				Tabs(el);
			}
		},
		External: function() {
			$('a[rel*="external"]').attr('target','_blank');
		}
	};

}();

/*
	DOM Loaded
\* ......................................................................................................................................... */

$(function(){

	M2.Init();

	/*
	$('div#side_nav .sub ').click(function(){
		if($(this).hasClass('act')){
			$(this).removeClass('act');
			$(this).parent('li').children('ul').fadeOut('fast');
		}else {
			$(this).addClass('act');
			$(this).parent('li').children('ul').fadeIn('fast');
		}
		return false;
	});
	*/

});

