/************************************************************
* Conjunto de funciones utilizadas con frecuencia.
*
*   Las siguientes funciones tiene problemas en Exploradores 
*   4.0: [restaCaracter y SelTodos]
*
*   Fecha        Creado por
*   10/06/1999    Miguel Angel Romar
*************************************************************
* MR Software <c> 1991-2004 Miguel Angel Romar
*************************************************************/
/*

binisob = new Image(); 
binisob.src = "../images/bpinisob.jpg";
bininor = new Image();
bininor.src = "../images/bpininor.jpg";
bfavsob = new Image(); 
bfavsob.src = "../images/bpfavsob.jpg";
bfavnor = new Image();
bfavnor.src = "../images/bpfavnor.jpg";
bemasob = new Image(); 
bemasob.src = "../images/bpemasob.jpg";
bemanor = new Image();
bemanor.src = "../images/bpemanor.jpg";
*/


if (document.images) {
// Controles de navegacion //
fsigasob = new Image(); 
fsigasob.src = "images/badelsob.jpg";
fsiganor = new Image();
fsiganor.src = "images/badelnor.jpg";
fantasob = new Image(); 
fantasob.src = "images/batrasob.jpg";
fantanor = new Image();
fantanor.src = "images/batranor.jpg";
farrasob = new Image(); 
farrasob.src = "images/barrsob.jpg";
farranor = new Image();
farranor.src = "images/barrnor.jpg";
fsigapsob = new Image(); 
fsigapsob.src = "images/badelsob.jpg";
fsigapnor = new Image();
fsigapnor.src = "images/badelnor.jpg";
fantapsob = new Image(); 
fantapsob.src = "images/batrasob.jpg";
fantapnor = new Image();
fantapnor.src = "images/batranor.jpg";
lvfirsob = new Image(); 
lvfirsob.src = "images/libfisob.jpg";
lvfirnor = new Image();
lvfirnor.src = "images/libfinor.jpg";
nsigasob = new Image(); 
nsigasob.src = "images/badelsob.jpg";
nsiganor = new Image();
nsiganor.src = "images/badelnor.jpg";
nantasob = new Image(); 
nantasob.src = "images/batrasob.jpg";
nantanor = new Image();
nantanor.src = "images/batranor.jpg";
b251sob = new Image(); 
b251sob.src = "images/bn25_1_sob.jpg";
b251nor = new Image();
b251nor.src = "images/bn25_1_nor.jpg";
b252sob = new Image(); 
b252sob.src = "images/bn25_2_sob.jpg";
b252nor = new Image();
b252nor.src = "images/bn25_2_nor.jpg";
galesigsob = new Image();
galesigsob.src = "images/galesigsob.jpg"
galesignor = new Image();
galesignor.src = "images/galesignor.jpg"
galeantsob = new Image();
galeantsob.src = "images/galeantsob.jpg"
galeantnor = new Image();
galeantnor.src = "images/galeantnor.jpg"
galeautosob = new Image();
galeautosob.src = "images/galeautosob.jpg"
galeautonor = new Image();
galeautonor.src = "images/galeautonor.jpg"
galehomesob = new Image();
galehomesob.src = "images/galehomesob.jpg"
galehomenor = new Image();
galehomenor.src = "images/galehomenor.jpg"
}

var winCount = 0;
function abreWin(url, wNomb, width, height, propiedades){
var winl = (screen.width - width) / 2;
var wint = (screen.height - height) / 2;
var winprops = 'height='+height+',width='+width+',top='+wint+',left='+winl;

  if(propiedades == "unica"){
    var hWin = window.open(url, wNomb+winCount, winprops +'directories=no,location=no,menubar=no,status=no,scrollbars=yes,resizable=yes,titlebars=no,toolbar=no');
    winCount++;
    hWin.focus();   
    return hWin;
  }else if (propiedades == "si"){
    var hWin = window.open(url, wNomb, winprops + 'directories=no,location=no,menubar=no,status=no,scrollbars=yes,resizable=yes,titlebars=no,toolbar=no');
    hWin.focus();
    return hWin;
  }else if (propiedades == "no"){
    var hWin = window.open(url, wNomb, winprops +  'directories=no,location=no,menubar=no,status=no,scrollbars=no,resizable=no,titlebars=no,toolbar=no');
    hWin.focus();
    return hWin;
  }else if (propiedades == "previa"){
    var hWin = window.open(url, wNomb, winprops +'directories=no,location=no,menubar=no,status=no,scrollbars=yes,resizable=yes,titlebars=no,toolbar=no');
    hWin.focus();
    return hWin;
  }else if (propiedades == "galima"){
    var hWin = window.open(url, wNomb, winprops + 'directories=no,location=no,menubar=no,status=yes,scrollbars=no,resizable=no,titlebars=no,toolbar=no');   
    hWin.focus();
    return hWin;    
  }else if(propiedades == "modal"){
    var hWin = window.showModalDialog(url, wNomb, 'location:no;menubar:no;status:no;scrollbars:yes;resizable:yes;titlebars:no;toolbar:no;dialogWidth:' + width + 'px;dialogHeight=' + height +'px;center:yes;');
    hWin.focus();
    return hWin;
  }
}

