function $(id)
	{
	 return document.getElementById(id);
	}
//---
var _findPosX=-1;
var _currentX;
//---
function getXY(e, element)
	{
	  var type=isReal(element.id) ? '_real' : '_ideal';
	  //---
	  if($('input_'+element.id+type).value!='')
		return;
	  //---
	  var x = e.clientX - findPosX(element);
	  x = (x == undefined || x<0) ? 0 : (x>500 ? 500 : x);
	  $(element.id+type).style.width=x+'px';
	  _currentX=x;
	}
//--- freeze x
function freeze(element)
	{
	 var type=isReal(element.id) ? '_real' : '_ideal';
	  if($('input_'+element.id+type).value=='')
		{
		 $('input_'+element.id+type).value=_currentX;
		 changeStatus(element.id);
		 //---
		 if(type=='_ideal')
			changeStatusGood(element.id);
		}
	}
//--- change status
function changeStatus(id)
	{
	 $(id+'_desc').innerHTML= (isReal(id) ? "На каком уровне это качество в данный момент? " : "А при каком уровне вы были бы довольны собой?") + ' <i>(кликните, чтобы закрепить)</i>';
	}
//--- thanks
function changeStatusGood(id)
	{
	 //var outh=' <a style="color: gray; text-decoration: none; border-bottom: 1px dotted;" href="#" onclick=\'$("input_'+id+'_real").value=""; $("input_'+id+'_ideal").value=""; changeStatus("'+id+'"); return false;\'>Ой, хочу переделать</a>';
	 $(id+'_desc').innerHTML= 'Отлично!';//+outh;
	}	
//--- is real
function isReal(id)
	{
	 return $('input_'+id+'_real').value == '';
	}
//--- show description
function showDesc(element)
	{
	 $(element.id+'_desc').style.display='block';
	}
//--- hide description
function hideDesc(element)
	{
	 $(element.id+'_desc').style.display='none';
	}	
//--- get x-position for element
function findPosX(obj)
	{
	 if(_findPosX>-1)
		return _findPosX;
	 //---
	 var currleft = 0;
	 if (obj.offsetParent)
		while (obj.offsetParent) 
			{
			 currleft += obj.offsetLeft
			 obj = obj.offsetParent;
			}
	 else 
		if (obj.x) currleft += obj.x;
	 //---
	 return currleft;
	}