function save_pos(obj, user)
{
  var x = $("matchings_" + obj).style.left;
  var y = $("matchings_" + obj).style.top;  
  
  new Ajax.Request("/ajax/windows/window_save_pos.php",{method:"post",parameters:"posx="+x+"&posy="+y+"&obj="+obj+"&user="+user});

  showz(obj);
}

function save_pos_start(x,y, obj)
{
   offx[obj] = x - posx[obj];
   offy[obj] = y - posy[obj];
   posx[obj] = x;
   posy[obj] = y;
  
   //var zi = $("matchings_" + obj).style.zIndex;
   
   zi = zi + 5;
   
   $("matchings_" + obj).style.zIndex = zi;
   
   showz(obj);
   //alert (zi);
   
  // posy[obj] = $("matchings_" + obj).style.top;
}

function HideOnly(wind)
{
	if($("matchings_"+wind))
	{
		var body = $("matchings_"+wind).parentNode;
		for(var i=0;i<body.childNodes.length;i++)
		{
			if(body.childNodes[i].id == "matchings_"+wind)
				body.removeChild(body.childNodes[i]);
		}
	}
}
function Hide(wind)
{
  if(!$("matchings_" + wind))
	return false;
  $("matchings_" + wind).style.display="none";
  new Ajax.Request("/ajax/windows/window_hide.php", {method:"post",parameters:"obj="+wind});
}
var count = 1;
function Show(wind)
{
	new Ajax.Request("/ajax/windows/window_hide.php", {method:"post",parameters:{obj:wind,on:1}});
	if($("matchings_" + wind))
	{
		$("matchings_" + wind).style.display="block";
	}
	else
	{
		var obj = document.getElementsByTagName('body')[0];
		var node = document.createElement('div');
		node.setAttribute('style','height:0px;width:0px;position:absolute;top:0;left:0');
		node.setAttribute('id','WindowLoad'+count);
		obj.appendChild(node);
		/* new Ajax.Request("/ajax/windows/window_load.php", {method:"post",evalScripts:true,parameters:{id:wind},onSuccess:function(t){
			document.getElementsByTagName('div')[document.getElementsByTagName('div').length-1].innerHTML = t.responseText;
			new Draggable("matchings_"+wind, {ghosting:false, revert:false,handle:"titel2"})
		}});	 */
		window.setTimeout("new Ajax.Updater('WindowLoad'+"+count+",'/ajax/windows/window_load.php',{method:'post',evalScripts:true,insertion:Insertion.bottom,parameters:{id:"+wind+"}});",250);
		count++;
	}
}
function ShowOnly(wind,sessid)
{
	if($("matchings_" + wind))
	{
		$("matchings_" + wind).style.display="block";
	}
	else
	{
		var obj = document.getElementsByTagName('body')[0];
		var node = document.createElement('div');
		node.setAttribute('style','height:0px;width:0px;position:absolute;top:0;left:0');
		node.setAttribute('id','WindowLoad'+count);
		obj.appendChild(node);
		/* new Ajax.Request("/ajax/windows/window_load.php", {method:"post",evalScripts:true,parameters:{id:wind},onSuccess:function(t){
			document.getElementsByTagName('div')[document.getElementsByTagName('div').length-1].innerHTML = t.responseText;
			new Draggable("matchings_"+wind, {ghosting:false, revert:false,handle:"titel2"})
		}});	 */
		window.setTimeout("new Ajax.Updater('WindowLoad'+"+count+",'/ajax/windows/window_load.php?PHPSESSID="+sessid+"',{method:'post',evalScripts:true,insertion:Insertion.bottom,parameters:{id:"+wind+"}});",250);
		count++;
	}
}

function minimize(obj)
{
  var bl;

  stat = $("fmain_" + obj).style.display;

  if (stat == "none")
  {
    $("fmain_" + obj).style.display="block";
    bl = 0;
  }
  else
  {
    $("fmain_" + obj).style.display="none";
    bl = 1;
  }
  
  new Ajax.Request("/ajax/windows/window_minimize.php", {method:"post",parameters:"ob="+obj+"&stat="+bl});
}

function showz(obj)
{
  //z1 = $("matchings_" + obj).style.zIndex;
  //$("f1").innerHTML = z1;
}

function Create(bname)
{
	Sortable.create(bname,
  {
    tag:'fieldset',
    overlap:'vertical',
    constraint:false,
    handle:'handlepoint',
    onUpdate:function()
    { 
      Update(Sortable.serialize(bname) + "&vnam="+bname); 
    }
  })
}

function Create2(bname)
{
	Sortable.create(bname,
  {
    tag:'fieldset',
    overlap:'horizontal',
    constraint:false,
    handle:'handlepoint',
    onUpdate:function()
    { 
      Update(Sortable.serialize(bname) + "&vnam="+bname); 
    }
  })
}

function Update(parameters)
{
	new Ajax.Request('/eros/ajax/start_boxen.php',{method:'post',parameters:parameters});
}

function test()
{
  alert("klappt");
}

posx = new Array();
posy = new Array();
offx = new Array();
offy = new Array();

var zi = 1000; 



