function IsNumeric(sText) {
	
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;
   
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
}

function cargaimagen (ruta,informacion,nuevoancho,url) {
	var texto;
	var textofinal;
	var ancho;
	var alto;
	var imagen = new Image();
	imagen.src = ruta;
	ancho = imagen.width;
	alto = imagen.height;

	if (IsNumeric(nuevoancho)) {
		if (nuevoancho != ancho) {
			alto = parseInt((nuevoancho*alto)/ancho);
			ancho = nuevoancho;
		}
	}
	
	if (url != "") {
		texto = '<a title="'+ informacion +'" href="'+ url +'"><div>\n';	
		textofinal = '</div></a>';
	} else {
		texto = '<div>\n';
		textofinal = '</div>';
	}
	texto += '	<div style="float:left;height:'+ (alto+28) +'px;width:14px;">\n';
	texto += '		<div style="width:14px; height:14px; background:url(marco/esq_supizq.png) no-repeat;"></div>\n';
	texto += '		<div style="width:14px; height:'+ alto +'px; background:url(marco/izq.png) repeat-y;"></div>\n';
	texto += '		<div style="width:14px; height:14px; background:url(marco/esq_infizq.png) no-repeat;"></div>\n';
	texto += '	</div>\n';
	texto += '	<div style="float:left;height:'+ (alto+28) +'px;width:'+ ancho +'px;">\n';
	texto += '		<div style="width:'+ ancho +'px; height:14px; background:url(marco/sup.png) repeat-x;"></div>\n';
	texto += '		<div style="width:'+ ancho +'px; height:'+ alto +'px;">\n';
	texto += '			<div style="position:absolute;height:'+ alto +'px;width:142px;background:url(marco/frontal.png) left bottom no-repeat;"></div>\n';
	texto += '			<img src="'+ ruta +'" alt="'+ informacion +'" width="'+ ancho +'" title="'+ informacion +'"/>\n';
	texto += '		</div>\n';
	texto += '	<div style="width:'+ ancho +'px; height:14px; background:url(marco/inf.png) repeat-x;"></div>\n';
	texto += '	</div>\n';
	texto += '	<div style="float:left;height:'+ (alto+28) +'px;width:14px;">\n';
	texto += '		<div style="width:14px; height:14px; background:url(marco/esq_supder.png) no-repeat;"></div>\n';
	texto += '		<div style="width:14px; height:'+ alto +'px; background:url(marco/der.png) repeat-y;"></div>\n';
	texto += '		<div style="width:14px; height:14px; background:url(marco/esq_infder.png) no-repeat;"></div>\n';
	texto += '	</div>\n';
	texto += textofinal;

	document.write (texto);
}