function sob(picture) {
  if (document.images) {
    document[picture].src = eval(picture + 'sob.src');
    //window.status=' ';
  }
}

function nor(picture) {
  if (document.images) {
    document[picture].src = eval(picture + 'nor.src');
    //window.status=' ';
  }
}

function validarCampos(valor, tipo, largo) {
  var bRet = false;
  /* Cadena vacia */  
  if (tipo == "V") {
    if (valor == "")
      bRet = true;
  }
  /* Cadena largo minimo permitido */
  if (tipo == "L") {
    if (valor.length < largo)
      bRet = true;
  }
  return bRet;  
}

function esFecha(valor){
/************************************
* Determinar que el formato de fecha
* sea valido dd/mm/yyyy
************************************/
  if (valor.length != 10) {
    alert("La fecha, debe ser una fecha valida con formato [dd/mm/yyyy]");
    return false;
  }
    var avalor = valor.split("/");
    for (var i=0; i < avalor.length; i++) {
      if (isNaN(avalor[i])) {
      alert("La fecha, debe ser una fecha valida con formato [dd/mm/yyyy]");
      return false;     
      }
    }    
    return true;
}

function esNumero(valor){
  var checkOK = "0123456789-.,";
  var checkStr = valor;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
    if (ch == checkOK.charAt(j))
      break;
    if (j == checkOK.length)
    {
    allValid = false;
    break;
    }
    if (ch == ".")
    {
    allNum += ".";
    decPoints++;
    }
    else if (ch != ",")
    allNum += ch;
  } 
  return allValid;
}

function esEmail(valor) {
  if ((valor == "" || valor.indexOf('@', 0) == -1) || valor.indexOf('.') == -1) {
    return false;
  }
  else {
    return true;
  }
}

function esURL(valor) {
  if ((valor == "" || valor.indexOf("http://") == -1) || valor.indexOf(".") == -1) {
    return false;
  }
  else {
    return true;
   }
}

function foco(oDest) {
/*******************************************
* Habilita el foco en un campo de formulario
* seleccionadolo.
********************************************/
  document.getElementById(oDest).focus();
  document.getElementById(oDest).select();  
}

function mrPost(valor) {
/*******************************************
* Enviar los datos del formulario
* principal
* solo funciona trabaja para un formulario.
********************************************/
  if (valor != null)
    document.forms[0].action = valor;
  else
    document.forms[0].action = 'si';
  document.forms[0].submit();
}

function obtFecha(){
/************************************
* Obtener la fecha del Sistema 
* covierte de date a string
* retornando una cadena con la fecha.
************************************/
  var dfecha = new Date();
  var nmes = dfecha.getMonth(); 
  var sdia = new String();
  var smes = new String();
  var sFecha = new String();
  
  // Sumar 1 al mes debido a que 
  // getMonth() enumera de 0 a 11.  
  nmes = nmes + 1;
    
  sdia = dfecha.getDate().toString();
  smes = nmes.toString(); 
  if (sdia.length == 1){
    sdia = "0" + sdia;
  }
  if (smes.length == 1){
    smes = "0" + smes;  
  }
  
  sFecha = sdia + "/" + smes + "/" + dfecha.getYear();  
  return sFecha;
}

function MakeArray(n) {
  this.length = n;
  return this
}

