function screenSize2() {
	var w, h; // Объявляем переменные, w - длина, h - высота
	w = (window.innerWidth) ? window.innerWidth : window.document.body.clientWidth;
	h = (window.innerHeight) ? window.innerHeight : window.document.body.clientHeight;
	return {w:w, h:h};
}
function addHandler2(object, event, handler, useCapture) {
	if (object.addEventListener) {
		object.addEventListener(event, handler, useCapture ? useCapture : false);
	} else if (object.attachEvent) {
		object.attachEvent('on' + event, handler);
	} else alert("Add handler is not supported");
}
function removeHandler2(object, event, handler) {
	if (object.removeEventListener) {
		object.removeEventListener(event, handler, false);
	} else if (object.detachEvent) {
		object.detachEvent('on' + event, handler);
	} else alert("Remove handler is not supported");
}
function cancelBubbling2(evt) {
	evt = evt || windiw.event;
	evt.cancelBubble = true;
  if (document.getElementById("userDropDownId")) {
    document.getElementById("userDropDownId").style.zIndex="100";
  }
	document.getElementById("userDropDownId2").style.zIndex="100000";
}
function allInvitee(user_id){
	window.open('http://deti.mail.ru/inc/all_invitee?user_id='+user_id, '', 'width=600,height=360,left='+(screen.width-660)/2+',top='+(screen.height-300)/2+',toolbars=no,scrollbars=yes,resizable=yes,left='+(screen.width-300)/2+',top='+(screen.height-600)/2)
}
function actionRulesInviteFriends(){
  window.open('http://deti.mail.ru/inc/action_rules_invite_friends', '', 'width=600,height=360,left='+(screen.width-660)/2+',top='+(screen.height-300)/2+',toolbars=no,scrollbars=yes,resizable=yes,left='+(screen.width-300)/2+',top='+(screen.height-600)/2)
}
function userMenuShow2(_link, evt, hintStatus, hintStar, chageStatus) {
  cancelBubbling2(evt);
  var ua = navigator.userAgent.toLowerCase();
  var isGecko = ua.indexOf("gecko") != -1;
/*  var mail = _link.href.substring(_link.href.indexOf("to=") + 3, _link.href.length);
  var tmp = mail.split("@");
  var username = tmp[0];
  tmp = tmp[1].split(".");
  var alias = tmp[0];
*/
  var hintStarText;
  if (hintStatus == undefined && hintStar == 1) { hintStarText = "Вы пригласили на проект Дети@Mail.Ru пять человек и получили звезду. Подробнее об акции &laquo;Пригласи друзей и получи звезду!&raquo; читайте <a href=\"#\" onclick=\"actionRulesInviteFriends(); return false;\">здесь</a>." }
  else if (hintStatus == undefined && hintStar == 2) { hintStarText = "Пользователь пригласил на проект Дети@Mail.Ru пять человек и получил звезду. Подробнее об акции &laquo;Пригласи друзей и получи звезду!&raquo; читайте <a href=\"#\" onclick=\"actionRulesInviteFriends(); return false;\">здесь</a>." }
  else if (hintStatus == 1 && hintStar == undefined && chageStatus == 1) {
    hintStarText = "<a href=\"/personal#changeStatusname\">Сменить статус</a>";
    document.getElementById("userDropDownId2").style.width="auto";
  }
  else if (hintStatus == 1 && hintStar == undefined) { hintStarText = "Чтобы получить индивидуальный статус, приглашай друзей и получай звезду. Подробнее читай <a href=\"#\" onclick=\"actionRulesInviteFriends(); return false;\">тут</a>." }
  else if (hintStatus == 2 && hintStar == undefined) { hintStarText = "Чтобы получить индивидуальный статус, приглашай друзей и получай звезду. Подробнее читай <a href=\"#\" onclick=\"actionRulesInviteFriends(); return false;\">тут</a>." }
  var html = hintStarText;
	var div = document.getElementById("userDropDownId2");
	div.innerHTML = html;
	div.style.top = absPosition2(_link).y + _link.offsetHeight + "px";
	div.style.left = ((screenSize2().w - absPosition2(_link).x - div.offsetWidth > 0) ? absPosition2(_link).x : absPosition2(_link).x - div.offsetWidth + _link.offsetWidth) + "px";
	div.className = "";
	addHandler2(div, "click", function(evt){cancelBubbling2(evt);});
	return false;
}
function userMenuHide2() {
	var div = document.getElementById("userDropDownId2");
	removeHandler2(div, "click", function(evt){cancelBubbling2(evt);});
	div.className = "none";
}
function absPosition2(obj) {
	this.x = 0;
	this.y = 0;
    while(obj) {
		this.x += obj.offsetLeft;
		this.y += obj.offsetTop;
		obj = obj.offsetParent;
	}
	return {x:this.x,y:this.y};
}
addHandler2(document, "click", userMenuHide2);
