                        function getElementPosition(offsetTrail)
                        {
                                var offsetLeft = 0;
                                var offsetTop = 0;
                                while(offsetTrail) {
                                        offsetLeft += offsetTrail.offsetLeft;
                                        offsetTop += offsetTrail.offsetTop;
                                        offsetTrail = offsetTrail.offsetParent;
                                }
                        return { left:offsetLeft, top:offsetTop }
                        }

                        function hideFootnotes()
                        {
                                var div = document.getElementById('current_footnote');
                                div.style.display = 'none';
    
                                return false;
                        }

                        function showFootnote(evt, id)
                        {
                                var evt = evt || window.event;
                                var o = evt.target || evt.srcElement;
                                var div = document.getElementById('current_footnote');
                                var coords = getElementPosition(o);
                                div.innerHTML = '<div id="innernote" class="innernote"><a href="#" onclick="return hideFootnotes()"><img src="/system/img/x.gif" height="13" width="13" border="0" style="float: right;" /></a><div style="float: right; width: 17px; height: 17px"></div><div style="padding: 7px">' + document.getElementById(id).innerHTML + '</div></div><iframe id="innerframe" scrolling="no" frameborder="0" style="opacity: 0; filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0); z-index: 100; top: 0px; left: 0px; width: 268px; position: absolute;"></iframe>';
                                div.style.top = (coords.top + o.offsetHeight) + 'px';
                                div.style.left = coords.left + 'px';
                                div.style.display = 'none';				
                                div.style.display = 'block';
				document.getElementById('innerframe').style.height=document.getElementById('innernote').offsetHeight+'px';
                                evt.cancelBubble = true;

                                return false;
                        }
                        
                        function getElementPosition2(offsetTrail)
                        {
                                var offsetLeft = 0;
                                var offsetTop = 0;
                                while(offsetTrail) {
                                        offsetLeft += offsetTrail.offsetLeft;
                                        offsetTop += offsetTrail.offsetTop;
                                        offsetTrail = offsetTrail.offsetParent;
                                }
                                offsetLeft=offsetLeft-250;
                        return { left:offsetLeft, top:offsetTop }
                        }


                        function showFootnote2(evt, id)
                        {
                                var evt = evt || window.event;
                                var o = evt.target || evt.srcElement;
                                var div = document.getElementById('current_footnote');
                                var coords = getElementPosition2(o);
                                div.innerHTML = '<iframe><a href="#" onclick="return hideFootnotes()"><img src="/system/img/x.gif" height="13" width="13" border="0" style="float: right;" /></a><div style="float: right; width: 17px; height: 17px"></div><div style="padding: 7px">' + document.getElementById(id).innerHTML + '</div></iframe>';
                                div.style.top = (coords.top + o.offsetHeight) + 'px';
                                div.style.left = coords.left + 'px';
                                div.style.display = 'none';
                                div.style.display = 'block';
                                evt.cancelBubble = true;

                                return false;
                        }

function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function getClientHeight()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}

function getBodyScrollTop()
{
        return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
}

function getBodyScrollLeft()
{
        return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);
}

function getClientCenterX()
{
        return parseInt(getClientWidth()/2)+getBodyScrollLeft();
}

function getClientCenterY()
{
        return parseInt(getClientHeight()/2)+getBodyScrollTop();
}

function open_pic(src,alt)
{
var image=new Image();
image.src=src;
image.onload=function() 
	{
	win=eval('window.open(\'\',\'\',\'left=0,top=0,screenx=0,screeny=0,Toolbar=0, Location=0, Directories=0, Status=0, Menubar=0, Scrollbar=0, Resizable=0, Copyhistory=0,Width='+image.width+',Height='+image.height+'\');');
	win.document.write('<html><title>'+alt+' ['+image.width+'x'+image.height+']</title><body style="margin:0px;"><input readonly id=url style="width:100%;background-color:#dedddb;" type="text">');
	win.document.write('<img src="'+src+'" width='+image.width+' height='+image.height+' alt="'+alt+'" border=0 onClick=\"window.close(self)\" style=\"cursor:pointer\"></body></html>');
	win.focus();
	win.document.getElementById('url').value=src;
	}
}

function open_url(http,width,height)
{
   	var win = window.open(http, "", "Width="+width+",Height="+(height+20)+",left=0,top=0,screenx=0,screeny=0,Toolbar=0, Location=0, Directories=0, Status=0, Menubar=0, Scrollbar=0, Resizable=0, Copyhistory=0");
    win.focus();
    return win;
}        

function ya(pho_id)
{
	x_its_me_on_photo(pho_id,ya_button);
}      

function ya_button(data)
{

arr=data.split(';');
//if(arr[1].length>0)		{
	if(document.getElementById('pic_'+arr[0]).title=='Я есть на фото!')
	{
		document.getElementById('pic_'+arr[0]).src='/images/16/user_del.gif';
		document.getElementById('pic_'+arr[0]).title='Ой, меня здесь нет :(';
		document.getElementById('mess_'+arr[0]).innerHTML='Ой, меня здесь нет :(';
	}
    else
    {
    	document.getElementById('pic_'+arr[0]).src='/images/16/user_add.gif';
        document.getElementById('pic_'+arr[0]).title='Я есть на фото!';
		document.getElementById('mess_'+arr[0]).innerHTML='Я есть на фото!';        
    }
		
        document.getElementById('people'+arr[0]).innerHTML=arr[1];
       // }
}  
      

function find(from,to)
{
var sel=document.getElementById(to);
var poisk=document.getElementById(from).value.toLowerCase();
var arr=poisk.split(' ');
//alert(arr.length);
if (arr.length==1)
{
	for(i=0;i<sel.length;i++)
	{
		if (sel.options[i].text.toLowerCase().indexOf(poisk)==0)
		{ 
		sel.options[i].selected=true;
		return;
		}
	}

	for(i=0;i<sel.length;i++)
	{
		if (sel.options[i].text.toLowerCase().indexOf(poisk)!=-1)
		{ 
		sel.options[i].selected=true;
		return;
		}
	}
	
}
else
{
	for(i=0;i<sel.length;i++)
	{
		flag=0;
		for(j=0;j<arr.length;j++)
		{
			if (sel.options[i].text.toLowerCase().indexOf(arr[j])!=-1)
			{ 
			flag++;
			if (arr.length==flag) {sel.options[i].selected=true;return;}
			}
			else break
		}
	}
}

}


function avatar0()
{
    x_make_avatar(document.getElementById("avatar_id").value,avatar2);
}

function avatar1(id)
{
    x_make_avatar(id,avatar2);
}

function avatar2(pic)
{
	document.getElementById("avatar").src=pic+'?'+Math.random();
}
