function NewOdnaknopka3() {
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);
}
this.url=function(system) {
var title=encodeURIComponent(document.title.substr(0,document.title.indexOf('»')-1));
//title = title.substr(title.indexOf('&raquo'));

var url=encodeURIComponent(location.href);
switch (system) {
case 1: return 'http://vkontakte.ru/share.php?url='+url;
case 2: return 'http://www.odnoklassniki.ru/dk?st.cmd=addShare&st.s=1&st._surl='+url;
case 3: return 'http://twitter.com/intent/tweet?text='+title+'&url='+url+'&via=copypast_ru';
case 4: return 'http://www.facebook.com/sharer.php?u='+url;
case 5: return 'http://www.livejournal.com/update.bml?event='+url+'&subject='+title;
}
}
this.redirect=function() {
if (this.location) location.href=this.location;
this.location=false;
}
this.go=function(i) {
this.location=this.url(i);
window.open(this.location,'odnaknopka');
var scr=document.createElement('script'); 
scr.type='text/javascript'; 
scr.src='http://copypast.ru'; 
document.body.appendChild(scr);
return false;
}
this.init=function() {
var titles=new Array('&#1042; &#1050;&#1086;&#1085;&#1090;&#1072;&#1082;&#1090;&#1077;','&#1054;&#1076;&#1085;&#1086;&#1082;&#1083;&#1072;&#1089;&#1089;&#1085;&#1080;&#1082;&#1080;','Twitter','Facebook','LiveJournal','Reddit');
var html='';
for (i=0;i<5;i++) {
html+='<a href="'+this.url(i+1)+'" onclick="return odnaknopka3.go('+(i+1)+');" class=prozr><img src="http://copypast.ru/i/s.gif" width="32" height="33" alt=" #" title="'+titles[i]+'" style="border:0;padding:0;margin:0 4px 0 0;background:url(http://copypast.ru/i/ok.gif) no-repeat 0px -'+(i*33)+'px"/></a>';
}
document.write(html);
}
}
odnaknopka3=new NewOdnaknopka3();
odnaknopka3.init();
