/*
//***********************************************************
// la classe qui sert ŕ stocker les infos sur le parcours et la couleur d'un concurrent
// flag pour afficher le parcours ou uniquement le dernier point

    flag : posiflag bool affiche-t-on ce concurrent
    flag : traceflag bool affiche-t-on sa trace
    string color : couleur de la trace
    tableau de points(double lat, double lng)   // le dernier point est le plus récent
*/

function dpoint(lati,lngi)
{
    this.lat = lati;
    this.lng = lngi;
}
//******************************************
cmpDatas.prototype.setposis = setposis;
cmpDatas.prototype.updateposis = updateposis;
cmpDatas.prototype.updateReplayPosi = UpdateReplayPosition;
cmpDatas.prototype.hideposi = hideposi;
cmpDatas.prototype.showposi = showposi;
cmpDatas.prototype.settrace = settrace;

cmpDatas.prototype.r = function() { return parseInt(this.color.substr(1,2),16);};
cmpDatas.prototype.g = function() { return parseInt(this.color.substr(3,2),16);};
cmpDatas.prototype.b = function() { return parseInt(this.color.substr(5,2),16);};

function cmpDatas()
{
    this.updated = false;
    this.nom = "";
    this.nom2 = "";
    this.numId = "";
    this.classId = 0;
    this.team = "";
    this.kind = "";
    this.posiflag = false;
    this.traceflag = false;
    this.color = null;
    this.lastposi = null;
    this.vitesse = null;
    this.lastdatetime=null;
    this.points = new Array();     // tableau de points
    this.polyline = null;   // change avec le type de map
    this.shape = null;      // change avec le type de map
    this.updatetrace = function() {
        this.points.push(this.lastposi);
    };
}
//----------------------------------------------------------
function setposis(compet)
{
    this.nom = compet.nom;
    this.nom2 = compet.nom2;
    this.numId = compet.numId;
    this.classId = compet.classId;
    this.kind = compet.vehi;
    this.team = compet.team;
    this.vitesse = compet.vitesse;
    this.lastdatetime= compet.date;
    this.lastposi = new dpoint(compet.lat,compet.longi);     // tableau de points
    if (this.traceflag)
        this.updatetrace();
    this.updated = true;
}
//----------------------------------------------------------
function hideposi()
{
    this.posiflag = false;
}
//----------------------------------------------------------
function showposi()
{
    this.posiflag = true;
}
//----------------------------------------------------------
function settrace(p1,p2,p3)
{
    if (arguments.length == 1)
        this.points = p1;
    else
    {
        this.nom = p1;
        this.numId = p2;
        this.points = p3;
    }
    
    this.traceflag = true;
}

//----------------------------------------------------------
function updateposis(compet)
{
    this.posiflag = true;
    this.lastposi = new dpoint(compet.lat,compet.longi);     // tableau de points
    this.vitesse = compet.vitesse;
    this.lastdatetime= compet.date;
    if (this.traceflag)
        this.updatetrace();
    this.updated = true;
}
//----------------------------------------------------------
function UpdateReplayPosition(lat,lng,speed,date,seq)
{
    var datas = replayPosList[seq-1];
    this.posiflag = true;
    this.lastposi = new dpoint(lat,lng);     // tableau de points
    this.vitesse = speed;
    this.lastdatetime= date;
    this.updated = true;
}
//******************************************************************
ReplayPosis.prototype.setReplayposis = setRposis;
function ReplayPosis()
{
    this.latitude = 0;
    this.longitude = 0;
    this.speed = 0;
    this.time = 0;
    this.seq = 0;
}

function setRposis(lat,lng,speed,time,seq)
{
    this.latitude = lat;
    this.longitude = lng;
    this.speed = speed;
    this.time = time;
    this.seq = seq;
}
//----------------------------------------------------------
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();