/*
*
* funkcje pozwalające na edytowanie jednej wartości
* Obiekty form i input generowane dynamicznie  
*
*/
var ie = (document.getElementById && document.all);
// =====================================================================================
function EditOneValue(Name,Value,Desc,Action,Arg1,Arg2,Arg3,Zdarzenie,Obiekt)
{
	DivObj = document.getElementById("EditOneValue");
	if (!DivObj)	
	{
		DivObj = document.createElement("div");	
		DivObj.setAttribute("id","EditOneValue");	
		DivObj.className = "ukryte absolut";
		BodyObj = document.getElementsByTagName("body");
		BodyObj[0].appendChild(DivObj);		
	}	
	DivObj.innerHTML = EOVPrepareForm(Name,Value,Desc,Action,Arg1,Arg2,Arg3);
	DivObj.className = "widoczne absolut";	
	EOVSetXY(Zdarzenie);	
	Place = DivObj.getElementsByTagName("input");
	for (i=0;i<Place.length;i++)
	{
		if (Place[i].name == Name)
		{
			Place[i].focus();
		}
	}
	Place = DivObj.getElementsByTagName("textarea");
	for (i=0;i<Place.length;i++)
	{
		if (Place[i].name == Name)
		{
			Place[i].focus();
		}
	}
		
}
// =============================================================
function EOVDestroy()
{	
	//alert("Hide");	
	DivObj = document.getElementById("EditOneValue");
	if (DivObj)	
	{
		DivObj.className = "ukryte";
		BodyObj = document.getElementsByTagName("body");
		BodyObj[0].removeChild(DivObj);	
	}		
}
// =============================================================
function EOVSetXY(Zdarzenie)
{

	if (ie)
	{
		X = Zdarzenie.clientX + document.documentElement.scrollLeft;
		X = X - (DivObj.offsetWidth);
		
		if (X < 0)
			X=5;
		Y = Zdarzenie.clientY + document.documentElement.scrollTop;
		DivObj.style.top = Y+0;
		DivObj.style.left = X+0;
		
		
	}
	else
	{
		Y = Zdarzenie.pageY + 0;	
		X = Zdarzenie.pageX - (DivObj.offsetWidth);
		if (X<0) 
			X=5;
		DivObj.setAttribute("style","top:"+Y+"px;left:"+X+"px;");
	}
	tmp = document.getElementById("EOVForm1");
	tmp.focus();
}
// =====================================================================================
function EOVPrepareForm(Name,Value,Desc,Action,Arg1,Arg2,Arg3)
{
	retval = "<form name='EOVForm1' id='EOVForm1' action='./' method='post'>";
	
	retval += "<table id='TableToolTip'>";
	
	//retval += "<tr>";
	//retval += "<td colspan=3 id='SmogToolTip'></td>";	
	//retval += "</tr>";
	
	retval += "<tr>";
	retval += "<td id='LeftTopToolTip'></td>";	
	retval += "<td id='TopToolTip'></td>";	
	retval += "<td id='RightTopToolTip'></td>";	
	retval += "</tr>";
	
	retval += "<tr>";
	retval += "<td id='LeftToolTip'></td>";	
	retval += "<td id='ToolTip'>";
	
	retval += "<p>"+Desc+"</p>";
	
	retval += "<p class='tab_desc'>";
	
	dl = Name.length;
	tmp = Name.substr(dl-3);
	if (tmp == '_nn')
	{
		if(Value != "")
		{
			retval += "<input class='tab' name='"+Name+"' value='"+Value+"'  OnBlur='CzyNull(this,\"tab\",\"tab_alert\")' > ";
		}	
		else
		{
			retval += "<input class='tab_alert' name='"+Name+"' value='"+Value+"' "+AddIn+"> ";
		}				
	}
	else if(tmp == '_bl') // blob 
	{		
		retval += "<textarea class='tab' cols=100 rows=10 Style='width:350px;height:150px'  name='"+Name+"'>"+Value+"</textarea>";
	}
	else 
	{
		retval += "<input class='tab' name='"+Name+"' value='"+Value+"' > ";
	}	
	
	
	retval += "<img alt='' style='cursor:pointer;' src='../img/accept.png' onClick='if (BeforeSubmit(document.getElementById(\"EOVForm1\"))) {document.getElementById(\"EOVForm1\").submit();}'>";
	retval += "<img alt='' style='cursor:pointer;' src='../img/cancel.png' onClick='EOVDestroy();'>";
	retval += "</p>";
	if (Name != "arg1")
		retval += "<input type='hidden' name='arg1' value='"+Arg1+"'>";
	if (Name != "arg2")
		retval += "<input type='hidden' name='arg2' value='"+Arg2+"'>";
	if (Name != "arg3")
		retval += "<input type='hidden' name='arg3' value='"+Arg3+"'>";
	retval += "<input type='hidden' name='act' value='"+Action+"'>";
	
	
	retval += "</td>";	
	retval += "<td id='RightToolTip'></td>";	
	retval += "</tr>";
	
	retval += "<tr>";
	retval += "<td id='LeftBottomToolTip'></td>";	
	retval += "<td id='BottomToolTip'></td>";	
	retval += "<td id='RightBottomToolTip'></td>";	
	retval += "</tr>";	
	
	
	retval += "</table></form>";
	
	return retval;	
}
// =====================================================================================

