var pagedisable = false;

function findPosX(obj){
	var curleft = 0;

	if (obj.offsetParent){
		while(1){
			curleft+=obj.offsetLeft;
			if (!obj.offsetParent){break}
			 obj=obj.offsetParent;
		 }

	}else if(obj.x){curleft+=obj.x}
	return curleft;
}

function call_loginscreen(media_parent1, media_child1)
{
	if(!pagedisable){
		login_at_attach(media_parent1, media_child1, "click", "y", "pointer");
	}
}

// ***** at_attach *****

// PARAMETERS:
// parent   - id of the parent html element
// child    - id of the child  html element that should be droped down
// showtype - "click" = drop down child html element on mouse click
//            "hover" = drop down child html element on mouse over
// position - "x" = display the child html element to the right
//            "y" = display the child html element below
// cursor   - omit to use default cursor or specify CSS cursor name

function login_at_attach(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);

  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  login_at_show_aux(p.id, c.id);
  c.style.position   = "absolute";
  c.style.visibility = "visible";
  c.style.display = "block";

  if (cursor != undefined) p.style.cursor = cursor;
}

function login_at_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );
  pos_x = findPosX(p);

  var top  = (c["at_position"] == "y") ? p.offsetHeight+0 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 10;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    //left += p.offsetLeft;
  }

  //substracting the width of the login div from the x position of login link and adding pixels
  left = pos_x-285;
  top = top + 10;
  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

function close_login_box()
{
	var a  = document.getElementById('Header_loginDiv');
	//a.onclick  = login_at_hide;
	a.style.visibility = "hidden";
	a.style.display = "none";
}
