function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
groszy = num%100;
num = Math.floor(num/100).toString();
if(groszy<10)
groszy = "0" + groszy;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+' '+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + num + ',' + groszy+" zł");
}

function ostatniesekundy(czas){
if(czas.substring(0,5)=="00:00" && czas.substring(6)<=10)
	return 1;
else
	return 0;
}

function aktualizujCzas(span,id,czas){

	  if(czas=="END") {
	  if(id!=""){
	  document.getElementById(span+'time'+id).style.fontSize = 20;
	  }
	  document.getElementById(span+'time'+id).style.color=normal_color;
	  document.getElementById(span+'time'+id).innerHTML = "Zakończona";
	  //document.getElementById('prowadziwygral'+id).innerHTML = "Wygrał:";
	  //document.getElementById('dopnij'+id).style.display="none";
	  document.getElementById(span+'prowadzi_napis'+id).innerHTML="Wygrał(a)";
	  if(id=="") {
	  	document.getElementById('licytuj').style.display="none";
	  	document.getElementById('autodopinacz').style.display="none";
	  	document.getElementById('pozostaly_napis').style.display="none";
	  	clearInterval(timer);
	  }
	  //}

	  } else {

	  if(czas.substring(0,1)=='S') {

	  czas=czas.substring(1);
	  		if(document.getElementById(span+'time'+id).innerHTML == 'STOP')
	  		document.getElementById(span+'time'+id).innerHTML = czas;
	  		else
	  		document.getElementById(span+'time'+id).innerHTML = 'STOP';

	  } else {
	  var temp="";
	  temp=document.getElementById(span+'time'+id).innerHTML;
	  document.getElementById(span+'time'+id).innerHTML = czas;

	    if (czas > temp)
	    {
	    mrugnij('div#'+span+'kwota'+id);
	    }

	    if(ostatniesekundy(czas)==1){
	    	document.getElementById(span+'time'+id).style.color=last_color;
	    } else {
	    	document.getElementById(span+'time'+id).style.color=normal_color;
	    }


	  }
	  }
}


function mrugnij(id)
{
$(id).colorBlend([{param:"color", fromColor:"#D01D00", toColor:"black",cycles:1, duration: 1200}]);
}


function getXMLHttpRequest()
{
  var request = false;

  try {
    request = new XMLHttpRequest();
  } catch(err1) {
    try {
      request = new ActiveXObject('Msxml2.XMLHTTP');
    } catch(err2) {
      try {
        request = new ActiveXObject('Microsoft.XMLHTTP');
      } catch(err3) {
        request = false;
      }
    }
  }
  return request;
}

function token(){
teraz = new Date()
return teraz.getDate() +teraz.getMonth() +teraz.getFullYear() +teraz.getHours() +teraz.getSeconds()+Math.random();
}


