﻿/***************************************************************
 * author: Leonhardt Multimedia GmbH - Stefan Fischer	
 * version: 1.0
 * date: 2011-03-29
 *
 ***************************************************************/

var iBeginShareInit=new iBeginShareMod();
iBeginShareInit.init();

function iBeginShareMod(){
	this.fileCss = 'http://www.bosch.si/content/ibegin-share/share.css';
	this.bookmarkLabel = 'Povej naprej';

	this.init = function(){
		var head = document.getElementsByTagName('head')[0];
		var link = document.createElement('link');
		link.rel = 'stylesheet';
		link.type = 'text/css';
		link.href = this.fileCss;
		head.appendChild(link);

		iBeginShare.plugins.builtin.bookmarks.addService('Twitter', 'http://twitter.com/share?text=__TITLE__&url=__URL__');
		iBeginShare.plugins.builtin.bookmarks.addService('Facebook', 'http://www.facebook.com/share.php?src=bm&u=__URL__&t=__TITLE__&v=3');
		iBeginShare.plugins.builtin.bookmarks.addService('MySpace', 'http://www.myspace.com/Modules/PostTo/Pages/?t=__TITLE__&c=%20&u=__URL__&l=2');
		iBeginShare.plugins.builtin.bookmarks.addService('Google', 'http://www.google.com/bookmarks/mark?op=add&title=__TITLE__&bkmk=__URL__');
		iBeginShare.plugins.builtin.bookmarks.addService('LinkedIn', 'http://www.linkedin.com/shareArticle?mini=true&url=__URL__&title=__TITLE__');
		iBeginShare.plugins.builtin.bookmarks.addService('Digg', 'http://digg.com/submit?url=__URL__&title=__TITLE__');
		
		// Uncomment any of these lines to disable plugin registration.
		// Adjust the order to adjust the order of tabs.
		iBeginShare.plugins.register(
			iBeginShare.plugins.builtin.bookmarks
			//iBeginShare.plugins.builtin.email,
			//iBeginShare.plugins.builtin.mypc,
			//iBeginShare.plugins.builtin.printer
		);
		iBeginShare.close_label = "";
		iBeginShare.plugins.builtin.bookmarks.label = this.bookmarkLabel;
		
		iBeginShare.attachLink('share-tool', {link: '', title: '', link_style: 'text', link_label: this.bookmarkLabel});
		iBeginShare.addEvent(document.getElementById("share-tool"), 'click', this.click);
		iBeginShare.addEvent(window, 'keydown', function(e){ if (e.keyCode == (window.event ? 27 : e.DOM_VK_ESCAPE)) { iBeginShare.hide(); }});
	}

	this.click = function(e){
		if ((navigator.userAgent.indexOf("MSIE")>=0 && document.compatMode=="CSS1Compat")||(navigator.userAgent.indexOf("MSIE")==-1)){
			if (!document.getElementById("share-box-overlay")){
				var divOverlay = document.createElement("div");
				divOverlay.setAttribute("id","share-box-overlay");
			  document.getElementById("share-box").appendChild(divOverlay);
			}
		}
	  document.getElementById("share-box").style.left=0;
	  var scrollTop = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop || window.pageYOffset || 0;
	  document.getElementById("share-box").style.top=parseInt(scrollTop+200)+"px";
		
	  document.getElementById("share-content").appendChild(document.getElementById("share-close"));
		document.getElementById("share-close").removeAttribute("title");
		if (document.getElementById("share-content").firstChild.tagName == "BR"){
			document.getElementById("share-content").removeChild(document.getElementById("share-content").firstChild);
		}
		
		var sci = document.getElementById("share-content-inner");
		var aTags = sci.getElementsByTagName("a");		
		for (var i = 0; i < aTags.length; i++) {
		 if(aTags[i].hasChildNodes()){
		 	var linktext = aTags[i].firstChild;
		  nodeLinktext = aTags[i].removeChild(linktext);
			var newNode = document.createElement("span");
			newNode.appendChild(nodeLinktext);
		  aTags[i].appendChild(newNode);
		 }
		}
	}

}

