$(document).ready(function(){
	$('#next-month, #prev-month').live('click',function(){
		var next = $(this).attr('alt');
	
		//alert( next );
		$.post('inc/calendar.php',
			{view: 'calendar', mes: next},
			function( data ){
				$('#calendar').html(data); 
		});
		$.post('inc/calendar.php',
			{view: 'table', mes: next},
			function( data ){
				$('#calendar-table').html(data); 
		});
	});
	$('a.externo').click(function( e ){
		e.preventDefault();
		window.open($(this).attr('href'));
	});
	
	/* slide show de perfil */
	$("#perfil li").not(':eq(0)').each(function(){
		var a = document.createElement('a');
		$( a ).className = 'fechar';
		
		var img = document.createElement('img');
		$( img ).attr({
			src: 'img/fechar.jpg',
			alt: ''
		});
		$( a ).append( img );
		
		$( a ).bind('click',function(){
			$( this ).parent('li').css({display: 'none'});
			$("#perfil li").eq(0).fadeIn('slow');
		});
		$( this ).append( a );
	});
	$("#perfil li").css({display: 'none'});
	$("#perfil li").eq(0).css({display: 'block'});
	$("#pb-color li").hover(
		function(){
			var img = $( this ).find('img');
			
			var base = pb( img, 6 );
			$( img ).attr({src: base+'color.jpg'});
		},
		function(){
			var img = $( this ).find('img');
			
			var base = pb( img, 9 );
			
			$( img ).attr({src: base+'pb.jpg'});
		});
	$("#pb-color li").click(function(){
		var rel = $(this).attr('rel');
		$("#perfil li").css({display: 'none'});
		$("#perfil li").eq( rel ).fadeIn('slow');
	});
	
	/* slide show do perfil */
	
	
	$('#popup a').click(function( e ){
		e.preventDefault();
		
		$( this ).parent('div').hide();
	});
});
function pb( img, menos )
{
	var str = $( img ).attr('src');
	return str.substring( 0, str.length-menos );	
}



