window.onload = function() {
	window.defaultStatus='ito@ito.edu.ru, http://ito.edu.ru';

// Open in new window for new messages on social networking

	var ca = document.getElementById("tweet_share");
	var ljs = document.getElementById("lj");

	window.my_callback = function(response) {
		if(response.error_message) ca.setAttribute("shorturl", location.href)
		else ca.setAttribute("shorturl", response.short_url)
	};
	var s = document.createElement("script");
	s.src = "http://ggl-shortener.appspot.com/?url=" + encodeURIComponent(location.href) + "&jsonp=my_callback";
	document.body.appendChild(s);

	ca.onclick = (function(ca){
		return function(){
			window.open('http://twitter.com/home/?status='+encodeURIComponent(document.title)+' '+ ca.getAttribute("shorturl"), '_blank');
			return false;
		}
	})(ca)

	ljs.onclick = (function(ljs){
		return function(){

			var tagArr = document.getElementsByTagName("p");
			var zagl = getMeta("zagl", tagArr);
			var param = '';
			if (zagl) {
				param = '?zagl='+encodeURIComponent(zagl);
				param += '&auth='+encodeURIComponent(getMeta("auth", tagArr));
				var annot = getMeta("annot", tagArr);
				if (annot) 
					param +='&annot='+encodeURIComponent(annot);
			} else {
				param = '?zagl='+encodeURIComponent(document.title);
			}


			window.open('http://utf.ito.edu.ru/lj.php' + param, '_blank');
			return false;
		}
	})(ljs)
}

/* socnet func */

function getMeta(className, tagArr) {
	var desc = '';
	for (var i = 0; i < tagArr.length; i++)
		if (tagArr[i].getAttribute("class") == className) {
			desc = tagArr[i].firstChild.nodeValue;
			if (desc) break;
		}
	return desc;
}