String.prototype.find=function(what){return(this.indexOf(what)>=0 ? true : false);}
function Click(selectors,options){v=selectors.split(',');for(i=0;i<v.length;i++){BuildWindow(v[i],options);}}
function MakeHide(el){c=document.createElement('a');c.className='hide';c.title='close';c.href='javascript:close("'+divwrap.id+'");';c.appendChild(el);return c;}
function MakeSimple(el){c=document.createElement('a');c.className='toggle';c.title='toggle';c.href='javascript:toggle("'+divcont.id+'");';c.appendChild(el);return c;}
function MakeMoo(el){c=document.createElement('a');c.className='toggle';c.title='toggle';c.href='javascript:var openclose=new fx.Height("'+divcont.id+'",{duration: 500});openclose.toggle();';c.appendChild(el);return c;}
function MakeHelp(el){c=document.createElement('span');c.className='help';c.appendChild(el);return c;}
function BuildWindow(el,options){if(options==null){return;}
	divwrap=document.getElementById(el);divcont=divwrap.lastChild;divbar=divwrap.firstChild;
	if(options.find('bar:')){
		if(options.find('bar:dra')){l=MakeDrag(document.createTextNode(' _ '));l.className='barra';ob=divbar.appendChild(l);divwrap.style.position='relative';Drag.init(ob,divwrap);}
		else if(options.find('bar:moo')){l=MakeMoo(document.createTextNode(' _ '));l.className='barra';divbar.appendChild(l);if(options.find('closed')){fallo=new fx.Height(divcont.id,{duration: 0});fallo.hide();}}
		else {l=MakeSimple(document.createTextNode(' _ '));l.className='barra';divbar.appendChild(l);if(options.find('closed')){divcont.style.display='none';}}
		}
	if(options.find('drag') || options.find('moofx') || options.find('simple') || options.find('max') || options.find('hide') || options.find('help')){
		wrapc=document.createElement('div');wrapc.className='wrapc';
		if(options.find('drag')){ob=wrapc.appendChild(MakeDrag(document.createTextNode(' + ')));divwrap.style.position='relative';Drag.init(ob,divwrap);}
		if(options.find('moofx') || options.find('simple')){if(options.find('moofx')){wrapc.appendChild(MakeMoo(document.createTextNode(' - ')));if(options.find('closed')){fallo=new fx.Height(divcont.id,{duration: 0});fallo.hide();}}else{wrapc.appendChild(MakeSimple(document.createTextNode(' - ')));if(options.find('closed')){divcont.style.display='none';}}}
		if(options.find('max')){wrapc.appendChild(MakeMax(document.createTextNode(' o ')));}
		if(options.find('hide')){wrapc.appendChild(MakeHide(document.createTextNode(' x ')));}
		divbar.appendChild(wrapc);
		}
	if(options.find('help')){if(divcont.lastChild.className=='desc'){t=divcont.lastChild.cloneNode(true);divcont.lastChild.style.display='none';h=divbar.insertBefore(MakeHelp(document.createTextNode(' ? ')),divbar.firstChild);t.className='tooltip';t.style.display='none';h.appendChild(t);h.onmouseover=showTooltip;h.onmouseout=hideTooltip;h.onclick=hideTooltip;}}
}
function toggle(el){div=document.getElementById(el);if(div.style.display=='none'){div.style.display='block';}else{div.style.display='none';}}
function close(el){div=document.getElementById(el);div.style.display='none';}
function showTooltip(event){this.style.zIndex='25';this.lastChild.style.display='block';}
function hideTooltip(event){this.style.zIndex='24';this.lastChild.style.display='none';}
