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

function delay(millis)
{
    var date = new Date();
    var curDate = null;

    do {
        curDate = new Date();
    }while(curDate-date < millis);
}

function timeLeft(since, to, elementId){
    var date1 = new Date(since);
    var date2 = new Date(to);
    var time = date2.getTime() - date1.getTime();

    setInterval(function(){
        if(time > 0){
            date3 = new Date();
            date3.setTime(time);
            document.getElementById(elementId).innerHTML = "Anuluj " + date3.getMinutes() + ":" + date3.getSeconds();
            time -= 1000;
        }else{
            document.getElementById(elementId).innerHTML = "";
        }
    }, 1000);
}

function showEditOffer(id, elementId) {
    
    xmlHttp.onreadystatechange=function() {
        if(xmlHttp.readyState==4) {
            a = xmlHttp.responseText;
            if (a != "false") {

                document.getElementById(elementId).innerHTML = a;
            }
        }
    }

    xmlHttp.open("GET","offer.php?id="+id+"");

    xmlHttp.send(null);
}
function changeOffer(id, elementId, params) {

    xmlHttp.onreadystatechange=function() {
        if(xmlHttp.readyState==4) {
            a = xmlHttp.responseText;
            if (a != "false") {

                document.getElementById(elementId).innerHTML = a;
            }
        }
    }
    if(params != '')
        params = "&"+params;
    xmlHttp.open("GET","offer.php?id="+id+""+params);

    xmlHttp.send(null);
}
