// 30 VII 2009 [kuba]
// drobne poprawki porzadkowe w kodzie
// dodana funkcja getHref() - dla onclick-ow z listy produktow

ns4 = (document.layers)? true:false
ie4 = (document.all)? true:false
ns6 = (document.getElementById) ? true : false;

function rp(init) {  //reloads the window if Nav4 resized //MM_reloadPage
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=rp; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
rp(true);

function zr() { //v3.0 //MM_swapImgRestore
  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 zp() { //v3.0 MM_preloadimages
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=zm.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 fo(n, d) { //v4.01 //MM_findObj
  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=fo(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function zm() { //v3.0 //MM_swapimage
  var i,j=0,x,a=zm.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=fo(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function send_address_form(pole0, pole1, pole2, pole3, pole4, pole5, pole6, pole7, pole8, pole9, pole10, pole11, pole12, pole13, pole14, pole15, pole16, pole17, pole18, pole19, pole20, pole21, pole22, pole23, pole24, pole25, pole26, pagetime)
{
	var maks=25; 
	var j=0;
	var adres='', pole_x=0;
	for (var i=0; i<=maks; i++)
	{
		pole_x="pole"+i; 
		if (pole_x=='undefined') { pole_x=0; }
		//alert ("i="+i+", pole="+pole_x+", pole_x="+eval(pole_x));
		//adres+=eval(pole_x);
		//if (i!=maks) { adres=adres+"|"; }
		if (eval(pole_x))
		{
			if (j>0) { adres+='&'; }
			switch(i)
			{
				case 0: adres+='str='; break; //AddressLang
				case 1: adres+='tp='; break; //AddressPageNo
				case 2: adres+='pid='; break; //AddressRoomNo
				case 3: adres+='kat1='; break; //AddressBrandId
				case 4: adres+='kat2='; break; //AddressProductsGroupId
				case 5: adres+='kat3='; break; //AddressPageNumber
				case 6: adres+='kat='; break; //AddressArchive
				case 7: adres+='wid='; break; //AddressProductId
				case 8: adres+='aid='; break; //AddressDate
				case 9: adres+='lb1='; break; //AddressDate
			}
			adres+=eval(pole_x);
			j++;
		}
	}
	//alert (pagetime);
	adres+='&ptim='+eval(pagetime);
	//alert(adres);
	//if (!typ)
	//{
		document.location.href="?"+adres;
	//}
	//else
	//{
		//document.location.href="?"+adres;
		//document.getElementById(typ).action="?"+adres;
	//}
}

if (navigator.appName == "Netscape") document.captureEvents(Event.KEYPRESS);
var Key;

function keyhandler(e)
{
	if (navigator.appName == "Netscape")
	{
		Key = e.which;
	}
	else
	{
		Key = window.event.keyCode;
	}
}

function przeskakuj(ktore, ile, gdzie)
{
	//alert(event.keyCode);
	var key;
	document.getElementById(ktore).onkeypress=keyhandler;
	if (document.getElementById(ktore).value.length==ile && Key!=37)
	{
		document.getElementById(gdzie).focus();
	}
}





<!--



//as the page loads - first thing to do is to load the dropdown array

function sElement(sParentId,sValue,sDescription)
{	
	// elements that will be loaded into the array structure and persisted
	// think of it as an object.
	this.ParentId = sParentId
	this.Id = sValue
	this.Description = sDescription
}

function bCascadeDrop(oDDsource,oDDdest)
{
	//function to enable cascading dropdowns
	//called as the parent dropdown changes.
	var iX
	var sText
	var iY= 0
	var sOptionId
	var sOptionDesc
	var iStartPos
		
	//find the value of the item currently selected		
	sText = oDDsource.options[oDDsource.selectedIndex].value 
	//alert('bOk='+bOk+',oDDsource='+oDDsource+', v='+oDDsource.options[oDDsource.selectedIndex].value+', sText='+sText);
	//if (sText != '0')
	//{
		//clear down the destination list box
		oDDdest.options.length = 0                
		
		//loop through the elements that are in the array
		// if they match the parent if then they should be displayed.
		for (iX=0; iX<=iArrayMax; iX++) 
		{		
			if(sText == Array[iX].ParentId)
			{
			//grab the values out of the element (Netscape is not happy doing too many things in a function call!)
			sOptionId = Array[iX].Id
			sOptionDesc= Array[iX].Description
			//alert(sOptionDesc)
			
			//write the element into the dripdown box.		
			oDDdest.options[iY] = new Option (sOptionDesc,sOptionId)	
			iY = iY +1		
			}	
		}	
	//}
	//else
	//{
		
	//}
}//-->

function set_display (obiekt,wyswietl)                                                                                     
{
    ie=document.all?1:0;
    ie4=ie&&!document.getElementById?1:0;
    ie5=ie&&document.getElementById?1:0;
    ie6 = (navigator.appVersion.indexOf('MSIE 6')>=0)?1:0;    
    op = (navigator.appName.indexOf('Opera')>=0)?1:0;        
    ns=document.layers||(document.getElementById&&!document.all)?1:0
    ns4=document.layers?1:0;
    ns6=ns&&!ns4?1:0

    if (op)
	obiekt.style = wyswietl ? 'display:inline' : 'display:none' ; 
    else if (ns6)
	obiekt.style.display = wyswietl ? '' : 'none' ;     
    else if (ie5 || ie6)
	obiekt.style.display = wyswietl ? 'inline' : 'none' ; 
    else
	obiekt.style = wyswietl ? 'display:yes' : 'display:none' ; 

    return 0;
}
  
function showadvanced(dopokazania, form_object)                                                                                   
{                                                                                                                
    wiersz = document.getElementById(dopokazania);                                                   
    if (wiersz == null)                                                                                      
	return 0;

	set_display(wiersz,true);
	
    return 0;                                                                                                    
}

function hideadvanced(form_object, start, end)                                                                                   
{
	for (var i=start; i<=end; i++)
	{
	    wiersz = document.getElementById(i);
    	if (wiersz == null)                                                                                      
		continue;
	
		set_display(wiersz,false);
	}
	
	return 0;                                                                                                    
}

function setPointer(theRow, thePointerColor)
{
    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        var theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        var theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    for (var c = 0; c < rowCellsCnt; c++) {
        theCells[c].style.backgroundColor = thePointerColor;
    }

    return true;
}

function setTextColor(theRow, thePointerColor)
{
    if (thePointerColor == '' || typeof(theRow.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        var theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        var theCells = theRow.cells;
    }
    else {
        return false;
    }

    var rowCellsCnt  = theCells.length;
    for (var c = 0; c < rowCellsCnt; c++) {
        theCells[c].style.color = thePointerColor;
    }

    return true;
}

function bgCell(theCell, thePointerColor)
{
    if (thePointerColor == '' || typeof(theCell.style) == 'undefined') {
        return false;
    }
    if (typeof(document.getElementsByTagName) != 'undefined') {
        var theCells = theCell.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        var theCells = theCell.cells;
    }
    else {
        return false;
    }

	theCell.style.backgroundColor = thePointerColor;
    //var rowCellsCnt  = theCells.length;
    //for (var c = 0; c < rowCellsCnt; c++) {
    //    theCells[c].style.backgroundColor = thePointerColor;
    //}

    return true;
}

function OKStrOfPenny(X, roundX)
{
	var T, S=new String(Math.round(X*100)), number;
	while (S.length<3) { S='0'+S; }
	number=S.substr(0, T=(S.length-2)) + '.' + S.substr(T, 2);
	if (roundX==1) { return parseInt(Math.round(number)); }
	return number;
}

function przejdz(gdzie)
{
	var result="";
	arrayofstring=gdzie.split(',');
	for (var i=0; i < arrayofstring.length; i++)
	{
		result=result+String.fromCharCode(arrayofstring[i]-10);
	}
	document.location=result;
}

function niepuste(x){return x>''}
function ismail(e){return /^[\w\.-]{2,}@[\w\.-]+\.[a-z]{2,5}$/i.test(e)}
function ispass(e){return /^[a-zA-Z0-9]{4,10}$/i.test(e)}
function jestlicznba(e){return /^[0-9]{2}-[0-9]{3}$/.test(e.value)}
function cyfra(c){return ((c >= "0") && (c <= "9"))}

function validate(f)
{
	var v,i,e;
	for(i=0;e=f[i++];)
	{
		if(v=window[e.getAttribute('valid')])
		{
			if(!v(e.value))
			{
				alert(e.getAttribute('alert'));e.focus();return 1;
			}
		}
	}
}

function se(l)
{
	var s=document.getElementById('search').value;
	s=trim(s);
	s=s.replace("\\","");
	
	self.location.href=l+((s) ? URLencode(s)+'/' : '');
}

function sea(l)
{
	var s1=trim(document.getElementById('search1').value);
	var s2=trim(document.getElementById('search2').value);
	var s3=trim(document.getElementById('search3').value);
	var s4=trim(document.getElementById('search4').value);
	var s5=trim(document.getElementById('search5').value);
	var s6=trim(document.getElementById('search6').value);
	var s7=trim(document.getElementById('search7').value);
	var s8=trim(document.getElementById('search8').value);
	var s9=trim(document.getElementById('search9').value);
	//var s10=trim(document.getElementById('search10').value);
	//tymczasowo
	var s10='';
	var s11=trim(document.getElementById('search11').value);
	var s12=trim(document.getElementById('search12').value);
	var s13=trim(document.getElementById('search13').value);
	var s14=trim(document.getElementById('search14').value);
	var s15=((document.getElementById('search15').checked) ? '1' : '0');
	
	// 22 IV 2010 [kuba]
	// dodane wymuszenie wyboru wydawcy z listy podpowiedzi
	var search16 = trim(document.getElementById('search16').value);
	var s16 = ((typeof(search16) == undefined) ? 0 : search16); // dokladnie wybrany wydawca z listy podpowiedzi
	
	// 10 XII 2010 [kuba]
	// dodane wymuszenie wyboru autora z listy podpowiedzi
	var search17 = trim(document.getElementById('search17').value);
	var s17 = ((typeof(search17) == undefined) ? 0 : search17); // dokladnie wybrany autor z listy podpowiedzi
	
	var s18 = trim(document.getElementById('search18').value);
	//alert(l+((s) ? URLencode(s)+'/' : ''));
	
	var s;
	s=	URLencode(s1)+':'+URLencode(s2)+':'+URLencode(s3)+':'+URLencode(s4)
		+':'+URLencode(s5)+':'+URLencode(s6)+':'+URLencode(s7)
		+':'+URLencode(s8)+':'+URLencode(s9)+':'+URLencode(s10)
		+':'+URLencode(s11)+':'+URLencode(s12)+':'+URLencode(s13)
		+':'+URLencode(s14)+':'+URLencode(s15)
		+':'+URLencode(s16)+':'+URLencode(s17)+':'+URLencode(s18)
		;
	//alert(l+((s) ? s+'/' : ''));
	self.location.href=l+((s) ? s+'/' : '');
	
}


function trim(s, ss)
{
	if (typeof ss == 'undefined') { ss = ' '; }
	var ssl = ss.length;
	
	while (s.substring(0,ssl) == ss)
	{
		s = s.substring(ssl,s.length);
	}
	while (s.substring(s.length-ssl,s.length) == ss)
	{
		s = s.substring(0,s.length-ssl);
	}
	return s;
}

function URLencode(s)
{
	var a=s.length, b=0, w;
	var str='';
	//alert(a+', '+str);
	while(a>b)
	{
		w = s.substr(b,1); //alert(w);
		w=w.replace('!','%21');
		w=w.replace('@','%40');
		w=w.replace('#','%23');
		w=w.replace('$','%24');
		w=w.replace('%','%25');
		w=w.replace('^','%5E');
		w=w.replace('&','%26');
		w=w.replace('*','%2A');
		w=w.replace('(','%28');
		w=w.replace(')','%29');
		w=w.replace('ę','%EA');
		w=w.replace('ó','%F3');
		w=w.replace('ą','%B1');
		w=w.replace('ś','%B6');
		w=w.replace('ł','%B3');
		w=w.replace('ż','%BF');
		w=w.replace('ź','%BC');
		w=w.replace('ć','%E6');
		w=w.replace('ń','%F1');
		w=w.replace('Ę','%CA');
		w=w.replace('Ó','%D3');
		w=w.replace('Ą','%A1');
		w=w.replace('Ś','%A6');
		w=w.replace('Ł','%A3');
		w=w.replace('Ż','%AF');
		w=w.replace('Ź','%AC');
		w=w.replace('Ć','%C6');
		w=w.replace('Ń','%D1');
		w=w.replace('<','%3C');
		w=w.replace('>','%3E');
		w=w.replace(',','%2C');
		//w=w.replace('.',','); // 19 I 2010 [kuba] - usunieta zamiana kropki na przecinek
		//w=w.replace('.',''); // 20 I 2010 [kuba] - dodana zamiana kropki na nic
		w=w.replace('.',' '); // 02 IX 2010 [kuba] - zmieniona zamiana kropki na spacje (byla zamiana na nic)
		w=w.replace('[','%5B');
		w=w.replace(']','%5D');
		w=w.replace(';','%3B');
		w=w.replace('\'','%27');
		w=w.replace('/','%2F');
		w=w.replace('{','%7B');
		w=w.replace('}','%7D');
		//w=w.replace(':','%3A');
		w=w.replace(':',' ');
		//w=w.replace('"','%22'); //10 II 2011 [kuba] - zrobiona zamiana " na spacje
		w=w.replace('"',' ');
		// 20 I 2010 [kuba] - dodana zamiana znaku zapytania na nic
		//w=w.replace('?','%3F');
		w=w.replace('?','');
		w=w.replace('-','-');
		w=w.replace('=','%3D');
		w=w.replace('\\','%5C');
		w=w.replace('_','_');
		w=w.replace('+','%2B');
		w=w.replace('|','%7C');
		w=w.replace(' ','+');
		str+=w;
		b++;
	}
	return str;
}



function wypisz_info(productid)
{
	var ss = document.getElementById('hintp'+productid);
	ss.innerHTML = 'Realizacja w ciągu 24h (dni robocze) dotyczy:<br/>- zamówień za pobraniem potwierdzonych danego dnia do godziny 12.00<br/>- zamówień opłaconych kartą kredytową do godziny 12.00<br/>- zamówień opłaconych przelewem po zaksięgowaniu wpłaty do godziny 12.00';
}

function wypisz_info_mz(productid)
{
	var ss = document.getElementById('hintm'+productid);
	ss.innerHTML = 'Mały zapas - produkt może być niedostępny - oznacza to, że na magazynach są ostatnie egzemplarze i istnieje prawdopodobieństwo, że produkt ten od naszego dostawcy może nie zostać nam dosłany. Realizujemy wówczas zamówienie bez tej pozycji.';
}

function wypisz_info_f()
{
	var ss = document.getElementById('hintf');
	ss.innerHTML = 'Wejdź na forum i podziel się opinią o wybranej pozycji, poznaj zdanie innych, podyskutuj. A dodatkowo możesz wygrać książkę! Co tydzień losowanie!';
}

x = 130;
y = 60;
function setVisible(obj,link,data)
{
	var ss = document.getElementById('okno_zapowiedz');
	ss.innerHTML = '<b>UWAGA!</b><br/><br/>Zamawiasz towar z działu <b>zapowiedzi wydawnicze</b>. Pamiętaj, że realizacja Twojego zamówienia ulegnie wydłużeniu do dnia ukazania się książki ('+data+')<br/><br/> <a href="'+ link + '">Tak Zamawiam</A> / <a href="#" onclick="setVisible(\'okno_zapowiedz\');return false"> Nie, rezygnuję</a> ';
	obj = document.getElementById(obj);
	obj.style.visibility = (obj.style.visibility == 'visible') ? 'hidden' : 'visible';
}

// 16 X 2009 [kuba]
// usuniecie wywolania tej funkcji co 500 sek - wystarczy ze jest ona wywolywana w onscroll
function placeIt(obj)
{
	obj = document.getElementById(obj);
	if (obj)
	{
		if (document.documentElement)
		{
			theLeft = document.documentElement.scrollLeft;
			theTop = document.documentElement.scrollTop;
		}
		else if (document.body)
		{
			theLeft = document.body.scrollLeft;
			theTop = document.body.scrollTop;
		}
		theLeft += screen.width/2  - x;
		theTop += screen.height/2  -y;
		obj.style.left = theLeft + 'px' ;
		obj.style.top = theTop + 'px' ;
		//setTimeout("placeIt('okno_zapowiedz')",500);
	}
}

// 15 X 2009 [kuba]
// dodana obsluga generacji captcha
function generateCaptcha(objectid)
{
	var cim = new Image();
	var tmp = new Date();
	var time = tmp.getTime();
	document.getElementById(objectid).src = '/server.php?act=cim&data='+time;
}

// 30 VII 2009 [kuba]
// dodana funkcja getHref() - dla onclick-ow z listy produktow
function getHref(p_intProductId)
{
	document.location.href = document.getElementById('p'+p_intProductId).href;
}

// 4 VIII 2009 [kuba]
// dodana obsluga warstwy 'okno_zapowiedz' - przeniesione z ./themes/theme2/modules/lib/productslist.php
window.onscroll = function()
{
	setTimeout("placeIt('okno_zapowiedz')", 500);
}

// 4 VIII 2009 [kuba]
// dla inicjacji ustawienia warstwy 'okno_zapowiedz'
// 16 X 2009 [kuba]
// zrobione wywolanie funkcji placeIt() od razu po zaladowaniu sie strony
window.onload = function()
{
	//setTimeout("placeIt('okno_zapowiedz')", 500);
	placeIt('okno_zapowiedz');
} 
