﻿$(document).ready(function() {

    $("#link1").click(function(event) {
        getEvento(1);


    });

    $("#link2").click(function(event) {
        getEvento(2);


    });

    $("#link3").click(function(event) {
        getEvento(3);


    });

    $("#link4").click(function(event) {
        getEvento(4);


    });

    $("#iRicarica").bind('mouseout',setHref);

    $("#iRicarica").keyup(function(event) {
        //alert('ciao');
    $("#aRicarica").attr('href', 'formricarica.htm?id=' + $("#iRicarica").val());


    });


    //    $("#linkRicarica").click(function(event) {
    //    loadPopupRicarica();


    //    });


});

function setHref() {

    $("#aRicarica").attr('href', 'formricarica.htm?id=' + $("#iRicarica").val());

}

function getEvento(id) {
    $.ajax({
        type: "POST",
        url: "ajaxService.asmx/getEvento",

        //data: "{'n': '" + $('#name').val() + "'}",
        data: "{'n': '" + id + "'}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(msg) {
            AjaxSucceeded(msg);
        },
        error: AjaxFailed

    });
}

function AjaxSucceeded(result) {
    $('#popUpTitle').html(result.d.nome);
    $('#popUpText').html(result.d.body);
    $('#popUpImg').attr('src', 'images/eventi/'+result.d.img1);
    
    
//    Shadowbox.open({
//    content: result.d.body,
//            player: "html",
//            title: result.d.nome,
//                height: 768,
//                width: 700
//            });



    //centering with css
    centerPopup($("#backgroundPopup"), $("#popupContact1"));
    //load popup
    loadPopup($("#backgroundPopup"), $("#popupContact1"));

    //alert(result.d.nome);
}
//function loadPopupRicarica() {
//   

//    //centering with css
//    centerPopup($("#backgroundPopup"), $("#popupRicarica"));
//    //load popup
//    loadPopup($("#backgroundPopup"), $("#popupRicarica"));

//    //alert(result.d.nome);
//}

function AjaxFailed(result) {
    alert(result.status + ' ' + result.statusText);
}  

