//
// (c) 2008 primeadd.net
// Service Widget
//
document.write('<style type="text/css">' +
 '#f_1740112942_primadd { width: 100%; overflow: hidden; padding: 0px; margin: 0px; list-style-type: none; }' +
 '#f_1740112942_primadd_icons { padding: 0px; margin: 0px; float:left;}' +
 '#f_1740112942_primadd_menu { position: absolute; background-color: white; border:1px solid black; font: normal 13px Verdana; z-index: 1000; visibility: hidden; padding-bottom: 10px;}' +
 '#f_1740112942_primadd_menu ul { list-style-type: none; padding: 0px; margin: 0px; overflow: hidden;}' +
 '#f_1740112942_primadd_menu li { float: left; display: block;}' +
 '#f_1740112942_primadd_menu li .tmp { margin-right: 4px; margin-top: 2px; background: url("//primadd.net/icon/services_32x32_2.gif") no-repeat; width: 32px; height: 32px; line-height: 32px; display: block; float: left;}' +
 '#f_1740112942_primadd_menu li .tmp2 { width: 176px; padding-left: 4px; float: left; line-height: 40px;}' +
 '#f_1740112942_primadd_menu li a { font-size: 12px; display: block; text-decoration: none; color: black;}' +
 '#f_1740112942_primadd_menu li a:hover { background-color: #bfdfbf;}' +
 '#f_1740112942_primadd div { width: 32px; height: 32px; background: url("//primadd.net/icon/services_32x32_2.gif") no-repeat; padding-right: 10px; }' +
 '#f_1740112942_primadd img { border:none; }' +
 '</style>');

document.write('<ul id="f_1740112942_primadd"><li id="f_1740112942_primadd_icons"></li><li><a href="#" onMouseover="f_1740112942_primadd_showmenu(event)" onMouseout="f_1740112942_primadd_hidemenu()">Bookmark</a></li></ul>');

var f_1740112942_defaultMenuWidth="360px" //set default menu width.

window.setTimeout("f_1740112942_primadd_animImg()", 0);
var f_1740112942_primadd_imgCnt = 0;

function f_1740112942_primadd_animImg()
{

	if (f_1740112942_primadd_imgCnt >= f_1740112942_list.length)
		f_1740112942_primadd_imgCnt = 0;
		
	document.getElementById('f_1740112942_primadd_icons').innerHTML = '<div style="background-position: 0px -'+(f_1740112942_list[f_1740112942_primadd_imgCnt][2]*32)+'px;">&nbsp;</div>'

	f_1740112942_primadd_imgCnt++;
	window.setTimeout("f_1740112942_primadd_animImg()", 1000);
}
var f_1740112942_list=new Array(
new Array('whatsthis', 'whatsthis', 0, 'http://en.wikipedia.com/', "what's this?"),
new Array('google_bookmarks', 'Google Bookmarks', 3, 'http://www.google.com/', ""),
new Array('delicious', 'del.icio.us', 4, 'http://del.icio.us/', ""),
new Array('slashdot', 'slashdot', 5, 'http://slashdot.org/', ""),
new Array('reddit', 'reddit', 7, 'http://reddit.com/', ""),
new Array('technorati', 'Technorati', 8, 'http://technorati.com/', ""),
new Array('facebook', 'Facebook', 9, 'http://www.facebook.com/', ""),
new Array('mister_wong', 'Mister Wong', 15, 'http://www.mister-wong.de/', ""),
new Array('digg', 'digg', 21, 'http://digg.com/', ""),
new Array('magnolia', 'ma.gnolia', 31, 'http://ma.gnolia.com/', ""),
new Array('more', 'more', 1, 'http://primadd.net/', "for more services"));
function f_1740112942_gotoService(service)
{
	subUrl = '//primadd.net/services/' + service + '/';
	if (service == 'more') subUrl = '//primadd.net/bookmark/submit/'
	url = subUrl + '?title='+encodeURIComponent(document.title)+'&url='+encodeURIComponent(window.location.href);
	window.open(url);
  
	if(typeof 'f_1740112942_hidemenu' == 'function')
	{
		f_1740112942_hidemenu();
	}
}
var ie5 = document.all && !window.opera;
var ns6 = document.getElementById;

if (ie5 || ns6)
{
  document.write('<span id="f_1740112942_primadd_menu" onMouseover="f_1740112942_clearhidemenu();" onMouseout="f_1740112942_dynamichide(event)"></span>');
}

