var dialog_cnt=0;
var dialog_open=0;

function err_show(message,kind,place)
{
	document.getElementById(place).className = "on";
    dialog_show(message,document.getElementById(place));
}

function dialog_show(title,message,kind,at)
{
	var at = document.getElementById(at);
	at.className = "on";
	var dialog_conten = document.getElementById("dialog_conten_"+kind);
	var dialog_conten_desc = document.getElementById("dialog_conten_"+kind+"_desc");
	dialog_conten.innerHTML = title;
	dialog_conten_desc.innerHTML = message;
	var oid = dialog_conten.id;
	dialog_conten.id = "conten_"+kind+dialog_cnt;
	var oid_desc = dialog_conten_desc.id;
	dialog_conten_desc.id = "conten_"+kind+dialog_cnt+"_desc";
	var dialog_all = document.getElementById("dialog_"+kind);
	var err_html = "<div id='dialog"+dialog_cnt+"' >";
	err_html += "<a name='dialog'></a>";
		err_html += dialog_all.innerHTML+"<br>";
		err_html += "</div>";

	dialog_conten.id = oid;
	dialog_conten_desc.id = oid_desc;
	at.innerHTML += err_html;

	dialog_cnt++;
	dialog_open++;
	
	if(kind=="err")
	{
		document.location = "#dialog";
	}
}

function clear_errors(at)
{
	var at = document.getElementById(at);
	at.innerHTML = "";
}

function err_ok(no)
{
	 document.getElementById("hot_errors").removeChild(document.getElementById("dialog"+no));
	 dialog_open--;
	 if(dialog_open==0)
	 {
		 document.getElementById("hot_errors").className = "";
	 }
}

function confirm_del(no)
{
	var conten = "<table width='99%' ><tr><td>Deseas borrar?</td><td align='right'>";
	conten += "<a href='javascript:confirm_end("+no+",false);'><img src='images/cancelar.gif' border='0' /></a>";
	conten += "<a href='javascript:confirm_end("+no+",true);'><img src='images/aceptar.gif' border='0' /></a></td></tr></table>";

	dialog_show(conten,document.getElementById("edit"+no));
 	error_cnt++;
	error_open++;
}

function confirm_end(no,res)
{
	if(res)
	{
		document.location="libro.html&des="+no;
		return;
	}
 	var node = document.getElementById("edit"+no);
	if (node && node.hasChildNodes && node.removeChild) 
	{
		while (node.hasChildNodes())
		{
			node.removeChild(node.firstChild);
		}
	}
}

function showErrorMarks(){
	for(i=0; i<arguments.length; i++){
		//alert("field_"+arguments[i]);
		document.getElementById("field_"+arguments[i]).style.display="block";
	}
}

