/* CORE */


/* FUNCTIONS */



/* END FUNCTIONS */


/* INIT */

$(document).ready(function() {

    $('input').each(function() { new Input($(this)); })
    
    new Input($('textarea'));

	$('a[rel="tooltip"]').hover(function(e) {

		var $x = (e.pageX-$('#icons').offset().left);
		var $y = (e.pageY-$('#icons').offset().top+240);

		$id = $(this).attr('id');
		$('#tooltip-'+$id).css('left',$x);
		$('#tooltip-'+$id).css('top',$y);
		$('#tooltip-'+$id).fadeIn('fast');

	},
	function() {

		$('.tooltip').hide();

	});

    var quem = "";
    
    $("#btnComentarios").click(function (e) {
        e.preventDefault();
        
        if(quem == ""){
            $("#comentarios").fadeIn("fast");
            quem = "#comentarios";
        }
        else{
            $(quem).hide();
            
            $("#comentarios").fadeIn("fast");
            quem = "#comentarios";
        }
    })
    
    $("#btnComente").click(function (e) {
        e.preventDefault();
        
        if(quem == ""){
            $("#comente").fadeIn("fast");
            quem = "#comente";
        }
        else{
            $(quem).hide();
            
            $("#comente").fadeIn("fast");
            quem = "#comente";
        }
    })
    
    $("#btnIndique").click(function (e) {
        e.preventDefault();
        
        if(quem == ""){
            $("#indique").fadeIn("fast");
            quem = "#indique";
        }
        else{
            $(quem).hide();
            
            $("#indique").fadeIn("fast");
            quem = "#indique";
        }
    })
    var g = 0;
    $("#btnPerguntar").click(function (e) {
        e.preventDefault();
        
        if(g == ""){
            $("#pergunte").fadeIn("fast");
            g = 1;
        }
        else{
            $("#pergunte").hide();
            g = 0;           
        }
        
    });
    
    $("#btnEnvieFrase").click(function (e) {
        e.preventDefault();
        
        if(quem == ""){
            $("#formFrase").fadeIn("fast");
            quem = "#formFrase";
        }
        else{
            $(quem).hide();
            
            //$("#formFrase").fadeIn("fast");
            quem = "";
        }
    })
    
    if (window.location.hash.indexOf('#pergunta')!==-1) {
        $("#pergunte").show();
        g = 1;
    }
    
    if (window.location.href.indexOf('?app=blog.comment')!==-1) {
        $("#comente").show();
        quem = "#comente";
    }
    
    if (window.location.href.indexOf('?app=blog.forward')!==-1) {
        $("#indique").show();
        quem = "#indique";
    }
    
    if (window.location.href.indexOf('?app=meu_deputado.frases')!==-1) {
        $("#formFrase").show();
        quem = "#formFrase";
    }
    
});