$().ready( function() {
	if(document.getElementById('enquete'))
		enquete();
	if(document.getElementById('calendario'))
		agenda();
	bancadas();
	abremenu();
	galeria();
	popups();
	abas();
//	newstickers();
} );

function enquete() {
	$(".enquete").bind("click", function() {

		$.ajax({
			url: "web/modulos/home/enquete.php",
			data: $(this).attr('name'),
			type: "POST",
			global: false,
			success: function(msg) {
				$("#enquete").html(msg);
				enquete();
			}
		});

		return false;
	} );
}

function agenda() {
	$(".agenda").bind("click", function() {
		$.ajax({
			url: "web/modulos/home/calendario.php",
			data: $(this).attr('href'),
			type: "GET",
			global: false,
			success: function(msg) {
				$("#calendario").html(msg);
				agenda();
			}
		});

		return false;
	} );
}

function bancadas() {
	$('div.bancada').each( function() {
		$(this).css('background', 'url(system/php/phpimages/images.php?arquivo=system/filemanager/'+$(this).attr('id')+'&largura=150&altura=150) top left no-repeat');
	} );
}

function abremenu() {
/*	var options = {minWidth: 120, hoverOpenDelay: 2, onClose: 1, arrowSrc: 'arrow_right.gif', onClick: function(e, menuItem){
		alert('you clicked item "' + $(this).text() + '"');
	}};
*/	var options = {
		minWidth: 150,
		hoverOpenDelay: 1,
		arrowSrc: 'web/system/js/jquery/menu.gif'
	};

	$('#menuone').menu(options);
}

function galeria() {
	$('a[rel*=facebox]').facebox();
}

function popups() {
	$('a.visible').bind('click', function() {
		$(this).addClass('hidden');
	} );
}

function abas() {
	$('.abas1').tabs();
	$('.abas2').tabs(2);
	$('.abas3').tabs( { fxSlide:true } );
	$('.abas4').tabs( { fxFade:true, fxSpeed:'fast' } );
	$('.abas5').tabs( { fxSlide:true, fxFade:true, fxSpeed:'normal' } );
	$('.abas6').tabs( { fxAutoHeight:true } );
	$('.abas7').tabs( { fxShow:{ height:'show', opacity:'show' }, fxSpeed:'normal' } );
}

function newstickers() {
	if(document.getElementById('apoio2'))
		$("#apoio").newsTicker(5000);
}
