var $j = jQuery.noConflict();

$j(document).ready(function() {
    $j(".share").toggle(function() {
        $j("#rightShare").css("visibility", "visible");
        return false;
    },
	function() {
	    $j("#rightShare").css("visibility", "hidden");
	    return false;
	});

    $j(".delicious").click(function() {
        pageTracker._trackPageview('/Share/delicious');
        window.open('http://del.icio.us/post?url=' + window.location.href + '&title=' + document.title);
        return false;
    });

    $j(".digg").click(function() {
        pageTracker._trackPageview('/Share/digg');
        window.open('http://digg.com/submit?phase=2&url=' + window.location.href);
        return false;
    });

    $j(".facebook").click(function() {
        pageTracker._trackPageview('/Share/facebook');
        window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(window.location.href) + '&t=' +
		encodeURIComponent(document.title), 'sharer', 'toolbar=0, status=0, width=626, height=436');
        return false;
    });

    $j(".linkedin").click(function() {
        pageTracker._trackPageview('/Share/linkedin');
        var targetUrl = 'http://www.linkedin.com/shareArticle?mini=true&' + 'url=' +
		encodeURIComponent(window.location.href) + "&title=" +
		encodeURIComponent(document.title) + '&summary=' +
		encodeURIComponent($j("#content").text().slice(0, 200) + "...") + '&source=' +
		encodeURIComponent("Keane");
        window.open(targetUrl, 'sharer', 'toolbar=0, status=0, width=520, height=570');
        return false;
    });

    $j(".reddit").click(function() {
        pageTracker._trackPageview('/Share/reddot');
        window.open('http://reddit.com/submit?url=' + window.location.href + '&title=' + document.title);
        return false;
    });

    $j(".stumbleupon").click(function() {
        pageTracker._trackPageview('/Share/stumbleupon');
        window.open('http://www.stumbleupon.com/submit?url=' + window.location.href);
        return false;
    });

    $j(".email").click(function() {
        pageTracker._trackPageview('/Share/email');
        window.location = 'mailto:TypeEmailHere?subject=Visit this link from Keane&body=' +
		document.title + ' - ' + window.location.href;
        return false;
    });

    $j(".print").click(function() {
        pageTracker._trackPageview('/Share/print');
        window.print();
        return false;
    });

    $j(".textUp").click(function() {
        $j("#content").css('font-size', 18);
        $j("#content").css('line-height', "22px");
        $j(".calloutText").css('font-size', 18);
        $j(".calloutText").css('line-height', "22px");
        $j(".calloutTable").css('font-size', 18);
        $j(".calloutTable").css('line-height', "22px");
        return false;
    });

    $j(".textDown").click(function() {
        $j("#content").css('font-size', 13);
        $j("#content").css('line-height', "16px");
        $j(".calloutText").css('font-size', 13);
        $j(".calloutText").css('line-height', "16px");
        $j(".calloutTable").css('font-size', 13);
        $j(".calloutTable").css('line-height', "16px");
        return false;
    });

    $j("#regionModal").dialog({ autoOpen: false, modal: true, width: 997, height: 160, resizable: false, position: ['center', 'top'] });

    $j(".changeRegion").click(function() {
        $j("#regionModal").dialog("open");
        return false;
    });
});
