////////////////////////////////////////////////////////////////////////////////////
//
//     ValdoImgInLineLib.js paveikslams
//
////////////////////////////////////////////////////////////////////////////////////

window.onerror=null;

var Im_SpanPad='0px';
var Im_SpanBord='0px solid olive';
var Im_SpanMarg='0px';
var Im_SpanVis='visible';
var Im_SpanPos='absolute';

////////////////////////////////////////////////////////////////////////////////////

function ComWrite(ElId,Cont) 
{
  if ( document.getElementById && !document.all ) 
  {  
    rng=document.createRange(); 
    el=document.getElementById(ElId); 
    rng.setStartBefore(el);
    htmlFrag=rng.createContextualFragment(Cont);

//    while (el.hasChildNodes())
//      el.removeChild(el.lastChild);
    
    el.appendChild(htmlFrag);
  }
}

///////////////////////////////////

function ImgInLineParams
  (nr,ImgName,spanTop,spanLeft,imgWidth,imgHeight,ImgHspace,ImgVspace,BgCol)
{
  if ( document.layers )
  {
    ImgPopNeParams
      (nr,ImgName,spanTop,spanLeft,imgWidth,imgHeight,ImgHspace,ImgVspace,BgCol);
  }
  else
  {
    if ( document.all )
    {
      ImgPopIeParams
        (nr,ImgName,spanTop,spanLeft,imgWidth,imgHeight,ImgHspace,ImgVspace,BgCol);
    }
    else
    {
      if ( document.getElementById )
      {
        ImgPopDomParams
          (nr,ImgName,spanTop,spanLeft,imgWidth,imgHeight,ImgHspace,ImgVspace,BgCol);
      }
    }
  }
}

function ImgPopIeParams
  (nr,ImgFile,spanTop,spanLeft,imgWidth,imgHeight,ImgHspace,ImgVspace,BgCol)
{
  var str;
  var IDname='d'+nr; 
  var ImgName='imgVab'+nr; 
  var spanWidth=imgWidth+ImgHspace;
  var spanHeight=imgHeight+ImgVspace;

  str="<SPAN ID="+IDname+" ";

  str=str+"STYLE='position:"+Im_SpanPos+"; left:"+spanLeft+"; top:"+spanTop+"; width:"+spanWidth+"; height:"+spanHeight+"; padding:"+Im_SpanPad+"; margin:"+Im_SpanMarg+"; border:"+Im_SpanBord+"; visibility:"+Im_SpanVis+"; z-index:"+nr+"; ";

  str=str+"background-color:"+BgCol+" ";
  
  str=str+"'>";

  str=str+"<CENTER>";

  if ( ImgName!=null)
  {
    str=str+"<img border='0' src="+ImgFile+" hspace="+ImgHspace+" vspace="+ImgVspace+" name="+ImgName+">";
  }

  str=str+"</center></SPAN>"; 

  document.write(str);  
}


function ImgPopDomParams
  (nr,ImgFile,spanTop,spanLeft,imgWidth,imgHeight,ImgHspace,ImgVspace,BgCol)
{
  var str;
  var IDname='d'+nr; 
  var ImgName='imgVab'+nr; 
  var spanWidth=imgWidth+ImgHspace;
  var spanHeight=imgHeight+ImgVspace;

  str="<SPAN ID="+IDname+" ";

  str=str+"STYLE='position:"+Im_SpanPos+"; left:"+spanLeft+"; top:"+spanTop+"; width:"+spanWidth+"; height:"+spanHeight+"; padding:"+Im_SpanPad+"; margin:"+Im_SpanMarg+"; border:"+Im_SpanBord+"; visibility:"+Im_SpanVis+"; z-index:"+nr+"; ";

  str=str+"background-color:"+BgCol+" ";
  
  str=str+"'>";

  str=str+"<CENTER>";

  if ( ImgName!=null)
  {
    str=str+"<img border='0' src="+ImgFile+" hspace="+ImgHspace+" vspace="+ImgVspace+" name="+ImgName+">";
  }

  str=str+"</center></SPAN>"; 

  ComWrite('Valdas',str);
}


function ImgPopNeParams
  (nr,ImgFile,spanTop,spanLeft,imgWidth,imgHeight,ImgHspace,ImgVspace,BgCol)
{
  var ae; 
  var IDname='d'+nr; 
  var NeIDname="Ne"+IDname;    
  var ImgName='imgVab'+nr;
  var spanWidth=imgWidth+ImgHspace;
  var spanHeight=imgHeight+ImgVspace;

  str="<LAYER LEFT="+spanLeft+" WIDTH="+spanWidth+" TOP="+spanTop+" HEIGHT="+spanHeight+" ";
  str=str+"BGCOLOR="+BgCol+" ";
  str=str+">"; 

  str=str+"<CENTER>"; 

  if ( ImgName!=null)
  {
    str=str+"<img border='0' src='"+ImgFile+"' hspace='"+ImgHspace+"' vspace='"+ImgVspace+"' name='"+ImgName+"'>";
  }

  str=str+"</CENTER></LAYER>";  

  ae=document.layers[NeIDname];
  ae.visibility="show";

  ae=document.layers[NeIDname].document; 
  ae.open(); ae.write(str); ae.close(); 

  Visibl=nr;
}


