/* 

Atlantic Sharing Script
v. 1.0

last mod: 7-31-08
by: Mark

Social Bookmarking and Sharing Scripts.
Modified from the NY Times' articleShare.

*/

function getSharePasskey() { return ''; }

function getShareURL()
{ return encodeURIComponent(window.location); }

function getShareHeadline() { return encodeURIComponent(document.title); }

function getShareDescription() { return encodeURIComponent(''); }

function getShareKeywords() { return encodeURIComponent(''); }

function getShareSection() { return encodeURIComponent(''); }

function getShareSectionDisplay() { return encodeURIComponent(''); }

function getShareSubSection() { return encodeURIComponent(''); }

function getShareByline() { return encodeURIComponent(''); }

function getSharePubdate() { 
	var ct = new Date();
	var m = ct.getMonth() + 1;
	var d = ct.getDate();
	var y = ct.getFullYear();
	var today = m + " " + d + ", " + y;
	
	return encodeURIComponent(today);
}



function share(site) {
	
	var popUpUrl;
    var title = getShareHeadline();
    var description = getShareDescription();
	
	switch (site) {
	
	case "facebook":
		popUpUrl = getShareURL();
		postPopUp('http://www.facebook.com/sharer.php?u=' + popUpUrl + '&t=' + title, 'facebook', 'toolbar=0,status=0,height=436,width=646,scrollbars=yes,resizable=yes');
		break;
	
	case "digg":
		popUpUrl = getShareURL();
		var topic = getShareSection();	
		postPopUp('http://digg.com/submit?url=' + popUpUrl + '&title=' + title + '&bodytext=' + description, 'digg', 'toolbar=0,status=0,height=450,width=650,scrollbars=yes,resizable=yes');
		break;
	
	case "delicious":
		popUpUrl = getShareURL();
		postPopUp('http://del.icio.us/post?url=' + popUpUrl + '&title=' + title + '&bodytext=' + description, 'delicious', 'toolbar=0,status=0,height=400,width=700,scrollbars=yes,resizable=no');
		break;
		
	case "stumbleupon":
		popUpUrl = getShareURL();
		postPopUp('http://www.stumbleupon.com/submit?url=' + popUpUrl + '&title=' + title, 'stumbleupon', 'toolbar=0,status=0,height=400,width=700,scrollbars=yes,resizable=no');
		break;
		
	case "twitthis":
		popUpUrl = getShareURL();
		postPopUp('http://twitthis.com/twit?url=' + popUpUrl, 'twitthis', 'toolbar=0,status=0,height=400,width=700,scrollbars=yes,resizable=no');
		break;
		
	case "twitter":
		popUpUrl = getShareURL();
		postPopUp('http://twitter.com/home/?status=' + title + ': ' + popUpUrl, 'twitter', 'toolbar=0,status=0,height=400,width=700,scrollbars=yes,resizable=no');
		break;
		
	case "google":
		popUpUrl = getShareURL();
		postPopUp('http://www.google.com/bookmarks/mark?op=edit&bkmk=' + popUpUrl + '&title=' + title, 'google', 'toolbar=0,status=0,height=400,width=700,scrollbars=yes,resizable=no');
		break;
		
	case "myspace":
		popUpUrl = getShareURL();
		postPopUp('http://www.myspace.com/index.cfm?fuseaction=postto&u=' + popUpUrl + '&t=' + title, 'myspace', 'toolbar=0,status=0,height=700,width=700,scrollbars=yes,resizable=no');
		break;
		
	}
}

function generatePasskeyURL(tracker) {
	if(document.getElementById) {
		var passkey = getSharePasskey();
	
		// make sure passkey exists
		if(passkey != '') {
			if (decodeURIComponent(getShareURL()).indexOf('?') > 0) {
				return getShareURL() + encodeURIComponent('&' + passkey + '&partner=' + tracker + '&exprod=' + tracker);
			} else {
				return getShareURL() + encodeURIComponent('?' + passkey + '&partner=' + tracker + '&exprod=' + tracker);
			}
		} else {
			if (decodeURIComponent(getShareURL()).indexOf('?') > 0) {
				return getShareURL() + encodeURIComponent('&partner=' + tracker + '&exprod=' + tracker);
			} else {
				return getShareURL() + encodeURIComponent('?partner=' + tracker + '&exprod=' + tracker);
			}
		}
	}
}

function postPopUp(url, name, params) { var win = window.open(url, name, params); }