function ObtFechaLarga(){
  var dfecha = new Date();
  var theDay = new String();
  var theMonth = new String();
  var sdia = new String();
  
  monthNames = new MakeArray(12)
  monthNames[1] = "Enero"
  monthNames[2] = "Febrero"
  monthNames[3] = "Marzo"
  monthNames[4] = "Abril"
  monthNames[5] = "Mayo"
  monthNames[6] = "Junio"
  monthNames[7] = "Julio"
  monthNames[8] = "Agosto"
  monthNames[9] = "Septiembre"
  monthNames[10] = "Octubre"
  monthNames[11] = "Noviembre"
  monthNames[12] = "Diciembre"
  daysNames = new MakeArray(7)
  daysNames[1] = "Domingo"
  daysNames[2] = "Lunes"
  daysNames[3] = "Martes"
  daysNames[4] = "Miercoles"
  daysNames[5] = "Jueves"
  daysNames[6] = "Viernes"
  daysNames[7] = "Sábado"

  theDay = daysNames[dfecha.getDay() +1];
  theMonth = monthNames[dfecha.getMonth() +1];
  sdia = dfecha.getDate().toString();
  if (sdia.length == 1){
    sdia = "0" + sdia;
  }
  return  theDay + ", " + sdia + "  de " + theMonth + " del " + dfecha.getFullYear();
}


/***********************************************
* Escribe los derechos de propiedad intelectual 
* con el año actualizado.
************************************************/
function obtregistracion()
{
  var dfecha = new Date();  
      document.write('Copyright 2002-' + dfecha.getFullYear() + ' Centro de difusi&oacute;n del Santuario Mar&iacute;a del Rosario de San Nicol&aacute;s');
}

function restaCaracter(mMax, oOrig, oDest) {
/*******************************************************************************
* Informar al usuario la cantidad de caracteres.
* que tiene disponible para escribir en un control textarea.
* Sintaxis:
*  onkeyup="javascript:void(restaCaracter('125',descripcion,'maxcar'))"
* Destino:
* <div id="maxcar" style="display: block; margin-left: 0em;">textoinicial</div>
*******************************************************************************/
  var valor = document.getElementById(oOrig).value;
  var svalido = new String();
  if (valor != null) {
    if (valor.length <= mMax) {
        key=document.getElementById(oDest);
        key.innerHTML="disponibles " + (mMax - valor.length) + " de " + mMax + " caracteres.";
    }
    else {
      for (var i=0;i<mMax;i++) {
        svalido = svalido + valor.charAt(i);
      }
      document.getElementById(oOrig).value = svalido;
      alert("Se ha superado la cantidad máxima de " + mMax + " caracteres permitidos para este campo.");
    }
  }
}

function SelTodos() {
/*******************************************
* Seleccionar todos los registros de una
* pagina para tareas globales (checkBox)
********************************************/
  for (var i=0;i<document.forms[0].elements.length;i++) {
    var e=document.forms[0].elements[i];
    e.checked=!e.checked;
  }
}

/******************************************
Abrir y Cerrar Divs para mostrar contenido 
y ahorrar espacio...
******************************************/
function cambiaitem(item) {
   obj=document.getElementById(item);
   visible=(obj.style.display!="none")
   key=document.getElementById("x" + item);
   if (visible) {
     obj.style.display="none";
     key.innerHTML='<img src="images/fleabr.gif" width="12" height="12" hspace="0" vspace="0" border="0">';
   } else {
      obj.style.display="block";
      key.innerHTML='<img src="images/flecer.gif" width="12" height="12" hspace="0" vspace="0" border="0">';
   }
}

function abriritem() {
   divs=document.getElementsByTagName("DIV");
   for (i=0;i<divs.length;i++) {
     if (divs[i].style.display== "none" || divs[i].style.display== "block"){  
     divs[i].style.display="block";
     key=document.getElementById("x" + divs[i].id);
     key.innerHTML='<img src="images/flecer.gif" width="12" height="12" hspace="0" vspace="0" border="0">';
   }
   }
}

function cerraritem() {
   divs=document.getElementsByTagName("DIV");
   for (i=0;i<divs.length;i++) {
   if (divs[i].style.display== "none" || divs[i].style.display== "block"){
     divs[i].style.display="none";
     key=document.getElementById("x" + divs[i].id);
     key.innerHTML="<img src='images/fleabr.gif' width='12' height='12' hspace='0' vspace='0' border='0'>";
   }
   }
}

/* Administrador de Cookies */
// Set the cookie.
// SetCookie('your_cookie_name', 'your_cookie_value', exp);
// Get the cookie.
// var someVariable = GetCookie('your_cookie_name');
var expDays = 300;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function getCookieVal (offset) {  
  var endstr = document.cookie.indexOf (";", offset);  
  if (endstr == -1) { endstr = document.cookie.length; }
  return unescape(document.cookie.substring(offset, endstr));
}

