function GetCookie(sName)
{
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0]) 
      return unescape(aCrumb[1]);
  }
  return "";
}

function SetCookie(sName, sValue)
{
  var date = new Date();
  document.cookie = sName + "=" + escape(sValue) + "";
}
function open_viewer(ph,SID)
{
	window.open('http://www.photovision.ru/viewer.php?photo=' + ph + '&SID='+SID,null,"height=550,width=700,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes");
	return false;
}
function open_up(user)
{
	window.open("http://"+document.location.host+"/up.php?usr=" + user+'&rnd=' + Math.round(Math.random()*1000000000), "UserUp", "width=500, height=400, directories=no, toolbar=no, location=no, menubar=no, status=no");
	return false;
}
function open_vote(kid, uid, SID)
{
	window.open('http://'+document.location.host+'/konkurs_vote.php?kid=' + kid + '&uid=' + uid + '&SID=' + SID, null, "height=500,width=600,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes");
	return false;
}

function win(link) {
	window.open(link,null,"height=300,width=400,status=yes,toolbar=no,menubar=no,location=no");
	return false;
}
function win2(sid,us) {
	window.open('http://'+document.location.host+'/mes/index.php?SID='+sid+'&selectuser='+us, 'TalkAbout', 'width=630, height=370, directories=no, toolbar=no, location=no, menubar=no, status=no');
	return false;
}
function toggle(d,i,id,n1,n2) {
	if (d.style.display == 'none')
	{
		d.style.display = 'block';
		i.src='http://'+document.location.host+'/im/a_opened.gif';
		SetCookie('show_menu'+id,1);
	}else
	{
		d.style.display = 'none';
		i.src='http://'+document.location.host+'/im/a_closed.gif';
		SetCookie('show_menu'+id,0);

	}

	return false;
}
function onfocus_field(f,val)
{
	if (f.value == val) f.value = '';
}
function onblur_field(f,val)
{
	if (f.value == '') f.value = val;
}

function toggle_form(gbf)
{
	if (gbf.style.display == 'none')
	{
		gbf.style.display = 'block';
		gbf.style.width = '100%';
	}
	else
	{
		gbf.style.display = 'none';
	}
	return false;
}
function GetX(le)
{
var x=0;
while (le)
{
x+=parseInt(le.offsetLeft);
le = le.offsetParent;
}
return x;
}
function GetY(le)
{
var y=0;
while (le)
{
y+=parseInt(le.offsetTop);
le = le.offsetParent;
}
return y;
}