// JavaScript Document
/**
 * Example
 *  theDivElement.addElement(aDivelement);

  var theElement=new DIVElement();
  theElement.addStyle('position:absolute');
  theElement.addStyle('top:0px');
  theElement.addStyle('left:-'+this.topOffset+'px');
  theElement.addStyle('height:'+this.height+'px');
  theElement.addStyle('width:'+this.topOffset+'px');
  theElement.addStyle('background-image:url('+this.backgroundImg+')');
 */ 
function DIVElement()
{
  this.beginTagStart='<div ';
  this.beginTagEnd='>';
  this.style='style="';
  this.endStyle='"';
  this.endTag='</div>';
  this.styleAttr=new Array();
  this.styleMap=new Array();
  this.children=new Array();
  this.attributes='';
  this.content='';  
  this.attList=new Array();
  this.element=null;// HTML document element
  
}

DIVElement.prototype.addStyleElement=function(aAttr, aValue)
{
  this.styleMap[aAttr]=aValue;
  return this;
}

DIVElement.prototype.addContent=function(aContent)
{
  this.content+=aContent;
  return this;
}

DIVElement.prototype.addAttribute=function(anAttr, aValue)
{
  
  this.attList[anAttr]=aValue;
  return this;
}

DIVElement.prototype.removeElements=function()
{
  if (this.children.length > 0)
  	this.children=new Array();
  return this;
}

DIVElement.prototype.addElement=function(anElement)
{
  this.children[this.children.length]=anElement;
  return this;
}

DIVElement.prototype.addStyle=function(aStyleAttr)
{
  this.styleAttr[this.styleAttr.length]=aStyleAttr;
  return this;
}


DIVElement.prototype.replaceAll=function(anElement)
{
	if (this.element==null && this.attList['id'])
	{
		this.element = document.getElementById(this.attList['id']);
	}
	if (this.element)
	{
		this.element.innerHTML=anElement.write();
	}
	else
	{
		this.children=new Array();
		this.children[0]=anElement;
	}
}

DIVElement.prototype.write=function()
{
  var theString = this.beginTagStart+' ';
  for (var e in this.attList)
  {
    theString+=e;
 	  theString+='="';
	  theString+=this.attList[e]; 
    theString+='" ';
  }
  
  theString+=this.style;
  for(var i=0;i<this.styleAttr.length;i++)
  {
    theString+=this.styleAttr[i]; 
    theString+="; ";
	
  }
  for (var j in this.styleMap)
  {
    theString+=j;
	theString+=":";
	theString+=this.styleMap[j]; 
    theString+="; ";
  }
  theString+=this.endStyle;
  theString+=this.beginTagEnd;
  if (this.content.length>0)
  {
    theString+=this.content;
  }
  for (var j=0;j<this.children.length;j++)
  {
    theString+=this.children[j].write();
  }
  
  theString+=this.endTag;
  //alert(theString);
  return theString;
}




// JavaScript Document
/**
 * Example
 *  theDivElement.addElement(aDivelement);

  var theElement=new DIVElement();
  theElement.addStyle('position:absolute');
  theElement.addStyle('top:0px');
  theElement.addStyle('left:-'+this.topOffset+'px');
  theElement.addStyle('height:'+this.height+'px');
  theElement.addStyle('width:'+this.topOffset+'px');
  theElement.addStyle('background-image:url('+this.backgroundImg+')');
 */ 
function ElementTag(aName)
{
  this.beginTagStart='<'+aName;
  this.beginTagEnd='>';
  this.style='style="';
  this.endStyle='"';
  this.endTag='</'+aName+'>';
  this.styleAttr=new Array();
  this.children=new Array();
  this.attributes='';  
  this.content='';  
  this.attList=new Array();
  this.id=null;
}

ElementTag.prototype.addStyleElement=function(aAttr, aValue)
{
  var theString=aAttr+':'+aValue;
  this.addStyle(theString);
  return this;
}

ElementTag.prototype.addAttribute=function(anAttr, aValue)
{
  this.attributes+=anAttr+'="'+aValue+'"';
  this.attributes+=' ';
  this.attList[anAttr]=aValue;
  
  return this;
}

ElementTag.prototype.addContent=function(aContent)
{
  this.content+=aContent;
  return this;
}



ElementTag.prototype.addElement=function(anElement)
{
  this.children[this.children.length]=anElement;
  return this;
}

ElementTag.prototype.addStyle=function(aStyleAttr)
{
  this.styleAttr[this.styleAttr.length]=aStyleAttr;
  return this;
}


