function createRequestObject() 
{
	var ro;
	var browser = navigator.appName;
	
	if(browser == "Microsoft Internet Explorer")
	{
		ro = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		ro = new XMLHttpRequest();
	}
	return ro;
}

var http = createRequestObject();
var click_id = -1;
var x = 0;
var y = 0;
var ajaxDiv = "edit_form";
var showCloseLink = 0;
var fixed = 0;

// REQUEST-METHODEN ----------------------------------------------------
function showEditForm(ea_id, p_ajaxDiv) 
{
	//click_id = id;
	ajaxDiv = p_ajaxDiv;
	showCloseLink = 1;
	http.open("get", "/scripts/bilanzrechner/index.php?ea_id="+ea_id+"&anw=edit_form");
	http.onreadystatechange = handleResponse;
  	http.send(null);
}

// REQUEST-METHODEN ENDE -----------------------------------------------

function setCoordinates(Ereignis) 
{
    	if (!Ereignis)
		Ereignis = window.event;
    	x = Ereignis.clientX;
    	y = Ereignis.clientY;
}

function handleResponse() 
{
	var pos = 0;
  	if(http.readyState == 4)
	{
    		document.getElementById(ajaxDiv).style.position = "absolute";
		// wenn IE am Start
    		if (document.body)
		{
			// Eigenschaft scrollTop erst vorhanden, wenn gescrollt wurde
      			if (document.body.scrollTop && document.body.scrollTop > 0);
				pos = document.body.scrollTop;
		}
		// für alle anderen Browser
    		else
      			pos = window.pageYOffset;
		with (document.getElementById(ajaxDiv))
		{
    			style.top = pos + y + "px";
	    		style.left = x + "px";
    			style.backgroundColor = "#eeeeee";
    			style.border = "1px dotted #333";
	    		style.visibility = "visible";
			if (showCloseLink == 1)
			{
   	 			innerHTML = http.responseText + "[ <a href=\'javascript: hide_div();\'>schliessen</a> ]";
			}
			else
			{
				innerHTML = http.responseText;
			}
		}
  	}
}

function hide_div() 
{
  	document.getElementById(ajaxDiv).style.visibility = "hidden";
}

function delete_confirm(dest)
{
	check = confirm("Wirklich entfernen?");
	if(check == true) 
	{
		document.location.href = dest;
	}
}

document.onmousedown = setCoordinates;