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 Newwykop4() {
	var style = document.createElement('link');
	style.setAttribute('rel','stylesheet');
	style.setAttribute('type', 'text/css');
	style.setAttribute('href', 'http://s.portal.kotstantin.dvdev.org.ua/links/css/bookmark.css');
	document.getElementsByTagName('head')[0].appendChild(style);

	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.portal.kotstantin.dvdev.org.ua';
	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('wykop.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=facebook';
			case 3: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=twitter';
			case 4: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=vkontakte';
			case 5: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=livejournal';
			case 6: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=email';
			case 7: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=links';
			case 8: return 'http://'+kopayurl+'/index.php?page=diggAdd&link='+decodeURI(url);
			case 9: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=bobrdobr';
			case 10: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=google';
			case 11: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=yandex';
			case 12: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=del';
			case 13: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=text20';
			case 14: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=news2';
			case 15: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=mister-wong';
			case 16: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=moemesto';
			case 17: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=smi2';
			case 18: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=vaau';
			case 19: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=myscoop';
			case 20: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=linkstore';
			case 21: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=ruspace';
			case 22: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=100zakladok';
			case 23: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=memori';
			case 24: return 'http://'+kopayurl+'/index.php?page=diggAdd&hidden_add=true&title='+title+'&link='+encodeURIComponent(location.href)+'&redir=digg';	
		}
	}
	
	this.make_wyk_drop=function() {
		if (!document.getElementById('bookmarks_dropdown')) {
			var style = document.createElement('link');
			style.setAttribute('rel','stylesheet');
			style.setAttribute('type', 'text/css');
			style.setAttribute('href', 'http://s.portal.kotstantin.dvdev.org.ua/links/css/bookmark.css');
			document.getElementsByTagName('head')[0].appendChild(style);
	
			document.write(
'				<div id="bookmarks_dropdown" onmouseover="document.getElementById(\'bookmarks_dropdown\').style.display = \'block\';" onmouseout="document.getElementById(\'bookmarks_dropdown\').style.display = \'none\';" style="display:none;" >'+
'           	<div class="bookmarks_cont">'+
'				<div class="bookmarks_list" >'+
'               	 <a href="'+this.get_url(8)+'" class="kopay" target="_blank">tochka.net</a>'+
'                    <a href="'+this.get_url(11)+'" class="yandex" target="_blank">Яндекс</a>'+
'                    <a href="'+this.get_url(12)+'" class="delicious" target="_blank">Delicious</a>'+
'                    <a href="'+this.get_url(23)+'" class="memori" target="_blank">Memori</a>'+
'                    <a href="'+this.get_url(24)+'" class="digg" target="_blank">Digg</a>'+
'                    <a href="'+this.get_url(14)+'" class="news2" target="_blank">News</a>'+
'                    <a href="'+this.get_url(16)+'" class="myplace" target="_blank">МоёМесто</a>'+
'                    <a href="'+this.get_url(17)+'" class="smi2" target="_blank">Smi2</a>'+
'                    <a href="'+this.get_url(9)+'" class="bobrdobr" target="_blank">BobrDobr</a>'+
'                    <a href="'+this.get_url(10)+'" class="google" target="_blank">Google</a>'+
'                    <a href="'+this.get_url(22)+'" class="stoZakladok" target="_blank">100zakladok</a>'+
'		     		<br clear="all" />'+
'               </div>'+
'               <div class="bottom">Сервис социальных закладок <a href="http://links.portal.kotstantin.dvdev.org.ua/">links.portal.kotstantin.dvdev.org.ua</a></div>'+
'				</div>'+
'				</div>' );

//	document.getElementById('setstyle').innerHTML = css;
		}
	
	}

	this.make_wyk=function() {
			var url = encodeURIComponent(location.host);
			
		document.write(
				
				'<span style="float: left;"><a href="'+this.get_url(2)+'" target="_blank"><img src="http://s.portal.kotstantin.dvdev.org.ua/images/common/icons/new_facebook_hov.gif"  alt="" /></a>&nbsp;'+
				'<a href="'+this.get_url(3)+'" target="_blank"><img src="http://s.portal.kotstantin.dvdev.org.ua/images/common/icons/new_twitter_hov.gif"  alt="" /></a>&nbsp;'+
				'<script type="text/javascript">' +
				'<!-- document.write(VK.Share.button(false,{type: "custom", text: "<a href="#" class="vkontakte"></a>"})); -->' +
				'</script>' +
				'<span onclick="VK.Share.click(0);" style="cursor: pointer;"><a class="vkontakte" href="'+this.get_url(4)+'"><img src="http://s.portal.kotstantin.dvdev.org.ua/images/common/icons/new_vkontakte_hov.gif"  alt="" /></a></span>&nbsp;'+
				'<a href="'+this.get_url(5)+'" target="_blank"><img src="http://s.portal.kotstantin.dvdev.org.ua/images/common/icons/new_livejournal_hov.gif"  alt="" /></a>&nbsp;'+
				'<a href="'+this.get_url(6)+'" target="_blank"><img src="http://s.portal.kotstantin.dvdev.org.ua/images/common/icons/new_email_hov.gif"  alt="" /></a>&nbsp;'+
				'<a href="'+this.get_url(8)+'" target="_blank"><img src="http://s.portal.kotstantin.dvdev.org.ua/images/common/icons/new_links_hov.gif"  alt="" /></a>&nbsp;</a><span style="float: left;"><span id="bookmarks_share_drop" onmouseover="document.getElementById(\'bookmarks_dropdown\').style.display = \'block\'" ></span><span class="jcount"></span></span></span>'
				);
		
			try{
		
			$.getJSON("http://links.portal.kotstantin.dvdev.org.ua/get_counter/?url="+url+"&jsoncallback=?",
					 
			function(data){
			
			$('.jcount').html(data.count);

			});
			
			} catch(e) {
				
				$('.jcount').html('');
			
			} 

	}
}
wykop4=new Newwykop4();
wykop4.make_wyk();
wykop4.make_wyk_drop();








//var counter = $.ajax({
//	url: 'http://links.portal.kotstantin.dvdev.org.ua/get_counter?url=auto.portal.kotstantin.dvdev.org.ua',  
//    dataType: 'json',  
//    mtype: 'post',
//    async: false,
//    success: function(data) {
//		count = data;
//   }});


//function include(url) {
//	  var script = document.createElement('script');
//	  script.setAttribute('type', 'text/javascript')
//	  script.setAttribute('src', url);
//	  document.getElementsByTagName('head').item(0).appendChild(script);
//	}
//
//	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 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;
//	}
//

