function outerHTML(objeto) {
    //Se usa esta funcion solo para compatibildad con firefox
    var parent = objeto.parentNode;
    var el = document.createElement(parent.tagName);
    el.appendChild(objeto);
    var shtml = el.innerHTML;
    parent.appendChild(objeto);
    return shtml;
}
function Imprimir(cod_area, cod_perfil, print_area, print_navegacion, print_titulo, estilos) {
    var pp = window.open();
    pp.document.writeln('<HTML>')
    pp.document.writeln('<HEAD><title>Vista previa</title>')
    pp.document.writeln(estilos)
    //pp.document.writeln('<LINK href="/estilos/PrintStyle.css"  type="text/css" rel="stylesheet" media="print"><base target="_self">')
    pp.document.writeln('</HEAD>')
    pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0">');
    pp.document.writeln('<form  method="post">');
    pp.document.writeln(' <div id="TBL_Cabecera">');
    pp.document.writeln(' <input name="button" type="button" id="PRINT" onclick="javascript:location.reload(true);window.print();" value="Imprimir" />');
    pp.document.writeln(' <input name="button2" type="button" id="CLOSE" onclick="window.close();" value="Cerrar" />');
    pp.document.writeln(' </div>');
    pp.document.writeln(' <div id="IMP_Cabecera">');
    pp.document.writeln('   <table width="100%" border="0" cellspacing="0" cellpadding="0">');
    pp.document.writeln('     <tr>');
    pp.document.writeln('       <td style="width: 50%;"><img src="/images/' + cod_area + '/imagen_logo1.gif" /></td>');
    //pp.document.writeln('       <td width="50%" align="right"><img src="/images/' + cod_area + '/' + cod_perfil + '/imagen_logo1.gif" /></td>');
    pp.document.writeln('     </tr>');
    pp.document.writeln('   </table>');
    pp.document.writeln(' </div>');
    pp.document.writeln(' <div class="IMP_BarraGris"></div>');
    pp.document.writeln(' <div class="IMP_BarraModulo"></div>');
    //pp.document.writeln(' <div class="IMP_Navegacion">' + document.getElementById(print_navegacion).innerHTML + '</div>');
    pp.document.writeln('<div class="WEB_CONTE_navegacion"><li><a href="http://www.turismoperu.info">Pagina principal</a></li></div>')
    pp.document.writeln(' <div class="WEB_CONTE_interno1">' + document.getElementById(print_titulo).innerHTML + '</div>');
    pp.document.writeln(' <div style="padding-bottom:20px;" class="IMP_Contenido">' + document.getElementById(print_area).innerHTML + '</div>');
    pp.document.writeln('</form></body></HTML>');
}


String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, '') }
var nav4 = window.Event ? true : false;
function acceptNum(evt) {
    var key = nav4 ? evt.which : evt.keyCode;
    return (key <= 13 || (key >= 48 && key <= 57));
}
function invocaPintadaJS(paramE) {
    document.write(paramE);
}
function noVacio(elm) {
    //alert("entro aqui")
    if (elm.value.trim() == "" ||
        elm.value == null)
        return false;
    else return true;
}
function trim(cadena) {
    for (i = 0; i < cadena.length; ) {
        if (cadena.charAt(i) == " ")
            cadena = cadena.substring(i + 1, cadena.length);
        else
            break;
    }

    for (i = cadena.length - 1; i >= 0; i = cadena.length - 1) {
        if (cadena.charAt(i) == " ")
            cadena = cadena.substring(0, i);
        else
            break;
    }

}

function valorDeCombo(objectoCombo) {
    return objectoCombo.options[objectoCombo.selectedIndex].value;
}


function consisfec(xdia, xmes, xano) {
    if (parseInt(xdia) == 0 || parseInt(xmes) == 0 || parseInt(xano) == 0) return false;
    var meses = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
    meses[1] = ((xano % 4) == 0) ? 29 : 28;
    return ((xdia <= meses[xmes - 1]) ? true : false);  // true -> OK     false -> KO
}

