﻿// Login
$(document).ready(function() {
    $('.loginLink').click(function() {
        $(this).toggleClass("ativo");
        $(".loginform").slideToggle("700");
        return false;
    });
});

// Filtro
$(document).ready(function() {
    $('#filtroLink').click(function() {
        $(this).toggleClass("ativo");
        $("#filtroForm ul").slideToggle("700");
        return false;
    });
    //    $('.filtroEnviar a').click(function() {
    //    });
});
function FiltroClick() {
    $('#filtroLink').toggleClass("ativo");
    $("#filtroForm ul").slideToggle("700");
    $("#conteudo").css('marginTop', ($(".filtroResultado").height() - 16) + "px");
}

// Menu de Funções (listagem)
$(document).ready(Listagem);

function Listagem() {
    $('.funcoesTwitter').click(function() {
        $(this).parent().children('.funcoesTwitter-submenu').slideToggle();
    });

    $('li.principal').hover(function() {
        $(this).addClass('ie7hack');
    }, function() {
        $(this).removeClass('ie7hack').children('h1').children('dl').children('.funcoesTwitter-submenu').hide();
        //$(this).find('.skullClick').hide();
    });
    // Thumbs Up
    $('.thumbsupOver').hide();
    $('.thumbsupOver2').hide();
    $('.thumbsup').hover(function() {
        $(this).parent().children('.thumbsupOver').show();
    }, function() {
        $(this).parent().children('.thumbsupOver').hide();
    });
    $('.thumbsupSa').hover(function() {
        $(this).parent().children('.thumbsupOver2').show();
    }, function() {
        $(this).parent().children('.thumbsupOver2').hide();
    });

    // Skulls
    $('.skullOver').hide();
    $('.skullOver2').hide();
    $('.skullClick').hide();
    $('.skull').hover(function() {
        $(this).parent().children('.skullOver').show();
    }, function() {
        $(this).parent().children('.skullOver').hide();
    });
    $('.skullSa').hover(function() {
        $(this).parent().children('.skullOver2').show();
    }, function() {
        $(this).parent().children('.skullOver2').hide();
    });
    $('.skull').click(function() {
        $(".skullOver").hide();
        $(this).parent().find(".skullClick").slideToggle();
        return false;
    });
    if (!$("div.tabsDicasLinks").hasClass("comTabs")) {
        $("div.tabsDicasLinks").tabs("div.tabsDicas > div", {
            rotate: true
        }).slideshow({ clickable: false });
        $("div.tabsDicasLinks").addClass("comTabs");
    }
}

// Quem São
// $(document).ready(function() {
//    $('.usuario500').hover(function() {
//        $(this).addClass('ativo').children('.quemsao-Info').show();
//    }, function() {
//        $(this).removeClass('ativo').children('.quemsao-Info').hide();
//    });
//});
$(document).ready(function() {
    $('.usuario500').tooltip({
        track: true,
        showURL: false,
        showBody: " - ",
        left: -90,
        fade: 50
    });
});

//Water Mark
$(function() {
    $(".water").focus(function() {
        $tb = $(this);
        if ($tb.val() == this.title) {
            $tb.val("");
            $tb.removeClass("water");
        }
    });
    $(".water").blur(function() {
        $tb = $(this);
        if ($.trim($tb.val()) == "") {
            $tb.val(this.title);
            $tb.addClass("water");
        }
    });
    $(".water").each(function() {
        $tb = $(this);
        if ($tb.val() != this.title) {
            $tb.removeClass("water");
        }
    });
});

$(document).ready(function() {
    $(".btnLoginOAuth").click(function(event) {
        event.preventDefault();
        window.open("Login.aspx?a=login&mod=false", "o500login", "width=800,height=400,left=150,top=100,status=no,toolbar=no,menubar=no,directories=no,scrollbar=no,resize=no");
    })
});



MyUtil = new Object();
MyUtil.selectFilterData = new Object();
MyUtil.selectFilter = function(selectId, filter) {
    var list = document.getElementById(selectId);
    if (!MyUtil.selectFilterData[selectId]) { //if we don't have a list of all the options, cache them now'
        MyUtil.selectFilterData[selectId] = new Array();
        for (var i = 0; i < list.options.length; i++) MyUtil.selectFilterData[selectId][i] = list.options[i];
    }
    list.options.length = 0;   //remove all elements from the list
    for (var i = 0; i < MyUtil.selectFilterData[selectId].length; i++) { //add elements from cache if they match filter
        var o = MyUtil.selectFilterData[selectId][i];
        if (o.text.toLowerCase().indexOf(filter.toLowerCase()) >= 0) list.add(o, null);
    }
}


$(document).ready(function() {
    $('.lbUsuario').hide();
    $('.txtUsuario').keyup(function() {
        var filter = $(this).val();
        var select = $('.lbUsuario').attr('id');
        MyUtil.selectFilter(select, filter)
    });
    $('.txtUsuario').focus(function() {
        $('.lbUsuario').fadeIn();
    });
    $('.txtUsuario').blur(function() {
        if (!$(".lbUsuario option:selected").length)
            $('.lbUsuario').fadeOut();
    });
    $('.lbUsuario').blur(function() {
        if (!$(".lbUsuario option:selected").length)
            $('.lbUsuario').fadeOut();
    });
});
