if (navigator.appVersion.indexOf('Mac') != -1)
{
	MAC=true;
}else{
	MAC=false
}


function borrahijos(nodo)
{
for( var x = 0; nodo.childNodes[x]; x++ )
  {
    borrahijos(nodo.childNodes[x]);
    nodo.removeChild(nodo.childNodes[x]);
  }
}

function devuelveElem(id)
{
 if (DOM) 
     { return document.getElementById(id);}
 else if (IE4)
  { return eval(id);}
 else if (NS4)     
  { return eval("document."+id);}
}

function buscaarray(matriz,elemento)
{
 var i=matriz.length-1;
 while (i>=0 && matriz[i]!=elemento)
 { i--
 }
 return i; 
} 

function confirmLink(theLink, theSqlQuery)
{
    // Confirmation is not required in the configuration file
    // or browser is Opera (crappy js implementation)

    var is_confirmed = confirm(theSqlQuery);
    if (is_confirmed) {
        theLink.href += '&inm_js_confirmed=1';
    }

    return is_confirmed;
} // end of the 'confirmLink()' function

function confirmcartelfoto(theSqlQuery, theLinkoriginal,titulo)
{
    // Confirmation is not required in the configuration file
    // or browser is Opera (crappy js implementation)

    var is_confirmed = confirm(theSqlQuery);
    var newlink='';
    if (is_confirmed==true)
    {
        newlink = theLinkoriginal+'&inm_js_confirmedfoto=1';
    } else {
        newlink = theLinkoriginal;
    }
    abreprint(newlink,titulo);
    return false;
} // end of the 'confirmcartelfoto()' function

function chgvisible(NomElemento,visible)
{
 elemento=devuelveElem(NomElemento);
 if (visible)
   {
       if (NS4)
           {elemento.visibility='show';}
       else
           {elemento.style.display='block';}
   }
 else
   {
       if (NS4)
           {elemento.visibility='hide';}
       else
           {elemento.style.display='none';}
   }
}


function esVisible(NomElemento)
{
  elemento=devuelveElem(NomElemento);
  if (NS4)
   { return elemento.visible!='hide' }
  else
   { return elemento.style.display!='none' }
}

function toglevisible(NomElemento)
{
 chgvisible(NomElemento,!esVisible(NomElemento)); 
}

function cambiacombo(combo,matriz,valores,indiceSeleccionado)
{
 combo.length=matriz.length;
 for (var i=0; i<matriz.length;i++){
        combo.options[i].text=matriz[i];
        combo.options[i].value=valores[i];
 }       
 combo.selectedIndex=indiceSeleccionado;    
}

function contadortexto(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}


/*
function cambiaNomcombo(NomForm,NomCombo,matriz,ValorActual)
{
 var combo=eval('document.' + NomForm + "." + NomCombo);
 combo.length=matriz.length;
 for (var i=0; i<matriz.length;i++){
        combo.options[i].text=matriz[i];
        combo.options[i].value=ar_valores[i];
        if (matriz[i]==ValorActual)
        { combo.selectedIndex=i+1;	
         }  
      }
 combo.selectedIndex=selected;    
}
*/

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }

}

function abreprint(url,nombre)
{
  window.open(url,nombre,'dependent=yes,toolbar=no,status=no,scrollbars=yes,menubar=yes,resizable=yes');
  return false;
}


