<script>
function serialize(data,separ)
{
var arr,key;
var sep = separ ? separ : [' ','=','"'];
arr = [];
for (key in data)
	{
	arr[arr.length] = data[key]!='' ? key + sep[1] + sep[2] + data[key] + sep[2] : '';
	}
return arr.join(sep[0]);
}


function classHtml()
{
var that = this;
//caption:function(){},thead:function(){},tr:function(){},th:function(){},td:function(){},tbody:function(){},tfoot:function(){},
this.func = {
link    :function(text,url,params){params = that.check(params); params['href'] = url; return that.draw('double','a',params,text);},
anchor  :function(name,params){params = that.check(params); params['name'] = name; params['id'] = name; return that.draw('double','a',params);},
code    :function(text,params){return that.draw('double','pre',params,text);},
image   :function(url,params){params = that.check(params); params['src'] = url; return that.draw('single','img',params);},
audio   :function(){},
video   :function(){},
text    :function(text,params){return that.draw('input','text',params,text);},
textarea:function(text,params){return that.draw('double','textarea',params,text);},
hidden  :function(text,params){return that.draw('input','hidden',params,text);},
check   :function(text,params){return that.draw('input','checkbox',params,text);},
radio   :function(text,params){return that.draw('inputlabel','radio',params,text);},
checkgroup :function(data,params){},
radiogroup :function(data,params){},
button  :function(text,params){return that.draw('double','button',params,text);},
buttonjs:function(text,params){return that.draw('input','text',params,text);},
div     :function(text,params){return that.draw('double','div',params,text);},
span    :function(text,params){return that.draw('double','span',params,text);},
header  :function(text,params){return that.draw('double','h1',params,text);},
p       :function(text,params){return that.draw('double','p',params,text);},
br      :function(params){return that.draw('single','br',params);},
hr      :function(params){return that.draw('single','hr',params);},
sub     :function(text,params){return that.draw('double','sub',params,text);},
sup     :function(text,params){return that.draw('double','sup',params,text);},
list    :function(){}, //ul //ol , li
table   :function(data,params){},
form    :function(text,params){return that.draw('double','form',params,text);},
label   :function(text,params){return that.draw('double','textarea',params,text);},
select  :function(data,params){},
//option  :function(){},
fieldset:function(text,params){return that.draw('double','fieldset',params,text);},
legend  :function(text,params){return that.draw('double','legend',params,text);},
iframe  :function(url,params){params = that.check(params); params['src'] = url; return that.draw('double','iframe',params,text);},
base    :function(params){return that.draw('single','hr',params);},
object  :function(){}
//script  :function(str){}
};

this.check = function (params)
	{
	return (params && typeof(params)=='object' ? params : {});
	}; 

this.draw = function (type,name,params,text)
	{
	params = this.check(params); 
	switch (type)
		{
		case 'single'    : return '<'+name+' ' + serialize(params) + '/>'; break;			// single tag
		case 'input'     : return '<input type="'+name+'" ' + serialize(params) + '\/>'; break;
		case 'inputlabel': return '<input type="'+name+'" ' + serialize(params) + '\/>'+this.draw('double','label', {onclick: params.onclick, title: params.title}, text); break;
		case 'double'    : return '<'+name+' '+serialize(params)+'>'+ text +'<\/'+name+'>'; break;	// double tag
		default	         : return '';
		}
	return '';
	}
this.init = function ()
	{
	var i;
	for(i in this.func)
		{window[i] = this.func[i];}
	}
this.init();
/*
this.templates =
	{
	'input': 'input type="text" size="6" name="%%%name%%%" value="%%%value%%%" onchange="%%%func%%%"/',
	'th'   : "\n"+'th%%%text%%%\/th',
	'td'   : "\n"+'td%%%bg%%%%%%fg%%%%%%text%%%\/td',
	}
this.draw = function (str,data)
	{
	for (i in data)
		{
		str = str.replace('%%%'+i+'%%%',data[i]);
		}
	return str;
	}
this.drawTpl = function (name,data)
	{
	if (this.templates && this.templates[name])
		{
		return(this.draw(this.templates[name],data));
		}
	return '';
	}
*/
}
/*
myrender = new drawhtml();
alert(myrender.drawTpl('td',{'bg':1,'fg':2,'text':'ahoj'}));
*/

var html = new classHtml();
document.write(link('ahoj','http://yko.cz'));




/*this.tags      = 'link,hook(anchor),image
code (pre)
check (checkbox)
input /   button
'

,audio,video,text,hidden,radio,check'.split(',');
div,span,header,p,sub,sup,ul,li,table,caption,thead,tr,th,td,tbody,tfoot,form,label,select,option,fieldset,legend,
iframe,base,object,

br,hr

  textarea
script,
'

this.tag_names = 'a,img'.split(',');
*/
</script>