function loadScript(src) {
   var script = document.createElement("script");
   script.type = "text/java"+"script";
   document.getElementsByTagName("head")[0].appendChild(script);
   if(src=='jquery.rating.pack.js'){
	  script.src =  site_host_url+'star_rating/'+src; 
   }else{
      script.src = site_host_url+'js/'+src;
   }
}

/*loadScript('jquery-1.4.3.min.js');
jQuery.noConflict();
loadScript('jquery.rating.pack.js');
loadScript('jScrollPane.js');
loadScript('jquery.tooltip.js');
loadScript('AC_RunActiveContent.js');
loadScript('AC_Flash.js');
loadScript('prototype.lite.js');
loadScript('prototype.js');
loadScript('moo.fx.js');
loadScript('moo.fx.pack.js');
loadScript('moo.ajax.js');
loadScript('sleight.js');
loadScript('sleightbg.js');
loadScript('effects.js');
loadScript('controls.js');
loadScript('builder.js');
loadScript('controls.js');
loadScript('dragdrop.js');
loadScript('slider.js');
loadScript('scriptaculous.js');
loadScript('lightbox.js');
loadScript('carousel.js');
loadScript('flexcroll.js');*/

function baner_gora(id){
				if(tab_baner_blokuj=='false' && id!=tab_baner_aktualny_id){
					tab_baner_blokuj='true';
					//obrazki
					document.getElementById('baner_gora_menu_'+id).src=site_host_url+'img/baner_gora_menu_hover.gif';
					document.getElementById('baner_gora_menu_'+tab_baner_aktualny_id).src=site_host_url+'img/baner_gora_menu.gif';
					
					tab_baner_gora[tab_baner_aktualny_id].toggle('width');
					setTimeout("tab_baner_gora["+id+"].toggle('width');", 50);
					tab_baner_aktualny_id=id;
					//odblokowanie
					setTimeout("tab_baner_blokuj='false';", tab_baner_gora_duration+11);
				}
}

function header_combo(action){
						if(action=='log_in'){
							if(document.getElementById('header_basket_left_combo_2').style.visibility=='hidden'){
								if(document.getElementById('header_basket_left_combo_3').style.visibility=='hidden'){
									header_combo_1.toggle('width');
								}else{
									header_combo_3.toggle('width');
								}
								setTimeout("header_combo_2.toggle('width');", 300);
							}else{
								if(koszyk_kwota=='0.00'){
									setTimeout("header_combo_1.toggle('width');", 300);
								}else{
									setTimeout("header_combo_3.toggle('width');", 300);
								}
								header_combo_2.toggle('width');
							}
						}
					}
function zaloguj(){
							ajaxLogin($('log_login').value,$('log_pass').value,'false');
}
function zmien_kategorie(){
						document.location.href=document.getElementById('select_kategorie').value;
					}
function baner_gora_prev(){
				var prev_id=0;
				prev_id=tab_baner_pom[tab_baner_pom.length-1];
				for(i=0; i<tab_baner_pom.length; i++){
					if(tab_baner_pom[i]==tab_baner_aktualny_id){
						i=tab_baner_pom.length;
					}else{
						prev_id=tab_baner_pom[i];
					}
				}
				
				if(prev_id!=0){
					baner_gora(prev_id);
				}
}
			
function baner_gora_next(){
				    
					if(timeout!=null){
					   clearTimeout(timeout);
				    }
					var next_id=0;
					next_id=tab_baner_pom[0];
					for(i=tab_baner_pom.length-1; i>=0; i--){
						if(tab_baner_pom[i]==tab_baner_aktualny_id){
							i=-1;
						}else{
							next_id=tab_baner_pom[i];
						}
					}
					
					if(next_id!=0){
						baner_gora(next_id);
					}
					timeout = setTimeout('baner_gora_next()',10000);
}

function auto_baner_index(){
				if(mouse_over_baner==false){
					baner_gora_next();
				}
				setTimeout("auto_baner_index();", 5000);
}

function dodajMape(idElementu){
	obj = jQuery('#'+idElementu+'');
	jQuery('#'+idElementu+'').remove();
	jQuery('#imageContainer').append(obj);
}

