	function InChar(strSearch, charSearchFor)
	{
		for (i=0; i < Len(strSearch); i++)
		{
		    if (charSearchFor == Mid(strSearch, i, 1))
		    {
				return i;
		    }
		}
		return -1;
	}

	function InStr(strSearch, strSearchFor)
	{
		for (i=0; i < Len(strSearch); i++)
		{
		    if (strSearchFor == Mid(strSearch, i, Len(strSearchFor)))
		    {
					return i;
		    }
		}
		return -1;
	}

  function Len(str) {  
  	return String(str).length;  
  }

	function Mid(str, start, len) {
	  if (start < 0 || len < 0) return "";
	
	  var iEnd, iLen = String(str).length;
	  if (start + len > iLen)
	          iEnd = iLen;
	  else
	          iEnd = start + len;
	
	  return String(str).substring(start,iEnd);
	}

	function Left(str, n){
		if (n <= 0)
		    return "";
		else if (n > String(str).length)
		    return str;
		else
		    return String(str).substring(0,n);
	}

	function Right(str, n){
	    if (n <= 0)
	       return "";
	    else if (n > String(str).length)
	       return str;
	    else {
	       var iLen = String(str).length;
	       return String(str).substring(iLen, iLen - n);
	    }
	}

function getContenido (contenido) {
	var abreTag = "";
	var contenidoLimpio = "";
	
	contenido = replaceSubstring(contenido, "<HR>", "-----");
	contenido = replaceSubstring(contenido, "&nbsp;", "");
	contenido = replaceSubstring(contenido, "</P>", "{BR}{BR}");
	contenido = replaceSubstring(contenido, "<BR>", "{BR}");
	
	for (i = 0; i < contenido.length; i++) {
		if ((contenido.substring(i, i + 1) == "<") && (abreTag == "")) {
			abreTag = "<";
		}
		if (abreTag == "") {
			contenidoLimpio = contenidoLimpio + contenido.substring(i, i + 1);
		}
		
		if ((contenido.substring(i, i + 1) == ">") && (abreTag != "")) {
			abreTag = "";
		}
	}
	contenidoLimpio = replaceSubstring(contenidoLimpio, "{BR}", "<BR>");
	return contenidoLimpio;
}

function replaceSubstring(inputString, fromString, toString) {
	var temp = inputString;
	if (fromString == "") {
	  return inputString;
	}
	if (toString.indexOf(fromString) == -1) { 
	  while (temp.indexOf(fromString) != -1) {
	     var toTheLeft = temp.substring(0, temp.indexOf(fromString));
	     var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
	     temp = toTheLeft + toString + toTheRight;
	  }
	} else { 
	  var midStrings = new Array("~", "`", "_", "^", "#");
	  var midStringLen = 1;
	  var midString = "";
	
	  while (midString == "") {
	     for (var i=0; i < midStrings.length; i++) {
	        var tempMidString = "";
	        for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
	        if (fromString.indexOf(tempMidString) == -1) {
	           midString = tempMidString;
	           i = midStrings.length + 1;
	        }
	     }
	  }
	  while (temp.indexOf(fromString) != -1) {
	     var toTheLeft = temp.substring(0, temp.indexOf(fromString));
	     var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
	     temp = toTheLeft + midString + toTheRight;
	  }
	  while (temp.indexOf(midString) != -1) {
	     var toTheLeft = temp.substring(0, temp.indexOf(midString));
	     var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
	     temp = toTheLeft + toString + toTheRight;
	  }
	}
	return temp;
}

function emptyObjCmb(obj){
		for (i = 0; i < obj.length; i++) {
	 		obj.options[i] = null;
	 	}
	 	obj.options.length = 0;
	}
	
	function selectItemCombo(id, cmb)
	{	/*Selecciona el ítem <id> del combo <cmb>	*/
		for(var j=0; j < cmb.length; j++){
			if(parseInt(cmb[j].value) == parseInt(id)){
				cmb[j].selected = true;						  			
			}
		}	  	
	}
	
	function verFoto_(strPath){
		var fecha = new Date();
		openPopup('verFoto.php?foto='+strPath, 200, 200, false, false, "foto"+fecha.getSeconds());
	}
	
	var ventana;
	var cont=0;
	
	function afoto(cual){
		/*if(cont==1){ventana.close();ventana=null}
		ventana=window.open('','ventana','resizable=yes,scrollbars=yes')
		ventana.document.write('<html><head><title></title></head><body style="overflow:hidden" marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" scroll="no" onUnload="opener.cont=0"><img src="' + cual + '" onLoad="opener.redimensionar(this.width, this.height)">');
		ventana.document.close();
		cont++;*/
		openPopup(cual, 800, 600, false, true, 'ventana');
	}
	function redimensionar(ancho, alto){
		ventana.resizeTo(ancho+12,alto+28);
		ventana.moveTo((screen.width-ancho)/2,(screen.height-alto)/2); //centra la ventana. Eliminar si no se quiere centrar el popup
	}
	
 