popUpDivs.prototype.__hideOnDocClick = function (e) 
{
	if (e.target)
		obj = e.target;
	else
		obj = e.srcElement;
	for (; obj; obj = obj.parentNode) {
		if (obj.id == upopUpDivs._child.id) {
			return;
		}
	}
	upopUpDivs._hideOnDocClick();
}
popUpDivs.prototype.__hideOnWinResize = function (e) {
	upopUpDivs._hideOnDocClick();
	upopUpDivs._current = null;
}
popUpDivs.prototype._getInnerHtmlStr = function (data)
{
	var phrases = { '0':{age:'Возраст', was1:'был', was2:'была', level: 'Уровень', rate: 'рейтинг', gift: 'Сделать подарок', talk1: 'Написать сообщение', talk2: 'Чат'},
			'2':{age:'Вік', was1:'був', was2:'була', level: 'Рівень', rate: 'рейтинг', gift: 'Зробити подарунок', talk1: 'Написати повідомлення', talk2: 'Чат'},
			'3':{age:'The age', was1:'was', was2:'was', level: 'the level', rate: 'the rate', gift: 'Make a present', talk1: 'Write a message', talk2: 'A chat'}};
	eval('var id = ' + this._parent['upArr'] + '[0];');
	this._child.className = (data.p == 1) ? "popupWrapper" : "popupWrapper offline";
	var str = 
'	<div class="floatleft marginR05">' + 
'		<a class="avatar" href="http://narod.i.ua/user/'+ id + '/">'+ ((data.u != 0) ? 
'			<div class="redCard card' + data.u + '"></div>' : '') + 
'			<img src="' + data.i + '" width="' + data.w + '" height="' + data.h+ '" alt="' + data.n + '" />' +
'		</a>' +
'	</div>';

	str += 
'	<div class="floatleft pcol2">' +
'		<p class="marginB02"><a class="' + ((data.b==1) ? 'boy' : 'girl') + ' bold" href="http://narod.i.ua/user/'+ id + '/">' + data.n + '</a></p> '+
'		<p class="marginB02"><span class="userstatusd">'+ ((data.p == 1) ? '' : ((data.b==1) ? phrases[this._langId]['was1'] : phrases[this._langId]['was2']) + ' ')+ data.o + '</span></p> '+
'		<p class="marginB05">'+ data.l + '</p> ' +
'		<p class="marginB05">' + phrases[this._langId]['age'] + ': ' + data.a + '</p>';
	if (data.r != '') {
		var tmp = Math.abs(data.r);
		var percent = tmp > 0 ? Math.round(Math.log(tmp) * 10) : 0;
		if (percent > 100)
			percent = 100;
		str += '' + 
'		<div class="rateContainer" title="' + phrases[this._langId]['level'] + ' ' + ((data.r < 0 ? -1 : 1) * Math.floor(percent/10))+ ', ' + phrases[this._langId]['rate'] + ' ' + data.r + '">' +
'			<div class="rateBox">' +
'				<div class="' + (data.r < 0 ? 'rateBarMinus' : 'rateBar') + '" style="width:' + percent + '%;"></div>' +
'			</div>' +
'		</div>';
	}

	str += 
'	</div>' +
'	<div class="userServices">';
	for (var k=0; k<data.s.length; k++) {
		str += (k==0) ? '' : ' &bull; ';
		str += data.s[k];
	}

	str +='</div>';

	var str1 = '';
	if (data.f == 1) {
		str1 +='		<a href="javascript:void(0)" class="marginR05 aslink" onclick="' + this.name + '.processFriend(this, ' + id + ')" isfriend="1"><img src="http://i1.i.ua/i_favourites2.gif" class="paddingR02 bgWhite verticalmiddle" title="' + this.phrases2[this._langId]['addtofriends2'] + '">' + this.phrases2[this._langId]['tofriends2'] + '</a>';
	} else if (data.f == 0) {
		str1 +='		<a href="javascript:void(0)" class="marginR05 aslink" onclick="' + this.name + '.processFriend(this, ' + id + ')" isfriend="0"><img src="http://i1.i.ua/i_favourites.gif" class="paddingR02 bgWhite verticalmiddle" title="' + this.phrases2[this._langId]['addtofriends1'] + '">' + this.phrases2[this._langId]['tofriends1'] + '</a>';
	}
	if (data.g == 1) {
		str1 += 
'		<a target="_blank" href="http://narod.i.ua/present/' + id + '/" class="marginR05 aslink"><img src="http://i1.i.ua/i_surprize.gif" title="' + phrases[this._langId]['gift'] + '" class="paddingR02 bgWhite verticalmiddle">' + phrases[this._langId]['gift'] + '</a>';
		str1 += 
'		<a target="_blank" href="http://talk.i.ua/' + id + '/" class="aslink"><img src="http://i1.i.ua/i_chat.gif" class="paddingR02 bgWhite verticalmiddle" title="' + phrases[this._langId]['talk1'] + '" />' + phrases[this._langId]['talk2'] + '</a>';

	}
	if (str1 != '') 
		str += 
'	<div class="userServices">' + str1 + '</div>';

	str += 
'	<div class="pupshad1"></div><div class="pupshad2"></div><div class="pupshad3"></div>';
	return str;
}
popUpDivs.prototype.processFriend = function (control, id)
{
	var isFriend = parseInt(control.getAttribute('isFriend'));
	if (isFriend) {
		var newIsFriend = 0;
		var nodeText = this.phrases2[this._langId]['tofriends1'];
		var imgSrc = 'i_favourites.gif';
		var imgTitle = this.phrases2[this._langId]['addtofriends1'];
	} else {
		var newIsFriend = 1;
		var nodeText = this.phrases2[this._langId]['tofriends2'];
		var imgSrc = 'i_favourites2.gif';
		var imgTitle = this.phrases2[this._langId]['addtofriends2'];
	}
	control.setAttribute('isFriend', newIsFriend);
	control.childNodes[0].src = 'http://i.i.ua/' + imgSrc;
	control.childNodes[0].title = imgTitle;
	control.childNodes[1].nodeValue = nodeText;

	if (!this.fakeIMG)
		this.fakeIMG = dce('IMG');
	this.fakeIMG.src = 'http://narod.i.ua/js/process_friend/?isFriend=' + newIsFriend + '&memberID=' + id + '&_rand=' + Math.random();
}
var upopUpDivs = new popUpDivs();
upopUpDivs.fakeIMG = null;
upopUpDivs.name = 'upopUpDivs';
upopUpDivs.phrases2 = {
			'0':{addtofriends1: 'Добавить в друзья', tofriends1: 'В друзья', addtofriends2: 'Удалить из друзей', tofriends2: 'Из друзей'},
			'2':{addtofriends1: 'Додати до друзів', tofriends1: 'До друзів', addtofriends2: 'Видалити з друзів', tofriends2: 'З друзів'},
			'3':{addtofriends1: 'Add to the friends', tofriends1: 'To the friends', addtofriends2: 'Remove from the friends', tofriends2: 'From the friends'}};

upopUpDivs_start = function ()
{
	upopUpDivs.start();
}
if (window.attachEvent) {
	window.attachEvent ('onload', upopUpDivs_start);
} else if (window.addEventListener) {
	window.addEventListener("load", upopUpDivs_start, false);
}
