﻿var pagina = {
    banner: function () {
        $("#lofslidecontent45").lofJSidernews({ interval: 5000,
            easing: 'easeInOutQuad',
            duration: 1000,
            auto: true
        });
    },
    paneles: function () {
        $('ul.hover_block li').hover(function () {
            $(this).find('img').animate({ top: '182px' }, { queue: false, duration: 500 });
        }, function () {
            $(this).find('img').animate({ top: '0px' }, { queue: false, duration: 500 });
        });
        $('ul.hover_block2 li').hover(function () {
            $(this).find('img').animate({ left: '300px' }, { queue: false, duration: 500 });
        }, function () {
            $(this).find('img').animate({ left: '0px' }, { queue: false, duration: 500 });
        });
    },
    settings: function () {
        $("#servicios").corner("6px");
        $("#vms").corner("6px");
        $("#internacional").corner("6px");
        $("#noticias").corner("6px");
        $("#dialog").dialog({
            autoOpen: false,
            width: 600,
            show: "clip",
            hide: "scale",
            modal: true,
            zIndex: 9999,
            buttons: [{
                text: "Cerrar",
                click: function () { $(this).dialog("close"); }
            }]
        });
    },
    noticias: function () {
        $("#myController").jFlow({
            slides: "#slides",
            controller: ".jFlowControl", // must be class, use . sign
            slideWrapper: "#jFlowSlide", // must be id, use # sign
            selectedWrapper: "jFlowSelected",  // just pure text, no sign
            auto: true, 	//auto change slide, default true
            width: "640px",
            height: "160px",
            duration: 400,
            prev: ".jFlowPrev", // must be class, use . sign
            next: ".jFlowNext" // must be class, use . sign
        });
    },
    enlaces: function (idioma) {
        $(".mas").click(function () {
            var datos = "{'id': '" + $(this).attr("id") + "'}";
            var url = (idioma == "es" ? "index.aspx/GetDetallesNoticia" : "hasiera.aspx/GetDetallesNoticia");
            $.ajax({
                type: "POST",
                url: url,
                data: datos,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                async: true,
                success: function (result) {
                    if (result.d.length > 0) {
                        if (result.d[0] == "1") {
                            //Es un enlace                            
                            window.open(result.d[4]);
                        }
                        else {
                            //Datos ampliados
                            $("#imagenPop").attr("src", result.d[3]);
                            $("#texto_largo").html(result.d[2]);
                            $("#enlace_dialogo").html(result.d[4]);
                            //Mostramos el dialogo
                            $("#dialog").dialog("option", "title", result.d[1]);
                            $("#dialog").dialog("open");
                        }
                        return false;
                    }
                    else {
                        alert("No values");
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert(textStatus + ": " + XMLHttpRequest.responseText);
                }
            });
        });
    }
}
