///////////////////////////////////////
//                                   //
//  OBJETOS HTML                     //
//  -------------------------------  //
//  Creación de texto HTML a partir  //
//  de objetos en JavaScript.        //
//  http://www.apuros.com            //
//                                   //
///////////////////////////////////////
function htmlTabla(_width, _align, _border, _cellPadding, _cellSpacing){
	this._align=(_align==undefined) ? null : _align ;	this._width=(_width==undefined) ? null : _width ;
	this._border=(_border==undefined) ? 0 : _border ;
	this._cellPadding=(_cellPadding==undefined) ? 0 : _cellPadding ;	this._cellSpacing=(_cellSpacing==undefined) ? 0 : _cellSpacing ;	this.aFilas=[];
	this.filas=0;}
htmlTabla.prototype.add=function(){
	var ultimo=this.aFilas.length;
	this.aFilas[ultimo]=new htmlFila();
	this.filas++;	return this.aFilas[ultimo];
};
htmlTabla.prototype.toString=function(){
	var str='<TABLE';	if (this._width!='' && this._width!=undefined) str+=' WIDTH="'+this._width+'"';	if (this._align!='' && this._align!=undefined) str+=' ALIGN="'+this._align+'"';	if (this._border!='' && this._border!=undefined) str+=' BORDER="'+this._border+'"';	if (this._cellPadding!='' && this._cellPadding!=undefined) str+=' CELLPADDING="'+this._cellPadding+'"';	if (this._cellSpacing!='' && this._cellSpacing!=undefined) str+=' CELLSPACING="'+this._cellSpacing+'"';	
	str+='>';	for (var i=0; i<this.aFilas.length; i++)
		str+=this.aFilas[i]+'\n'
	return str+'</TABLE>';
};
// objeto htmlFila
function htmlFila(){
	this.aCeldas=[];}htmlFila.prototype.add=function(contenido, _vAlign, _align, _width, _class, _colspan) {
	var ultimo=this.aCeldas.length;	this.aCeldas[ultimo]=new htmlCelda(contenido, _vAlign, _align, _width, _class, _colspan);	return this.aCeldas[ultimo];
};htmlFila.prototype.toString=function(){
	var str='<TR>';	for (var i=0; i<this.aCeldas.length; i++)
		str+=this.aCeldas[i]
	return str+'</TR>';
};
// objeto htmlCelda
function htmlCelda(contenido, _vAlign, _align, _width, _class, _colspan){
	this.contenido='\n'+contenido+'\n';	this._align=(_align==undefined) ? null : _align ;	this._width=(_width==undefined) ? null : _width ;
	this._colspan=(_colspan==undefined) ? 0 : _colspan ;
	this._vAlign=(_vAlign==undefined) ? 0 : _vAlign ;	this._class=(_class==undefined) ? 0 : _class ;}
htmlCelda.prototype.toString=function(){
	var str='<TD';
	if (this._vAlign!='' && this._vAlign!=undefined) str+=' VALIGN="'+this._vAlign+'"';
	if (this._align!='' && this._align!=undefined) str+=' ALIGN="'+this._align+'"';
	if (this._width!='' && this._width!=undefined) str+=' WIDTH="'+this._width+'"';
	if (this._class!='' && this._class!=undefined) str+=' CLASS="'+this._class+'"';	if (this._colspan!='' && this._colspan!=undefined) str+=' COLSPAN="'+this._colspan+'"';
	if (this._bgcolor!='' && this._bgcolor!=undefined) str+=' BGCOLOR="'+this._bgcolor+'"';	if (this._background!='' && this._background!=undefined) str+=' BACKGROUND="'+this._background+'"';	str+='>'+this.contenido+'</TD>';	return str;};
//<IMGfunction htmlImagen(url,borde,ancho,alto){
	this.url=url;
	this.borde=borde;
	this.ancho=ancho;
	this.alto=alto;}htmlImagen.prototype.toString=function(){
	var str='<img src="'+this.url+'"';	if (this.borde!='') str+=' border="'+this.borde+'"';	if (this.ancho!='') str+=' width="'+this.ancho+'"';	if (this.alto!='') str+=' height="'+this.alto+'"';	str+='>';	return str;
};
//<A HREF...>function htmlAncla(url,texto){
	this.url=url;
	this.texto=texto;
}htmlAncla.prototype.toString=function(){
/*	var str='';	if (this.texto==''){		str='<A NAME="'+this.url+'"></A>';	}else{		str='<A HREF="'+this.url+'">'+this.texto+'</A>';
	}	return str;*/
	return (this.texto=='') ? '<A NAME="'+this.url+'"></A>' : '<A HREF="'+this.url+'">'+this.texto+'</A>'};
