function ge()
{
  var ea;
  for( var i = 0; i < arguments.length; i++ ) {
    var e = arguments[i];
    if( typeof e == 'string' )
      e = document.getElementById(e);
    if( arguments.length == 1 )
      return e;
    if( !ea )
      ea = new Array();
    ea[ea.length] = e;
  }
  return ea;
}

function placeholderSetup(id, color) {
	var el = ge(id);
	if(!el) return;
	if(el.type != 'text') return;
	if(el.type != 'text') return;
	
	var ph = el.getAttribute("placeholder");
	if( ph && ph != "" ) {
		el.value = ph;
		el.style.color = color;
		el.is_focused = 0;
		el.onfocus = placeholderFocus;
		el.onblur = placeholderBlur;
	}
}

function placeholderFocus() {
  if(!this.is_focused) {
    this.is_focused = 1;
    this.value = '';
   /* this.style.color = '#aca39e';*/

    var rs = this.getAttribute("radioselect");
    if( rs && rs != "" ) {
      var re = document.getElementById(rs);
      if(!re) { return; }
      if(re.type != 'radio') return;

      re.checked=true;
    }
  }
}

function placeholderBlur() {
  var ph = this.getAttribute("placeholder")
  if( this.is_focused && ph && this.value == "" ) {
		this.is_focused = 0;
    this.value = ph;
    /*this.style.color = '#aca39e';*/
  }
}

function getBounds(element)
{
	var left = element.offsetLeft;
  	var top = element.offsetTop;
  	for (var parent = element.offsetParent; parent; parent = parent.offsetParent) {
    	left += parent.offsetLeft;
    	top += parent.offsetTop;
  	}
  	return {left: left, top: top, width: element.offsetWidth, height: element.offsetHeight};
}

function ShowLogin()
{
	var login_span = document.getElementById('login');
	var coord = getBounds(login_span);
	var lf = document.getElementById('login_form');
	lf.style.left = (coord.left + 30) + 'px';
	lf.style.visibility = "visible";
	
	return false;
}

function HideLogin()
{
	var lf = document.getElementById('login_form');
	lf.style.visibility = "hidden";
	
	return false;
}

function ShowZakazat()
{
	var zakazat_span = document.getElementById('zakazat');
	var coord = getBounds(zakazat_span);
	var lf = document.getElementById('zakazat_form');
	lf.style.left = (coord.left) + 'px';
	lf.style.visibility = "visible";
	
	return false;
}

function HideZakazat()
{
	var lf = document.getElementById('zakazat_form');
	lf.style.visibility = "hidden";
	
	return false;
}

function ShowInfo(info_span, type)
{
	HideInfo();
	var coord = getBounds(info_span);
	var lf = document.getElementById('info_form');
	lf.style.left = (coord.left) + 'px';
	if(type == 1) lf.style.top = (coord.top) + 'px';
	if(type == 2) lf.style.top = (coord.top - 70) + 'px';
	lf.style.visibility = "visible";
	
	return false;
}

function HideInfo()
{
	var lf = document.getElementById('info_form');
	lf.style.visibility = "hidden";
	
	return false;
}
