﻿//***************** funciones standard *********************
function MM_openBrWindow(theURL, winName, features) { //v2.0
    window.open(theURL, winName, features);
}

function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}

function MM_preloadImages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; } 
    }
}

function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
    }

function MM_changeProp(objName, x, theProp, theValue) { //v6.0
    var obj = MM_findObj(objName);
    if (obj && (theProp.indexOf("style.") == -1 || obj.style)) {
        if (theValue == true || theValue == false)
            eval("obj." + theProp + "=" + theValue);
        else eval("obj." + theProp + "='" + theValue + "'");
    }
}

function ShowDiv(Img, Linea, num) {
        Img.style.visibility = 'visible';
        Linea.style.visibility = 'visible';
    if (num > 1) {
        document.getElementById('lin1').style.visibility = 'hidden';
        document.getElementById('ven1').style.visibility = 'hidden';
    }
    }

/* Oculta la tabla del subítem correspondiente */
function HideDiv(Img, Linea, num) {
    if (num > 1) {
        Img.style.visibility = 'hidden';
        Linea.style.visibility = 'hidden';
        document.getElementById('lin1').style.visibility = 'visible';
        document.getElementById('ven1').style.visibility = 'visible';
    }
}

function limpiaTxtBuscador(objInput, llena) {
    if (objInput.value == "Buscador" && llena == "0") objInput.value = "";
    if (objInput.value == "" && llena == "1") objInput.value = "Buscador";
}

/* Hace visible la tabla del subítem correspondiente */
function Menuin(Menu, posX) {
    document.getElementById('global').style.zIndex = 100;
    document.getElementById('global').style.color = '#C52233';
    positionX = findPosX(posX) - findPosX(document.getElementById('cap-bots'));
    //Menu.style.left = positionX +'px';
    Menu.style.right = document.getElementById('cap-bots').style.right;
    Menu.style.visibility = 'visible';
}
/* Oculta la tabla del subítem correspondiente */
function Menuout(Menu) {
    document.getElementById('global').style.zIndex = 1;
    document.getElementById('global').style.color = '#535353';
    Menu.style.visibility = 'hidden';
}
/* Cambia de color la celda del subítem correspondiente */
function Itemin(MenuItem) {
    //MenuItem.style.backgroundColor = '#b6adad';
}

/* Vuelve el color a la celda del subítem correspondiente */
function Itemout(MenuItem) {
    //MenuItem.style.backgroundColor = '#dbcfcf';
}

function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent)
        while (1) {
        curleft += obj.offsetLeft;
        if (!obj.offsetParent)
            break;
        obj = obj.offsetParent;
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}

function popup(pagina){
	var myLeft = (screen.width-640)/2;
	var myTop = (screen.height-450)/2;
	
	var opciones="toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=1, resizable=no, width=640, height=450, top="+myTop+", left="+myLeft+"";
	window.open(pagina,"",opciones);
}

function AbrePopUp(pagina, ancho, alto) {
    var myLeft = (screen.width - ancho) / 2;
    var myTop = (screen.height - alto) / 2;

    var opciones = "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=1, resizable=no, width=" + ancho + ", height=" + alto + ", top=" + myTop + ", left=" + myLeft + "";
    window.open(pagina, "", opciones);
}

function flaHome(){
    document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='582' height='231'><param name='movie' value='swf/destacados-as.swf' /><param name='wmode' value='transparent' /><param name='quality' value='high' /><embed src='swf/destacados-as.swf' quality='high' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='582' height='231'></embed></object>");
}

function flaOferta(archivo, ancho, alto) {
    document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='" + ancho + "' height='" + alto + "'><param name='movie' value='" + archivo + "' /><param name='wmode' value='transparent' /><param name='quality' value='high' /><embed src='" + archivo + "' quality='high' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='" + ancho + "' height='" + alto + "'></embed></object>");
}

function turyocio(num_target) {
    bTuryOcio = true;
    if (num_target.value != "") {
        var num_target;
        var tamano;
        var resultado = "";
        var x = 0;
        var y = 0;
        var sumatorio = 0;
        var v5 = 0;
        var v6 = 0;
        var v7 = 0;
        var v8 = 0;
        var v9 = 0;
        var v10 = 0;
        var v11 = 0;
        var v12 = 0;
        var v13 = 0;
        var v14 = 0;
        var valor = "";
        var unidad = 0;
        var digito1;
        var digito2;

        tamano = num_target.length;
        //------- elimino los posibles espacios en blanco ------------
        var i = 0;
        for (i = 0; i < num_target.length + 1; i++) {
            if (num_target.charAt(i) != " ") {
                resultado = resultado + num_target.charAt(i);
            }
        }

        //-------------- comprobamos el nº de dígitos de la targeta  = 16 ---------------------------------------
        tamano = resultado.length
        if (tamano < 16) {
            bTuryOcio = false;
            alert("El número de su tarjeta Turyocio no es correcto");
        }
        else if (tamano > 16) {
            bTuryOcio = false;
            alert("El número de su tarjeta Turyocio no es correcto");
        }
        else {
            sumatorio = 32;
            for (i = 0; i < tamano; i++) {
                if (resultado.charAt(0) == 9) {
                    if (resultado.charAt(1) == 7) {
                        if (resultado.charAt(2) == 2) {
                            if (resultado.charAt(3) == 4) {
                                if (resultado.charAt(4) == 4) {
                                    v5 = (resultado.charAt(5)) * 1;
                                    v6 = (resultado.charAt(6)) * 2;
                                    v7 = (resultado.charAt(7)) * 1;
                                    v8 = (resultado.charAt(8)) * 2;
                                    v9 = (resultado.charAt(9)) * 1;
                                    v10 = (resultado.charAt(10)) * 2;
                                    v11 = (resultado.charAt(11)) * 1;
                                    v12 = (resultado.charAt(12)) * 2;
                                    v13 = (resultado.charAt(13)) * 1;
                                    v14 = (resultado.charAt(14)) * 2;
                                    digito1 = resultado.charAt(15);

                                    if (i >= 5 && i <= 14) {

                                        if (eval("v" + i) >= 10) {
                                            valor = "v" + i;
                                            v = eval("v" + i);
                                            var cadena = v + "";
                                            y = 0;
                                            for (x = 0; x < cadena.length + 1; x++) {
                                                if (cadena.charAt(x) != "") {
                                                    y = y + eval(cadena.charAt(x));
                                                }
                                            }
                                            sumatorio = eval(sumatorio + y);

                                        }
                                        else {
                                            sumatorio = sumatorio + eval("v" + i);
                                        }

                                    }
                                }
                            }
                        }
                    }
                }
            }
            valor = sumatorio + " ";
            i = 0;
            for (i = 0; i < valor.length - 1; i++) {
                unidad = valor.charAt(i);
            }
            if (unidad == 0) {
                digito2 = 0;
            }
            else {
                digito2 = eval(10 - unidad);
            }

            if ((digito1 - digito2) == 0) {
                //document.frmformapago.submit();
                bTuryOcio = true;
            }
            else {
                alert("El número de su tarjeta Turyocio no es correcto: " + num_target.length);
                bTuryOcio = false;
            }
        }
    }
}

function favoritos(){
    title = "EverestDirecto";
    url = window.location.href;

    if (window.sidebar) { // Mozilla Firefox Bookmark 
        window.sidebar.addPanel(title, url, "");
    } else if (window.external) { // IE Favorite 
        window.external.AddFavorite(url, title);
    }
    else if (window.opera && window.print) { // Opera Hotlist 
        return true;
    }
}
