﻿
/*############################CLASSIFICA E RISULTATI##################################*/

GetClassifica = function(squadra) {

    var urlAjax = 'AJAX/ClassificheAjax.aspx';
    var pars = '?azione=Classifica&Squadra=' + squadra; //+'&rnd=' + getRnd();
    $.get(urlAjax + pars, function(data) {    
    
    $("#divTabClassifica").removeClass("notsel");
    $("#divTabRisultati").removeClass("sel");
    $("#DivClassificheRisultati").html(data);
    $("#divTabClassifica").addClass("sel");
    $("#divTabRisultati").addClass("notsel");

    });
};


CambioGiornata = function(squadra, giornata) {

    var urlAjax = 'AJAX/ClassificheAjax.aspx';
    var pars = '?azione=CambioGiornata&Squadra=' + squadra + '&Giornata=' + giornata.value;
    $.get(urlAjax + pars, function(data) {
        $("#divRisultatiChange").html(data);
        $("#divRisultatiChange").slideDown("slow");
    });
};

getUltimiRisultatiHome = function(squadra) {

    var urlAjax = 'AJAX/ClassificheAjax.aspx';
    var pars = '?azione=UltimaGiornata&Squadra=' + squadra;
    $.get(urlAjax + pars, function(data) {
        $("#divHtmlRisultatiNextMatch").html(data);
    });
};

getNextMatch = function(squadra) {

    var urlAjax = 'AJAX/ClassificheAjax.aspx';
    var pars = '?azione=NextMatch&Squadra=' + squadra;
    $.get(urlAjax + pars, function(data) {
        $("#divHtmlRisultatiNextMatch").html(data);
    });
};

GetClassificheRisultati = function(squadra) {
    var urlAjax = 'AJAX/ClassificheAjax.aspx';
    var pars = '?azione=CreaPaginaRisultati&Squadra=' + squadra;
    $.get(urlAjax + pars, function(data) {
        $("#DivClassificheRisultati").html(data);
        $("#divTabClassifica").removeClass("sel");
        $("#divTabRisultati").removeClass("notsel");
        $("#DivClassificheRisultati").html(data);
        $("#divTabClassifica").addClass("notsel");
        $("#divTabRisultati").addClass("sel");
        $("#divProssimoIncontro").corner();
        $("#divTabbellino").corner();
    });
};
/*############################ FINE CLASSIFICA E RISULTATI##################################*/
/*############################GIOCATORI##################################*/
ClickGiocatore = function (Giocatore) {
    var urlAjax = 'AJAX/GiocatoriAjax.aspx';
    var pars = '?azione=Anagrafica&IdGiocatore=' + Giocatore;
    $.get(urlAjax + pars, function (data) {

        $("#divInfoGiocatore").html(data);
        $("#divInfoGiocatore").show("slide");
        $("#divSquadrePassate").hide();
        $("#divSquadrePassate").corner();
        $("#divAnnoInCorso").corner();
        $("#divSchedaAnagrafica").corner();
        $("#divContenitore").addClass("divContenitoreScuro");
        $(".tdNominativo div").addClass("displayNone");
        var altezza = $(document).height();
        var larghezza = $(document).width();
        $("#divInfoGiocatore").width(larghezza);
        $("#divInfoGiocatore").height(altezza);
        $("#divInfoGiocatore").fadeIn(300);
        $("#divLogoLuce").hide();
        
    });
};

ClickApriSquadrePassate = function() {
$("#divAnnoInCorso").hide();
$("#divSquadrePassate").show("slide");

}

ClickApriStagioneOdierna = function() {
    $("#divAnnoInCorso").show("slide");
    $("#divSquadrePassate").hide();

}

ChiudiInfoGiocatore = function() {
$("#divInfoGiocatore").hide("slow");
$("#divContenitore").removeClass("divContenitoreScuro");
$(".tdNominativo div").removeClass("displayNone");
$("#divLogoLuce").show();
}



ClickSquadrePrecedenti = function(Giocatore) {
    var urlAjax = 'AJAX/GiocatoriAjax.aspx';
    var pars = '?azione=GetSquadrePrecedenti&IdGiocatore=' + Giocatore;
    $.get(urlAjax + pars, function(data) {
        $("#DivClassificheRisultati").html(data);
    });

};

centerDiv = function(div) {
    var DIVwidth = $(div).width();
    var DIVheight = $(div).height();
    var SCREENwidth = $(document).width();
    var SCREENheight = $(window).height();
    var SCREENscrolltop = $(window).scrollTop();
    //$(div).hide();
    $(div).css({ "position": "absolute", "left": (SCREENwidth - DIVwidth) / 2 + "px", "top": (SCREENheight - DIVheight) / 2 + SCREENscrolltop + "px" });
    //$(div).show();

};

/*############################FINE GIOCATORI##################################*/
/*############################VIDEO##################################*/



CaricaVideo = function(Anno, descrizioneAnno) {
    var urlAjax = 'AJAX/VideoAjax.aspx';
    var pars = '?azione=GetVideo&Anno=' + Anno;
    $.get(urlAjax + pars, function(data) {
        $("#divElencoVideo").html(data);
        $("#lblAnno").html(descrizioneAnno);
    });

};

ApriVideo = function(IdVideo) {
    var urlAjax = 'AJAX/VideoAjax.aspx';
    var pars = '?azione=ClickVideo&IdVideo=' + IdVideo;
    $.get(urlAjax + pars, function(data) {
    $("#light").show("slide");
    $("#light").html(data);
        document.getElementById('light').style.display = 'block';
        document.getElementById('fade').style.display = 'block';
    });


};

ChiudiVideo = function() {
$("#light").hide("slide");
    document.getElementById('light').style.display = 'none';
    document.getElementById('fade').style.display = 'none';
};

