function openWindows(url, w, h){
    var left = 0;
    var top = 0;
    var opciones = '';
    if (w != 0){
        left = (screen.width - w) / 2;
        top = (screen.height - h) / 2;
        opciones = 'width='+w+',height='+h+',';
    }
    window.open(url, '', opciones+'left='+left+',top='+top+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes');
}

function convertirTexto(texto){
    /*reemplaza el acento de la letra a por comodin*/
    while (texto.indexOf('á',0)!=-1){
        texto = texto.replace('á', '%');
    }
    /*reemplaza el acento de la letra e por comodin*/
    while (texto.indexOf('é',0)!=-1){
        texto = texto.replace('é', '%');
    }
    /*reemplaza el acento de la letra i por comodin*/
    while (texto.indexOf('í',0)!=-1){
        texto = texto.replace('í', '%');
    }
    /*reemplaza el acento de la letra o por comodin*/
    while (texto.indexOf('ó',0)!=-1){
        texto = texto.replace('ó', '%');
    }
    /*reemplaza el acento de la letra u por comodin*/
    while (texto.indexOf('ú',0)!=-1){
        texto = texto.replace('ú', '%');
    }

    /*reemplaza la dieresis*/
    texto = texto.replace('ü', '%');
    texto = texto.replace('Ü', '%');

    /*reemplaza eñes*/
    texto = texto.replace('ñ', '%');
    texto = texto.replace('Ñ', '%');

    return texto;
}

function convertirAcentos(texto){
    /*reemplaza el acento de la letra a por comodin*/
    while (texto.indexOf('\u00e1',0)!=-1){
        texto = texto.replace('\u00e1', '&aacute;');
    }
    /*reemplaza el acento de la letra e por comodin*/
    while (texto.indexOf('\u00e9',0)!=-1){
        texto = texto.replace('\u00e9', '&eacute;');
    }
    /*reemplaza el acento de la letra i por comodin*/
    while (texto.indexOf('\u00ed',0)!=-1){
        texto = texto.replace('\u00ed', '&iacute;');
    }
    /*reemplaza el acento de la letra o por comodin*/
    while (texto.indexOf('\u00f3',0)!=-1){
        texto = texto.replace('\u00f3', '&oacute;');
    }
    /*reemplaza el acento de la letra u por comodin*/
    while (texto.indexOf('\u00fa',0)!=-1){
        texto = texto.replace('\u00fa', '&uacute;');
    }

    return texto;
}

function redimensionarFoto(foto, maxAncho, maxAlto){
    var imgFoto = new Image();
    imgFoto.src = foto.src;

    var w = imgFoto.width;
    var h = imgFoto.height;

    if (w > h){
        pH = h * maxAncho / w;;
        imgFoto.width = maxAncho;
        imgFoto.height = pH;
    } else{
        pW = w * maxAlto / h;
        imgFoto.width = pW;
        imgFoto.height = maxAlto;
    }

    foto.width = imgFoto.width;
    foto.height = imgFoto.height;
}

function isNumeric(strString){
    var strValidChars = "0123456789.-";
    var strChar;
    var blnResult = true;

    if (strString.length == 0) return false;

    //  test strString consists of valid characters listed above
    for (i = 0; i < strString.length && blnResult == true; i++)
    {
        strChar = strString.charAt(i);
        if (strValidChars.indexOf(strChar) == -1)
        {
            blnResult = false;
        }
    }
    return blnResult;
}

function realizarBusqueda(url, idElementFiltro){
    
    //document.location.href = url+convertirTexto(document.getElementById(idElementFiltro).value);
    document.location.href = url+document.getElementById(idElementFiltro).value;
}
function eliminarBusqueda(){
    document.location.href = "admin_index";
}

function contadorLetras(idElement, idDiv){
    obj = document.getElementById(idElement);
    var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : "";
    /* limita un maximo *
    if (obj.getAttribute && obj.value.length>mlength){
        obj.value=obj.value.substring(0,mlength);
    }
    /**/

    text = obj.value;
    document.getElementById(idDiv).innerHTML = text.length ; //mlength - text.length;
}

function verCorreo(a, b){
    alert('e-mail: '+a+'@'+b);
}
