var ql = 0;
var ss = 0;
var active = 0;

$(document).ready(function(){  
	
//Facebox height fix
h = $(window).height();
$('#facebox_overlay').height(h);

//Cufon
Cufon.replace('h1, h2', { fontFamily: 'Kozuka Gothic Pro OpenType' });
Cufon.replace('h3', { fontFamily: 'Bell Gothic Std' });
Cufon.replace('h4', { fontFamily: 'BellGothicBold' });

//Top-Bar
var h = $(".ql-items").height();
$("#top-bar").css({ "height": h+15, "marginTop": -h - 35 });

    $("#btn-quicklink").click(function(){
        //hide other data
        $("#sitesearch").hide()
        //hide
        if(ql > 0) {
            $("#top-bar").stop().animate({
                marginTop: -h - 35
            }, 250)
            ql = 0;
        } else if(ss > 0) {
        //fade in quicklinks
            $("#top-bar").stop().animate({
                marginTop: "0"
            }, 250)
            $("#quicklinks").fadeIn(500);
            ql = 1;
            ss = 0;
        } else {
        //show
        $("#top-bar").stop().animate({
            marginTop: "0"
        }, 250)
        ql++
        $("#quicklinks").fadeIn(500);
    }
    });
   
    $("#btn-sitesearch").click(function(){
        //hide other data
        $("#quicklinks").hide()
        //hide
        if(ss > 0) {
            $("#top-bar").stop().animate({
                marginTop: -h - 35
            }, 250)
            ss = 0;
        } else if(ql > 0) {
        //fade in sitesearch
        $("#top-bar").stop().animate({
            marginTop: -h + 25
        }, 250)
        $("#sitesearch").fadeIn(500);
            ss = 1;
            ql = 0;
        }    else {
        //show
        ss++
        $("#top-bar").stop().animate({
            marginTop: -h + 25
        }, 250)
        $("#sitesearch").fadeIn(500);
    }
    });	
	
//Member-bar  
$(".bar-nav").hover ( function() 
   {
     var children = jQuery(this).next(".hover-body");
     if (children.is(":hidden")) 
     {
       children.fadeIn(100);
     }
   },
   function() 
   {
      var children = jQuery(this).next(".hover-body");
      children.fadeOut(100);
   });

});

function showPopup(id) {
	$.facebox($('#'+id));
	$('#'+id).show();
}
