function acute(letra)
{  switch(letra)
   {  case "a":return(String.fromCharCode(225));break;
      case "e":return(String.fromCharCode(233));break;
      case "i":return(String.fromCharCode(237));break;
      case "o":return(String.fromCharCode(243));break;
      case "u":return(String.fromCharCode(250));break;
      case "A":return(String.fromCharCode(193));break;
      case "E":return(String.fromCharCode(201));break;
      case "I":return(String.fromCharCode(205));break;
      case "O":return(String.fromCharCode(211));break;
      case "U":return(String.fromCharCode(218));break;

	  default:return("");
   }
}

function tilde(letra)
{  switch(letra)
   {  case "n":return(String.fromCharCode(241));break;
      case "N":return(String.fromCharCode(209));break;

	  default:return("");
   }
}

function amp()
{  return(String.fromCharCode(38));
}

//------------------------------------------------------------------------------

function youtubeVideoView(id,width,height,lang)
{  var hl="es";
   switch(lang)
   {  case "es":hl="es";break;
      case "en":hl="en";break;
   }

   var video="<object width=\""+width+"\" height=\""+height+"\">";
   video=video+"<param name=\"movie\" value=\"http://www.youtube.com/v/"+id+"&hl="+hl+"&fs=1\"></param>";
   video=video+"<param name=\"allowFullScreen\" value=\"true\"></param>";
   video=video+"<param name=\"allowscriptaccess\" value=\"always\"></param>";
   video=video+"<embed src=\"http://www.youtube.com/v/"+id+"&hl="+hl+"&fs=1\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\""+width+"\" height=\""+height+"\"></embed>";
   video=video+"</object>";

   document.write(video);
}

//------------------------------------------------------------------------------

function displayAlert(div,sw)
{  document.getElementById(div).style.display=(sw==1)? "inline":"none";
}

//------------------------------------------------------------------------------

function iframe(id,name)
{  document.write("<iframe id=\""+id+"\" name=\""+name+"\"></iframe>");
}

//------------------------------------------------------------------------------

function strReplace(cadenaBuscada,cadenaReemplazo,cadena)
{  var expresion=eval("/"+cadenaBuscada+"/gi");

   return(cadena.replace(expresion,cadenaReemplazo));
}

//------------------------------------------------------------------------------

function friendlyURL(url)
{  url=url.toLowerCase(); //Pasar a minusculas

   url=strReplace(String.fromCharCode(225),"a",url); //Caracteres especiales latinos
   url=strReplace(String.fromCharCode(233),"e",url);
   url=strReplace(String.fromCharCode(237),"i",url);
   url=strReplace(String.fromCharCode(243),"o",url);
   url=strReplace(String.fromCharCode(250),"u",url);
   url=strReplace(String.fromCharCode(241),"n",url);

   url=strReplace(" ",   "-",url); //Conversion
   url=strReplace("&",   "-",url);
   url=strReplace("\\r\\n","-",url);
   url=strReplace("\\n",  "-",url);
   //url=strReplace("+",   "-",url);

   url=url.replace(/[^a-z0-9\-<>]/,"");  //Caracteres especiales
   url=url.replace(/[\-]+/,        "-");
   url=url.replace(/<[^>]*>/,      "");

   return(url);
}

//------------------------------------------------------------------------------

//function rowUpdateBG(fila,bgOver,bgOut,sw)
function rowUpdateBG(fila,sw)
{  //si sw=1: el mouse esta en la fila
   //si sw=0: el mouse salio de la fila

   var celdas=null;

   celdas=fila.getElementsByTagName("td");

   for(var i=0;i<=celdas.length-1;i++)
   {  switch(sw)
	  {  case 1:celdas[i].style.background="#CCFFCC";  // VERDE
	            celdas[i].style.cursor="pointer";
	            break;
	     case 0:celdas[i].style.background="#E8EAEA";
		        break;
	  }
   }
}

//------------------------------------------------------------------------------

function limitTEXTKEY(objTXT,maxLength,contOutput)
{  if(objTXT.value.length>maxLength)
   {  objTXT.value=objTXT.value.substring(0,maxLength);
      var charLeft=0;
   }
   else
   {  var charLeft=maxLength-objTXT.value.length;
   }

   document.getElementById(contOutput).innerHTML=charLeft;
}

//------------------------------------------------------------------------------

function selectUpdateSelected(combo,valor)
{  for(var i=0;i<=combo.length-1;i++)
   {  if(combo.options[i].value==valor)
      {  combo.options[i].selected=true;
      }
   }
}

//------------------------------------------------------------------------------

function openWindow(pageWeb,name,opcion)
{  var miVentana;

   switch(opcion)
   {  case "max":  miVentana=window.open(pageWeb,name,"width="+(screen.width-10)+",height="+(screen.height-75)+",resizable=no,toolbar=no,menubar=no,scrollbars=yes,status=yes,location=no,left=0,top=0");
                   break;
      case "small"://var w=550;
	               //var h=325;
	               var w=650;
	               var h=425;
                   //miVentana=window.open(pageWeb,name,"width="+w+",height="+h+",resizable=no,toolbar=no,menubar=no,scrollbars=no,status=yes,location=no,left="+((screen.width/2)-(w/2))+",top="+((screen.height/2)-(h/2)));
                   miVentana=window.open(pageWeb,name,"width="+w+",height="+h+",resizable=no,toolbar=no,menubar=no,scrollbars=yes,status=yes,location=no,left="+((screen.width/2)-(w/2))+",top="+((screen.height/2)-(h/2)));
				   break;

	  default:miVentana=window.open(pageWeb,name);
   }
}

//------------------------------------------------------------------------------

function addEvent(elemento,nombreEvento,funcion,captura)
{  if(elemento.attachEvent)
   {  elemento.attachEvent("on"+nombreEvento,funcion);
      return true;
   }
   else
   {  if(elemento.addEventListener)
      {  elemento.addEventListener(nombreEvento,funcion,captura);
         return true;
      }
      else
      {  return false;
	  }
   }
}

function createXMLHttpRequest()
{  /*
   Obtener la instancia del objeto XMLHttpRequest

   Crea el objeto AJAX. Esta funcion es generica para cualquier utilidad de
   este tipo, por lo que se puede copiar tal como esta aqui
   */

   var xmlhttp=false;

   try
   {  //Creacion del objeto AJAX para navegadores no IE
      xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
   }
   catch(e)
   {  try
      {  //Creacion del objeto AJAX para IE
         xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch(E)
	  {  xmlhttp=false;
	  }
   }

   if(!xmlhttp && typeof XMLHttpRequest!="undefined")
   {  //Creacion del objeto AJAX para Mozilla, Safari, ...
      xmlhttp=new XMLHttpRequest();
   }

   return(xmlhttp);
}