function czysc_pole(id,name,type){
	if(document.getElementById(id).value==name){document.getElementById(id).value='';}
	if(type=='password'){document.getElementById(id).setAttribute("type","password");}
}
function uzupelnij_pole(id,name,type){
	if(document.getElementById(id).value==''){
		document.getElementById(id).value=name;
		if(type=='password'){document.getElementById(id).setAttribute("type","text");}
	}
}

function kopiujWartosc(objIdBaza, objIdCel){
	$(objIdCel).value = $(objIdBaza).value;
	return true;
}

function blokujPlatnosc(){
	if(jQuery('#id_typu_dostawy_7').attr('checked') && jQuery('#id_typu_platnosci_2').attr('checked')){
		jQuery('#id_typu_platnosci_3').attr('checked','checked');
		jQuery('#id_typu_platnosci_2').attr('disabled','disabled');
	}else{
		jQuery('#id_typu_platnosci_2').removeAttr('disabled');
	}
}

function pokazUkryjFVat2(id, pole_id){
	  
	  pole = document.getElementById(id);
	  pole1 = document.getElementById(pole_id);
	  if(pole){
		  wlasciwosc = pole.style.display;
		  if(wlasciwosc=='none'){
			  //pole.style.display = 'block';
			  jQuery('#'+id+'').slideDown(500);
			  if(pole1){
				  pole1.value = 1;
			  }
		  }else{
			  //pole.style.display = 'none';
			  jQuery('#'+id+'').slideUp(500);
			  if(pole1){
				  pole1.value = 0;
			  }
		  }
	  }
  }


function kopiujAdres(){
	kopiujWartosc('firma', 'firma_koresp');
	kopiujWartosc('telefon', 'telefon_koresp');
	kopiujWartosc('imie', 'imie_koresp');
	kopiujWartosc('nazwisko', 'nazwisko_koresp');
	kopiujWartosc('ulica_glowny', 'ulica_koresp');
	kopiujWartosc('nr_domu_glowny', 'nr_domu_koresp');
	kopiujWartosc('nr_mieszkania_glowny', 'nr_mieszkania_koresp');
	kopiujWartosc('kod_pocztowy_glowny', 'kod_pocztowy_koresp');
	kopiujWartosc('miejscowosc_glowny', 'miejscowosc_koresp');
	return true;
}

function kopiujAdres2(){
	kopiujWartosc('firma', 'firma_faktura');
	//kopiujWartosc('telefon', 'telefon_faktura');
	kopiujWartosc('imie', 'imie_faktura');
	kopiujWartosc('nazwisko', 'nazwisko_faktura');
	kopiujWartosc('ulica_glowny', 'ulica_faktura');
	kopiujWartosc('nr_domu_glowny', 'nr_domu_faktura');
	kopiujWartosc('nr_mieszkania_glowny', 'nr_mieszkania_faktura');
	kopiujWartosc('kod_pocztowy_glowny', 'kod_pocztowy_faktura');
	kopiujWartosc('miejscowosc_glowny', 'miejscowosc_faktura');
	return true;
}

var IE = (document.all && document.getElementById && !window.opera );
var FF = (!document.all && document.getElementById && !window.opera);
var OP = (document.all && document.getElementById && window.opera);

