<!-- //

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;
   }
}

function AktualizujKoszyk(id,lang)
{
	jQuery.post("/"+lang+"/ajax/koszyk-aktualizuj", { id: id, ilosc: jQuery("#ilosc-"+id).val() }, function(data){ var dane = data.split("|"); jQuery('#koszykIlosc').html(dane[0]); jQuery('#koszykSuma').html(dane[1]); jQuery('#ilosc_'+id).html(dane[2]); 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('#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').attr("onsubmit","");			
			jQuery('#formLogin').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 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(kwota, iloscMiejscPoPrzecinku)
{	
	kwota = kwota.toString().replace(/\s+/g,'');
  	if(kwota == '') return '';
	if(typeof(iloscMiejscPoPrzecinku) != 'undefined')
	{
   	kwota = Math.round((0.0 + eval(kwota))*Math.pow(10, iloscMiejscPoPrzecinku)).toString();
    	kwota = kwota.replace(/\..*/, '');
    	if(iloscMiejscPoPrzecinku != 0)
    	{
      	while(kwota.replace('-', '').length <= iloscMiejscPoPrzecinku)
      	{
        		kwota = kwota.replace(/(\d+)/,'0$1');
      	}
      	kwota = kwota.replace(new RegExp('(.{' + iloscMiejscPoPrzecinku + '})$'), '.$1');
    	}
  	}

  	if(kwota.indexOf('.') < 0)
  	{
   	//kwota = kwota.replace(/(\d)(?=(\d\d\d)+$)/g, '$1 ');
   }
  	else
   {
   	//kwota = kwota.replace(/(\d)(?=(\d\d\d)+\.)/g, '$1 ');
   }
	
	return kwota;  
}

function NaprawPoleFloat(wartosc)
{
	wartosc = wartosc.replace( /^\s+|\s+$/g,"");
	if(wartosc == '') wartosc = 0;
  	var polePoprawione = wartosc.replace(/,/g, '.');;
  	while(polePoprawione.indexOf('.') != polePoprawione.lastIndexOf('.'))
  	{
   	polePoprawione = polePoprawione.replace('.', '');
  	}
  	polePoprawione = polePoprawione.replace(/[^\.0-9\s]/g, '');
  	if(polePoprawione != wartosc)
  	{
  		wartosc = polePoprawione;
  	}
  	return parseFloat(wartosc.replace(/ /g, ''));
}

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("/ajax/newsletter.php", { jezyk: lang, a: newsletter_action, e: jQuery('#newsletter_email').val() }, function(data)
	{
		var tab = data.split("|");
		if(tab[0] == 'OK')
		{
			jQuery('#newsletter_info').html(tab[1]);
			jQuery('#newsletter_email').val("");
		}
		else
		{
			jQuery('#newsletter_info').html(tab[1]);
			jQuery('#newsletter_email').focus();
		}
	});
}

var mapa = '';

function loadMap()
{
	if(GBrowserIsCompatible())    
 	{  
     	mapa = new GMap2(document.getElementById('map'),{mapTypes: [G_NORMAL_MAP]});  
     	mapa.setCenter(new GLatLng(52.131802,21.196747),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.131802,21.196747,"<b>TOFIVET</b><br />ul. Nadwiślańska 123<br />05-410 Józefów<br /><b>tel. kom.: 0-723 630 853</b>");  
 
     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);
	}
}

// -->
