﻿menu_selected = "";
function Ini_CufonFont() {
    var headings = $('h1,h2,h3,h4,h5,h6, #navigation a, .tit-slider-texto, .txt-slider-texto, .ini-txt-slider, .fin-txt-slider, .txt-resalte, .labelBio');
    if (typeof (Cufon) != 'undefined') {
        Cufon.replace(headings);  
    }
}
function seleccion_menu() {
    if (menu_selected != '') {
        $('#navigation a').each(function() {
            $(this).removeClass('top-selected').addClass('top');
            href = $(this).attr('href');
            if (href.indexOf(menu_selected) != -1) {
                $(this).removeClass('top').addClass('top-selected');
            }
        });    
    }
}
//function formatJSONDateToHTML(fecha) {
//    if (fecha==null) { return ""; }
//    fechaOK = /^\/Date\((-?[0-9]+)\)\/$/.exec(fecha);
//    if (fechaOK) {
//        var dt = new Date(parseInt(fechaOK[1], 10));
//        mes = dt.getMonth() + 1;      
//        var dia = Right("00" + dt.getDate(), 2);
//        var mes = Right("00" + mes, 2);
//        return dia + "/" + mes + "/" + dt.getFullYear();
//    }
//}

//bComprobarFechasEventos = true;
//function CssColorFecha(fecha,CssClassEventoOn,CssClassEventoOff) {
//    if (bComprobarFechasEventos) {
//        if (fecha == null) { return CssClassEventoOff; }
//        fechaOK = /^\/Date\((-?[0-9]+)\)\/$/.exec(fecha);
//        if (fechaOK) {
//            var dt = new Date(parseInt(fechaOK[1], 10));
//            mes = dt.getMonth() + 1;
//            var dia = Right("00" + dt.getDate(), 2);
//            var mes = Right("00" + mes, 2);
//            fechaA = new Date(mes + "/" + dia + "/" + dt.getFullYear());
//            fechaHoy = new Date();
//            if (fechaA < fechaHoy) {
//                return CssClassEventoOff;
//            } else {
//                bComprobarFechasEventos = false;
//                return CssClassEventoOn;
//                // desde ahora todas las fechas son mayores a ahora. No compruebo más.            
//            }
//        }
//    } else {
//        return CssClassEventoOn;
//    }
//}

//function Right(str, n) {
//    if (n <= 0)
//        return "";
//    else if (n > String(str).length)
//        return str;
//    else {
//        var iLen = String(str).length;
//        return String(str).substring(iLen, iLen - n);
//    }
//}

//function parseBoolean(str) {
//    return (str==true || str.toLowerCase()=="true" || String(str)=="1") ? true : false;
//}

filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
function check_email_address(email) {    
    if (filter.test(email)) { 
        return true; 
    } else {
        return false;
    }
}

//$(function() {

//    $("#status").empty();

//    $("#submit_btn").click(function() {
//        // valida y proceso el formulario de contacto 
//        // primero oculta los mensajes previos
//        $("#status").empty();
//        var emailReg = filter; ///^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;

//        var nombre = $("input#nombre").val();
//        if (nombre == "") {
//            $("#status").append('<span class="error">Por favor introduce tu nombre.</span>');
//            return false;
//        }
//        var email = $("input#email").val();
//        if (email == "") {
//            $("#status").append('<span class="error">Por favor introduce tu email.</span>');
//            return false;
//        }
//        if (!emailReg.test(email)) {
//            $("#status").append('<span class="error">Por favor introduce una dirección de email válida.</span>');
//            return false;
//        }
//        var texto = $('textarea#texto').val();
//        if (texto == "") {
//            $("#status").append('<span class="error">Por favor introduce tu consulta o el texto que quieras hacernos llegar.</span>');
//            return false;
//        }

//        var dataString = 'n=' + nombre + '&e=' + email + '&tx=' + texto;
//        $('#status').append('<img src="/images/loading.gif" alt="Enviando información..." />');

//        $.post('ajax/test.html', function(data) {
//            $('.result').html(data);
//        });

//        $.ajax({
//            type: "POST",
//            url: "/contacto/default.aspx",
//            data: dataString,
//            success: function(data) {
//                $("#message").empty();
//                $("#contactform").hide();
//                if (data != "error") {                   
//                    $('#message').html("<h2>Gracias</h2>")
//                .append("<p>Hemos recibido tus datos.<br />Contactaremos contigo a la mayor brevedad.</p>")
//                .hide()
//                .fadeIn(1500);
//                } else {
//                    $('#message').html("<h2>ERROR</h2>")
//                    .append("<p>No hemos podido procesar tu petición.<br />Inténtalo de nuevo más tarde.</p>")
//                    .hide()
//                    .fadeIn(1500);
//                }
//            }, failure: function(msg) {
//                alert("ERROR. " + msg);
//            }
//        });
//        return false;

//    });
//});

//$(document).ready(function() {
//    $LayerFormContacto = $("#LayerFormContacto");
//    $("#btnInfo").click(function(event) {
//        event.preventDefault();
//        event.stopPropagation();
//        $("#contactform").show();        
//        if ($.browser.msie) { $LayerFormContacto.show(); } else { $LayerFormContacto.fadeIn("slow"); }
//    });
//    $("#btnCerrarContacto").click(function(event) {
//        event.preventDefault();
//        event.stopPropagation();
//        if ($.browser.msie) { $LayerFormContacto.hide(); } else { $LayerFormContacto.fadeOut("slow"); }
//        $('#status').empty();
//        $("#message").empty();
//        $("input#email").val('');
//        $("input#nombre").val('');
//        $("textarea#texto").val('');   
//    });
//});
