function include2(url) {
  var script = document.createElement('script');
  script.setAttribute('type', 'text/javascript')
  script.setAttribute('src', url);
  document.getElementsByTagName('head').item(0).appendChild(script);
}

function getXMLHTTPRequest() {
	try {
		req = new XMLHttpRequest();
	} catch(err1) {
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (err2) {
				try {
						req = new ActiveXObject("Microsoft.XMLHTTP");
					} catch (err3) {
							req = false;
					}
		}
	}
	return req;
}

function getmeta(what) {
	metaCollection = document.getElementsByTagName('meta');
	
	for (ii=0;ii<metaCollection.length;ii++) {
		nameAttribute = metaCollection[ii].name.search(what);
		
		if (nameAttribute!= -1) {
			return metaCollection[ii].content;
		}
	}
}

function Newwykop2() {
	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.redirect=function() {
		if (this.location) window.open(this.location,'_blank');
	//	this.location=false;
	}
	
	var kopayurl = 'links.tochka.net';
	
	this.go=function(i) {
	
		//if(i != 1) {
			
			var title = encodeURIComponent(document.title);
			var tags = encodeURIComponent(getmeta('keywords'));
			var desc = encodeURIComponent(getmeta('description'));
			
			if (tags == undefined || tags == 'undefined') tags = '';
			if (desc == undefined || desc == 'undefined') desc = '';
			
			/*var http = getXMLHTTPRequest();
			http.open("POST", location.protocol+"//"+location.hostname+"/send_request.php", true);
			http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			http.send("&desc="+desc+
					  "&falseLink="+encodeURIComponent(location.href)+
					  "&link="+encodeURIComponent(location.href)+
					  "&tags="+tags+
					  "&title="+title+
					  "&type=3"+
					  "&hidden_add=true"
				      );
		}*/
		this.location=this.get_url(i);
		setTimeout('wykop2.redirect()',1000);
		return false;
		
	}
	
	this.get_url=function(system) {
		var title=encodeURIComponent(document.title);
		var url=encodeURIComponent(location.href);
		
		switch (system) {
			case 1: return 'http://'+kopayurl+'/index.php?page=diggAdd&link='+decodeURI(url);
			case 2: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=bobrdobr';
			case 3: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=google';
			case 4: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=yandex';
			case 5: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=twitter';
			case 6: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=del';
			case 7: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=text20';
			case 8: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=news2';
			case 9: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=mister-wong';
			case 10: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=moemesto';
			case 11: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=smi2';
			case 12: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=vaau';
			case 13: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=myscoop';
			case 14: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=linkstore';
			case 15: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=ruspace';
			case 16: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=100zakladok';
			case 17: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=memori';
			case 18: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=digg';
		}
	}

	this.make_wyk=function() {
		if (!document.getElementById('bookmarks_cont')) {
			var style = document.createElement('link');
			style.setAttribute('rel','stylesheet');
			style.setAttribute('type', 'text/css');
			style.setAttribute('href', 'http://s.tochka.net/links/css/bookmark.css');
			document.getElementsByTagName('head')[0].appendChild(style);
	
			document.write(
//'        <div id="bookmarks_share2" onmouseover="document.getElementById(\'bookmarks_dropdown2\').style.display = \'block\'" onmouseout="document.getElementById(\'bookmarks_dropdown2\').style.display = \'none\';">'+
//'        <a href="http://links.tochka.net/"><img src="http://s.tochka.net/links/img/bookmark/bookmark2.gif" alt="" /></a>'+
'        <div id="bookmarks_dropdown2" style="display: none;">'+
'        	<img src="http://s.tochka.net/links/img/bookmark/bookmark_top.gif" style="padding:0 !important;" alt="" />'+
'            <div class="bookmarks_cont">'+
'                <div class="bookmarks_list">'+
'					 <a href="'+this.get_url(1)+'" class="kopay" target="_blank">tochka.net</a>'+
'                    <a href="'+this.get_url(4)+'" class="yandex" target="_blank">Яндекс</a>'+
'                    <a href="'+this.get_url(5)+'" class="twitter" target="_blank">Twitter</a>'+
'                    <a href="'+this.get_url(6)+'" class="delicious" target="_blank">Delicious</a>'+
'                    <a href="'+this.get_url(17)+'" class="memori" target="_blank">Memori</a>'+
'                    <a href="'+this.get_url(18)+'" class="digg" target="_blank">Digg</a>'+
'                    <a href="'+this.get_url(8)+'" class="news2" target="_blank">News</a>'+
'                    <a href="'+this.get_url(10)+'" class="myplace" target="_blank">МоёМесто</a>'+
'                    <a href="'+this.get_url(11)+'" class="smi2" target="_blank">Smi2</a>'+
'                    <a href="'+this.get_url(2)+'" class="bobrdobr" target="_blank">BobrDobr</a>'+
'                    <a href="'+this.get_url(3)+'" class="google" target="_blank">Google</a>'+
'                    <a href="'+this.get_url(16)+'" class="stoZakladok" target="_blank">100zakladok</a>'+
'                </div>'+
'                <div class="bottom"><a href="http://links.tochka.net/">links.tochka.net</a></div>'+
'            </div>'+
'        	<img src="http://s.tochka.net/links/img/bookmark/bookmark_bottom.gif" style="padding:0 !important;" alt="" />'+
'        </div>');
//'    </div>');
//	document.getElementById('setstyle').innerHTML = css;
		}
	
	}
}
wykop2=new Newwykop2();
wykop2.make_wyk()
