<!-- //

function BullStatistic()
{
	var colorDepth = window.screen.colorDepth;
	var res = window.screen.width + "," + window.screen.height;
	var referer = escape(document.referrer);
	document.write('<img src="/statystyka/zlicz.php?colors=' + colorDepth + '&resolution=' + res + '&referer=' + referer + '" style="width:0;height:0;" />');
}

function zaladujPolecamy(id,lang)
{
	jQuery.post("/"+lang+"/ajax/polecamy-strona-glowna", { id: id }, function(data){ jQuery('.mainProductBox').html(data); });
	jQuery("#pictureChange a").attr("class","link");
	jQuery("#polecamy_"+id).attr("class","link active");
}

function RepairFieldIntiger(obj)
{
	var pom = '';
	for(var i = 0; i < obj.value.length; i++)
	{
		if(isInteger(obj.value.charAt(i))) pom = pom+obj.value.charAt(i);
	}
	return pom;
}

function CheckValidEmail(adres)
{
   a = adres.search(/@/i);
   a1 = adres.substring(0,a);
   a2 = a1.length;
   a = a + 1;
   b = adres.indexOf(".");
   b1 = adres.substring(a,b);
   b2 = b1.length;
   b = b + 1;
   c = adres.length;
   c1 = adres.substring(b,c);
   c2 = c1.length;
   if(adres.indexOf("@") != "-1" && adres.indexOf(".") != "-1" && a2 >= 1 && b2 >= 1 && c2 >= 1)
   {
   	return true;
   }
   else
   {
   	return false;
   }
}

function AktualizujKoszyk(id,lang)
{
	jQuery.post("/"+lang+"/ajax/koszyk-hurtownia-aktualizuj", { id: id, ilosc: jQuery("#ilosc-"+id).val() }, function(data){ var dane = data.split("|"); jQuery('.loggingFormSum').html(dane[0]); jQuery('#ilosc_'+id).html(dane[1]); jQuery('#ilosc-'+id).val(""); });
}

function isInteger(s)
{
	return (s.toString().search(/^-?[0-9]+$/) == 0);
}


function noWhiteSpace(s){	if((s==null)||(typeof(s)!='string')||!s.length)return'';return s.replace(/\s+/g,'')}

function SendForm(form,send)
{
	jQuery("#send").val(jQuery("#"+send).val());
	jQuery("#"+form).submit();
}

function ShowSearch(lang,serwis)
{
	jQuery.get("/"+lang+"/ajax/wyszukiwarka-zaawansowana", {  }, function(data){ jQuery('#search_special').html(data); });
}

function PokazFormyDostawy(id,lang)
{
	jQuery.post("/"+lang+"/ajax/zamowienie-formy-dostawy", { id: id },	
  	 function(data){
			jQuery('#formSposobDostawy').html(data);
  	});
}

function Zaloguj(lang,user,pass,formularz)
{
	jQuery.post("/"+lang+"/ajax/logowanie", { user: jQuery("#"+user).val(), pass: jQuery("#"+pass).val() },	
  	 function(data){
		var tab = data.split("|");
		if(tab[0] != 'OK')
		{
			alert(tab[1]);
		}
		else
		{
			jQuery("#"+formularz).submit();
		}
  	});
	return false;
}

function RemindPassword(lang)
{
	jQuery.post("/"+lang+"/ajax/sklep-przypomnienie-hasla", { email: jQuery('#przypomnij_email').val(), postcode: jQuery('#przypomnij_kod').val() },	
  	 function(data){
		var tab = data.split("|");
		if(tab[0] != 'OK')
		{
			alert(tab[1]);
		}
		else
		{
			jQuery('#przypomnijHasloBox').html(tab[1]);
		}
  	});
	return false;
}

function CompareProducts()
{
	var objCheckBoxes = document.forms["products"].elements["zaz[]"];
   var countCheckBoxes = objCheckBoxes.length;
   for(var i = 0; i < countCheckBoxes; i++)
	{
		var id = objCheckBoxes[i].id.split("_");
		id = id[1];
		if(objCheckBoxes[i].checked)
		{
			AddToCompareList(id,lang);
		}
		else
		{
			RemoveFromCompareList(id,lang);
		}
	}
}

function ToCompareList(object,id,lang)
{
	if(object.checked)
	{
		AddToCompareList(id,lang);
	}
	else
	{
		RemoveFromCompareList(id,lang);
	}
}

function AddToCompareList(id,lang)
{
	jQuery.post("/"+lang+"/ajax/dodaj-do-porownania", { product_id: id }, function(data){ jQuery('#compareButton').html(data); });
}

function RemoveFromCompareList(id,lang)
{
	jQuery.post("/"+lang+"/ajax/usun-z-porowania", { product_id: id }, function(data){ jQuery('#compareButton').html(data); });
}

function RemoveAllProductsFromComparisonList(lang)
{
	jQuery.post("/"+lang+"/ajax/usun-wszystko-z-porowania", { }, function(data){ jQuery(".compare_remove").html(data) });
	var checkboxy = document.getElementsByTagName('input');
	for(i = 0; i < checkboxy.length; i++)
	if(checkboxy[i].type == 'checkbox' && checkboxy[i].name.substr(0,3) == 'zaz')
	{
		checkboxy[i].checked = false;
	}
}

