function fbs_click() {
	u=location.href;
	t=document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}

function getShareUrl(theService) {
	var theUrl = "";

	switch(theService) {
		case "digg":
  			theUrl = "http://digg.com/submit";
			theUrl += "?url=" + shareLocation;
			theUrl += "&title=" + shareTitle;
			theUrl += "&bodytext=" + shareBlurb;
			theUrl += "&media=news";
			theUrl += "&topic=movies";
  			break;    
		case "facebook":
  			theUrl = "return fbs_click()";
  			break;
		case "delicious":
  			theUrl = "window.open('http://del.icio.us/post?v=4&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=700,height=400'); return false;";
  			break;
		case "reddit":
  			theUrl = "http://reddit.com/submit";
			theUrl += "?url=" + shareLocation;
			theUrl += "&title=" + shareTitle;  			
  			break;
		case "stumbleupon":
  			theUrl = "http://www.stumbleupon.com/submit";
			theUrl += "?url=" + shareLocation;
			theUrl += "%26title%3D" + shareTitle;
  			break;
		case "mixx":
  			theUrl = "http://www.mixx.com/submit";
			theUrl += "?page_url=" + shareLocation;
  			break;
	}
	return theUrl;
}

function initSharePanel() {
    $("#diggIcon,#diggLink").attr({href:getShareUrl("digg")});
    $("#facebookIcon,#facebookLink").attr({onclick:getShareUrl("facebook")});
	$("#deliciousIcon,#deliciousLink").attr({onclick:getShareUrl("delicious")});
	$("#redditIcon,#redditLink").attr({href:getShareUrl("reddit")});
	$("#stumbleuponIcon,#stumbleuponLink").attr({href:getShareUrl("stumbleupon")});
	$("#mixxIcon,#mixxLink").attr({href:getShareUrl("mixx")});
}

$(document).ready(function() {
	$("div.overout").mouseover(function(){
			$("p:first",this).text("mouse over");
			$("p:last",this).text(++i);
	})
    		
	$.fn.cluetip.defaults = {  // default options; override as needed
	    width:            148,      // The width of the clueTip
	    height:           'auto',   // The height of the clueTip. more info below [1]
	    cluezIndex:       97,       // Sets the z-index style property of the clueTip
	    positionBy:       'auto',   // Sets the type of positioning. more info below [2]
	    topOffset:        -20,       // Number of px to offset clueTip from top of invoking element. more info below [3]
	    leftOffset:       -52,       // Number of px to offset clueTip from left of invoking element. more info below [4]
	    local:            true,    // Whether to use content from the same page for the clueTip's body
	                                // (treats the attribute used for accessing the tip as a jQuery selector,
	                                // but only selects the first element if the selector matches more than one). more info below [5]
	    hideLocal:        true,     // If local option is set to true, this determines whether local content
	                                //  to be shown in clueTip should be hidden at its original location
	    attribute:        'rel',    // the attribute to be used for fetching the clueTip's body content
	    titleAttribute:   'title',  // the attribute to be used for fetching the clueTip's title
	    splitTitle:       '',       // A character used to split the title attribute into the clueTip title and divs
	                                // within the clueTip body. more info below [6]
	    showTitle:        false,    // show title bar of the clueTip, even if title attribute not set
	    cluetipClass:     'default',// class added to outermost clueTip div in the form of 'cluetip-' + clueTipClass. more info below [7]
	    hoverClass:       '',       // class applied to the invoking element onmouseover and removed onmouseout
	    waitImage:        false,     // whether to show a "loading" img, which is set in jquery.cluetip.css
	    arrows:           false,    // if true, displays arrow on appropriate side of clueTip. more info below [8]
	    dropShadow:       false,    // set to false if you don't want the drop-shadow effect on the clueTip
	    dropShadowSteps:  6,        // adjusts the size of the drop shadow
	    sticky:           true,     // keep visible until manually closed
	    mouseOutClose:    true,     // close when clueTip is moused out
	    activation:       'hover',  // set to 'click' to force user to click to show clueTip
	    clickThrough:     false,    // if true, and activation is not 'click', then clicking on a clueTipped link will take user to 
	                                // the link's href, even if href and tipAttribute are equal
	    tracking:         false,    // if true, clueTip will track mouse movement (experimental)
	    delayedClose:     0,        // close clueTip on a timed delay (experimental)
	    closePosition:    'top',    // location of close text for sticky cluetips; can be 'top' or 'bottom' or 'title'
	    closeText:        '<img src="/img/global/share_close.png" />',  // text (or HTML) to to be clicked to close sticky clueTips
	    truncate:         0,        // number of characters to truncate clueTip's contents. if 0, no truncation occurs
	
	    // effect and speed for opening clueTips
	    fx: {             
	                      open:       'show', // can be 'show' or 'slideDown' or 'fadeIn'
	                      openSpeed:  ''
	    },
	                  
	    // function to run just before clueTip is shown.            
	    onActivate:       function(e) {return true;},
	
	    // function to run just after clueTip is shown.
	    onShow:           function(ct, c){},
	    
	    // whether to cache results of ajax request to avoid unnecessary hits to server
	    ajaxCache:        true,     
	    
	    // process data retrieved via xhr before it's displayed
	    ajaxProcess:      function(data) {
	                        data = $(data).not('style, meta, link, script, title');
	                        return data;
	    },
	    
	    // can pass in standard $.ajax() parameters, not including error, complete, success, and url
	    ajaxSettings: {   
	                      dataType: 'html'
	    }
	  };
	$("a.shareLink").cluetip({local:true, cursor: 'pointer'});
	
	initSharePanel();
	populateEmailThisLinks();

	/* begin popup settings */	
	var popupProfiles =
	{
		emailThis:
		{
			height:417,
			width:546,
			status:0,
			toolbar:0,
			scrollbars:0,
			resizable:0,
			center:1,
			createnew:0
		}
	};
	
	$(function() {
		$(".popupwindow").popupwindow(popupProfiles);
	});
	/* end popup settings */
});

function populateEmailThisLinks() {
		var emailThisUrl = "/email_this.jsp?popupwindow";
		emailThisUrl += "&url=" + shareLocation;
		emailThisUrl += "&title=" + shareTitle;
		emailThisUrl += "&world=" + worldName;
		$(".emailThisLink").attr({href:emailThisUrl});
}