/**
 * doijs package
 * 
 * @author donna iwan setiawan
 * @version 1.1 
 * copyright - (c) 2007 - 2009 donna iwan setiawan
 * license - GPL version 3 or any later version <http://www.gnu.org/licenses/gpl-3.0.txt>
 */
doi.widget.button=function(){var a=arguments[0]||false,c=[],b=[];return{render:function(){if(!a){c=doi.dom.$("tag:button;title=doi-widget-button:true")}else{if(a.length){c=a}else{c=[a]}}for(var e=0;e<c.length;e++){if(!doi.dom.isElement(c[e])){continue}var d=new doi.widget.buttonByElement(c[e]);d.render();b.push(d)}}}};doi.widget.register(doi.widget.button);doi.widget.buttonByElement=function(){var b=arguments[0]||false,a,g,f=this,h,c=false,e="doi-widget-button",d,i="";return{render:function(){if(c){return}if(!doi.dom.isElement(b)){var n=document.createElement("button");doi.dom.write(n);g=doi.widget.instance.save(this);b=n;h=g}else{g=doi.widget.instance.save(this,b.id);e=b.className||e;h=b.name||g}b.name=h;b.id=g;doi.dom.className(b,e);a=doi.dom.parseAttribute(b.getAttribute("title"))||{};if(!a.imagePosition){a.imagePosition="left"}if(a.title){b.setAttribute("title",a.title)}else{b.setAttribute("title","")}for(var m=0;m<b.childNodes.length;m++){if(b.childNodes[m].nodeName=="IMG"){d=b.childNodes[m].cloneNode(true)}else{i+=doi.dom.outerHTML(b.childNodes[m])}}var p=document.createElement("table");var k=document.createElement("tbody");p.appendChild(k);p.setAttribute("cellPadding",2);p.setAttribute("cellSpacing",0);p.setAttribute("border",0);var j=document.createElement("tr");var q=document.createElement("tr");var o=document.createElement("td");o.setAttribute("valign","middle");o.setAttribute("align","center");var l=document.createElement("td");l.setAttribute("valign","middle");l.setAttribute("align","center");if(i==""&&!d){k.appendChild(j);o.innerHTML="&nbsp";j.appendChild(o)}else{switch(a.imagePosition){case"right":k.appendChild(j);if(i!=""){o.innerHTML=i;j.appendChild(o)}if(d){l.appendChild(d);j.appendChild(l)}break;case"top":if(d){o.appendChild(d);j.appendChild(o);k.appendChild(j)}if(i!=""){l.innerHTML=i;q.appendChild(l);k.appendChild(q)}break;case"bottom":if(i!=""){o.innerHTML=i;j.appendChild(o);k.appendChild(j)}if(d){l.appendChild(d);q.appendChild(l);k.appendChild(q)}break;default:k.appendChild(j);if(d){o.appendChild(d);j.appendChild(o)}if(i!=""){l.innerHTML=i;j.appendChild(l)}}}b.innerHTML="";b.appendChild(p);doi.event.add(b,"mouseover",function(){doi.dom.addClass(this,e+"-hover")});doi.event.add(b,"mouseout",function(){doi.dom.removeClass(this,e+"-hover")});doi.event.add(b,"mousedown",function(){doi.dom.removeClass(this,e+"-hover");doi.dom.addClass(this,e+"-down")});doi.event.add(b,"mouseup",function(){doi.dom.removeClass(this,e+"-down");doi.dom.addClass(this,e+"-hover")});c=true},element:function(){return b}}};