$(document).ready(function()
{
	$("#productPhoto a").colorbox({scalePhotos: true, maxWidth: '950px', maxHeight: '100%', close: 'Zamknij'});
$('a.lightbox,a[rel=lightbox]').colorbox({close:"zamknij"});

});


function cq (kod,zm) {

		var tmpIl = eval( "document.grupa[\"il["+kod+"]\"].value;");

		++tmpIl;

		--tmpIl;

		reszta = tmpIl%zm;

		if ((zm > 0) && (tmpIl < 999999) ) {

			eval( "document.grupa[\"il["+kod+"]\"].value = tmpIl + zm - reszta;");

		}

		else if ((zm < 0) && (tmpIl > 0)){

			if ( reszta > 0 ) { eval( "document.grupa[\"il["+kod+"]\"].value = tmpIl - reszta;"); }

			else {	eval( "document.grupa[\"il["+kod+"]\"].value = tmpIl + zm;"); }

		}

	if (document.getElementById('zzm')) {

			

			document.getElementById('zzm').className  = "bma";

		}

}

function number_format(a, b, c, d) {
 if (b == null) b = 2;
 if (c == null) c = ',';
 if (d == null) d = ' ';
 a = Math.round(a * Math.pow(10, b)) / Math.pow(10, b);
 e = a + '';
 f = e.split('.');
 if (!f[0]) {
  f[0] = '0';
 }
 if (!f[1]) {
  f[1] = '';
 }
 if (f[1].length < b) {
  g = f[1];
  for (i=f[1].length + 1; i <= b; i++) {
   g += '0';
  }
  f[1] = g;
 }
 if(d != '' && f[0].length > 3) {
  h = f[0];
  f[0] = '';
  for(j = 3; j < h.length; j+=3) {
   i = h.slice(h.length - j, h.length - j + 3);
   f[0] = d + i +  f[0] + '';
  }
  j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3));
  f[0] = j + f[0];
 }
 c = (b <= 0) ? '' : c;
 return f[0] + c + f[1];
}


$(document).ready( function(){


	$('.sp-kill').hide();
	$('.display-none').hide();
	$('.sp-kill input').val('nospam');



	$('a.login-required').click(function() {
		this.innerHTML = $(this).attr('nicetitle');
		return false;
	});
	
	$('a.add-cart').click(function(){
		var opts = '';
		var pid = $(this).attr('rel');
		$('select.product-option-select').each(function(){
			opts += (opts == '' ? '?':'&')+(pid ? this.name.replace(/\[\d+\]/,'['+pid+']') : this.name)+'='+this.value;
		});
		//alert (opts);
		document.location.href = this.href + opts;
		return false;
	});

});

