﻿// File JScript
var controlId;
var txtMedia;
var txtVoti;

function SwfInitialize(media, voti, strControlId, modulePath, swflink, VideoId, VideoTitle, larghezza, altezza, VideoDesc, VideoLink)
{   
    controlId = strControlId;
    txtMedia = media;
    txtVoti = voti;
    //LabelTitle = $get('ctl00_CPHCenter_lblTitle');
    //LabelTitle.innerHTML = VideoTitle;
    CommonWs.SetVisits(VideoId,OnSuccededViews, null);
    //Common.SetNumeroCommenti(VideoId,OnSetNumeroCommenti, null);
    //Common.SetCommenti(VideoId,OnSetCommenti, null);
    //Common.SetDettaglioVideo(VideoId,OnSetDettaglioVideo, null);
    SetVideo(modulePath, swflink,larghezza,altezza,VideoTitle,VideoDesc,VideoLink);
}

function OnSuccededViews(result)
{
    if (result != 'nd')
    {
       result = String(result);
       var stringa = result.split("__");
       Totale = stringa[1];
       Media = stringa[0];
       StatsInitialize();
       LabelStats = $get(controlId + '_Lblstatistiche');
       LabelStats.innerHTML = String(txtMedia) + ': ' + String(Media) + ' - '+ String(txtVoti) +': ' + String(Totale);
       GestStarColor(Media);  
    }
    else
    {
        StatsInitialize();
    }    
}

function OnSetNumeroCommenti(result)
{
    LabelIdVideo = $get('ctl00_txtNumComm');
    LabelIdVideo.innerHTML = result;
}

function OnSetCommenti(result)
{
    LabelCommenti = $get('linkCommenti');
    LabelCommenti.href = result;
}

function OnSetDettaglioVideo(result)
{
    LabelDettaglio = $get('linkDettalio');
    if (result != '')
    {
       LabelDettaglio.href = result;
       LabelDettaglio.innerHTML = '» Scheda evento';
    }
    else
    {
       LabelDettaglio.href = '';
       LabelDettaglio.innerHTML = '';
    }
    
}


function StatsInitialize()
{
    SpanStar1 = $get(controlId + '_Rating1_Star_1');
    SpanStar2 = $get(controlId + '_Rating1_Star_2');
    SpanStar3 = $get(controlId + '_Rating1_Star_3');
    SpanStar4 = $get(controlId + '_Rating1_Star_4');
    SpanStar5 = $get(controlId + '_Rating1_Star_5');
    SpanStar1.className = 'ratingStar emptyRatingStar'; 
    SpanStar2.className = 'ratingStar emptyRatingStar'; 
    SpanStar3.className = 'ratingStar emptyRatingStar'; 
    SpanStar4.className = 'ratingStar emptyRatingStar'; 
    SpanStar5.className = 'ratingStar emptyRatingStar';
    LabelStats = $get(controlId + '_Lblstatistiche');
    LabelStats.innerHTML = '';
}
function GestStarColor(result)
{    
    result = parseInt(result);
    for (i=1;i<6;i++)
    {
        if (i<=result)
        {
            SpanStar = $get(controlId + '_Rating1_Star_' + String(i));
            SpanStar.className =  'ratingStar filledRatingStar'; 
        }
    }
}
function SetVideo(modulePath,swflink,larghezza,altezza,titolo,descrizione,link)
{
    var fo = new SWFObject(modulePath + "Player/player.swf", "FlowPlayer", "" + larghezza + "", "" + altezza + "", "7", "#ffffff", true);
    fo.addParam("allowScriptAccess", "always");
    //titolo:'"+ titolo +"', desc:'"+ descrizione +"', link:'"+ link +"'
    fo.addParam("wmode", "transparent");
	fo.addParam("bgcolor", "#000000");
    fo.addParam("allowFullScreen", "true");
    fo.addVariable("titolo", titolo);
    fo.addVariable("desc", descrizione);
    fo.addVariable("link", link);
    fo.addVariable("url", swflink);
    fo.addVariable("modulePath", modulePath);
    //fo.addVariable("config", "{ countryCode: 'it', playList: [ {overlayId: 'play' }, { url: '" + swflink + "' } ], initialScale: 'scale',  fullScreenScriptURL: 'fullscreen.js'}");
    fo.write("flashcontent");
}
function SwfInitializeOnDetail(VideoId, IdCat)
{   
    location.replace("dettagliovideo.aspx?idvideo=" + VideoId + "&idcat=" + IdCat);
}




