/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


function tickInvestmentTimer(timeleft)
{
    if (timeleft <= 0)
    {
        $('#timer-running').hide();
        $('#timer-end').show();
        return;
    }

    temp=timeleft;

    // please forgive me
    seconds=temp%60;
    temp=(temp-seconds)/60;
    minutes=temp%60;
    temp=(temp-minutes)/60;
    hours=temp % 24;
    temp=(temp-hours)/24;
    days = temp;

    if (seconds<10) seconds="0"+seconds;
    if (minutes<10) minutes="0"+minutes;
    if (hours<10) hours="0"+hours;

    $('#timer-seconds').html(seconds);
    $('#timer-minutes').html(minutes);
    $('#timer-hours').html(hours);
    $('#timer-days').html(days);

    timeleft-=1;
    setTimeout("tickInvestmentTimer("+ timeleft+ ")",1000);
}

function navigateFlats(url,targetId){
    $('#'+targetId).show();
    $('#'+targetId).html('<div style="text-align:center;"><img src="/images/loading.gif" alt="Ładowanie" /></div>');

    $.ajax({
        url: url,
        success: function(data) { jQuery('#'+targetId).html(data);}
    });

    return false;
}
