var Degri = {};

Degri.PinsList = new Array();
Degri.Moto = null;
Degri._pc = null;

Degri.InitializeComponents = function()
{
    var pin;

    pin = new Degri.Pin('redCaramel', 58, 58, '/img/pin-redcaramel.png');
    pin.x = 310;
    pin.y = 450;
    Degri.PinsList[Degri.PinsList.length] = pin;
    
    pin = new Degri.Pin('evening', 63, 63, '/img/pin-evening.png');
    pin.x = 920;
    pin.y = -21;
    Degri.PinsList[Degri.PinsList.length] = pin;
    
    pin = new Degri.Pin('plane', 52, 52, '/img/pin-plane.png');
    pin.x = 1133;
    pin.y = 64;
    Degri.PinsList[Degri.PinsList.length] = pin;
    
    pin = new Degri.Pin('safe', 50, 50, '/img/pin-safe.png');
    pin.x = 1388;
    pin.y = 66;
    Degri.PinsList[Degri.PinsList.length] = pin;
    
    pin = new Degri.Pin('neon', 58, 59, '/img/pin-neon.png');
    pin.x = -69;
    pin.y = 219;
    Degri.PinsList[Degri.PinsList.length] = pin;
    
    pin = new Degri.Pin('flowers', 80, 80, '/img/pin-flowers.png');
    pin.x = 966;
    pin.y = 260;
    Degri.PinsList[Degri.PinsList.length] = pin;
    
    pin = new Degri.Pin('sport', 87, 88, '/img/pin-sport.png');
    pin.x = -245;
    pin.y = 485;
    Degri.PinsList[Degri.PinsList.length] = pin;
    
    pin = new Degri.Pin('cinema', 70, 71, '/img/pin-cinema.png');
    pin.x = 820;
    pin.y = 465;
    Degri.PinsList[Degri.PinsList.length] = pin;
    
    pin = new Degri.Pin('city', 70, 71, '/img/pin-city.png');
    pin.x = 1155;
    pin.y = 425;
    Degri.PinsList[Degri.PinsList.length] = pin;
    
    pin = new Degri.Pin('strips', 58, 58, '/img/pin-strips.png');
    pin.x = 1390;
    pin.y = 398;
    Degri.PinsList[Degri.PinsList.length] = pin;
    
    pin = new Degri.Pin('tits', 49, 49, '/img/pin-tits.png');
    pin.x = -389;
    pin.y = 500;
    Degri.PinsList[Degri.PinsList.length] = pin;
    
    pin = new Degri.Pin('girl', 73, 73, '/img/pin-girl.png');
    pin.x = -30;
    pin.y = 590;
    Degri.PinsList[Degri.PinsList.length] = pin;
    
    pin = new Degri.Pin('house', 96, 97, '/img/pin-house.png');
    pin.x = 550;
    pin.y = 637;
    Degri.PinsList[Degri.PinsList.length] = pin;
    
    pin = new Degri.Pin('carpet', 70, 71, '/img/pin-carpet.png');
    pin.x = 1180;
    pin.y = 637;
    Degri.PinsList[Degri.PinsList.length] = pin;
    
    pin = new Degri.Pin('grass', 58, 58, '/img/pin-grass.png');
    pin.x = -220;
    pin.y = 785;
    Degri.PinsList[Degri.PinsList.length] = pin;
    
    pin = new Degri.Pin('green', 58, 58, '/img/pin-green.png');
    pin.x = 1045;
    pin.y = 840;
    Degri.PinsList[Degri.PinsList.length] = pin;
    
    pin = new Degri.Pin('cosmo', 58, 58, '/img/pin-cosmo.png');
    pin.x = -450;
    pin.y = 990;
    Degri.PinsList[Degri.PinsList.length] = pin;
    
    pin = new Degri.Pin('gradient', 70, 71, '/img/pin-gradient.png');
    pin.x = -200;
    pin.y = 1043;
    Degri.PinsList[Degri.PinsList.length] = pin;
    
    pin = new Degri.Pin('strips2', 62, 62, '/img/pin-strips2.png');
    pin.x = 890;
    pin.y = 1200;
    Degri.PinsList[Degri.PinsList.length] = pin;
    
    pin = new Degri.Pin('face', 58, 59, '/img/pin-face.png');
    pin.x = -450;
    pin.y = 1440;
    Degri.PinsList[Degri.PinsList.length] = pin;
    
    pin = new Degri.Pin('dollar', 69, 69, '/img/pin-dollar.png');
    pin.x = -90;
    pin.y = 1395;
    Degri.PinsList[Degri.PinsList.length] = pin;
    
    Degri.Moto = new Degri.Motoman('motoman');
    
    Degri._pc = new Degri.ProjectControl('projectsShow');
}

Degri.DrawPins = function()
{
    for (i = 0; i < Degri.PinsList.length; i++)
    {
        Degri.PinsList[i].Draw();
    }
    
    setTimeout(Degri.PullPin,100);
}

Degri.PullPin = function()
{
    var pin = Degri.GetRandomPin();
    pin.Shake();
    
    setTimeout(Degri.PullPin,((Math.random() * 1) + 0.2) * 500);
}

Degri.GetRandomPin = function()
{
    return Degri.PinsList[Math.round(Math.random() * (Degri.PinsList.length-1))];
}

Degri.StartMotoman = function()
{
    Degri.Moto.Drive();
    
    setTimeout(Degri.StartMotoman,((Math.random() * 3) + 5) * 1000);
}

Degri.ShowModal = function(divID)
{
    //window.onscroll = function () { document.getElementById(divID).style.top = document.body.scrollTop; };
    document.getElementById(divID).style.display = "block";
    document.getElementById(divID).style.top = document.body.scrollTop;
}

Degri.HideModal = function(divID)
{
    document.getElementById(divID).style.display = "none";
}
