function cssAdd(elm,newClass)
{
	if(elm.className) o0=elm;
	else o0=document.getElementById(elm);
	if(o0) o0.className=cssRemove(elm, newClass)+" "+newClass;
  //showDebug("cssAdd id="+o0.getAttribute('id')+" className='"+o0.className+"'<br />\n");
}

function cssRemove(elm,oldClass)
{
  var x;
	if(elm.className) o0=elm;
	else o0=document.getElementById(elm);
	if(!o0) return '';
	x=" "+o0.className+" ";
	x=x.replace(" "+oldClass+" ","").substr(1);
	if(x.substr(x.length-1)==" ") x=x.substr(0,x.length-1);
  //addDebug("cssRemove id="+o0.getAttribute('id')+" className='"+o0.className+"', x='"+x+"'<br />\n");
	o0.className=x;
	return x;
}

function pblScaleImage(img0, maxW, maxH)
{
var s0, s1;
  if(!img0.width) return;
	if(!img0.height) return;
  s0=maxH/img0.height;
	s1=maxW/img0.width;
	if(s1<s0) s0=s1;
	img0.height=img0.height*s0;
	img0.width=img0.width*s0;
	return;
}
function showDebug(txt)
{
  d=document.getElementById('debug');
	if(d) d.innerHTML=txt;
}
function addDebug(txt)
{
  d=document.getElementById('debug');
	if(d) d.innerHTML+=txt;
}
