$(document).ready(function(){
    $('body.page-6').createAccordeon({
        accordeonElements: 'body.page-6 #post-6 div',
        accordeonLinks: 'body.page-6 #mnGlos a',
        activeClass: 'active',
        disabledClass: 'inactive'
    });
	$('#tab').createTabs({
		tabContainer: '#tab',
		tabList: '#tab #tabmn',
		tabListLinks: '#tab #tabmn a',
		tabPanels: '#tab div',
		tabLinkEnabledClass: 'ativo',
		tabLinkDisabledClass: 'inativo',
		tabPanelEnabledClass: 'ativo',
		tabPanelDisabledClass: 'inativo'
	});

	// Parte de download
	var arrLinks = new Array();

	for(var i = 0; i < $("#right ul.pdf li a").length; i++){
	    arrLinks[i] = $("#right ul.pdf li a")[i].href;
	    $("#right ul.pdf li a")[i].name = [i];
	}
	$('#right ul.pdf li a').attr('href','#');
	/*Formulario antecedente de download*/
	$("#right ul.pdf li a").click(function(){
		$("#right ul.pdf,#right h4").hide();
		$.post("form-download.php",{arquivo:arrLinks[$(this).attr('name')]},
			function(resposta){
			$("#right").html(resposta);
			}
		)
	});
	$("#form-down").submit(function(){
		$("#down-02").hide();
		$("#down-03").show();
		return false;
	});
});

$.fn.createTabs = function(options){
	return this.each(function(options){
		var options = jQuery.extend({
			tabContainer: '#tab',
			tabList: '#tabmn',
			tabListItems: '#tabmn li',
			tabListLinks: '#tab #tabmn a',
			tabPanels: '#tab > div',
			tabLinkEnabledClass: 'ativo',
			tabLinkDisabledClass: 'inativo',
			tabPanelEnabledClass: 'ativo',
			tabPanelDisabledClass: 'inativo'
		}, options);
		
		jQuery(options.tabListItems).removeClass('ativo');
		jQuery(options.tabPanels).hide();
		jQuery(options.tabListItems + ':first').addClass('ativo');
		jQuery(options.tabPanels + ':first').show();
		
		jQuery(options.tabListLinks).click(function(){
			jQuery(options.tabListItems).removeClass('ativo');
			jQuery(options.tabPanels).hide();
			jQuery(this.hash).show();
			$(this).parents('li').addClass('ativo');
			return false;
		});
		
		
	});
}

$.fn.createAccordeon = function(options){
    return this.each(function(options){
		var options = jQuery.extend({
			accordeonElements: 'body.page-6 #post-6 div',
			accordeonLinks: 'body.page-6 #mnGlos a',
			activeClass: 'active',
			disabledClass: 'inactive'
		}, options);
		jQuery(options.accordeonElements).hide();
		jQuery(options.accordeonElements + ':first').show();
		jQuery(options.accordeonLinks).click(function(){
			jQuery(options.accordeonElements + ':visible').hide();
			jQuery(options.accordeonLinks + '.' + options.activeClass).removeClass(options.activeClass);
			jQuery(this.hash).show();
			jQuery(this).addClass(options.activeClass);
			return false;
		}).each(function(){
			if (jQuery(this.hash).size() == 0) {
				jQuery(this).addClass(options.disabledClass).unbind().click(function(){
					return false;
				}).attr('href', '#')
			}
		});
	});
};
