/* funkcje własne ! */

function number_format( number, decimals, dec_point, thousands_sep ){ 
var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
var d = dec_point == undefined ? "." : dec_point;
var t = thousands_sep == undefined ? "." : thousands_sep, s = n < 0 ? "-" : "";
var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
}

function cena_sms(cena) {
  var cena = cena;  
  if (cena == 0) return 0;  
  else if (cena < 0.50) return 1;
  else if (cena < 1) return 2;
  else if (cena < 1.50) return 3;
  else if (cena < 2) return 4;
  else if (cena < 2.50) return 5;
  else if (cena < 3) return 6;  
  else if (cena < 4.50) return 9;    
	else if (cena < 7) return 14;
  else if (cena < 9.50) return 19;                
  else if (cena < 18.00) return 25;  
  else return 'N/D';   
}

function in_array_match(array, value)
{
   for (var i=0; i<array.length; ++i) {
      if (value.match(/array[i]/))
         return true;
   }
   return false;
}

function adrefresh() {
	var views = parent.history.length-init;
	if (views != last) {
    document.getElementById('info').innerHTML='';
    counting++;
    var count = timer - counting;
    document.getElementById('count').innerHTML=count;
    if (counting >= timer) {
      counting = 0;
      last++;
      document.getElementById('info').innerHTML='Kliknij w kolejny odnośnik...';
    }
	}
	
	if(last >= minimum) { 
    document.getElementById('info').innerHTML='Za chwilkę otrzymasz premie...';
    sURL = sURL + '&sb=' + last;
    refresh();
  }
	else {
    setTimeout("adrefresh()",1000);
  }
  
  var left = minimum - last;
  document.getElementById('last').innerHTML=last;
  
}