function GetCookie (name) {  
  var arg = name + "=";  
  var alen = arg.length;  
  var clen = document.cookie.length;  
  var i = 0;  
  while (i < clen) {    
    var j = i + alen;    
    if (document.cookie.substring(i, j) == arg) return getCookieVal (j);    
    i = document.cookie.indexOf(" ", i) + 1;    
    if (i == 0) break;   
  }  
  return null;
}

function SetCookie (name, value) {  
  var argv = SetCookie.arguments;  
  var argc = SetCookie.arguments.length;  
  var expires = (argc > 2) ? argv[2] : null;  
  var path = (argc > 3) ? argv[3] : null;  
  var domain = (argc > 4) ? argv[4] : null;  
  var secure = (argc > 5) ? argv[5] : false;  
  document.cookie = name + "=" + escape (value) + 
  ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
  ((path == null) ? "" : ("; path=" + path)) +  
  ((domain == null) ? "" : ("; domain=" + domain)) +    
  ((secure == true) ? "; secure" : "");
}

function estpaginicio()
{
  if (document.all){
    document.write('<a href="javascript:history.go(0);" onClick="this.style.behavior=\'url(#default#homepage)\';this.setHomePage(\'http://www.virgen-de-san-nicolas.org\');">');
    document.write('Hacer esta su p&aacute;gina de inicio</a>');
  }
  else if (document.getElementById){
    document.write('<a href="http://www.virgen-de-san-nicolas.org">Hacer esta su p&aacute;gina de inicio</a>');
    document.write('<br /><div align="right">Arrastre el enlace hacia el botón de inicio del <br />explorador para hacer esta, su p&aacute;gina de inicio.</div>');
  }
}

function bookmark(url,title){
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Pulse CTRL+D si usa Netscape\nO pulse CTRL+T Si usa Opera\n\nPara agregar esta página a favoritos");
  }
}

function noopera() {
  if (navigator.appName == "Opera"){
    alert('Este sitio no es compatible con el navegador Opera.\nThis site is no compatible with Opera navigator.');
  }
}

/* Para enviar una noticia a un amigo*/
function isPPC() {
if (navigator.appVersion.indexOf("PPC") != -1) return true;
else return false;
}

function estenvnota(){
  if (isPPC()) {
  document.write('<A CLASS="contact" HREF=\"mailto:\?subject\=Ver esta noticia que encontre en el sitio SANTUARIO MARIA DEL ROSARIO DE SAN NICOLAS. ' + '?body=Se puede ver esta p&aacute;gina en: ' + window.location + '\" onMouseOver="window.status=\'Envié el enlace de esta nota por correo electrónico\'; return true" TITLE="Envié el enlace de esta nota por correo electrónico">Enviar este enlace por e-mail<\/A>');
  }
  else { document.write('<A CLASS="contact" HREF=\"mailto:\?body\=Ver esta noticia que encontre en el sitio SANTUARIO MARIA DEL ROSARIO DE SAN NICOLAS.' + ' Se puede ver esta pagina en: ' + window.location + '\" onMouseOver="window.status=\'Envié el enlace de esta nota por correo electrónico\'; return true" TITLE="Envié el enlace de esta nota por correo electrónico">Enviar este enlace por e-mail<\/A>');
  }
}

function estMarcador(sColor){
var sUrl = String(window.location); 
  if (sUrl.indexOf('#') != -1){
    var sAnchor = sUrl.split('#');
      key=document.getElementById(sAnchor[1]);
    key.innerHTML='<img src="images/bol_c.gif" width="10" height="15" alt="Marcador" hspace="10" vspace="0" border="0">';
    bk=document.getElementById(sAnchor[1] + 'tk');
    bk.style.background=sColor;
    bk.align="center"   
  }     
}

/* Rotar Banner estaticos */
var refreshTime = 7000; //- 5000 ms = 5 seconds -\\

//-4) number of ads to rotate -\\
var numAds = 4;

function makeAd() {
  this.width = ''
  this.height = ''
  this.src = ''
  this.href = ''
  this.mouseover = ''
  this.sponsor = ''
}

var ads = new Array()
for(var i = 1; i <= numAds; i++) { ads[i] = new makeAd() }

//- 5) Copy and paste the lines between the banner definition for 
//each banner you want to rotate and be sure to change numAds to 
//the number of banners (look about 15 lines up for numAds)
i = 1;