function mMoveXY(event){
	if(mBoxBgImageIsLoaded){
		mouseX = 0;
		mouseY = 0;
		if(!event){
			var event = window.event;
		}
		if(IE){
			mouseX = event.clientX + document.documentElement.scrollLeft;
			mouseY = event.clientY + document.documentElement.scrollTop;
		}else{ 
			mouseX = event.pageX;
			mouseY = event.pageY;
		}
		mouseX -= $(mContainerId).offsetLeft;
		mouseY -= $(mContainerId).offsetTop;
	
		mFrameOffsetX = parseFloat(mFrameWidth / 2);
		mFrameOffsetY = parseFloat(mFrameHeight / 2);
	
		mBoxBgX = parseInt((-imagesWidthRatio * mouseX) + parseFloat(mBoxWidth / 2));
		mBoxBgY = parseInt((-imagesHeightRatio * mouseY) + parseFloat(mBoxHeight / 2));
	
		if(mBoxBgX > 0){
			mBoxBgX = 0;
		}else if(mBoxBgX < -(mBoxBgImageWidth - mBoxWidth)){
			mBoxBgX = -(mBoxBgImageWidth - mBoxWidth); 
		}
		if(mBoxBgY > 0){
			mBoxBgY = 0;
		}else if(mBoxBgY < -(mBoxBgImageHeight - mBoxHeight)){
			mBoxBgY = -(mBoxBgImageHeight - mBoxHeight); 
		}
		
		setCssBackgroundPosition(mBoxId, mBoxBgX, mBoxBgY);
		
		mFrameY = mouseY - mFrameOffsetY;
		mFrameX = mouseX - mFrameOffsetX;
	
		if(mouseX + mFrameOffsetX > mBaseWidth){
			mFrameX = mBaseWidth - (2 * mFrameOffsetX);
		}else if(mFrameX < 0){
			mFrameX = 0;
		}
			
		if(mouseY + mFrameOffsetY > mBaseHeight){
			mFrameY = mBaseHeight - (2 * mFrameOffsetY);
		}else if(mFrameY < 0){
			mFrameY = 0;
		}
	
		setCssPosition(mFrameId, mFrameY, mFrameX);
		//setCssBackgroundImage(mFrameId, mBoxBgImage, mFrameY, mFrameX);
		//setCssBackgroundImage(mFrameId, '/eokulary/img/loading.gif', '50%', '50%');
	}
	return true;
}

function calculatemFrameSize(objId, width1, height1, width2, height2){
	width = Math.floor(parseInt(width2) / parseInt(width1));
	height = Math.floor(parseInt(height2) / parseInt(height1));
	setCssSize(objId, height * mFrameRatio, width * mFrameRatio);
	return true;
}

function setCssBackgroundPosition(objId, x, y){
	$(objId).style.backgroundPosition = ''+x+'px '+y+'px';
}

function setCssPosition(objId, top, left){
	$(objId).style.top = parseInt(top)+'px';
	$(objId).style.left = parseInt(left)+'px';
}

function setCssSize(objId, width, height){
	$(objId).style.width = parseInt(width)+'px';
	$(objId).style.height = parseInt(height)+'px';
}

function setCssBackgroundImage(objId, img, left, top){
	$(objId).style.backgroundImage = 'url('+img+')';
	$(objId).style.backgroundPosition = left+' '+top;
}

function mBoxHide(){
	$(mBaseId).className ='';
	$(mFrameId).style.display = 'none';
	$(mBoxId).style.display = 'none';
	return true;
}
function mBoxShow(){
	$(mFrameId).style.display = 'block';
	//calculatemFrameSize(mFrameId, mBaseWidth, mBaseHeight, mBoxBgImageWidth, mBoxBgImageHeight);
	mFrameWidth = parseInt(getCssStyleProperties($(mFrameId), 'width'));
	mFrameHeight = parseInt(getCssStyleProperties($(mFrameId), 'height'));
	$(mBaseId).className = 'trans';	
	$(mBoxId).style.display = 'block';
	setCssBackgroundImage(mBoxId, '/eokulary/img/loading.gif', '50%', '50%');
	if(mBoxBgImageIsLoaded){
		setCssBackgroundImage(mBoxId, mBoxBgImage, '0', '0');
	}else{
		var pomImg = new Image();
		pomImg.src = mBoxBgImage;
		pomImg.onload = function(){
			mBoxBgImageIsLoaded = true;
			setCssBackgroundImage(mBoxId, mBoxBgImage, '0', '0');
		}
	}
	return true;
}

function getCssStyleProperties(objId,styleProperties){
	if ($(objId).currentStyle){
		return $(objId).currentStyle[styleProperties];
	}else if (window.getComputedStyle){
		return document.defaultView.getComputedStyle($(objId),null).getPropertyValue(styleProperties);
	}
}

function przeladuj(loc){
	document.location.href = loc;
}


function loadKoszty(request){
	var xmlResponse = request.responseXML.documentElement;
	//if(xmlResponse.childNodes.length > 0){
		$('koszty-info').innerHTML = xmlResponse.childNodes.length ? xmlResponse.childNodes.item(0).firstChild.data : 'error: 036';
	//}
	return true;
}