function validarEntero(texto1) {
    var texto = texto1;
    var vAlido = (texto != '' && texto != null);
    if (vAlido == true) for (i = 0; (i < texto.length && vAlido); i++) vAlido = vAlido && (texto.charAt(i) >= '0' && texto.charAt(i) <= '9');
    if (vAlido == true) while (texto.charAt(0) == '0') texto = texto.substring(1);
    if (vAlido == true) vAlido = (parseInt(texto) > 0);
    return vAlido;
}

function abreVentana(pUrl, pWindowName, pWidth, pHeight, pAttrib, pCuadrante) {
    var anchoDisponibleVentana = window.screen.availWidth;
    var altoDisponibleVentana = window.screen.availHeight;
    // '1 si, 2 sd, 3 ii, 4 id, 5 c [pCuadrante]
    var lngX = 0;
    var lngY = 0;
    if (pCuadrante == 1) { lngX = 0; lngY = 0; }
    else if (pCuadrante == 2) { lngX = (anchoDisponibleVentana - pWidth - 15); lngY = 0; }
    else if (pCuadrante == 3) { lngX = 0; lngY = (altoDisponibleVentana - 30 - pHeight); }
    else if (pCuadrante == 4) { lngX = (anchoDisponibleVentana - pWidth - 15); lngY = (altoDisponibleVentana - 30 - pHeight); }
    else { lngX = ((anchoDisponibleVentana - pWidth) / 2); lngY = ((altoDisponibleVentana - pHeight) / 2); }

    var attrib = 'left=' + lngX + ',top=' + (lngY - 30) + ',';
    attrib += 'screenX=' + lngX + ',screenY=' + lngY + ',width=' + pWidth + ',height=' + pHeight;
    //attrib += 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,maximize=no';}
    attrib += pAttrib;
    window.open(pUrl, pWindowName, attrib);
}

/* Tab Botones Inferiores */

var A_tabContenido = ["", "fondo_tab_contenido1", "fondo_tab_contenido2", "fondo_tab_contenido3", "fondo_tab_contenido4"];

function TabInferiorContenido() {
    var tab_elegido = this.className.substring(22, 21);
    for (var i = 1; i < 5; i++) {
        document.getElementById("Tab_Inferior" + i).className = "WEB_CONTE_tabInferior" + i;
    }
    this.className = "WEB_CONTE_tabInferior" + tab_elegido + "_on";

    fondoContenido = "images/" + A_tabContenido[tab_elegido] + ".jpg";

    //$("div.WEB_CONTE_tabContenido").css("background-image",fondoContenido);
    document.getElementById("tab_contenido").className = "WEB_CONTE_tabContenidoFondo" + tab_elegido;
    //alert(A_tabContenido[tab_elegido]);
}


var timerID = "";
var duracion = 10000;

function Temporizador1() {
    timerID = setTimeout("OcultarMensaje()", duracion);
}

function Temporizador2() {
    timerID = setTimeout("MostrarMensaje()", duracion);
}

function OcultarMensaje() {
    clearTimeout(timerID);
    //	$("div.WEB_CONTE_bannerMensaje").hide("slow",Temporizador2());
    $("div.WEB_CONTE_bannerMensaje").hide("slow", "");
}

function MostrarMensaje() {
    clearTimeout(timerID);
    $("div.WEB_CONTE_bannerMensaje").show("slow", Temporizador1());
}

/* ******************************************************************* */
/* ******************************************************************* */
/* ******************************************************************* */
/* ******************************************************************* */

/* Noticias Scroll */


var pausa_inicio = 6000;
var velocidad_scroll = 1;
var pausa_scroll = 1;

var velocidad_temp = velocidad_scroll;
var pausa_velocidad = (pausa_scroll == 0) ? velocidad_temp : 0;
var altura_actual = 0;