function ShowPopUpWyslijZapytanieOProdukt(product_id,lang)
{
	jQuery.blockUI({ 
		message: '<div id="popup"></div>', 
		css: { 
			width: '450px',
			border: '1px solid #000000',
			padding: '15px', 
			background: '#FFFFFF', 
			color: '#000000', 
			height: '300px' 
		}
	});
	jQuery.post("/"+lang+"/ajax/wyslij-zapytanie-o-produkt-okno", { product_id: product_id }, function(data){ jQuery('#popup').html(data); });
}

function ShowPopUpPolecProdukt(product_id,lang)
{
	jQuery.blockUI({ 
		message: '<div id="popup"></div>', 
		css: { 
			width: '450px',
			border: '1px solid #000000',
			padding: '15px', 
			background: '#FFFFFF', 
			color: '#000000', 
			height: '300px' 
		}
	});
	jQuery.post("/"+lang+"/ajax/polec-produkt-okno", { product_id: product_id }, function(data){ jQuery('#popup').html(data); });
}

function ShowBookmark(obj,id)
{
	//jQuery("#bookmarks a").removeClass("bookmark_active");
	for(var i = 1; i < 4; i++)
	{
		if(i == parseInt(id))
		{
			jQuery("#bookmark"+i).css("display","block");
			jQuery("#bookmarks a:eq("+(i-1)+")").addClass("bookmark_active");
		}
		else
		{
			jQuery("#bookmark"+i).css("display","none");
			jQuery("#bookmarks a:eq("+(i-1)+")").removeClass("bookmark_active");
		}
	}
}

function PrintProduct(id,lang)
{
	var okno = '';
	width = 700;
	height = 480;
	ScrWidth = window.screen.width;
	ScrHeight = window.screen.height;
	PosX = Math.round((ScrWidth - width) / 2);
	PosY = Math.round((ScrHeight - height) / 2);
	okno = window.open("/"+lang+"/print/"+id, "print", "menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhistory=no,width=" + width + ",height=" + height + ",left=" + PosX + ",top=" + PosY);
}

function FormatWaluty(num)
{
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	{
		num = "0";
	}
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num % 100;
	num = Math.floor(num/100).toString();
	if(cents < 10)
	{
		cents = "0" + cents;
	}
	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 + ',' + cents);
}

function KontrolaIlosci(pole,msg)
{
	WzorN = /^[0-9]{1,4}$/;
  	if(!WzorN.test(pole.value))
  	{
		window.alert(msg);
		pole.focus();
		return false;
  	}
  	return true;
}

function WyslijFormularzZamowienia()
{
	jQuery("#formZamowienia").submit();
}

function UstawDaneFirmy(obj)
{
	if(obj.checked)
	{
		jQuery(".formFirma").css("display","block");
	}
	else
	{
		jQuery(".formFirma").css("display","none");
	}
}

function UstawMiejsceDostawy(obj)
{
	if(obj.checked)
	{
		if(jQuery("#faktura").attr("checked"))
		{
			jQuery("#d_nazwa").val(jQuery("#firma").val());
		}
		else
		{
			jQuery("#d_nazwa").val(jQuery("#imie").val()+" "+jQuery("#nazwisko").val());
		}
		jQuery("#d_ulica").val(jQuery("#ulica").val());
		jQuery("#d_ulica_n1").val(jQuery("#ulica_n1").val());
		jQuery("#d_ulica_n2").val(jQuery("#ulica_n2").val());
		jQuery("#d_miejscowosc").val(jQuery("#miejscowosc").val());
		jQuery("#d_kod_pocztowy").val(jQuery("#kod_pocztowy").val());
		jQuery("#d_kraj").val(jQuery("#kraj").val());
	}
	else
	{
		jQuery("#d_nazwa").val("");
		jQuery("#d_ulica").val("");
		jQuery("#d_ulica_n1").val("");
		jQuery("#d_ulica_n2").val("");
		jQuery("#d_miejscowosc").val("");
		jQuery("#d_kod_pocztowy").val("");
		jQuery("#d_kraj").val("");
	}
}

function Newsletter(lang,newsletter_action)
{
	jQuery.post("/"+lang+"/ajax/newsletter", { a: newsletter_action, e: jQuery('#newsletter_email').val() }, function(data){ jQuery('#newsletter_info').html(data); jQuery('#newsletter_email').focus(); });
}

var map='';

function loadMap()
{
	if (GBrowserIsCompatible())
	{
		map = new GMap2(document.getElementById("map"));
		map.setCenter(new GLatLng(51.774001, 19.481506), 13);
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
	}
}

function setMapPoint(address,zoom)
{
	if(zoom == '') zoom = 11;
	var geocoder = new GClientGeocoder();
	var marker;
			if(address)
			{
				  geocoder.getLatLng(
				    address,
				    function(point) {


				      if (!point) {
				        jQuery("#map").hide();
				      } else {
				      	map.addOverlay(new GMarker(point));
				      	map.setCenter(point, zoom);
				      }
				    }
				  );
			}
			else
			{
				var center = new GLatLng(51.774001, 19.481506);
				map.setCenter(center, 11);
			}
}

// -->