function ajaxKoszty(form, poleDostawa, polePlatnosci){
	idDostawy = 0;
	idPlatnosci = 0;
	for(i=0; i < $(form).elements.length; i++){
		if($(form).elements[i].type == 'radio'){
			if($(form).elements[i].name == poleDostawa && $(form).elements[i].checked){
				idDostawy = $(form).elements[i].value;
			}else if($(form).elements[i].name == polePlatnosci && $(form).elements[i].checked){
				idPlatnosci = $(form).elements[i].value;
			}
		}
	}
	
	
	var parametry = "id_dostawy="+escape(idDostawy)+"&id_platnosci="+escape(idPlatnosci);
	var url = site_host_url+site_lang+'/ajax_koszty.php';
	//new ajax(''+url+'', {postBody: ''+parametry+'', onComplete: loadKoszty});
		jQuery.ajax({url: url, 
				 type: 'POST', 
				 data: parametry, 
				 dataType: 'xml', 
				 complete: function(request){
					 loadKoszty(request);
				 }
		});
	return true;
}


function loadZone1(request){
	var xmlResponse = request.responseXML.documentElement;
	//if(xmlResponse.childNodes.length > 0){
		$('client-zone1').innerHTML = xmlResponse.childNodes.length ? xmlResponse.childNodes.item(0).firstChild.data : 'error: 034';
		if(xmlResponse.childNodes.item(1).firstChild.data!=''){
			document.location=xmlResponse.childNodes.item(1).firstChild.data;
		}
	//}
	return true;
}

function loadZone3(request){
	var xmlResponse = request.responseXML.documentElement;
	//if(xmlResponse.childNodes.length > 0){
		$('header_basket_info').innerHTML = xmlResponse.childNodes.length ? xmlResponse.childNodes.item(0).firstChild.data : 'error: 034';
		if(xmlResponse.childNodes.item(1).firstChild.data!='null'){
			document.location=xmlResponse.childNodes.item(1).firstChild.data;
			
			var IE = (document.all && document.getElementById && !window.opera );
			if(IE){
				document.location=site_host_url;
			}
		}
	//}
	return true;
}

function loadZone2(request){
	var xmlResponse = request.responseXML.documentElement;
	//if(xmlResponse.childNodes.length > 0){
		$('cart_logowanie_info').innerHTML = xmlResponse.childNodes.length ? xmlResponse.childNodes.item(0).firstChild.data : 'error: 034';
		if(xmlResponse.childNodes.item(1).firstChild.data!=''){
			document.location=xmlResponse.childNodes.item(1).firstChild.data;
		}
	//}
	return true;
}

function ajaxLogin(login, pass, log_pl){
	var parametry = "login="+login+"&pass="+pass+"&log_pl="+log_pl;
	var url = site_host_url+site_lang+'/login.html';
	//new ajax(''+url+'', {postBody: ''+parametry+'', onComplete: loadZone3});
	jQuery.ajax({url: url, 
				 type: 'POST', 
				 data: parametry, 
				 dataType: 'xml', 
				 complete: function(request){
					 loadZone3(request);
				 }
		});
	return true;
}

function ajaxLogin2(login, pass, log_pl){
	var parametry = "login="+login+"&pass="+pass+"&log_pl="+log_pl+"&cart_info=t";
	var url = site_host_url+'login.php';
	//new ajax(''+url+'', {postBody: ''+parametry+'', onComplete: loadZone2});
	jQuery.ajax({url: url, 
				 type: 'POST', 
				 data: parametry, 
				 dataType: 'xml', 
				 complete: function(request){
					 loadZone2(request);
				 }
		});
	return true;
}

function zaloguj(){
	ajaxLogin($('log_login').value,$('log_pass').value,'false');
}


function loadLoginInfo(objId, site_host){
	document.getElementById('zone').style.backgroundPosition="50% 0px";
	$(objId).innerHTML = '<div id="client-zone1-1"><a class="clent-zone-button" href="javascript:void(0);" onclick="loadLoginForm(\'client-zone1\', \''+site_host+'\');"><img src="'+site_host+'img/zaloguj_sie.jpg" width="79" height="24" alt="zaloguj się" title="zaloguj się" style="margin-top:7px;" /></a></div><div id="client-zone1-2"><a class="clent-zone-button" style="margin-right:20px;" href="'+site_host+'new_account.php"><img src="'+site_host+'img/zaloz_konto.jpg" width="81" height="24" alt="załóż konto" title="załóż konto" style="margin-top:7px;" /></a><div class="clear_both"></div></div><div id="client-zone1-3"><a href="'+site_host+'site/34/regulamin-sklepu.html" style="display:block; width:130px; height:33px;">&nbsp;</a></div><div id="client-zone1-4"><a href="'+site_host+'site/33/dostawa-i-koszty-przesylki.html" style="display:block; width:180px; height:33px;">&nbsp;</a></div><div class="clear_both"></div>';	
	return true;
}