/*############################FINE VIDEO##################################*/


/*##############################CARICA LIVE#########################*/
AggiornaLive = function(IdLive) {

  AggiornaRisultatoLive(IdLive);
 AggiornaCronacaLive(IdLive);
  

};

AggiornaRisultatoLive = function(IdLive) {
    var urlAjax = 'AJAX/Live_Ajax.aspx';
    var pars = '?azione=AggiornaRisultato&IdLive=' + IdLive + '&rnd=' + getRnd();
    $.get(urlAjax + pars, function(data) {
        $("#tdRisultato").html(data);
    })
};


AggiornaCronacaLive = function(IdLive) {
    var urlAjax = 'AJAX/Live_Ajax.aspx'; 
   var pars = '?azione=AggiornaCronaca&IdLive=' + IdLive + '&rnd=' + getRnd();
    $.get(urlAjax + pars, function(data) {
        $("#tdCommento").html(data);
    })
};
/*##############################FINE CARICA LIVE#########################*/


/*##############################CARICA IMMAGINI#########################*/


CaricaImages = function(IdSquadraCalcioA5live, descrizione) {
    var urlAjax = 'AJAX/ImmaginiAjax.aspx';
    var pars = '?azione=GetImg&Squadra=' + IdSquadraCalcioA5live;
    $.get(urlAjax + pars, function(data) {
        $("#divCopertine").html(data);
        $("#divCopertine").slideDown("slow");
        $("#ContenitoreUl").html("");
        $("#lblSquadra").html(descrizione);
        //  $("#divImmagineSelezionata").html("");
    });

};

ClickImages = function(Cartella) {
    var urlAjax = 'AJAX/ImmaginiAjax.aspx';
    var pars = '?azione=ClickCopertina&Cartella=' + Cartella;
    $.get(urlAjax + pars, function(data) {
    $("#ContenitoreUl").html(data);
    $("#ContenitoreUl").slideDown("slow");
});


};

caricaGallery = function() {
// We only want these styles applied when javascript is enabled
$('div.content').css('display', 'block');

// Initially set opacity on thumbs and add
// additional styling for hover effect on thumbs
var onMouseOutOpacity = 0.67;
$('#thumbs ul.thumbs li, div.navigation a.pageLink').opacityrollover({
    mouseOutOpacity: onMouseOutOpacity,
    mouseOverOpacity: 1.0,
    fadeSpeed: 'fast',
    exemptionSelector: '.selected'
});

// Initialize Advanced Galleriffic Gallery
var gallery = $('#thumbs').galleriffic({
    delay: 2500,
    numThumbs: 20,
    preloadAhead: 10,
    enableTopPager: true,
    enableBottomPager: true,
    imageContainerSel: '#slideshow',
    controlsContainerSel: '#controls',
    captionContainerSel: '#caption',
    loadingContainerSel: '#loading',
    renderSSControls: true,
    renderNavControls: true,
    playLinkText: 'Play Slideshow',
    pauseLinkText: 'Pause Slideshow',
    prevLinkText: '&lsaquo; Previous Photo',
    nextLinkText: 'Next Photo &rsaquo;',
    nextPageLinkText: 'Next &rsaquo;',
    prevPageLinkText: '&lsaquo; Prev',
    enableHistory: true,
    autoStart: false,
    syncTransitions: true,
    defaultTransitionDuration: 900,
    onSlideChange: function(prevIndex, nextIndex) {
        // 'this' refers to the gallery, which is an extension of $('#thumbs')
        this.find('ul.thumbs').children()
							.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
							.eq(nextIndex).fadeTo('fast', 1.0);

        // Update the photo index display
        this.$captionContainer.find('div.photo-index')
							.html('Photo ' + (nextIndex + 1) + ' of ' + this.data.length);
    },
    onPageTransitionOut: function(callback) {
        this.fadeTo('fast', 0.0, callback);
    },
    onPageTransitionIn: function() {
        var prevPageLink = this.find('a.prev').css('visibility', 'hidden');
        var nextPageLink = this.find('a.next').css('visibility', 'hidden');

        // Show appropriate next / prev page links
        if (this.displayedPage > 0)
            prevPageLink.css('visibility', 'visible');

        var lastPage = this.getNumPages() - 1;
        if (this.displayedPage < lastPage)
            nextPageLink.css('visibility', 'visible');

        this.fadeTo('fast', 1.0);
    }
});

/**************** Event handlers for custom next / prev page links **********************/

gallery.find('a.prev').click(function(e) {
    gallery.previousPage();
    e.preventDefault();
});

gallery.find('a.next').click(function(e) {
    gallery.nextPage();
    e.preventDefault();
});

/****************************************************************************************/

/**** Functions to support integration of galleriffic with the jquery.history plugin ****/

// PageLoad function
// This function is called when:
// 1. after calling $.historyInit();
// 2. after calling $.historyLoad();
// 3. after pushing "Go Back" button of a browser
function pageload(hash) {
    // alert("pageload: " + hash);
    // hash doesn't contain the first # character.
    if (hash) {
        $.galleriffic.gotoImage(hash);
    } else {
        gallery.gotoIndex(0);
    }
}

// Initialize history plugin.
// The callback is called at once by present location.hash. 
$.historyInit(pageload, "advanced.html");

// set onlick event for buttons using the jQuery 1.3 live method
$("a[rel='history']").live('click', function(e) {
    if (e.button != 0) return true;

    var hash = this.href;
    hash = hash.replace(/^.*#/, '');

    // moves to a new page. 
    // pageload is called at once. 
    // hash don't contain "#", "?"
    $.historyLoad(hash);

    return false;
});

};



/*###################################FINE CARICA IMMAGINI#############*/

getRnd = function() {
    d = new Date();
    return d.getMilliseconds();
};