function ScrollActivado() {
    if (parseInt(id_scroll.style.top) > (altura_actual * (-1) + 8)) {
        id_scroll.style.top = parseInt(id_scroll.style.top) - velocidad_temp + "px";
    } else {
        id_scroll.style.top = parseInt(id_contenedor) + 8 + "px";
    }
}

function IniciarScroll() {
    id_scroll = document.getElementById("WEB_ID_noticias");
    $("div.WEB_CONTE_bloqueContenidoNoticias").css("top", 0);
    id_contenedor = $("div.WEB_CONTE_scrollNoticias").height();
    altura_actual = $("div.WEB_CONTE_bloqueContenidoNoticias").height();
    setTimeout("id_interval=setInterval('ScrollActivado()',65)", pausa_inicio);
    $("div.WEB_CONTE_scrollNoticias").bind('mouseover', DetenerScroll).bind('mouseout', AvanzarScroll);
}


function DetenerScroll() {
    velocidad_temp = pausa_velocidad;
}

function AvanzarScroll() {
    velocidad_temp = velocidad_scroll;
}

/* Actividades */

var pausa_inicioact = 6000;
var velocidad_scrollact = 1;
var pausa_scrollact = 1;

var velocidad_tempact = velocidad_scrollact;
var pausa_velocidadact = (pausa_scrollact == 0) ? velocidad_tempact : 0;
var altura_actualact = 0;

function ScrollActividades() {
    if (parseInt(id_scrollact.style.top) > (altura_actualact * (-1) + 8)) {
        id_scrollact.style.top = parseInt(id_scrollact.style.top) - velocidad_tempact + "px";
    } else {
        id_scrollact.style.top = parseInt(id_contenedoract) + 8 + "px";
    }
}

function IniciarScrollActividades() {
    id_scrollact = document.getElementById("WEB_ID_actividades");
    $("div.WEB_CONTE_bloqueContenidoActividades").css("top", 0);
    id_contenedoract = $("div.WEB_CONTE_scrollActividades").height();
    altura_actualact = $("div.WEB_CONTE_bloqueContenidoActividades").height();
    setTimeout("id_interval=setInterval('ScrollActividades()',65)", pausa_inicioact);
    $("div.WEB_CONTE_scrollActividades").bind('mouseover', DetenerActividades).bind('mouseout', AvanzarActividades);
}

function DetenerActividades() {
    velocidad_tempact = pausa_velocidadact;
}

function AvanzarActividades() {
    velocidad_tempact = velocidad_scrollact;
}

/* ********************************************************************************************* */
/* ********************************************************************************************* */
/* ********************************************************************************************* */

/* Buscador Texto por Default */

function TextoBuscador(id_input, valor) {
    if ($.trim($(id_input).val()) == "") {
        $(id_input).val(valor);
    }

    $(id_input).focus(function() {
        if ($(id_input).val() == valor) {
            $(id_input).val("");
        }
    });

    $(id_input).blur(function() {
        if ($.trim($(id_input).val()) == "") {
            $(id_input).val(valor);
        }
    });
}

/* ********************************************************************************************* */
/* ********************************************************************************************* */
/* ********************************************************************************************* */


var A_menuCombo = ["", -64, -199, 0];

function MenuCombo() {
    $("div.WEB_CONTE_menuCombo1").hide();
    $("div.WEB_CONTE_menuCombo2").hide();
    var combo_id = $(this).children(".WEB_CONTE_menuCombo1").attr("id");
    var combo_elegido = combo_id.substring(7, 6);
    $(this).children("div.WEB_CONTE_menuCombo1").slideDown();
    $(this).children("div.WEB_CONTE_menuCombo1").css("left", A_menuCombo[combo_elegido]);
    $(this).children("div.WEB_CONTE_menuCombo1").hover(MenuComboEncima, MenuComboFuera)
}

function MenuComboEncima() {
    $(this).show();
}

function MenuComboFuera() {
    $(this).hide();
}

function ComboEncima1() {
    $(this).addClass("WEB_CONTE_comboInferior1_on");
}