ElementTag.prototype.write=function()
{
  var theString = this.beginTagStart+' '+this.attributes+" "+this.style;
  for(var i=0;i<this.styleAttr.length;i++)
  {
    theString+=this.styleAttr[i];
    theString+="; ";
  }
  theString+=this.endStyle;
  theString+=this.beginTagEnd;
  for (var j=0;j<this.children.length;j++)
  {
    theString+=this.children[j].write();
  }
  
  theString+=this.endTag;
  //alert(theString);
  return theString;
}
/**
 * Reslisiert ein <span> Element.
 * @author Markus Hanses
 */
function SPANElement() {
	this.beginTagStart='<span';
  	this.beginTagEnd='>';
  	this.style='style="';
  	this.endStyle='"';
  	this.endTag='</span>';
  	this.styleAttr=new Array();
  	this.children=new Array();
  	this.attributes='';  
  	this.content='';  
  	this.attList=new Array();
}
/**
 * @author Markus Hanses
 * @param {Object} aAttr
 * @param {Object} aValue
 */
SPANElement.prototype.addStyleElement=function(aAttr, aValue)
{
  var theString=aAttr+':'+aValue;
  this.addStyle(theString);
  return this;
}
/**
 * @author Markus Hanses
 * @param {Object} anAttr
 * @param {Object} aValue
 */
SPANElement.prototype.addAttribute=function(anAttr, aValue)
{
  this.attributes+=anAttr+'="'+aValue+'"';
  this.attributes+=' ';
  this.attList[anAttr]=aValue;
  return this;
}
/**
 * @author Markus Hanses
 * @param {Object} aContent
 */
SPANElement.prototype.addContent=function(aContent)
{
  this.content+=aContent;
  return this;
}
/**
 * @author Markus Hanses
 * @param {Object} anElement
 */
SPANElement.prototype.addElement=function(anElement)
{
  this.children[this.children.length]=anElement;
  return this;
}
/**
 * @author Markus Hanses
 * @param {Object} aStyleAttr
 */
SPANElement.prototype.addStyle=function(aStyleAttr)
{
  this.styleAttr[this.styleAttr.length]=aStyleAttr;
  return this;
}
/**
 * Erzeugt den HTML Code.
 * @author Markus Hanses
 */
SPANElement.prototype.write=function()
{
  var theString = this.beginTagStart+' '+this.attributes+" "+this.style;
  for(var i=0;i<this.styleAttr.length;i++)
  {
    theString+=this.styleAttr[i];
    theString+="; ";
  }
  theString+=this.endStyle;
  theString+=this.beginTagEnd;
  theString+=this.content;
  for (var j=0;j<this.children.length;j++)
  {
    theString+=this.children[j].write();
  }
  
  theString+=this.endTag;  
  return theString;
}

// JavaScript Document
/**
 * Example
 *  theDivElement.addElement(aDivelement);

  var theElement=new DIVElement();
  theElement.addStyle('position:absolute');
  theElement.addStyle('top:0px');
  theElement.addStyle('left:-'+this.topOffset+'px');
  theElement.addStyle('height:'+this.height+'px');
  theElement.addStyle('width:'+this.topOffset+'px');
  theElement.addStyle('background-image:url('+this.backgroundImg+')');
 */ 
function PElement()
{
  this.beginTagStart='<p';
  this.beginTagEnd='>';
  this.style='style="';
  this.endStyle='"';
  this.endTag='</p>';
  this.styleAttr=new Array();
  this.children=new Array();
  this.attributes='';  
  this.content='';  
  this.attList=new Array();
}

PElement.prototype.addStyleElement=function(aAttr, aValue)
{
  var theString=aAttr+':'+aValue;
  this.addStyle(theString);
  return this;
}

PElement.prototype.addAttribute=function(anAttr, aValue)
{
  this.attributes+=anAttr+'="'+aValue+'"';
  this.attributes+=' ';
  this.attList[anAttr]=aValue;
  return this;
}

PElement.prototype.addContent=function(aContent)
{
  this.content+=aContent;
  return this;
}


PElement.prototype.addElement=function(anElement)
{
  this.children[this.children.length]=anElement;
  return this;
}

PElement.prototype.addStyle=function(aStyleAttr)
{
  this.styleAttr[this.styleAttr.length]=aStyleAttr;
  return this;
}


PElement.prototype.write=function()
{
  var theString = this.beginTagStart+' '+this.attributes+" "+this.style;
  for(var i=0;i<this.styleAttr.length;i++)
  {
    theString+=this.styleAttr[i];
    theString+="; ";
  }
  theString+=this.endStyle;
  theString+=this.beginTagEnd;
  theString+=this.content;
  for (var j=0;j<this.children.length;j++)
  {
    theString+=this.children[j].write();
  }
  
  theString+=this.endTag;
  //alert(theString);
  return theString;
}