function loadLoginForm(objId, site_host){
	document.getElementById('zone').style.backgroundPosition="0px -50px";
	$(objId).innerHTML = '<form name="logform" method="post" action="'+site_host+'login.php" onsubmit="return false;" style="padding-top:0px;">'
+ '<div id="form_login">login: <input type="text" name="log_login" id="log_login" class="inp" size="17" maxlength="32" /> &nbsp; '
+ 'hasło: <input type="password" name="log_pass" id="log_pass" class="inp" size="17" maxlength="32" /><br />'
+ '<input type="checkbox" name="log_pl" id="log_pl" value="t" /> <label for="log_pl">pamiętaj moje logowanie</label></div> '
+ '<div id="form_login2"><input name="submit_log" type="image" src="'+site_host+'img/bt_zaloguj.jpg" onclick="ajaxLogin($(log_login).value,$(log_pass).value,$(log_pl).checked)" style="margin-right:20px;" /> '	
+ '<input name="submit_log2" type="image" src="'+site_host+'img/bt_przypomnij_haslo.jpg" onclick="document.location=\''+site_host+'password.php\'" style="margin-right:20px;" /> '
+ '<input name="submit_log3" type="image" src="'+site_host+'img/bt_back.jpg" onclick="loadLoginInfo(\'client-zone1\', \''+site_host+'\');" /> '
+ '</div></form>';	
	return true;
}

function checkClientZone(){
	bazTop = 94;
	bazLeft = 0;
	pozTop = 0;
	pozLeft = 0;
	obj = document.getElementById('client-zone');

	if(navigator.appName == "Microsoft Internet Explorer"){
		pozTop = document.documentElement.scrollTop;
		pozLeft = document.documentElement.scrollLeft;
	}else{
		pozTop = window.pageYOffset;
		pozLeft = window.pageXOffset;
	}

	if(pozTop < bazTop){
		pozTop = bazTop;
	}
	
	if(pozLeft < bazLeft){
		pozLeft = bazLeft;
	}
	
	obj.style.top = pozTop+'px';
	//obj.style.left = pozLeft+'px';
	
	bazTop = null;
	bazLeft = null;
	pozTop = null;
	pozLeft = null;
	obj	= null;
	return true;
}

function zliczPlik(id){
	var parametry = "id="+id;
	var url = site_host_url+'ajax_plik.php';
	//new ajax(''+url+'', {postBody: ''+parametry+'', onComplete: function(){ return true; }});
	jQuery.ajax({url: url, 
				 type: 'POST', 
				 data: parametry, 
				 dataType: 'xml', 
				 complete: function(request){
					 return true;
				 }
		});
	return true;
}

function ustawWartosc(nazwaPola, wartosc){
	document.getElementById(nazwaPola).value = wartosc;
}

function ustaw_checkboxy(formularz, opcja){
	d = eval("document." + formularz + "");
	if(opcja == "select"){
		for (i = 0; i<d.elements.length; i++){
			if(d.elements[i].type == "checkbox"){
				d.elements[i].checked = true;
			}
		}
	}else if(opcja == "deselect"){
		for (i = 0; i<d.elements.length; i++){
			if(d.elements[i].type == "checkbox"){
				d.elements[i].checked = false;
			}
		}
	}else if(opcja == "invert"){
		for (i = 0; i<d.elements.length; i++){
			if(d.elements[i].type == "checkbox"){
				if(d.elements[i].checked == true){
					d.elements[i].checked = false;
				}else{
					d.elements[i].checked = true;
				}
			}
		}
	}
}

function formatuj_liczbe(n, dokladnosc){
	/*
	n = Math.round(n * 100) / 100;
	//n = (n + 0.001) + '';
	n = (n + 0.001) + '';
	n = (n - 0.001) + '';
	//alert("n: " + n);
	return n.substring(0, n.indexOf('.') + 3);
	*/
	//num = 930.9805;
	//result = n.toFixed(2);
	return n.toFixed(dokladnosc);
}