function ComboFuera1() {
    $(this).removeClass("WEB_CONTE_comboInferior1_on");
    $("div.WEB_CONTE_menuCombo2").hide();
    $(this).children("div.WEB_CONTE_menuCombo1").hide();
}



function MenuCombo2() {

    var combo_id = $(this).children(".WEB_CONTE_menuCombo2").attr("id");

    $(this).children("div.WEB_CONTE_menuCombo2:hidden").slideDown();

    $("div.WEB_CONTE_menuCombo1").hide();
    $("div.WEB_CONTE_menuCombo2").hide();

    var combo_elegido = combo_id.substring(7, 6);

    $(this).children("div.WEB_CONTE_menuCombo2").css("left", A_menuCombo[combo_elegido]);

    $(this).children("div.WEB_CONTE_menuCombo2").hover(MenuComboEncima2, MenuComboFuera2)

}

function MenuComboEncima2() {
    $(this).show();
}

function MenuComboFuera2() {
    $(this).hide();
}

function ComboEncima2() {

    $(this).addClass("WEB_CONTE_comboInferior2_on");
}

function ComboFuera2() {
    $(this).removeClass("WEB_CONTE_comboInferior2_on");
    var combo_id = $(this).children(".WEB_CONTE_menuCombo2").attr("id");
    $("div.WEB_CONTE_menuCombo2").not("div[id=" + combo_id + "]").hide();
    $("div.WEB_CONTE_menuCombo1").hide();
}





var A_anchoBotones = [];

function TabAncho(i) {
    var x = $(this);
    A_anchoBotones[i] = x.width();
}


function TabEncima1() {
    $(this).children("div.WEB_CONTE_tabParte1").addClass("WEB_CONTE_tabParte1_on");
    $(this).children("div.WEB_CONTE_tabParte2").addClass("WEB_CONTE_tabParte2_on");
    $(this).children("div.WEB_CONTE_menuTab1").fadeIn(400);
    var tab_id = $(this).find("div[id^=Tab]").attr("id");
    var tab_elegido = tab_id.substring(5, 4);
    var tab_ancho = $(this).width();
    var tab_posicion = 0;
    for (var i = 0; i < tab_elegido; i++) {
        tab_posicion += A_anchoBotones[i];
    }
    $(this).children("div.WEB_CONTE_menuTab1").css("left", -(tab_posicion - tab_ancho));
    $("div.WEB_CONTE_tabActivo").css("left", tab_posicion).show();
}

function TabFuera1() {
    $(this).children("div.WEB_CONTE_tabParte1").removeClass("WEB_CONTE_tabParte1_on");
    $(this).children("div.WEB_CONTE_tabParte2").removeClass("WEB_CONTE_tabParte2_on");
    $(this).children("div.WEB_CONTE_menuTab1").hide();
    $("div.WEB_CONTE_tabActivo").hide();
}

function EnlaceEncima1() {
    $(this).addClass("WEB_CONTE_botonBannerTitulo1_on");
    $(this).parent().parent().children().children("div.WEB_CONTE_botonBannerImagen1").css({ "border": "1px solid #ef8608" });
}

function EnlaceFuera1() {
    $(this).removeClass("WEB_CONTE_botonBannerTitulo1_on");
    $(this).parent().parent().children().children("div.WEB_CONTE_botonBannerImagen1").css({ "border": "1px solid white" });
}


function EnlaceEncima2() {
    $(this).addClass("WEB_CONTE_botonBannerTitulo2_on");
    $(this).parent().parent().children().children("div.WEB_CONTE_botonBannerImagen2").css({ "border": "1px solid #ef8608" });
}

function EnlaceFuera2() {
    $(this).removeClass("WEB_CONTE_botonBannerTitulo2_on");
    $(this).parent().parent().children().children("div.WEB_CONTE_botonBannerImagen2").css({ "border": "1px solid white" });
}

