function toggleLang(aitem) {
	var href = window.location.href;
	if(href.indexOf("http://") == 0) {
		href = href.substring(7);
		href = href.substring(href.indexOf("/"));
	}
	if(href.indexOf("/ru/") == 0)
		href = href.substring(4);
	else
		href = href.substring(1);

	if(href == "")
		return true;

	var url = aitem.href + href;
	var reg;
	if (typeof XMLHttpRequest != "undefined") {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	req.open("get", url, true);
	req.onreadystatechange = function() {
		if (req.readyState == 4) {
			if (req.status == 200) 
				window.location.href = url;				
			else
				window.location.href = aitem.href;
	    }
	};
	req.send(null);
	
	return false;
}

function decodeMail(mail) {
	var toReturn = "";
	for(var pos = mail.indexOf("."); mail.length > 0 ; pos = mail.indexOf(".")) {
		toReturn += String.fromCharCode(pos == -1 ? mail : mail.substr(0,pos));
		mail = pos == -1 ? "" : mail.substr(pos + 1);
	}
	return toReturn;
}
function writeMail(mail) {
	var dmail = decodeMail(mail);
	document.write("<a href=\"mailto:" + dmail + "\">" + dmail + "</a>");
}