var __share_href = document.location.href;
var __share_baseURL = __share_href.substring(0,__share_href.indexOf('/',__share_href.indexOf('//')+2));
var __share_hrefPre = __share_href.substring(0,__share_href.indexOf('//')+2);
var __share_hrefAft = __share_href.substring(__share_href.indexOf('/',__share_hrefPre.length));
var __share_ffr = '';
if ((__share_hrefAft.length >= 7) && (__share_hrefAft.substring(0,7).toLowerCase() == '/ffroot')) {
	__share_hrefAft = __share_hrefAft.substring(7);
	__share_ffr = '/ffroot';
}
__share_href = __share_hrefPre+'www.FunctionFox.com'+__share_hrefAft;

var __share_links = [
	/*
	,['Ask','http://myjeeves.ask.com/mysearch/BookmarkIt?v=1.2&t=webpages&url=%HREF%&title=%TITLE%']
	,['Backflip','http://www.backflip.com/add_page_pop.ihtml?url=%HREF%&title=%TITLE%']
	,['Blinklist','http://www.blinklist.com/index.php?Action=Blink/addblink.php&Description=&Tag=&url=%HREF%&Title=%TITLE%']
	,['Blogmarks','http://blogmarks.net/my/new.php?mini=1&simple=1&url=%HREF%&title=%TITLE%']
	,*/
	['Del.icio.us','http://del.icio.us/post?v=4&noui&jump=close&url=%HREF%&title=%TITLE%']
	,['Digg','http://digg.com/submit?phase=2&url=%HREF%&title=%TITLE%']
	/*
	,['Diigo','http://www.diigo.com/post?tag=&comments=&url=%HREF%&title=%TITLE%']
	,['Facebook','http://www.facebook.com/sharer.php?u=%HREF%&t=%TITLE%']
	,['Fark','http://cgi.fark.com/cgi/fark/submit.pl?new_url=%HREF%&new_comment=%TITLE%']
	,['Furl','http://www.furl.net/storeIt.jsp?keywords=&u=%HREF%&t=%TITLE%']
	,['Feed Me Links','http://feedmelinks.com/categorize?from=toolbar&op=submit&url=%HREF%&name=%TITLE%']
	*/
	,['Google Bookmark','http://www.google.com/bookmarks/mark?op=add&hl=en&bkmk=%HREF%&title=%TITLE%']
	/*
	,['LinkaGoGo','http://www.linkagogo.com/go/AddNoPopup?url=%HREF%&title=%TITLE%']
	,['Live Bookmarks','https://favorites.live.com/quickadd.aspx?marklet=1&mkt=en-ca&top=1&url=%HREF%&title=%TITLE%']
	,['Magnolia','http://ma.gnolia.com/bookmarklet/add?url=%HREF%&title=%TITLE%']
	,['Mixx','http://www.mixx.com/submit?page_url=%HREF%&page_title=%TITLE%']
	,['Mr Wong','http://www.mister-wong.de/index.php?action=addurl&bm_notice=&bm_tags=&bm_url=%HREF%&bm_description=%TITLE%']
	,['myAOL','http://favorites.my.aol.com/ffclient/webroot/0.4.3/src/html/addBookmarkDialog.html?favelet=true&url=%HREF%&title=%TITLE%']
	,['MySpace','http://ca.myspace.com/Modules/PostTo/Pages/?u=%HREF%&c=%TITLE%&t=%TITLE%']
	,['Netvouz','http://www.netvouz.com/action/submitBookmark?url=%HREF%&title=%TITLE%']
	,['Newsvine','http://www.newsvine.com/_tools/seed&save?u=%HREF%&h=%TITLE%']
	,['Propeller (Netscape)','http://www.netscape.com/submit/?U=%HREF%&T=%TITLE%']
	,['Reddit','http://reddit.com/submit?url=%HREF%&title=%TITLE%']
	,['Segnalo','http://segnalo.alice.it/login.html.php?uri=%HREF%&title=%TITLE%']
	,['Simpy','http://www.simpy.com/simpy/LinkAdd.do?tags=&note=&href=%HREF%&title=%TITLE%']
	,['Slashdot','http://slashdot.org/bookmark.pl?url=%HREF%&title=%TITLE%']
	,['Smarking','http://smarking.com/editbookmark/?tags=&url=%HREF%&description=%TITLE%']
	,['Spurl','http://www.spurl.net/spurl.php?v=3&tags=&url=%HREF%&title=%TITLE%']
	,['StumbleUpon','http://www.stumbleupon.com/submit?url=%HREF%&title=%TITLE%']
	,['Technorati','http://technorati.com/faves?tag=&add=%HREF%&title=%TITLE%']
	,['Twitter','http://twitter.com/home/?status=Check%20Out+%HREF%']
	,['Webnews','http://www.webnews.de/einstellen?url=%HREF%&title=%TITLE%']
	,['Yahoo MyWeb','http://myweb.yahoo.com/myresults/bookmarklet?ei=UTF-8&u=%HREF%&t=%TITLE%']
	,['Yahoo Bookmarks','http://bookmarks.yahoo.com/toolbar/savebm/opener?tb=amp&u=%HREF%&t=%TITLE%']
	*/
];
function __share_handlerMM(e) {
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) return [e.pageX,e.pageY];
	if (e.clientX || e.clientY) return [e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft, e.clientY+document.body.scrollTop+document.documentElement.scrollTop];
	return [0,0];
}
function __share_findPos(el) {
	var arPos = [el.offsetLeft,el.offsetTop];
	while (el = el.offsetParent) {
		arPos[0] += el.offsetLeft;
		arPos[1] += el.offsetTop;
	}
	return arPos;
}
function __share_noMoreEvents(e) {
	if (!e) var e = window.event;
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
}
function __share_share(e,el) {
	if (document.getElementById('__share_tblShare')) return;
	__share_noMoreEvents(e);
	var arPos = __share_findPos(el);
	var opts = '<a href="" onclick="return __share_shareViaEmail();">Email</a>';
	for (var i = 0; i < __share_links.length; i++) {
		var href = __share_links[i][1].replace('%HREF%',escape(__share_href)).replace('%TITLE%',escape(document.title));
		opts += '<br><a href="'+href+'" onclick="var tImg = new Image(1,1); tImg.src = \''+__share_ffr+'/images/t.gif?href='+escape(href)+'\';" target="_blank">'+__share_links[i][0]+'</a>';
	}
	var tbl = document.createElement('table');
	tbl.style.left = (arPos[0]+el.offsetWidth+20)+'px';
	tbl.style.top = (arPos[1])+'px';
	tbl.id = '__share_tblShare';
	tbl.style.position = 'absolute';
	tbl.style.color = '#04652C';
	tbl.style.backgroundColor = '#FFFFFF';
	tbl.style.zIndex = '99';
	tbl.style.border = '2px solid #04652C';
	var tr = tbl.insertRow(-1);
	var td = tr.insertCell(-1);
	td.innerHTML = opts;
	td.style.padding = '1em 0 1em 1em';
	td = tr.insertCell(-1);
	td.innerHTML = '<span style="font-weight: bold; cursor: pointer;" onclick="__share_removeTable(this);">X</span>';
	td.style.textAlign = 'right';
	td.style.padding = '2px';
	td.style.verticalAlign = 'top';
	tbl.onmousedown = function(event) {__share_tblOnMouseDown(event,this);};
	tbl.onmouseup = function(event) {__share_tblOnMouseUp(event,this);};
	document.body.appendChild(tbl);
}
var __share_arOnMDownPos = [0,0];
function __share_tblOnMouseDown(e,el) {
	__share_arOnMDownPos = __share_handlerMM(e);
	el.onmousemove = function(event) {__share_tblOnMouseMove(event,el);};
}
function __share_tblOnMouseUp(e,el) {
	el.onmousemove = null;
}
function __share_tblOnMouseMove(e,el) {
	var arCurPos = __share_handlerMM(e);
	el.style.left = (parseInt(el.style.left,10)+arCurPos[0]-__share_arOnMDownPos[0])+'px';
	el.style.top = (parseInt(el.style.top,10)+arCurPos[1]-__share_arOnMDownPos[1])+'px';
	__share_arOnMDownPos = arCurPos;
}
function __share_shareViaEmail() {
	var tbl = document.getElementById('__share_tblShare');
	var td = tbl.getElementsByTagName('td')[0];
	td.innerHTML = '<form id="frmShareViaEmail" name="frmShareViaEmail"><table>'
		+'<tr><td align="right"><b>From:</b></td><td width="10"></td><td><input name="from" size="200" style="width: 200px;"/></td></tr>'
		+'<tr><td align="right"><b>To:</b></td><td width="10"></td><td><input name="to" size="200" style="width: 200px;"/></td></tr>'
		+'<tr valign="top"><td align="right"><b>Message:</b></td><td width="10"></td><td><textarea name="msg" style="width: 200px;"></textarea></td></tr>'
		+'<tr><td></td><td width="10"></td><td><input type="button" onclick="__share_SendEmail(this);" value="Send Email"/></td></tr>'
		+'</table></form>'
	return false;
}
function __share_removeTable(tbl) {
	while (tbl.nodeName.toLowerCase() != 'table') tbl = tbl.parentNode;
	document.body.removeChild(tbl);
}
function __share_webRequest(url,handler) {
	this.xmlhttp=null;
	this.url = url;
	this.handler = handler;
	this.makeRequest();
}
__share_webRequest.prototype.makeRequest = function() {
	if (this.xmlhttp = this.newXHR()) {
		try {
			var thisWebRequest = this;
			this.xmlhttp.onreadystatechange = function() {
				thisWebRequest.onStateChange.call(thisWebRequest);
			}
			this.xmlhttp.open('GET',this.url,true); //widget does not seem to like post
			this.xmlhttp.setRequestHeader("Cache-Control", "no-cache");
			this.xmlhttp.send(null);
		} catch (err) {
			alert('ERROR: '+err.message);
		}
	} else {
		alert('Error: XHR not supported.');
	}
}
__share_webRequest.prototype.onStateChange = function() {
	if (this.xmlhttp.readyState == 4) {
		if (this.xmlhttp.status == 200) {
			if (this.handler) this.handler.call(this);
		} else {
			alert("Error: " + this.xmlhttp.responseText);
		}
	}
}
__share_webRequest.prototype.newXHR = function() {
	xmlhttp = null;
	try {
		xmlhttp = new XMLHttpRequest();
	} catch(errXHR1) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch(errXHR2) {
			alert('Error: XHR not supported.');
		}
	}
	return xmlhttp;
}
function __share_EmailSent() {
	var arPos = [400,400];
	var tblEmailSent = document.getElementById('__share_tblEmailSent');
	if (tblEmailSent) document.body.removeChild(tblEmailSent);
	var tblShare = document.getElementById('__share_tblShare');
	if (tblShare) arPos = __share_findPos(tblShare);
	var tbl = document.createElement('table');
	tbl.style.left = (arPos[0])+'px';
	tbl.style.top = (arPos[1])+'px';
	tbl.id = '__share_tblEmailSent';
	tbl.style.position = 'absolute';
	tbl.style.color = '#000000';
	tbl.style.backgroundColor = '#FFFFFF';
	tbl.style.zIndex = '99';
	tbl.style.border = '2px solid #04652C';
	tbl.style.width = '400px';
	var tr = tbl.insertRow(-1);
	var td = tr.insertCell(-1);
	td.innerHTML = this.xmlhttp.responseText;
	td.style.padding = '1em 0 1em 1em';
	td = tr.insertCell(-1);
	td.innerHTML = '<span style="font-weight: bold; cursor: pointer;" onclick="__share_removeTable(this);">X</span>';
	td.style.textAlign = 'right';
	td.style.padding = '2px';
	td.style.verticalAlign = 'top';
	tbl.onmousedown = function(event) {__share_tblOnMouseDown(event,this);};
	tbl.onmouseup = function(event) {__share_tblOnMouseUp(event,this);};
	document.body.appendChild(tbl);
}
function __share_SendEmail(el) {
	var frm = el;
	while (frm.tagName.toLowerCase() != 'form') frm = frm.parentNode;
	var err = '';
	if (! /\S+@\S+\.\S+/.exec(frm.from.value)) err += '\n- From email is required';
	if (! /\S+@\S+\.\S+/.exec(frm.to.value)) err += '\n- To email is required';
	if (err > '') {
		alert('Please fix the following:'+err);
		return;
	}
	var url = __share_baseURL+__share_ffr+'/shareEmail.asp';
	url += '?from='+escape(frm.from.value)
		+'&to='+escape(frm.to.value)
		+'&msg='+escape(frm.msg.value)
		+'&href='+escape(__share_href)
		+'&title='+escape(document.title);
	new __share_webRequest(url,__share_EmailSent);
}