function f_1740112942_addLinks()
{
	var ret = '<ul>';
	for (var i = 0; i < f_1740112942_list.length; i++)
	{
		var service = f_1740112942_list[i][0];
		var offset_y = f_1740112942_list[i][2];
		var domain = f_1740112942_list[i][3];
		var txt = ''
		if (f_1740112942_list[i][4] != '') 
			txt = f_1740112942_list[i][4];
		else
			txt = f_1740112942_list[i][1];
		
		ret += '<li><a class="tmp2" onclick="f_1740112942_gotoService('+"'"+service+"'"+');return false;" href="'+ domain + '">' + 
		'<div class="tmp" style="background-position: 0px -'+(offset_y*32)+'px;"></div><span>' + txt + '</span></a></li>';
	}
	return ret + '</ul>';
}

function iecompattest()
{
  return (document.compatMode && document.compatMode.indexOf('CSS') != -1) ? document.documentElement : document.body;
}

function f_1740112942_primadd_showmenu(e, optWidth)
{
	if (!document.all&&!document.getElementById)
	{
		// no dom model
		return;
	}
	
	f_1740112942_clearhidemenu();
	
	menuobj = ie5 ? document.all.f_1740112942_primadd_menu : document.getElementById('f_1740112942_primadd_menu');
	menuobj.innerHTML     = 'Add Article to' + f_1740112942_addLinks();
	menuobj.style.width   = (typeof optWidth != 'undefined') ? optWidth : f_1740112942_defaultMenuWidth;
	menuobj.contentwidth  = menuobj.offsetWidth;
	menuobj.contentheight = menuobj.offsetHeight;
	var eventX = ie5 ? event.clientX : e.clientX;
	var eventY = ie5 ? event.clientY : e.clientY;

	//Find out how close the mouse is to the corner of the window
	var rightedge  = ie5 ? iecompattest().clientWidth  - eventX : window.innerWidth  - eventX;
	var bottomedge = ie5 ? iecompattest().clientHeight - eventY : window.innerHeight - eventY;
	
/*	
	//if the horizontal distance isn't enough to accomodate the width of the context menu
	if (rightedge < menuobj.contentwidth)
	{
	  //move the horizontal position of the menu to the left by it's width
		menuobj.style.left = ie5 ? iecompattest().scrollLeft + eventX - menuobj.contentwidth + 'px'
		  : window.pageXOffset + eventX-menuobj.contentwidth + 'px';
	}
	else
	{
		//position the horizontal position of the menu where the mouse was clicked
		menuobj.style.left = ie5 ? iecompattest().scrollLeft + eventX + 'px' : window.pageXOffset + eventX + 'px';
	}

	//same concept with the vertical position
  if (bottomedge<menuobj.contentheight)
  {
    menuobj.style.top = ie5 ? iecompattest().scrollTop + eventY - menuobj.contentheight + 'px'
       : window.pageYOffset + eventY - menuobj.contentheight + 'px';
  }
  else
  {
    menuobj.style.top = ie5 ? iecompattest().scrollTop + event.clientY + 'px'
       : window.pageYOffset + eventY + 'px';
  }*/

  menuobj.style.visibility = 'visible';
  return false;
}

function f_1740112942_contains_ns6(a, b)
{
  // Determines if 1 element in contained in another
  while (b.parentNode)
  {
    if ((b = b.parentNode) == a)
    {
      return true;
    }
  }
  return false;
}

function f_1740112942_hidemenu()
{
  if (window.menuobj)
  {
    menuobj.style.visibility = 'hidden';
  }
}

function f_1740112942_dynamichide(e)
{
  if (ie5 && !menuobj.contains(e.toElement))
  {
    f_1740112942_hidemenu();
  }
  else if (ns6 && e.currentTarget != e.relatedTarget && !f_1740112942_contains_ns6(e.currentTarget, e.relatedTarget))
  {
    f_1740112942_hidemenu();
  }
}

function f_1740112942_primadd_hidemenu()
{
  f_1740112942_delayhide = setTimeout('f_1740112942_hidemenu()', 500);
}

function f_1740112942_clearhidemenu()
{
	if (window.f_1740112942_delayhide)
	{
    clearTimeout(f_1740112942_delayhide);
  }
}

if (ie5||ns6)
{
  document.onclick = f_1740112942_hidemenu;
}