function ImagenEncima1() {
    $(this).css({ "border": "1px solid #ef8608" });
    $(this).parent().parent().children().children("div.WEB_CONTE_botonBannerTitulo1").addClass("WEB_CONTE_botonBannerTitulo1_on");
}

function ImagenFuera1() {
    $(this).css({ "border": "1px solid white" });
    $(this).parent().parent().children().children("div.WEB_CONTE_botonBannerTitulo1").removeClass("WEB_CONTE_botonBannerTitulo1_on");
}


function ImagenEncima2() {
    $(this).css({ "border": "1px solid #ef8608" });
    $(this).parent().parent().children().children("div.WEB_CONTE_botonBannerTitulo2").addClass("WEB_CONTE_botonBannerTitulo2_on");
}

function ImagenFuera2() {
    $(this).css({ "border": "1px solid white" });
    $(this).parent().parent().children().children("div.WEB_CONTE_botonBannerTitulo2").removeClass("WEB_CONTE_botonBannerTitulo2_on");
}


var mFormData = null
function Call(functionName, functionArguments, endFunction, context) {
    __FormularioPostData = "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=&"

    WebForm_DoCallback('__Page', functionName + '|' + functionArguments, endFunction, context, null, false)
}
function FormCall(functionName, dummy, endFunction) {

    mFormData = new String()
    InitFormCallback()

    __theFormPostData = "__FORMCALLBACK=1&__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=&" + mFormData
    WebForm_DoCallback('__Page', functionName, endFunction, null, null, false)
}

function InitFormCallback() {
    var count = theForm.elements.length;
    var element;
    for (var i = 0; i < count; i++) {
        element = theForm.elements[i];
        var tagName = element.tagName.toLowerCase();
        if (tagName == "input") {
            var type = element.type;

            if ((type == "text" || type == "hidden" || type == "password" || ((type == "checkbox" || type == "radio") && element.checked)) && (element.id != "__EVENTVALIDATION" && element.id != "__VIEWSTATE" && element.id != "__EVENTTARGET" && element.id != "__EVENTARGUMENT")) {

                InitCallbackAddField(element.name, element.value);
            }
        }
        else if (tagName == "select") {
            var selectCount = element.options.length;
            for (var j = 0; j < selectCount; j++) {
                var selectChild = element.options[j];
                if (selectChild.selected == true) {
                    InitCallbackAddField(element.name, element.value);
                }
            }
        }
        else if (tagName == "textarea") {
            InitCallbackAddField(element.name, element.value);
        }
    }
}

function InitCallbackAddField(name, value) {
    mFormData += name + "=" + WebForm_EncodeCallback(value) + "&";
}

function EnlaceMenu(url, target) {
    target = target.toLowerCase();
    if (target == '_blank') window.open(url);
    else if (target == '_top') top.location.href = url;
    else if (target == '_parent') parent.location.href = url;
    else self.location.href = url;
}
function fvnot_BorrrarTodo(form) {
    var count = theForm.elements.length;
    var element;
    for (var i = 0; i < count; i++) {
        element = theForm.elements[i];
        var tagName = element.tagName.toLowerCase();
        if (tagName == "input") {
            var type = element.type;

            if ((type == "text" || type == "hidden" || type == "password" || ((type == "checkbox" || type == "radio") && element.checked)) && (element.id != "__EVENTVALIDATION" && element.id != "__VIEWSTATE" && element.id != "__EVENTTARGET" && element.id != "__EVENTARGUMENT")) {

                element.value = '';
            }
        }
        else if (tagName == "select") {
            /*var selectCount = element.options.length;
            for (var j = 0; j < selectCount; j++) {
            var selectChild = element.options[j];
            selectChild.value='-1';
            }*/
        }
        else if (tagName == "textarea") {
            element.value = ''
        }

    }

    if (document.getElementById('btn_Registrar') != null) {
        document.getElementById('btn_Registrar').disabled = false;
    }
    if (form.ctl00_PortalPlaceHolder_txt_Nombre != null) {
        form.ctl00_PortalPlaceHolder_txt_Nombre.focus()
    }

}