function limit_dla_pola(limit, pole, span_pole){
	if (document.getElementById(pole).value.length > limit){
		document.getElementById(pole).value = document.getElementById(pole).value.substring(0, limit);
	}
	if(span_pole.length > 0){
		txt = "";
		ile_pozostalo = limit - document.getElementById(pole).value.length;
		txt = "Pozostało " + ile_pozostalo + " z " + limit + " znaków.";
		document.getElementById(span_pole).innerHTML = txt;
	}
}

function migajacy_text(id, k1, t1, k2, t2){
  if (document.getElementById){
    document.getElementById(id).style.color = k1;
	setTimeout('migajacy_text("' +  id + '","' + k2 + '",' + t2 + ',"' + k1 + '",' + t1 + ')', t1);
  }else if (document.all){
    document.all[id].style.color = k1;
	setTimeout('migajacy_text("' +  id + '","' + k2 + '",' + t2 + ',"' + k1 + '",' + t1 + ')', t1);
  }
}

function popraw_telefon(nazwa_pola, max_znakow) {
    document.getElementById(nazwa_pola).value = document.getElementById(nazwa_pola).value.replace(/[^0-9\(\)\ ]/g,"");
	if(max_znakow.length > 0){
		document.getElementById(nazwa_pola).value = przytnij_text(document.getElementById(nazwa_pola).value, max_znakow);
	}
}

