type="";    // info|data|form
boxpos=0;   // 0 = nada, 1 = izquierda, 2 = derecha, 3 = varias columnas
prefix="";  // I|D|F
rowpar=0;  // para el fondo de las filas pares/impares
rowpos=0;  // numero de columna (type data)
numrows=0; // cantidad de columnas (type data)
margen=20; // solo para box de texto

// ventanas
//{{{function box_start(size, titulo)
function box_start(t, size, titulo)
{
	type=t;
	if (type=="info") prefix="I";
	if (type=="form") prefix="F";
	if (type=="data") prefix="D";
	if (type=="text") prefix="T";
	
	dkbsize=size;
	dkbtitulo=titulo;
	if (type=="info") dkbicon="/img/computer.png";
	if (type=="form") dkbicon="/img/computer2.png";
	if (type=="data") dkbicon="/img/window.png";
	if (type=="text") dkbicon="/img/window.png";
	if (type=="form") type="info";
		
	if (type=="data") { dkbestiloalt='_data'; }

	document.write("<br><center>");
	dkb_start();

	if (type=="text") {
		document.write("<table width=100% align=justify cellpadding="+margen+" cellspacing=0><tr><td>");
	} else if (type=="info") {
		//document.write("<br>");
		document.write("<table align=center cellpadding=3 cellspacing=1>");
	} else {
		document.write("<table width=100% align=center cellpadding=3 cellspacing=1>");
	}

	if (type=="data") boxpos=3;  // multiples columnas
	else boxpos=1; // izquierda
	numrows=0;
}
//}}}
//{{{ function box_head(txt, prop)
function box_head(txt, prop)
{
	if(numrows==0) document.write("<tr align=left>");
	document.write("<th class="+prefix+"txtb "+prop+">");
	document.write(txt);
	document.write("</th>");
	numrows++;
	rowpos=1;
}
//}}}}
//{{{ function box_data_start(prop, tags)
function box_data_start(prop, tags)
{
	if(!prop) prop="";

	switch(boxpos) {
		case 1: // abrimos izquierda
			document.write("<tr><th  "+prop+">");
			break;
		case 2: // abrimos derecha
			document.write ("<td "+prop+">");
			break
		case 3:
			if(rowpos!=1) { // abrimos celda
				document.write("<td "+postfix+prop+">");
			} else { // abrimos celda y fila
				if (rowpar=="1") rowpar="0"; else rowpar="1";
				if (rowpar=="1") postfix="class=par "; else postfix="class=impar ";
				document.write("<tr><td "+postfix+prop+">");
			}
			break
	}

	if(!tags) tags="<nobr>";
	document.write(tags);
}
//}}}
//{{{ function box_data_end()
function box_data_end(prop, tags)
{
	if(!prop) prop="";

	if(!tags) tags="</nobr>";
	document.write(tags);

	switch(boxpos) {
		case 1: // terminamos izquierda
			document.write("</th>");
			boxpos=2;
			break;
		case 2: // terminamos derecha
			document.write ("</td></tr>");
			boxpos=1;
			break
		case 3:
			if(rowpos<numrows) { // terminamos celda
				document.write("</td>");
				rowpos++;
			} else { // terminamos celda y fila
				document.write("</td></tr>");
				rowpos=1;
			}
			break
	}
}
//}}}
//{{{ function box_data()
function box_data(txt, prop)
{
	box_data_start(prop);
	document.write(txt);
	box_data_end();
}
//}}}

//{{{function box_sep()
function box_sep()
{
	if (type=="text") document.write("</td></tr>");
	document.write("</table>");
	//if (type=="info") document.write("<br>");
	//dkbtxtclass=prefix+"bar";
	dkb_sepnext();
	//if (type=="info") document.write("<br>");

	if (type!="text") {
		document.write("<table width=100% align=center cellpadding=3 cellspacing=1>");
	} else {
		document.write("<table width=100% align=justify cellpadding="+margen+" cellspacing=0><tr><td class=Ttxt>");
	}
}
//}}}
//{{{function box_bar()
function box_bar(str)
{
	if (type=="text") document.write("</td></tr>");
	document.write("</table>");
	//if (type=="info") document.write("<br>");
	//dkbtxtclass=prefix+"bar";
	//dkb_sepnext("padding:5px");
	//dkb_sepnext("padding:5px");
	dkb_sepbtn();
	boxpos=0;
	document.write("<table align=center><tr><td>");
	if (str) document.write(str);
}
//}}}
//{{{ function box_end()
function box_end()
{
	if (boxpos==0)
	{
		// cerramos la barra de botones
		document.write("</td></tr></table>");
	}
	
	if (boxpos==1 || boxpos==3) {
		if (type=="text") document.write("</td></tr>");
		document.write("</table>");
		//if (type=="info") document.write("<br>");
	}
	//if (type=="data") document.write("</table>");
	dkb_end();
	document.write("</center><br>");
	
	if (type=="info") document.write("<br>");
	
	boxpos=0;
}
//}}}