/*------------begin banner definition----------*/
ads[i].width = "220"                           //width of image
ads[i].height = "57"                           //height of image
ads[i].src = "images/a1.jpg"               //image url
ads[i].href = "http://www.patronato-infancia.org.ar/"                    //link url
ads[i].mouseover = "Ellos también necesitan!"            //text to display when mouse moves over banner
ads[i].sponsor = "Ellos también necesitan"                     //text to display for text link under banner
i++

ads[i].width = "220"    
ads[i].height = "57"                  
ads[i].src = "images/a2.jpg"        
ads[i].href = "http://www.caritas.org.ar/home1.htm"              
ads[i].mouseover = "Ellos también necesitan!"       
ads[i].sponsor = "Ellos también necesitan"                 
i++

ads[i].width = "220"    
ads[i].height = "57"                  
ads[i].src = "images/a3.jpg"        
ads[i].href = "http://www.feliceslosninos.org/"              
ads[i].mouseover = "Ellos también necesitan!"       
ads[i].sponsor = "Ellos también necesitan"                 
i++
ads[i].width = "220"    
ads[i].height = "57"                  
ads[i].src = "images/a4.jpg"        
ads[i].href = "http://www.donorione.org.ar/mirador/inicio.htm"             
ads[i].mouseover = "Ellos también necesitan!"       
ads[i].sponsor = "Ellos también necesitan"                 
i++
/*-------------end banner definition-----------*/

var myCode = '';
do {
var n= Math.floor(Math.random() * (numAds + 1) + 1);
} while(n > numAds);
var current_ad = n;
myCode = getCode(n);

function getCode(adNumber){
  var tempCode = ""
  tempCode += ('<a href="'+ ads[adNumber].href +'" \n')
  tempCode += ('onMouseOver="status=\''+ ads[adNumber].mouseover +'\';return true" \n')
  tempCode += ('onMouseOut="status=\'\'"> \n')
  tempCode += ('<img src="' + ads[adNumber].src + '" width=' + ads[adNumber].width)
  tempCode += (' onLoad="setTimeout(\'newAd();\',' + refreshTime + ');"')
  tempCode += ('\n height=' + ads[adNumber].height + ' border="0" align="middle" >')
  //tempCode += ('<br>Sponsored by: <b>' + ads[adNumber].sponsor + '</b>') //delete this line if you don't want any text to be displayed under your banner
  tempCode += ('</a><br />')
  return tempCode;
  }

function newAd(){
  current_ad++;
  if (current_ad > numAds)
    current_ad = 1;
  if (document.all){
     write(getCode(current_ad));
     }
}

function write(text){
  if (document.layers) {
    document.bannerAd.document.write(text)
    document.bannerAd.document.close();
    }
  else {
    if (document.all)
      document.all.bannerAd.innerHTML = text;
  } 
}


function navviejo(){
  <!-- Begin
  var useragent = navigator.userAgent;
  var bName = (useragent.indexOf('Opera') > -1) ? 'Opera' : navigator.appName;
  var pos = useragent.indexOf('MSIE');
  if (pos > -1) {
  bVer = useragent.substring(pos + 5);
  var pos = bVer.indexOf(';');
  var bVer = bVer.substring(0,pos);
    if (bVer.substring(0,1,1) != '6'){
      return true;
    } 
  }
  var pos = useragent.indexOf('Opera');
  if (pos > -1) {
  bVer = useragent.substring(pos + 6);
  var pos = bVer.indexOf(' ');
  var bVer = bVer.substring(0, pos);
    if (bVer.substring(0,1,1) != '8'){
      return true;
    } 
  }
  if(navigator.userAgent.indexOf("Firefox")!=-1){
  var versionindex=navigator.userAgent.indexOf("Firefox")+8
  var pos = useragent.lastIndexOf('/');
  var bVer = useragent.substring(pos + 1);
  var nval = bVer.substring(0,3)
    if (parseFloat(nval) < 1.4 ){
      return true;
    }
  }
  else{
    if (bName == "Netscape") {
    var bVer = useragent.substring(8);
    var pos = bVer.indexOf(' ');
    var bVer = bVer.substring(0, pos);
      if (bVer.substring(0,1,1) != '8'){
        return true;
      } 
    }
    if (bName == "Netscape" && parseInt(navigator.appVersion) >= 5) {
    var pos = useragent.lastIndexOf('/');
    var bVer = useragent.substring(pos + 1);
    var bVer = bVer.substring(0, pos);
      if (bVer.substring(0,1,1) != '8'){
        return true;
      } 
    }
  }
  return false;
}