<?php
$buttontag='button';
// $pstyle='height:1.2em;';

if(empty($pid)){$pid=microtime()*1000000;}
if(empty($pobj)){$pobj=3;}
if(empty($psize)){$psize=1;}
if(empty($plabel)){$plabel=$pcaption;}
if(!empty($psize) and $psize!=1){$pstyle.='font-size:'.($psize).'em;';}
if(!empty($pcolor)){$pstyle.='background:'.$pcolor.';';}
if(!empty($pcolor) and hexdec($pcolor)<=100){$pstyle.='color:#808080;';}

// if($ptcells>=1){$pstyle.='width:100%;';}
// if(!empty($pdom) and $ptcells>=1){$pstyle.='width:100%;';}
// if(mb_stristr($pwidth,'%')){$pstyle.='width:100%;';}
if(mb_stristr($pwidth,'%') or $ptcells>=1){$pstyle.='width:100%;';}

$domi = new DOMDocument();
     $domi->encoding = 'utf-8';
     $domi->xmlVersion = '1.0';
     $domi->formatOutput = true;
$elem=$domi;

if(!empty($pdom)){$domi=$pdom;}
if(!empty($pele)){$elem=$pele;}

if($ptcells>=2)
{
  $vrbutton=$elem->appendChild($domi->createElement("td"));
  $vrbutton->setAttribute("colspan",$ptcells);
  $vrbutton->setAttribute("valign","top");
}
else
{$vrbutton=$elem->appendChild($domi->createElement("span"));}

if(!empty($palign)){$vrbutton->setAttribute("align",$palign);}

// windows
//    if($pobj==2 or $pobj==3 )
   {
     $button=$vrbutton->appendChild($domi->createElement($buttontag,$plabel));   
          if(!empty($pid)){$button->setAttribute("id",$pid);}
          if(!empty($ptype)){$button->setAttribute("type",$ptype);}
          if(!empty($pstyle)){$button->setAttribute("style",$pstyle);}
          if(!empty($pclass)){$button->setAttribute("class",$pclass);}
          if(!empty($pvalue)){$button->setAttribute("value",$pvalue);}
          if(!empty($ponclick)){$button->setAttribute("onclick",$ponclick);}
     $span=$vrbutton->appendChild($domi->createElement("span",""));   
          if(!empty($pid)){$button->setAttribute("id",$pid.'_msg');}
   }

if(empty($pdom))
{
     if($pxml==1){$pxml=$domi->saveXML();}
     else{echo $domi->saveXML();}
}     

$pid='';
$pdom='';
$pele='';
$plabel='';
$pvalue='';
$pclass='';
$ponclick;

$ptype='';
$pplace='';
$pstyle='';
$pwidth='';
$psize='';
$palign='';
$pcolor='';
?>