function sprawdz_mail(email_pole) {
	if (document.getElementById(email_pole).value.length>0){
		Wzor = /^[0-9a-zA-Z.-_\-]+\@[0-9a-zA-Z.-_\-]+\.[0-9a-zA-Z.]{2,4}$/;
	   	if (Wzor.test(document.getElementById(email_pole).value) == false){
    		alert("Niewłasciwy format adresu e-mail!");
	    	return false;
	    }  
   		return true; 
    }
  	return true;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_swapImgRestore(){ //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages(){ //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d){ //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage(){ //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function pop_new_window(nazwa_pliku, zmienna, id, qs){
	var plik = nazwa_pliku + "?" + zmienna + "=" + id + qs;
	var Win = window.open(plik, "okno","menubar=0,location=0,status=0,toolbar=0,directories=0,alwaysRaised=1,scrollbars=1,titlebar=1,resizable=1");
}

function pop_zdjecie(nazwa_zdjecia_big, nazwa_podkatalogu){
	var plik = site_host_url+"pop_zdjecie.php?foto=" + nazwa_zdjecia_big + "&podkatalog=" + nazwa_podkatalogu;
	var Win = window.open(plik, "big_foto","menubar=0,location=0,status=0,toolbar=0,directories=0,alwaysRaised=1,scrollbars=1,titlebar=1,resizable=1");
}

function przytnij_text(text, max_znakow){
	if (text.length > max_znakow){
		text = text.substring(0, max_znakow);
	}
	return text;
}

function tylko_cyfry(nazwa_pola, max_znakow) {
    document.getElementById(nazwa_pola).value = document.getElementById(nazwa_pola).value.replace(/[^0-9]/g,"");
	if(max_znakow.length > 0){
		document.getElementById(nazwa_pola).value = przytnij_text(document.getElementById(nazwa_pola).value, max_znakow);
	}
}

function tylko_litery(nazwa_pola, max_znakow) {
    document.getElementById(nazwa_pola).value = document.getElementById(nazwa_pola).value.replace(/[^a-z]/g,"");
	if(max_znakow.length > 0){
		document.getElementById(nazwa_pola).value = przytnij_text(document.getElementById(nazwa_pola).value, max_znakow);
	}
}

function usun_biale_znaki(ciag){
	ciag = ciag.replace(/\r/g, " ");
  	ciag = ciag.replace(/[^ A-Za-z0-9`~!@#\$%\^&\*\(\)-_=\+\\\|\]\[\}\{'";:\?\/\.>,<]/g, "");
	ciag = ciag.replace(/'/g, "");
	ciag = ciag.replace(/ +/g, " ");  
	ciag = ciag.replace(/^\s/g, "");
	ciag = ciag.replace(/\s$/g, "");	
	return ciag;
}

function uwzglednij_rabat(pole_brutto, pole_oryg_netto,  pole_netto, pole_rabat, pole_vat){
		document.getElementById(pole_netto).value = formatuj_liczbe((document.getElementById(pole_oryg_netto).value * (1 - usun_biale_znaki(document.getElementById(pole_rabat).value) / 100)), 3);		
		wylicz_wartosc(pole_netto, pole_brutto, '0', pole_vat, 'brutto');
}

function wylicz_wartosc(pole_baza, pole_zmiana, rabat, pole_vat, opcja){
	if(opcja == 'brutto'){
		document.getElementById(pole_zmiana).value = formatuj_liczbe(document.getElementById(pole_baza).value * (1 + usun_biale_znaki(document.getElementById(pole_vat).value) / 100), 3);
	}else if(opcja == 'netto'){
		document.getElementById(pole_zmiana).value = formatuj_liczbe(document.getElementById(pole_baza).value / (1 + usun_biale_znaki(document.getElementById(pole_vat).value) / 100), 3);
	}
}

function add_listener(element, action, action_ie, funct){
	if(element.addEventListener){
		element.addEventListener(action, funct, false);
	}else if(element.attachEvent){
		element.attachEvent(action_ie, funct);
	}
}

function sprawdz_wymagane_pola(tekst){
				if (document.myfrm.pass_email.value.length<1){ 
					alert(tekst);
					return false;
				}
				if(!sprawdz_mail('pass_email')){
					return false;
				}
				return true;
			}
			
function posAbs(obj, typ){
						var nleft = 0;
						var ntop = 0;
						if(obj.offsetParent){
							nleft = obj.offsetLeft;
							ntop = obj.offsetTop;
							while(obj = obj.offsetParent){
								nleft += obj.offsetLeft;
								ntop += obj.offsetTop;
							}
						}
						
						if(typ=='left'){
							return nleft;
						}else{
							return ntop;
						}
					}
					
					function setOpacity(obj, value){
						obj.style.opacity = value/10;
						obj.style.filter = 'alpha(opacity='+value*10+')';
					}

function lupka_mousemove(e){
						document.getElementById(lupka_powiekszenie).style.display='block';
						document.getElementById(lupka).style.display='block';
						document.getElementById(lupka_zdjecie_opacity).style.display='block';
						
						if(IE){ // grab the x-y pos.s if browser is IE
							tempX=event.clientX+document.documentElement.scrollLeft;
							tempY=event.clientY+document.documentElement.scrollTop;
						}else{ // grab the x-y pos.s if browser is NS
							tempX=e.pageX;
							tempY=e.pageY;
						}
						
						lupkaX=(tempX-posAbs(document.getElementById(lupka_zdjecie), 'left')-parseInt(document.getElementById(lupka).offsetWidth/2));
						lupkaY=(tempY-posAbs(document.getElementById(lupka_zdjecie), 'top')-parseInt(document.getElementById(lupka).offsetHeight/2));
						
						if(lupkaX<0){
							lupkaX=0;
						}else if(lupkaX>(document.getElementById(lupka_zdjecie).offsetWidth-document.getElementById(lupka).offsetWidth)){
							lupkaX=document.getElementById(lupka_zdjecie).offsetWidth-document.getElementById(lupka).offsetWidth;
						}
						
						if(lupkaY<0){
							lupkaY=0;
						}else if(lupkaY>(document.getElementById(lupka_zdjecie).offsetHeight-document.getElementById(lupka).offsetHeight)){
							lupkaY=document.getElementById(lupka_zdjecie).offsetHeight-document.getElementById(lupka).offsetHeight;
						}
						
						document.getElementById(lupka).style.left=lupkaX+'px';
						document.getElementById(lupka).style.top=lupkaY+'px';
						
						//tlo
						document.getElementById(lupka).style.backgroundPosition='-'+lupkaX+'px -'+lupkaY+'px';
						document.getElementById(lupka_powiekszenie).style.backgroundPosition='-'+parseInt(lupkaX*2.6)+'px -'+parseInt(lupkaY*2.6)+'px';
						//tlo//
					}
					
					function lupka_mouseout(e){
						document.getElementById(lupka_powiekszenie).style.display='none';
						document.getElementById(lupka).style.display='none';
						document.getElementById(lupka_zdjecie_opacity).style.display='none';
					}
					
					function lupka_mouseover(e){
						document.getElementById(lupka_powiekszenie).style.display='block';
						document.getElementById(lupka).style.display='block';
						document.getElementById(lupka_zdjecie_opacity).style.display='block';
					}
					
				function wybor_kolory_zdjecia(action,id){
								if(action=='over'){
									document.getElementById('kolory_zdjecia_id_'+id).style.background='#7EBAD0';
								}
								if(action=='out'){
									document.getElementById('kolory_zdjecia_id_'+id).style.background='#6699CC';
								}
								if(action=='click'){
									//zdjecia
									wybor_zdjecie(''+id+'', ''+tab_rk[id][6]+'', ''+tab_rk[id][7]+'', ''+tab_rk[id][8]+'');
								}
							}
			function wybor_kolor(action,id,wal){
						if(action=='over'){
							document.getElementById('box_kolor_id_'+id).style.background='#EF9A27';
						}
						if(action=='out'){
							if(wybrany_kolor!=id){
								document.getElementById('box_kolor_id_'+id).style.background='#6699CC';
							}
						}
						if(action=='click'){
							document.getElementById('box_kolor_id_'+wybrany_kolor).style.background='#6699CC';
							document.getElementById('box_kolor_id_'+id).style.background='#EF9A27';
							document.getElementById('box_kolor_nazwa').innerHTML=tab_rk[id][1];
							//document.getElementById('colorid').value=id_kolor;
							
							//rozmiary
							document.getElementById('box_kolor_idkoloru_'+tab_rk[wybrany_kolor][3]).style.display='none';
							document.getElementById('box_kolor_idkoloru_'+tab_rk[id][3]).style.display='block';
							wybor_rozmiar('click', ''+id+'',wal);
							
							wybrany_kolor=id;
						}
					}
					
					function wybor_rozmiar(action,id, wal){
						if(action=='over'){
							document.getElementById('box_rozmiar_id_'+id).style.background='#EF9A27';
						}
						if(action=='out'){
							if(wybrany_rozmiar!=id){
								document.getElementById('box_rozmiar_id_'+id).style.background='#6699CC';
							}
						}
						if(action=='click'){
							document.getElementById('box_rozmiar_id_'+wybrany_rozmiar).style.background='#6699CC';
							document.getElementById('box_rozmiar_id_'+id).style.background='#EF9A27';
							document.getElementById('box_cena').innerHTML=tab_rk[id][5]+wal+'';
							document.getElementById('box_rozmiar_akt').innerHTML=tab_rk[id][2];
							document.getElementById('termin_dostawy_span').innerHTML=tab_rk[id][9];
							document.getElementById('add_id').value=id;
							wybrany_rozmiar=id;
							
							//zdjecia
							wybor_zdjecie(''+id+'', ''+tab_rk[id][6]+'', ''+tab_rk[id][7]+'', ''+tab_rk[id][8]+'');
						}
					}
					
					function wybor_zdjecie(id, foto1, foto2, foto3){
						document.getElementById(lupka_zdjecie).style.backgroundImage='url('+site_host_url+'foto/'+foto2+')';
						document.getElementById(lupka).style.backgroundImage='url('+site_host_url+'foto/'+foto2+')';
						document.getElementById(lupka_powiekszenie).style.backgroundImage='url('+site_host_url+'foto/'+foto3+')';
					}
					
					function f_needHelpPos(id){
						siteWidth=$('header').offsetWidth;
						jQuery('#'+id+'').css('left', ((document.body.clientWidth-siteWidth)/2)+siteWidth+'px');
						jQuery('#needHelpBox').css('right', ((document.body.clientWidth-siteWidth)/2)+'px');
					}
					
					function header_combo(action){
						if(action=='log_in'){
							if(document.getElementById('header_basket_left_combo_2').style.visibility=='hidden'){
								if(document.getElementById('header_basket_left_combo_3').style.visibility=='hidden'){
									header_combo_1.toggle('width');
								}else{
									header_combo_3.toggle('width');
								}
								setTimeout("header_combo_2.toggle('width');", 300);
							}else{
								if(koszyk_kwota=='0.00'){
									setTimeout("header_combo_1.toggle('width');", 300);
								}else{
									setTimeout("header_combo_3.toggle('width');", 300);
								}
								header_combo_2.toggle('width');
							}
						}
					}
