$(document).ready(function () {		

	$('a.video').click(function (e) {
		e.preventDefault();
		$('div.video-'+this.id).modal();
	});


	$('[name=nascimento_user]').calendar();
	
	function cajax(uri){
		var meio,div;
		$('span.retorno').html('');
		meio = $('#meio').html();
		$(this).ajaxStart(function() {
		   $('#meio').html('<img src="/images/pages/loader.gif" />'+meio).show();
		});
		// opções a serem enviadas pela função
		var options = {
		   url: uri+'?ajax=true',
		   type: "post", // metodo de envio, post ou get
		   success: function(resposta) {
				div = '<span class="retorno">'+resposta+'</span>';
				$('#meio').html(div+meio);
		   }
		}
		$(this).ajaxSubmit(options);
		// isso é para que o formulário não envio os dados, pois os mesmos serão enviados por ajax
		return false;
	}	

	$('a[id^=a]').live("click",function(){
		id = this.id;
		id = id.replace("a","r");
		$('div[id='+id+']').hide();
	});
	
	$('a.ajax').live("click",function(){
		cajax(this.href);
		return false;	
	});
	
	$('img.user-big').show(function(){																				
		lnl = 190;
		lna = 250;
		la = this.width;
		aa = this.height;
		if(la > lnl || aa > lna){
			if( la > aa ) {
				nl = lnl;
				na = (nl * aa) / la;
				if(na > lna){
					na = lna;
					nl = (la * na) / aa;				
				}
			} 
			else {
				na = lna;
				nl = (la * na) / aa;
				if(nl > lnl){
					nl = lnl;
					na = (nl * aa) / la;				
				}
			}
			
			$(this).css({
				height: na + "px",
				widht: nl + "px"
			});
		}
	});
	

	$('a[title]').qtip({
		style: {
			name: 'dark',
			tip: 'bottomMiddle',
			fontSize: '0.7em'
		},
		position: {
		  corner: {
			 target: 'topMiddle',
			 tooltip: 'bottomMiddle'
		  }
		}

	});	
});