function imposeMaxLength(Object, MaxLen) {
    return (Object.value.length <= MaxLen);
}

function soloLetrasTildes(e) {

    var key = nav4 ? e.which : e.keyCode;
    //alert(key);
    return ((65 <= key && key <= 90) ||
    (97 <= key && key <= 122) ||
    (key == 32 || key == 8 ||
     key == 0) || key == 241
     || key == 96
     || key == 180
     || key == 8
      || key == 209
     || (key >= 225 && key <= 300))
}

function soloLetras(e) {

    var key = nav4 ? e.which : e.keyCode;
    //alert(key); 
    return ( key == 209  || (65 <= key && key <= 90) || (97 <= key && key <= 122) || (key == 32 || key == 8 || key == 0) || key == 241)
}
function soloCaracteresNick(e) {
    /*var key = nav4 ? e.which : e.keyCode;
    return ((48 <= key && key <= 59) || (65 <= key && key <= 90) || (97 <= key && key <= 122) || key == 241 || (key == 95 || key == 8 || key == 0))*/

    var key = nav4 ? e.which : e.keyCode;
    //alert(key);
    return ((48 <= key && key <= 59) || (65 <= key && key <= 90) ||
    (97 <= key && key <= 122) ||
    (key == 32 || key == 8 ||
     key == 0) || key == 241
     || key == 96
     || key == 180
     || key == 8
      || key == 209
      || key == 95
      || key == 45
     || (key >= 225 && key <= 300))

}




//function isEmailAddress(emailStr) {

//    /* Verificar si el email tiene el formato user@dominio. */
//    var emailPat = /^(.+)@(.+)$/

//    /* Verificar la existencia de caracteres. ( ) < > @ , ; : \ " . [ ] */
//    var specialChars = "\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"

//    /* Verifica los caracteres que son válidos en una dirección de email */
//    var validChars = "\[^\\s" + specialChars + "\]"

//    var quotedUser = "(\"[^\"]*\")"

//    /* Verifica si la dirección de email está representada con una dirección IP Válida */


//    var ipDomainPat = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/


//    /* Verificar caracteres inválidos */

//    var atom = validChars + '+'
//    var word = "(" + atom + "|" + quotedUser + ")"
//    var userPat = new RegExp("^" + word + "(\\." + word + ")*$")
//    //domain, as opposed to ipDomainPat, shown above. */
//    var domainPat = new RegExp("^" + atom + "(\\." + atom + ")*$")


//    var matchArray = emailStr.toString().match(emailPat)
//    if (matchArray == null) {
//        alert("Email address seems incorrect (check @ and .'s)")
//        return false
//    }
//    var user = matchArray[1]
//    var domain = matchArray[2]

//    // Si el user "user" es valido 
//    if (user.match(userPat) == null) {
//        // Si no
//        alert("El nombre de usuario no es válido.")
//        return false
//    }

//    /* Si la dirección IP es válida */
//    var IPArray = domain.match(ipDomainPat)
//    if (IPArray != null) {
//        for (var i = 1; i <= 4; i++) {
//            if (IPArray[i] > 255) {
//                alert("IP de destino inválida")
//                return false
//            }
//        }
//        return true
//    }

//    var domainArray = domain.match(domainPat)
//    if (domainArray == null) {
//        alert("El dominio parece no ser válido.")
//        return false
//    }

//    var atomPat = new RegExp(atom, "g")
//    var domArr = domain.match(atomPat)
//    var len = domArr.length
//    if (domArr[domArr.length - 1].length < 2 ||
//    domArr[domArr.length - 1].length > 3) {

//        alert("La dicrección debe tener 3 letras si es .\"com\" o 2 si en de algún pais.")
//        return false
//    }

//    if (len < 2) {
//        var errStr = "La dirección es erronea"
//        alert(errStr)
//        return false
//    }

//    // La dirección de email ingresada es Válida
//    return true;
//}
//// End -->
