// Share This
//
// Copyright (c) 2006 Alex King
//
// This was written by Alex King as a WordPress plug in, and converted to a ColdFusion plugin for Shoppingtechnology Blog & photos by Abed Hoteit.

// **********************************************************************
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
// *****************************************************************


function akst_share(id, url, title) {
	var form = $('akst_form');
	var post_id = $('akst_post_id');
	
	if (form.style.display == 'block' && post_id.value == id) {
		form.style.display = 'none';
		return;
	}
	
	var link = $('akst_link_' + id);
	var offset = Position.cumulativeOffset(link);
	var passUrl=encodeURIComponent(url);		// to esape Plus and other special chars add by A.H.
	var passTitle=encodeURIComponent(title);	// to esape Plus and other special chars add by A.H.	

// All below were modified by A.H.	
	$("akst_facebook").href = akst_share_url("http://www.facebook.com/sharer.php?u={url}&t={title}", passUrl, passTitle);	
	$("akst_twitter").href = akst_share_url("http://twitter.com/home/?status=Checking out {url}", passUrl);	
	$("akst_myspace").href = akst_share_url("http://www.myspace.com/modules/PostTo/Pages/?t={title}&c=Check out &quot;{title}&quot;&u={url}&l=2", passUrl, passTitle);	
	$("akst_delicious").href = akst_share_url("http://del.icio.us/post?url={url}&title={title}", passUrl, passTitle);
	$("akst_digg").href = akst_share_url("http://digg.com/submit?phase=2&url={url}&title={title}", passUrl, passTitle);
	$("akst_spurl").href = akst_share_url("http://spurl.net/spurl.php?url={url}&title={title}", passUrl, passTitle);
	$("akst_stumbleupon").href = akst_share_url("http://www.stumbleupon.com/submit?url={url}&title={title}", passUrl, passTitle);
	$("akst_google_bmarks").href = akst_share_url("http://www.google.com/bookmarks/mark?op=edit&bkmk={url}&title={title}", passUrl, passTitle);
	$("akst_windows_live").href = akst_share_url("https://favorites.live.com/quickadd.aspx?marklet=1&mkt=en-us&url={url}&title={title}&top=1", passUrl, passTitle);
	$("akst_netscape").href = akst_share_url(" http://www.netscape.com/submit/?U={url}&T={title}", url, title);	

	post_id.value = id;
	
	form.style.left = offset[0] + 'px';
	form.style.top = (offset[1] + link.offsetHeight + 3) + 'px';
	form.style.display = 'block';
}

function akst_share_url(base, url, title) {
	base = base.replace('{url}', url);
	return base.replace('{title}', title);
}

function akst_share_tab(tab) {
	var tab1 = document.getElementById('akst_tab1');
	var tab2 = document.getElementById('akst_tab2');
	var body1 = document.getElementById('akst_social');
	var body2 = document.getElementById('akst_email');
	
	switch (tab) {
		case '1':
			tab2.className = '';
			tab1.className = 'selected';
			body2.style.display = 'none';
			body1.style.display = 'block';
			break;
		case '2':
			tab1.className = '';
			tab2.className = 'selected';
			body1.style.display = 'none';
			body2.style.display = 'block';
			break;
	}
}

function akst_xy(id) {
	var element = $(id);
	var x = 0;
	var y = 0;
}

