﻿jQuery(document).ready(function($) {
    $('#sharing-click').live("click", function() {
        $('#sharing').fadeThenSlideToggle();
        $('#sharing-image').fadeOut("fast", function() {
            if ($('#sharing-image').attr("src") == "/images/icons/navigate_open.png") { $('#sharing-image').attr("src", "/images/icons/navigate_close.png"); }
            else { $('#sharing-image').attr("src", "/images/icons/navigate_open.png"); }
            $('#sharing-image').fadeIn("fast");
        });
    });

    $('#contribute-click').live("click", function() {
        $('#contribute-options').fadeThenSlideToggle();
        $('#contribute-image').fadeOut("fast", function() {
            if ($('#contribute-image').attr("src") == "/images/icons/navigate_open.png") { $('#contribute-image').attr("src", "/images/icons/navigate_close.png"); }
            else { $('#contribute-image').attr("src", "/images/icons/navigate_open.png"); }
            $('#contribute-image').fadeIn("fast");
        });
    });

    $('#data-click').live("click", function() {
        $('#data').fadeThenSlideToggle();
        $('#data-image').fadeOut("fast", function() {
            if ($('#data-image').attr("src") == "/images/icons/navigate_open.png") { $('#data-image').attr("src", "/images/icons/navigate_close.png"); }
            else { $('#data-image').attr("src", "/images/icons/navigate_open.png"); }
            $('#data-image').fadeIn("fast");
        });
    });
});

jQuery.fn.fadeThenSlideToggle = function(speed, easing, callback) { if (this.is(":hidden")) { return this.slideDown(speed, easing).fadeTo(speed, 1, easing, callback); } else { return this.fadeTo(speed, 0, easing).slideUp(speed, easing, callback); } };
jQuery.fn.equalizeCols = function() {
        var height = 0,
			reset = jQuery.browser.msie ? "1%" : "auto";

        return this
			.css("height", reset)
			.each(function() {
			    height = Math.max(height, jQuery(this).outerHeight(true));
			})
			.css("height", height)
			.each(function() {
			    var h = jQuery(this).outerHeight(true);
			    if (h > height) {
			        jQuery(this).css("height", height - (h - height));
			    };
			});

    };

function getQS(name) { name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); var regexS = "[\\?&]" + name + "=([^&#]*)"; var regex = new RegExp(regexS); var results = regex.exec(window.location.href); if (results == null) return ""; else return results[1]; }
