

$(document).ready(function() {

	//SHARE THIS PAGE
	var inputFocus = null;
	var shareTimeout;
	
	//Share this page events
	$('.share').hide();
	
	$('.ShareButton').click( function() {
		$('.share').fadeIn("slow");
		$(document).bind('mousedown', checkMouse);
	});
	    	
});


//helper methods

//close when click outside of element
var checkMouse = function(element)
{
        var element = $(element.target)[0];
        var observe = $('.shareWrap')[0];

        while(true)
        {
                if(element == observe)
                {
                        return true;
                }
                else if(element == document)
                {
                        return closeSharePage();
                }
                else
                {
                        element = $(element).parent()[0];
                }
        }

        return true;

};


function closeSharePage(){
	$('.share').fadeOut("slow");
}