function clearText(elemid){
    dojo.byId(elemid).select();
}

function my_htmlentities(str)
{
	if(isArray(str)){
		for(x=0;x<str.length;x++){
			if (is_string(str[x]))
				str[x] = do_htmlentities(str[x]);
		}
	}
	else str = do_htmlentities(str);
	return str;
}

function my_htmlentities_decode(str){
	if(isArray(str)){
		for(x=0;x<str.length;x++){
			if (is_string(str[x]))
				str[x] = do_htmlentities_decode(str[x]);
		}
	}
	else str = do_htmlentities_decode(str);
	return str;
}

function do_htmlentities(str)
{
	str = str.replace(/�/g,'$Agrave;');
	str = str.replace(/�/g,'$Aacute;');
	str = str.replace(/�/g,'$Acirc;');
	str = str.replace(/�/g,'$Atilde;');
	str = str.replace(/�/g,'$Auml;');
	str = str.replace(/�/g,'$Aring;');
	str = str.replace(/�/g,'$AElig;');
	str = str.replace(/�/g,'$Ccedil;');
	str = str.replace(/�/g,'$Egrave;');
	str = str.replace(/�/g,'$Eacute;');
	str = str.replace(/�/g,'$Ecirc;');
	str = str.replace(/�/g,'$Euml;');
	str = str.replace(/�/g,'$Igrave;');
	str = str.replace(/�/g,'$Iacute;');
	str = str.replace(/�/g,'$Icirc;');
	str = str.replace(/�/g,'$Iuml;');
	str = str.replace(/�/g,'$ETH;');
	str = str.replace(/�/g,'$Ntilde;');
	str = str.replace(/�/g,'$Ograve;');
	str = str.replace(/�/g,'$Oacute;');
	str = str.replace(/�/g,'$Ocirc;');
	str = str.replace(/�/g,'$Otilde;');
	str = str.replace(/�/g,'$Ouml;');
	str = str.replace(/�/g,'$Oslash;');
	str = str.replace(/�/g,'$Ugrave;');
	str = str.replace(/�/g,'$Uacute;');
	str = str.replace(/�/g,'$Ucirc;');
	str = str.replace(/�/g,'$Uuml;');
	str = str.replace(/�/g,'$Yacute;');
	str = str.replace(/�/g,'$THORN;');
	str = str.replace(/�/g,'$szlig;');
	str = str.replace(/�/g,'$agrave;');
	str = str.replace(/�/g,'$aacute;');
	str = str.replace(/�/g,'$acirc;');
	str = str.replace(/�/g,'$atilde;');
	str = str.replace(/�/g,'$auml;');
	str = str.replace(/�/g,'$aring;');
	str = str.replace(/�/g,'$aelig;');
	str = str.replace(/�/g,'$ccedil;');
	str = str.replace(/�/g,'$egrave;');
	str = str.replace(/�/g,'$eacute;');
	str = str.replace(/�/g,'$ecirc;');
	str = str.replace(/�/g,'$euml;');
	str = str.replace(/�/g,'$igrave;');
	str = str.replace(/�/g,'$iacute;');
	str = str.replace(/�/g,'$icirc;');
	str = str.replace(/�/g,'$iuml;');
	str = str.replace(/�/g,'$eth;');
	str = str.replace(/�/g,'$ntilde;');
	str = str.replace(/�/g,'$ograve;');
	str = str.replace(/�/g,'$oacute;');
	str = str.replace(/�/g,'$ocirc;');
	str = str.replace(/�/g,'$otilde;');
	str = str.replace(/�/g,'$ouml;');
	str = str.replace(/�/g,'$oslash;');
	str = str.replace(/�/g,'$ugrave;');
	str = str.replace(/�/g,'$uacute;');
	str = str.replace(/�/g,'$ucirc;');
	str = str.replace(/�/g,'$uuml;');
	str = str.replace(/�/g,'$yacute;');
	str = str.replace(/�/g,'$thorn;');
	str = str.replace(/�/g,'$yuml;');
	str = str.replace(/\"/g,'$quot;');
	str = str.replace(/\'/g,'$39;');
	str = str.replace(/&/g,'$amp;');
	str = str.replace(/#/g,'$35;');
	str = str.replace(/%/g,'$percent;');
	str = str.replace(/</g,'$lt;');
	str = str.replace(/>/g,'$gt;');
	str = str.replace(/�/g,'$iexcl;');
	str = str.replace(/�/g,'$curren;');
	str = str.replace(/�/g,'$cent;');
	str = str.replace(/�/g,'$pound;');
	str = str.replace(/�/g,'$yen;');
	str = str.replace(/�/g,'$brvbar;');
	str = str.replace(/�/g,'$sect;');
	str = str.replace(/�/g,'$uml;');
	str = str.replace(/�/g,'$copy;');
	str = str.replace(/�/g,'$ordf;');
	str = str.replace(/�/g,'$laquo;');
	str = str.replace(/�/g,'$not;');
	str = str.replace(/�/g,'$shy;');
	str = str.replace(/�/g,'$reg;');
	str = str.replace(/�/g,'$trade;');
	str = str.replace(/�/g,'$macr;');
	str = str.replace(/�/g,'$deg;');
	str = str.replace(/�/g,'$plusmn;');
	str = str.replace(/�/g,'$sup2;');
	str = str.replace(/�/g,'$sup3;');
	str = str.replace(/�/g,'$acute;');
	str = str.replace(/�/g,'$micro;');
	str = str.replace(/�/g,'$para;');
	str = str.replace(/�/g,'$middot;');
	str = str.replace(/�/g,'$cedil;');
	str = str.replace(/�/g,'$sup1;');
	str = str.replace(/�/g,'$ordm;');
	str = str.replace(/�/g,'$raquo;');
	str = str.replace(/�/g,'$frac14;');
	str = str.replace(/�/g,'$frac12;');
	str = str.replace(/�/g,'$frac34;');
	str = str.replace(/�/g,'$iquest;');
	str = str.replace(/�/g,'$times;');
	str = str.replace(/�/g,'$divide;');
	str = str.replace(/�/g,'$lsquo;');
	str = str.replace(/�/g,'$rsquo;');
	return str;
}
function do_htmlentities_decode(str)
{
	for(x=0;x<20;x++) {
		str = str.replace('$Agrave;','�');
		str = str.replace('$Aacute;','�');
		str = str.replace('$Acirc;','�');
		str = str.replace('$Atilde;','�');
		str = str.replace('$Auml;','�');
		str = str.replace('$Aring;','�');
		str = str.replace('$AElig;','�');
		str = str.replace('$Ccedil;','�');
		str = str.replace('$Egrave;','�');
		str = str.replace('$Eacute;','�');
		str = str.replace('$Ecirc;','�');
		str = str.replace('$Euml;','�');
		str = str.replace('$Igrave;','�');
		str = str.replace('$Iacute;','�');
		str = str.replace('$Icirc;','�');
		str = str.replace('$Iuml;','�');
		str = str.replace('$ETH;','�');
		str = str.replace('$Ntilde;','�');
		str = str.replace('$Ograve;','�');
		str = str.replace('$Oacute;','�');
		str = str.replace('$Ocirc;','�');
		str = str.replace('$Otilde;','�');
		str = str.replace('$Ouml;','�');
		str = str.replace('$Oslash;','�');
		str = str.replace('$Ugrave;','�');
		str = str.replace('$Uacute;','�');
		str = str.replace('$Ucirc;','�');
		str = str.replace('$Uuml;','�');
		str = str.replace('$Yacute;','�');
		str = str.replace('$THORN;','�');
		str = str.replace('$szlig;','�');
		str = str.replace('$agrave;','�');
		str = str.replace('$aacute;','�');
		str = str.replace('$acirc;','�');
		str = str.replace('$atilde;','�');
		str = str.replace('$auml;','�');
		str = str.replace('$aring;','�');
		str = str.replace('$aelig;','�');
		str = str.replace('$ccedil;','�');
		str = str.replace('$egrave;','�');
		str = str.replace('$eacute;','�');
		str = str.replace('$ecirc;','�');
		str = str.replace('$euml;','�');
		str = str.replace('$igrave;','�');
		str = str.replace('$iacute;','�');
		str = str.replace('$icirc;','�');
		str = str.replace('$iuml;','�');
		str = str.replace('$eth;','�');
		str = str.replace('$ntilde;','�');
		str = str.replace('$ograve;','�');
		str = str.replace('$oacute;','�');
		str = str.replace('$ocirc;','�');
		str = str.replace('$otilde;','�');
		str = str.replace('$ouml;','�');
		str = str.replace('$oslash;','�');
		str = str.replace('$ugrave;','�');
		str = str.replace('$uacute;','�');
		str = str.replace('$ucirc;','�');
		str = str.replace('$uuml;','�');
		str = str.replace('$yacute;','�');
		str = str.replace('$thorn;','�');
		str = str.replace('$yuml;','�');
		str = str.replace('$quot;','\"');
		str = str.replace('$39;','\'');
		str = str.replace('$amp;','&');
		str = str.replace('$35;','#');
		str = str.replace('$percent;','%');
		str = str.replace('$lt;','<');
		str = str.replace('$gt;','>');
		str = str.replace('$iexcl;','�');
		str = str.replace('$curren;','�');
		str = str.replace('$cent;','�');
		str = str.replace('$pound;','�');
		str = str.replace('$yen;','�');
		str = str.replace('$brvbar;','�');
		str = str.replace('$sect;','�');
		str = str.replace('$uml;','�');
		str = str.replace('$copy;','�');
		str = str.replace('$ordf;','�');
		str = str.replace('$laquo;','�');
		str = str.replace('$not;','�');
		str = str.replace('$shy;','�');
		str = str.replace('$reg;','�');
		str = str.replace('$trade;','�');
		str = str.replace('$macr;','�');
		str = str.replace('$deg;','�');
		str = str.replace('$plusmn;','�');
		str = str.replace('$sup2;','�');
		str = str.replace('$sup3;','�');
		str = str.replace('$acute;','�');
		str = str.replace('$micro;','�');
		str = str.replace('$para;','�');
		str = str.replace('$middot;','�');
		str = str.replace('$cedil;','�');
		str = str.replace('$sup1;','�');
		str = str.replace('$ordm;','�');
		str = str.replace('$raquo;','�');
		str = str.replace('$frac14;','�');
		str = str.replace('$frac12;','�');
		str = str.replace('$frac34;','�');
		str = str.replace('$iquest;','�');
		str = str.replace('$times;','�');
		str = str.replace('$divide;','�');
		str = str.replace('$lsquo;','�');
		str = str.replace('$rsquo;','�');
	}
	return str;
}

function isArray(object) {
  return object != null && typeof object === "object" &&
    'splice' in object && 'join' in object;
}

