<!-- //

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 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;
   }
}

var mapa = '';

function loadMap()
{
	if(GBrowserIsCompatible())    
 	{  
     	mapa = new GMap2(document.getElementById('map'),{mapTypes: [G_NORMAL_MAP]});  
     	mapa.setCenter(new GLatLng(52.152477,21.187284),15);
		mapa.addControl(new GLargeMapControl()); 
		mapa.addControl(new GOverviewMapControl());      
       
     	function dodajMarker(lat,lon,txt)  
     	{   
         var marker = new GMarker(new GLatLng(lat,lon),{title: txt});  
         marker.txt=txt;  
         mapa.addOverlay(marker);  
         GEvent.addListener(marker,"click",function() {  
             marker.openInfoWindowHtml(marker.txt);  
         });  
           
         return marker;  
     }  
       
     var marker = dodajMarker(52.152477,21.187284,"<b>Autoland</b><br />ul. WaÅ‚ MiedzeszyÅ„ski 41b");  
 
     marker.openInfoWindowHtml(marker.txt);  
	}  
}

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(52.275852, 20.980153);
		map.setCenter(center, 11);
	}
}

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()
{
	jQuery("#send").val("56213");
	jQuery("#formular").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('#sposoby_dostawy').html(data);
  	});
}

function PokazFormyDostawyHurt(id,lang)
{
	jQuery.post("/"+lang+"/ajax/zamowienie-hurt-formy-dostawy", { id: id },	
  	 function(data){
			jQuery('#sposoby_dostawy').html(data);
  	});
}

function ZalogujSklep(lang)
{
	jQuery.post("/"+lang+"/ajax/sklep-logowanie", { user: jQuery('#user').val(), pass: jQuery('#pass').val() },	
  	 function(data){
		var tab = data.split("|");
		if(tab[0] != 'OK')
		{
			alert(tab[1]);
		}
		else
		{
			jQuery('#formLogin').submit();
		}
  	});
	return false;
}

function ZalogujHurt(lang)
{
	jQuery.post("/"+lang+"/ajax/hurtownia-logowanie", { user: jQuery('#user').val(), pass: jQuery('#pass').val() },	
  	 function(data){
		var tab = data.split("|");
		if(tab[0] != 'OK')
		{
			alert(tab[1]);
		}
		else
		{
			jQuery('#formLogin').submit();
		}
  	});
	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 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(); });
}

function OtworzEdytor(pole)
{
	var oknoEdytor = null;
	szerokosc = 800;
	wysokosc = 600;
	if(window.screen)
  	{
   	szerokosc = window.screen.width*0.8;
		wysokosc = window.screen.height*0.8;
  	}
  	oknoEdytor = window.open("edytor.php?pole="+pole, "edytor", "menubar=no,toolbar=no,location=no,directories=no,status=yes,scrollbars=no,resizable=no,copyhistory=no,width="+ szerokosc +",height="+ wysokosc +",left=0,top=0");
	oknoEdytor.focus();
}

function PowiekszZdjecie(url)
{
	var okno = null;
	if(okno) okno.close();
	var width = 800;
	var height = 600;
	if(window.screen)
  	{
   	ScrWidth = window.screen.width;
		ScrHeight = window.screen.height;
  	}
	var PosX = Math.round((ScrWidth - width) / 2);
  	var PosY = Math.round((ScrHeight - height) / 2);
	
	okno = window.open("", "", "menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,width=" + width + ",height=" + height + ",left=" + PosX + ",top=" + PosY);
  	okno.document.open();
  	okno.document.clear();
  	okno.document.write("<HTML><head><meta http-equiv=\"Content-type\" content=\"text/html; charset=iso-8859-2\"><title>CMS BullDesign - powiÄ™kszenie zdjÄ™cia</title></HEAD><body leftmargin=0 topmargin=0 rightmargin=0 bottommargin=0 marginwidth=0 marginheight=0><a href='javascript:window.close()'><img src="+url+" alt='Kliknij gdziekolwiek aby zamknÄ…Ä‡ to okno.' border='0'></a></BODY></HTML>");
  	okno.document.close();
  	okno.focus();
}

function keepMeAlive(imgName)
{
   myImg = document.getElementById(imgName);
   if (myImg) myImg.src = myImg.src.replace(/\?.*$/, '?' + Math.random());
}

function selectAll(box)
{
	for(var i=0; i<box.length; i++) {
		box.options[i].selected = true;
	}
}

function sprawdz(wiadomosc)
{
	var czy_potwierdzony = confirm(wiadomosc);
   if(czy_potwierdzony) { return true; }
	else { return false; }
}

function SetActive(obj)
{
	var data = obj.id.split("_");
	jQuery.post("ajax.php?m=ustaw-aktywnosc", { id: data[2], value: obj.checked, lang: data[1], module: data[3] },	
	  	function(data){
			if(data != "OK") alert("B³±d: " + data);
	});
}

function ZaznaczOdznaczWszystkie(f,pole,akcja)
{
	var checkboxy = document.getElementById(f).getElementsByTagName('input');
	for(i = 0; i < checkboxy.length; i++)
	if(checkboxy[i].type == 'checkbox' && checkboxy[i].name.substr(0,3) == pole)
	{
		checkboxy[i].checked = akcja;
	}
}

// -->