function open_popup(url) { 
        window.open(url, 'pop_up','height=800,width=556,resizable,left=10,top=10,scrollbars=no,toolbar=no');
        return false; 
}
jQuery.fn.expandSingleSection = function() {
	var element_already_open = 0;
	target = $(this);
	expanded_sections = $("div.expanded-section");
	
	if (expanded_sections.length > 0){
		this_element = $(expanded_sections[0]);
		if (this_element.attr("id") == target.attr("id")){
			element_already_open = 1;
		}
		this_element.removeClass("expanded-section").siblings("div.more-info").slideUp();
	}
	
	if (element_already_open === 0){
		target.addClass("expanded-section").siblings("div.more-info").slideToggle();
	}
	
	return false;
};
function count_page(uri, title) {
    $.post("/track/page/", { uri: uri, title: title });
}

$(document).ready(function() {
    $("div#most-popular ul.tabs li").click(function(){
        tab = $(this);
        if (!tab.hasClass("selected")){
           tab.addClass("selected").siblings().removeClass("selected");
           panel_id = "div#" + tab.attr("id") + "-panel";
           $(panel_id).addClass("visible").siblings().removeClass("visible");
        }
    });
    
    function did_make_comment(){
            var rx = /\?c=([0-9]+)/;
            var qs = window.location.search;
            var matches = qs.match(rx);
            if (matches !== null){
                var comment = $("#c" + matches[1]);
                $('html,body').animate({
                    scrollTop: (comment.position().top - 50)
                }, 1000);
                comment.css("background-color","#ffffcc");
                comment.animate({
                    backgroundColor: "white"
                }, 4000);
                return true;
            }
            return false;
        }
    
    did_make_comment();
});
