//-------- Для закладок браузера 
function getBrowserInfo() {
 var t,v = undefined;
 if (window.opera) t = 'Opera';
 else if (document.all) {
  t = 'IE';
  var nv = navigator.appVersion;
  var s = nv.indexOf('MSIE')+5;
  v = nv.substring(s,s+1);
 }
 else if (navigator.appName) t = 'Netscape';
 return {type:t,version:v};
}
 
function bookmark(a){
 var url = window.document.location;
 var title = window.document.title;
 var b = getBrowserInfo();
 if (b.type == 'IE' && b.version >= 4) window.external.AddFavorite(url,title);
 else if (b.type == 'Opera') {
  a.href = url;
  a.rel = "sidebar";
  a.title = title;
  return true;
 }
 else if (b.type == "Netscape") window.sidebar.addPanel(title,url,"");
 else alert("Нажмите CTRL-D, чтобы добавить страницу в закладки.");
 return false;
}



//--------- Ссылки
function NewServiceLinks() {
	
	this.domain=location.href+'/';
	this.domain=this.domain.substr(this.domain.indexOf('://')+3);
	this.domain=this.domain.substr(0,this.domain.indexOf('/'));
	this.location=false;
	this.selection=function() {
	
		var sel;
		if (window.getSelection) sel=window.getSelection();
		else if (document.selection) sel=document.selection.createRange();
		else sel='';
	
		if (sel.text) sel=sel.text;
		return encodeURIComponent(sel);
	}

	
	
	var Links = new Array();
	var title=encodeURIComponent(document.title);
	var url=encodeURIComponent(location.href);
	Links[1] = 'http://vkontakte.ru/share.php?url='+url;
	Links[2] = 'http://www.facebook.com/sharer.php?u='+url; 
	Links[3] = 'http://twitter.com/home?status='+title+' '+url;
	Links[4] = 'http://friendfeed.com/?title='+title+'&url='+url;
	Links[5] = 'http://www.livejournal.com/update.bml?event='+url+'&subject='+title;
	Links[6] = 'http://connect.mail.ru/share?share_url='+url;
	Links[7] = 'http://memori.ru/link/?sm=1&u_data[url]='+url+'&u_data[name]='+title; 
	Links[8] = 'http://www.google.com/bookmarks/mark?op=add&bkmk='+url+'&title='+title;
	Links[9] = 'http://zakladki.yandex.ru/newlink.xml?url='+url+'&name='+title;
	Links[10] = 'http://bobrdobr.ru/addext.html?url='+url+'&title='+title;
	Links[11] = 'http://www.mister-wong.ru/index.php?action=addurl&bm_url='+url+'&bm_description='+title;
	Links[12] = 'http://del.icio.us/post?v=4&noui&jump=close&url='+url+'&title='+title;
	Links[13] = 'http://moemesto.ru/post.php?url='+url+'&title='+title;
	Links[14] = 'http://www.100zakladok.ru/save/?bmurl='+url+'&bmtitle='+title;
	
	Links[15] = 'http://myscoop.ru/add/?URL='+url+'&title='+title;
	Links[16] = 'http://www.linkstore.ru/linkstore/temp.jsp?a=add&url='+url+'&title='+title;
	
	this.url=function(i) {
		return Links[i];
	}
	
	this.hide=function() {
		if (this.timeout) clearTimeout(this.timeout);
		$("#mk_sl").css( {'visibility': 'hidden'} );
	}
	this.show=function(element) {
		if (this.timeout) clearTimeout(this.timeout);
		$("#mk_sl").css( {'visibility': 'visible'} );
	}
	this.init=function() {
		var titles=new Array('Вконтакте',
							 'Facebook',
							 'Twitter',
							 'FriendFeeds',
							 'LiveJournal',
							 'Мой Мир',
							 'Memori',
							 'Google',
							 'Яндекс',
							 'БобрДобр',
							 'Mister Wong',
							 'Delicious',
							 'Мое Место',
							 'Сто Закладок',
							 'Myscoop',
							 'Linkstore.ru');
		if (document.getElementById('mk_sl')) {
			var div=document.getElementById('mk_sl');
			div.innerHTML='<span style="position:relative;top:0;margin:0;padding:0;width:130px;background:#fff;float:left;text-align:left;color:#c61618;font:normal 13px arial;line-height:20px"><b>&nbsp;&#1044;&#1086;&#1073;&#1072;&#1074;&#1080;&#1090;&#1100; &#1074;...</b></span>';
			div.innerHTML+='&nbsp;&nbsp;<img src="/images/starbm.gif" border="0" style="margin:2px;cursor:pointer;"  alt="Добавить в избранное браузера" onclick="return bookmark(this);"><a href="javascript:void(0);" onclick="return bookmark(this);" class="a_man" title="Добавить в избранное браузера" style="width:120px;color:#000;text-align:left;text-decoration:none;color:#000;font:normal 12px arial;line-height:25px;border:0" onmouseover="this.style.background=\'#fff2da\'" onmouseout="this.style.background=\'#fff\'" >&nbsp;Избранное</a><br />';

			for (i=0;i<8;i++) {
				div.innerHTML+='<a href="'+this.url(2*i+1)+'" target="_blank"><img src="/images/none.gif" width="16" height="16" alt=" #" title="'+titles[2*i]+'" style="border:0;padding:0;margin:2px;float:left;background:url(/images/smilesmilebm.gif) -'+(i*32)+'px"/></a><a href="'+this.url(2*i+1)+'" target="_blank" style="float:left;width:120px;text-align:left;text-decoration:none;color:#000;font:normal 12px arial;line-height:25px;border:0" onmouseover="this.style.background=\'#fff2da\'" onmouseout="this.style.background=\'#fff\'">&nbsp;'+titles[2*i]+'</a><a href="'+this.url(2*i+2)+'" target="_blank"><img src="/images/none.gif" width="16" height="16" alt=" #" title="'+titles[2*i+1]+'" style="border:0;padding:0;margin:2px;float:left;background:url(/images/smilesmilebm.gif) -'+(i*32+16)+'px"/></a><a href="'+this.url(2*i+2)+'" target="_blank" style="float:left;width:120px;color:#000;text-align:left;text-decoration:none;color:#000;font:normal 12px arial;line-height:25px;border:0" onmouseover="this.style.background=\'#fff2da\'" onmouseout="this.style.background=\'#fff\'">&nbsp;'+titles[2*i+1]+'</a><br />';
			}
			div.onmouseover=function() {if (smile_sl.timeout) clearTimeout(smile_sl.timeout)}
			div.onmouseout=function() {smile_sl.timeout=setTimeout('smile_sl.hide()',500)};

		}
		//document.write('<br><a href="" onclick="return false" onmouseover="smile_sl.show(this);" onmouseout="smile_sl.timeout=setTimeout(\'smile_sl.hide()\',500);"  class="btn" style="font-weight:normal;position:static"><img src="/images/sharebtn.gif" border="0"></a>');
		document.write('<br><a href="" onclick="return false" onmouseover="smile_sl.show(this);" onmouseout="smile_sl.timeout=setTimeout(\'smile_sl.hide()\',500);"  style="font-weight:normal;position:static"><img src="/images/sharebtn.gif" border="0"></a>');
	}
}
