' + match + '<\/strong>' });
};
Autocomplete.prototype = {
killerFn: null,
initialize: function() {
var me = this;
this.killerFn = function(e) {
if (!$(Event.element(e)).up('.autocomplete')) {
me.killSuggestions();
me.disableKillerFn();
}
} .bindAsEventListener(this);
if (!this.options.width) { this.options.width = this.el.getWidth(); }
var div = new Element('div', { style: 'position:absolute;' });
div.update('');
this.options.container = $(this.options.container);
if (this.options.container) {
this.options.container.appendChild(div);
this.fixPosition = function() { };
} else {
document.body.appendChild(div);
}
this.mainContainerId = div.identify();
this.container = $('Autocomplete_' + this.id);
this.fixPosition();
Event.observe(this.el, window.opera ? 'keypress':'keydown', this.onKeyPress.bind(this));
Event.observe(this.el, 'keyup', this.onKeyUp.bind(this));
Event.observe(this.el, 'blur', this.enableKillerFn.bind(this));
Event.observe(this.el, 'focus', this.fixPosition.bind(this));
this.container.setStyle({ maxHeight: this.options.maxHeight + 'px' });
this.instanceId = Autocomplete.instances.push(this) - 1;
},
fixPosition: function() {
var offset = this.el.cumulativeOffset();
$(this.mainContainerId).setStyle({ top: (offset.top + this.el.getHeight()) + 'px', left: offset.left + 'px' });
},
enableKillerFn: function() {
Event.observe(document.body, 'click', this.killerFn);
},
disableKillerFn: function() {
Event.stopObserving(document.body, 'click', this.killerFn);
},
killSuggestions: function() {
this.stopKillSuggestions();
this.intervalId = window.setInterval(function() { this.hide(); this.stopKillSuggestions(); } .bind(this), 300);
},
stopKillSuggestions: function() {
window.clearInterval(this.intervalId);
},
onKeyPress: function(e) {
if (!this.enabled) { return; }
// return will exit the function
// and event will not fire
switch (e.keyCode) {
case Event.KEY_ESC:
this.el.value = this.currentValue;
this.hide();
break;
case Event.KEY_TAB:
case Event.KEY_RETURN:
if (this.selectedIndex === -1) {
this.hide();
return;
}
this.select(this.selectedIndex);
if (e.keyCode === Event.KEY_TAB) { return; }
break;
case Event.KEY_UP:
this.moveUp();
break;
case Event.KEY_DOWN:
this.moveDown();
break;
default:
return;
}
Event.stop(e);
},
onKeyUp: function(e) {
switch (e.keyCode) {
case Event.KEY_UP:
case Event.KEY_DOWN:
return;
}
clearInterval(this.onChangeInterval);
if (this.currentValue !== this.el.value) {
if (this.options.deferRequestBy > 0) {
// Defer lookup in case when value changes very quickly:
this.onChangeInterval = setInterval((function() {
this.onValueChange();
}).bind(this), this.options.deferRequestBy);
} else {
this.onValueChange();
}
}
},
onValueChange: function() {
clearInterval(this.onChangeInterval);
this.currentValue = this.el.value;
this.selectedIndex = -1;
if (this.ignoreValueChange) {
this.ignoreValueChange = false;
return;
}
if (this.currentValue === '' || this.currentValue.length < this.options.minChars) {
this.hide();
} else {
this.getSuggestions();
}
},
getSuggestions: function() {
var cr = this.cachedResponse[this.currentValue];
if (cr && Object.isArray(cr.suggestions)) {
this.suggestions = cr.suggestions;
this.data = cr.data;
this.suggest();
} else if (!this.isBadQuery(this.currentValue)) {
new Ajax.Request(this.serviceUrl, {
parameters: { query: this.currentValue },
onComplete: this.processResponse.bind(this),
method: 'get'
});
}
},
isBadQuery: function(q) {
var i = this.badQueries.length;
while (i--) {
if (q.indexOf(this.badQueries[i]) === 0) { return true; }
}
return false;
},
hide: function() {
this.enabled = false;
this.selectedIndex = -1;
this.container.hide();
},
suggest: function() {
if (this.suggestions.length === 0) {
this.hide();
return;
}
var content = [];
var re = new RegExp('\\b' + this.currentValue.match(/\w+/g).join('|\\b'), 'gi');
this.suggestions.each(function(value, i) {
content.push((this.selectedIndex === i ? '', Autocomplete.highlight(value, re), '
');
} .bind(this));
this.enabled = true;
this.container.update(content.join('')).show();
},
processResponse: function(xhr) {
var response;
try {
response = xhr.responseText.evalJSON();
if (!Object.isArray(response.data)) { response.data = []; }
} catch (err) { return; }
this.cachedResponse[response.query] = response;
if (response.suggestions.length === 0) { this.badQueries.push(response.query); }
if (response.query === this.currentValue) {
this.suggestions = response.suggestions;
this.data = response.data;
this.suggest();
}
},
activate: function(index) {
var divs = this.container.childNodes;
var activeItem;
// Clear previous selection:
if (this.selectedIndex !== -1 && divs.length > this.selectedIndex) {
divs[this.selectedIndex].className = '';
}
this.selectedIndex = index;
if (this.selectedIndex !== -1 && divs.length > this.selectedIndex) {
activeItem = divs[this.selectedIndex]
activeItem.className = 'selected';
}
return activeItem;
},
deactivate: function(div, index) {
div.className = '';
if (this.selectedIndex === index) { this.selectedIndex = -1; }
},
select: function(i) {
var selectedValue = this.suggestions[i];
if (selectedValue) {
this.el.value = selectedValue;
if (this.options.autoSubmit && this.el.form) {
this.el.form.submit();
}
this.ignoreValueChange = true;
this.hide();
this.onSelect(i);
}
},
moveUp: function() {
if (this.selectedIndex === -1) { return; }
if (this.selectedIndex === 0) {
this.container.childNodes[0].className = '';
this.selectedIndex = -1;
this.el.value = this.currentValue;
return;
}
this.adjustScroll(this.selectedIndex - 1);
},
moveDown: function() {
if (this.selectedIndex === (this.suggestions.length - 1)) { return; }
this.adjustScroll(this.selectedIndex + 1);
},
adjustScroll: function(i) {
var container = this.container;
var activeItem = this.activate(i);
var offsetTop = activeItem.offsetTop;
var upperBound = container.scrollTop;
var lowerBound = upperBound + this.options.maxHeight - 25;
if (offsetTop < upperBound) {
container.scrollTop = offsetTop;
} else if (offsetTop > lowerBound) {
container.scrollTop = offsetTop - this.options.maxHeight + 25;
}
this.el.value = this.suggestions[i];
},
onSelect: function(i) {
(this.options.onSelect || Prototype.emptyFunction)(this.suggestions[i], this.data[i]);
}
};
Event.observe(document, 'dom:loaded', function(){ Autocomplete.isDomLoaded = true; }, false);
function IntoBasket(ID) { parent.location.href = "/koszyk-akcja/insert="+ID; }
function IntoBasketCombo(ids) { parent.location.href = "/koszyk-akcja/insertcombo="+ids; }
function KonfigBasket(ID) { parent.location.href = "/koszyk-akcja/konfig="+ID; }
function DetailedInfo(id) { okno = window.open('/showtowar.php?ID='+id, 'info_o_towarze_'+id , 'toolbar=yes,resizable=1,scrollbars=yes,menubar=yes,location=yes, width=600, height=640, left=50, top=0'); if (parseInt(navigator.appVersion)>=4) okno.window.focus(); }
function tplP(id) { okno = window.open('/tpl.php?tplP='+id, 'info_o_towarze_'+id , 'toolbar=no,resizable=0,scrollbars=yes,menubar=no,location=no, width=660, height=640, left=50, top=0');if (parseInt(navigator.appVersion)>=4) okno.window.focus(); }
function otworzokono(mypage,myname,w,h,features) {
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
if(navigator.appName == 'Opera') wint = parseInt(wint * 0.5);
if (winl < 0) winl = 0;
if (wint < 0) wint = 0;
var settings = 'height=' + h + ',';
settings += 'width=' + w + ',';
settings += 'top=' + wint + ',';
settings += 'left=' + winl + ',';
settings += features;
win = window.open(mypage,myname,settings);
win.window.focus();
}
function Pomoc(temat) {
if(typeof(pomoc)!='undefined') {
if(pomoc.open && !pomoc.closed) {
pomoc.close();
}
}
otworzokono('/centrum-pomocy/'+(temat), 'pomoc', 640, 500, 'toolbar=no,resizable=0,scrollbars=yes,menubar=no,location=no')
return false;
}
function BigFoto(id ) {
id++;
}
function LoadSnow() {
var myObj = new FlashTML("/layout/snow_lq.swf", "930", "100", {quality:'low',menu:'false',wmode:'transparent'});
myObj.replace("snoww");
}
var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var tempX = 0;
var tempY = 0;
function getMouseXY(e) {
if (IE) { // grab the x-y pos.s if browser is IE
tempX = event.clientX + document.body.scrollLeft;
tempY = event.clientY + document.body.scrollTop;
}
else { // grab the x-y pos.s if browser is NS
tempX = e.pageX;
tempY = e.pageY;
}
if (tempX < 0){tempX = 0;}
if (tempY < 0){tempY = 0;}
return true;
}
var cod = 0;
var cdo = 0;
var ppi = 0;
var cs = 0;
var spp = 0;
var tar = '';
var forcenomove = true;
function przenies_pas(ktory) {
tar = ktory;
spp = tempX;
if(ktory == 'belka_od') {
cs = parseInt($('jasnypas1').style.width);
}else{
cs = parseInt($('srodek').style.width);
}
forcenomove = false;
ppi = setInterval('przenos()',1);
}
function przenos() {
if(forcenomove) return true;
var dif = tempX - spp;
var v = cs + dif;
var w1 = parseInt($('jasnypas1').style.width);
var w2 = 16;
var w3 = parseInt($('srodek').style.width);
var w4 = 16;
var w5 = parseInt($('jasnypas2').style.width);
if(tar == 'belka_od') {
var min = 0;
var max = 180 - (w2+w4+w5+1);
}else{
var min = 1;
var max = 180 - (w1+w2+w4);
}
v = parseInt(v);
if(v < min) v = min;
if(v > max) v = max;
if(tar == 'belka_od') {
w1 = v;
w3 = 180 - (w1+w5+w4+w2);
}else{
w3 = v;
w5 = 180 - (w1+w2+w3+w4);
}
$('jasnypas1').style.width = w1+'px';
$('srodek').style.width = w3+'px';
$('jasnypas2').style.width = w5+'px';
if(tar == 'belka_od') {
$('testcena_od').value = parseInt((mincena + w1 * ror / (180-w2-w2)) / 50) * 50;
}else{
var cod = parseInt(mincena + w1 * ror / (180-w2-w2));
$('testcena_do').value = parseInt((cod + w3 * ror / (180-w2-w2)) / 50) * 50 + 50;
}
}
function update_testcena() {
var cod = $('testcena_od').value;
var cdo = $('testcena_do').value;
cod = parseInt(cod);
cdo = parseInt(cdo);
var w2 = 16;
if(isNaN(cod)) cod = parseInt(mincena);
if(isNaN(cdo)) cdo = parseInt(maxcena);
if(cod < mincena) cod = mincena;
if(cdo > maxcena) cdo = maxcena;
if(cod > cdo) cod = mincena;
if(cdo < cod) cdo = maxcena;
w1 = parseInt( ((cod-mincena)*(180-w2-w2) / ror) / 1 ) * 1;
w3 = parseInt( ((cdo-cod)*(180-w2-w2) / ror) / 1 ) * 1;
w5 = 180 - (w1+w2+w2+w3);
$('jasnypas1').style.width = w1+'px';
$('srodek').style.width = w3+'px';
$('jasnypas2').style.width = w5+'px';
$('testcena_od').value = cod;
$('testcena_do').value = cdo;
}
function nie_przenos_pasa() {
forcenomove = true;
clearInterval(ppi);
ppi = 0;
}
function rgbhex(r,g,b) {
var hr = parseInt(r).toString(16);
var hg = parseInt(g).toString(16);
var hb = parseInt(b).toString(16);
if(r < 16) hr = '0'+hr;
if(g < 16) hg = '0'+hg;
if(b < 16) hb = '0'+hb;
return '#'+hr+hg+hb;
}
function bar_color(f) {
b = 30;
f = 1 - f;
if(f < 0.5) {
g = 230;
r = f * 230 * 2;
}else{
r = 230;
g = 230 - (f-0.5) * 230;
}
return rgbhex(r,g,b);
}
var testy = new Array(0,0,0,0);
function updatetb(nr,ibox) {
var v = ibox.value;
if(v < 0) v = 0;
if(v > bar_max[nr-1]) v = bar_max[nr-1];
ibox.value = v;
var f = v / bar_max[nr-1];
stopeffect = 30;
$('testbar'+nr).style.width = parseInt(180*f);
$('testbar'+nr).style.backgroundColor = bar_color(f);
}
function set_bars() {
var w = $('konfigi').options[$('konfigi').selectedIndex].value;
if(w >= 0) {
var tab = konfig[w].split(',');
var ceny = tab[0].split('-');
var sortby = tab[1];
var ind = 0;
//sortselect
var f = document.forms['bibliotekaform']['konfig[sortby]'];
for(var i=0;i 1) {
wyn = tab[i];
}else{
wyn = parseInt(tab[i] * bar_max[i-1]);
}
nr = i - 1;
$('pwynik'+nr).value = wyn;
if(wyn > 0) {
$('testbaron'+nr).checked = true;
}else{
$('testbaron'+nr).checked = false;
}
shtb(nr,wyn>0);
updatetb(nr,$('pwynik'+nr));
}
update_testcena();
}
}
function shtb(nr,bool) {
if(bool) {
$('dtestbar'+nr).style.display = 'block';
}else{
$('dtestbar'+nr).style.display = 'none';
}
$('pwynik'+nr).style.display = $('dtestbar'+nr).style.display;
}
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+encodeURIComponent(value)+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return decodeURIComponent(c.substring(nameEQ.length,c.length));
}
return null;
}
function DodajPorownanie(id) {
var str = readCookie('bench_porownywane');
var nowy;
if(str) {
nowy = str+','+id;
}else{
nowy = id;
}
createCookie('bench_porownywane',nowy,9999);
var ile = parseInt($('porcount').innerHTML);
$('porcount').innerHTML = ile + 1;
$('porownanie'+id).innerHTML = '';
$('porbtn').innerHTML = '';
return false;
}
function DodajPorownanie2(id) {
var str = readCookie('bench_porownywane');
var nowy;
if(str) {
nowy = str+','+id;
}else{
nowy = id;
}
createCookie('bench_porownywane',nowy,9999);
var ile = parseInt($('porcount').innerHTML);
$('porcount').innerHTML = ile + 1;
$('porownanie'+id).innerHTML = '';
$('porbtn').innerHTML = '';
return false;
}
function UsunPorownanie(id) {
$('komputer'+id).style.display = 'none';
UsunFunction(id);
return false;
}
function UsunFunction(id) {
var str = readCookie('bench_porownywane');
var tab = str.split(',');
var newtab = new Array();
for(var i=0;i 0) && (tab[i] != id)) newtab.push(tab[i]);
}
createCookie('bench_porownywane',newtab.join(','),9999);
var ile = parseInt($('porcount').innerHTML);
$('porcount').innerHTML = ile - 1;
if((ile-1) == 0) {
$('mainben').innerHTML = 'Lista komputerów jest pusta.
';
}
}
function UsunPorownanie2(id,nr) {
var vnr = ctab[nr];
ctab[nr] = '';
var s = ctab.join(',');
for(var i=(vnr+1);i