// inputs
//{{{ function box_input(clase, type, name, value, prop)
function box_input(clase, type, name, value, prop)
{
	with (document) {
		write("<input ");
		write(" type='"+type+"'");
		write(" name='"+name+"'");
		write(" value='"+value+"'");
		if (prop) write(" "+prop);
		write(">");
		if (type=="button" || type=="submit" || type=="reset") write("&nbsp;");
	}
}
//}}}
//{{{ function box_texarea(clase, name, value, prop)
function box_textarea(clase, name, value, prop)
{
	with (document) {
		write("<textarea class='"+clase+"'");
		write(" name='"+name+"'");
		if (prop) write(prop);
		write(">");
		value=value.replace(RegExp('¬','gi'), '\n');
		write(value);
		write("</textarea>");
	}
}
//}}}
//{{{ function box_boton(name, value, url)
function box_boton(name, value, prop)
{
	box_input(prefix+"btn", "submit", name, value, prop);

}
//}}}
//{{{ function box_btn(name, value, url)
function box_btn(name, value, url)
{
	prop="";
	if (url) prop="onclick=location.href='"+url+"'";
	box_input(prefix+"btn", "button", name, value, prop);

}
//}}}
//{{{ function box_btns(name, value, url)
function box_btns(name, value, url)
{
	prop="";
	if (url) prop="onclick=location.href='"+url+"'";
	box_input(prefix+"btn", "submit", name, value, prop);

}
//}}}
//{{{ function box_botons(name, value, url)
function box_botons(name, value, url)
{
	//prop="";
	//if (url) prop="onclick=location.href='"+url+"'";
	//box_input(prefix+"btn", "submit", name, value, prop);
	
	dkb_btn_start();
	with (document) {
		//truco para que las fuentes salgan centradas en explorer
		//write('<font style="font-size:13px">&nbsp;</font>');
		write("<input type=hidden name='"+name+"'>");
		write("<a class=btn ");
		write("onmouseover=\"window.status='"+name+"';return true\" ");
		write("href=\"javascript:document.form."+name+".value='"+value+"';document.form.submit();\">");
		write(value);
		//write('<font style="font-size:14px">&nbsp;</font>');
		write("</a>");
		//truco para que las fuentes salgan centradas en explorer
		//write('<font style="font-size:13px">&nbsp;</font>');
	}
	dkb_btn_end();

}
//}}}
//{{{ function box_btnr(name, value, url)
function box_btnr(name, value, url)
{
	prop="";
	if (url) prop="onclick=location.href='"+url+"'";
	box_input(prefix+"btn", "reset", name, value, prop);
}
//}}}
//{{{ function box_txt(tipo, name, value, prop)
function box_txt(tipo, name, value, prop)
{
	if (tipo=="textarea") {
		box_textarea(prefix+"box", name, value, prop);
	} else {
		box_input(prefix+"box", tipo, name, value, prop);
	}
}
//}}}

// frontend inputs/ventanas
//{{{function box_formline_raw(txt, tipo, name, value, prop)
function box_formline_raw(txt, tipo, name, value, prop, txt2)
{
	if(!value) value="";

	box_data_start();
	document.write(txt);
	box_data_end();
	box_data_start();
	box_txt(tipo, name, value, prop);
	if (txt2) document.write(txt2);
	box_data_end();
}
//}}}
//{{{function box_formline(txt, name, value, prop)
function box_formline(txt, name, value, prop, txt2)
{
	box_formline_raw(txt, "text", name, value, prop, txt2);
}
//}}}
//{{{function box_formlinep(txt, name, value, prop)
function box_formlinep(txt, name, value, prop, txt2)
{
	box_formline_raw(txt, "password", name, value, prop, txt2);
}
//}}}
//{{{function box_formlinea(txt, name, value, prop)
function box_formlinea(txt, name, value, prop, txt2)
{
	box_formline_raw(txt, "textarea", name, value, prop, txt2);
}
//}}}
//{{{function box_formlinefile(txt, name, value, prop)
function box_formlinefile(txt, name, value, prop, txt2)
{
	box_formline_raw(txt, "file", name, value, prop, txt2);
/*

	if(!value) value="";

	box_data_start();
	document.write(txt);
	box_data_end();
	box_data_start();
	//box_txt(tipo, name, value, prop);
	box_txt(tipo, name, value, prop);
	//with (document) {
	//	write("<input class='"+clase+"'");
	//	write(" type='text'");
	//	write(" name='"+name+"'");
	//	write(" value='"+value+"'");
	//	if (prop) write(" "+prop);
	//	write(">");
	//}
	if (txt2) document.write(txt2);
	box_data_end();
	*/
}
//}}}

//{{{ function box_infoline(txt, txt2)
function box_infoline(txt, txt2)
{
	//box_data_start("width=50%");
	box_data_start();
	document.write(txt);
	box_data_end();
	box_data_start();
	document.write(txt2);
	box_data_end();
}
//}}}

////////////////////////////////////////////////////////////////////////////////

//{{{function msg_start()
function msg_start()
{
		//document.write("<div id=ias>");
		//document.write("<table border=0 cellspacing=1 cellpadding=0 bgcolor=#000000 width=70%><tr><td>");
		//document.write("<table border=0 cellspacing=0 cellpadding=0 width=100%><tr><td class=msg>");
		dkb_msg_start();
}
//}}}
//{{{function msg_end()
function msg_end()
{
		dkb_msg_end();
		//document.write("</td></tr></table>");
		//document.write("</td></tr></table>");
		//document.write("</div>");
		//document.write("<br>");
}
//}}}

//{{{ function box_btnimg(name, url)
function box_btnimg(name, url)
{
	dkb_btn_start(1);
	with (document)
	{
		// pequeño truco para que la fuente salga centrada en explorer
		//write('<font style="font-size:13px">&nbsp;</font>');

		write("<a class=btn ");
		//write("onmouseover=\"window.status=\'"+bar+"\';return true;\" ");
		//if (hlp!="") {
		//	write("title='"+hlp+"' ");
		//}
		write("href='"+url+"'>");
		write(name);
		write("</a>");
		//write('<font style="font-size:13px">&nbsp;</font>');
	}
	dkb_btn_end(0);
}
//}}}

//}}}
