function g(o)
{
return document.getElementById(o);
}
var dlugosc = 0;
var tekst = '';
function find(input)
{
dlugosc=0;
if(input==null || input=='') return;
var regInput = input.toLowerCase().replace(/\./g, '\\.');
var ch = regInput.charAt(0);
var tab = null;
if(ch>'z' || ch<'a')
{
tab = d[26];
}
else
{
tab = d[ch.charCodeAt(0)-'a'.charCodeAt(0)];
}
tekst = '<table id="tabelaWyn" width="100%" border="0" cellspacing="0" cellpadding="0">';
for(var i=0;i<tab.length;i++)
{
var name = tab[i];
var lName = name.toLowerCase();
var found = 0;
if(lName.match('^'+regInput+'.*$')) found=1;
if(found==0 && lName.replace(/-/g, '').match('^'+regInput+'.*$')) found=2;
if(found>0)
{
var endInd = 0;
var skipped = 0;
for(var a=0;a<input.length;a++)
{
if(found==2 && lName.charAt(a+skipped)=='-')
{
skipped++;
a--;
}
endInd++;
}
tekst += '<tr><td onmouseover="selectItem(this);" onmouseout="freeItem();" onclick="clickItem(this);" class="bial"><b>'+name.substring(0,endInd)+'</b>'+name.substring(endInd)+'</td></tr>';
dlugosc++;
}
}
tekst += '</table>';
}
function keyUp(e)
{
var text = g('s');
var div1 = g('s1');
var div2 = g('s2');
var table = g('tabelaWyn');
var keynum;
if(window.event) //ie
{
keynum = e.keyCode;
}
else if(e.which) //netscape/ff/opera
{
keynum = e.which;
}
if(keynum==38 || keynum==40)
{
if((div1.style.display=='block' || div2.style.display=='block') && table!=null)
{
if(selectedItem==null)
{
if(keynum==40)
{
selectItem(table.rows[0].cells[0]);
}
}
else
{
var rows = table.rows;
var selTr = selectedItem.parentNode;
var ind = 0;
for(var tr=0;tr<rows.length;tr++)
{
if(selTr==rows[tr])
{
ind = tr;
break;
}
}
if(keynum==40 && tr<table.rows.length-1)
{
selectItem(table.rows[tr+1].cells[0]);
}
else if(keynum==38 && tr>0)
{
selectItem(table.rows[tr-1].cells[0]);
}
}
}
return true;
}
else if(keynum==13 && (div1.style.display=='block' || div2.style.display=='block'))
{
if(!clickItem(null)) return false;
}
if(selectedItem!=null) freeItem();
find(text.value);
if(dlugosc==0)
{
div1.style.display = 'none';
div2.style.display = 'none';
return true;
}
var table = g('tabelaWyn');
if (dlugosc<=12)
{
div2.innerHTML = '';
div1.style.height = '2px';
div1.innerHTML = tekst;
div1.style.display = 'block';
div2.style.display = 'none';
}
else
{
div1.innerHTML = '';
div2.innerHTML = tekst;
div2.scrollTop = 0;
div2.style.display = 'block';
div1.style.display = 'none';
}
return true;
}
var selectedItem = null;
function selectItem(obj)
{
if(selectedItem!=null)
{
freeItem();
}
selectedItem = obj;
obj.className = 'nieb';
var div2 = g('s2');
var table = g('tabelaWyn');
if(table.parentNode == div2) //scroll
{
if(div2.scrollTop + div2.offsetHeight < obj.offsetTop + obj.offsetHeight)
{
div2.scrollTop = obj.offsetTop + obj.offsetHeight - div2.offsetHeight + 2;
}
else if(obj.offsetTop<div2.scrollTop)
{
div2.scrollTop = obj.offsetTop;
}
}
}
function freeItem()
{
if(selectedItem!=null)
{
selectedItem.className = 'bial';
selectedItem = null;
}
}
function clickItem(obj)
{
if(obj!=null && obj!=selectedItem)
{
selectItem(obj);
}
if(selectedItem==null) //click first item
{
var table = g('tabelaWyn');
if(table!=null && table.rows.length>=1)
{
selectItem(table.rows[0].cells[0]);
}
}
if(selectedItem!=null)
{
var name = selectedItem.innerHTML;
name = name.substring(3);
var ind = name.indexOf('<');
name = name.substring(0,ind) + name.substring(ind+4);
g('s').value = name;
location.href = '/leki/' + nazwa2link(name) + '.htm';
return false;
}
return true;
}
function wra()
{
document.write('<div style="display:none;">');
}
function nazwa2link(name)
{
name = name.toLowerCase();
var ind = name.indexOf('&#174;');
while(ind >= 0)
{
name = name.substring(0, ind) + '-r' + name.substring(ind+6);
ind = name.indexOf('&#174;');
}
ind = name.indexOf('&reg;');
while(ind >= 0)
{
name = name.substring(0, ind) + '-r' + name.substring(ind+5);
ind = name.indexOf('&reg;');
}
ind = name.indexOf('®');
while(ind >= 0)
{
name = name.substring(0, ind) + '-r' + name.substring(ind+1);
ind = name.indexOf('®');
}
var previousStrange = false;
var ret = '';
for(var i=0;i<name.length;i++)
{
var ch = name.charAt(i);
if(ch=='ą') ch = 'a';
else if(ch=='ć') ch = 'c';
else if(ch=='ę') ch = 'e';
else if(ch=='ł') ch = 'l';
else if(ch=='ń') ch = 'n';
else if(ch=='ó') ch = 'o';
else if(ch=='ś') ch = 's';
else if(ch=='ź') ch = 'z';
else if(ch=='ż') ch = 'z';
if((ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch=='.' || ch==',')
{
if(previousStrange && ret.length > 0)
{
ret += "-";
}
ret += ch;
previousStrange = false;
}
else
{
previousStrange = true;
}
}
return ret;
}
function wrb()
{
document.write('</div>');
}
function s()
{
g('s1').style.display='none';
g('s2').style.display='none';
}
function m()
{
g('z1').childNodes[0].href='mailto:adm'+'in@leki-refun'+'dowane.com';
var w = window.location.href;
var i = w.indexOf('dn=');
if(i>0)
{
w = decodeURIComponent(w.substring(i+3).replace(/[+]/gi,'%20'));
var s = g('g');
if(s) s.innerHTML = 'Lek <b>' + w + "</b> wypadł z listy leków refundowanych lub występuje pod inną nazwą.<br /><br />";
s.style.color = '#f77';
}
}
function z3c()
{
var z3 = g('z3');
for(var i=0;i<z3.childNodes.length;i++)
{
var ch = z3.childNodes[i];
if(ch.nodeName.toUpperCase()=='DIV')
{
var inner = ch.innerHTML;
z3.removeChild(ch);
z3.innerHTML += inner;
break;
}
}
for(var i=0;i<z3.childNodes.length;i++)
{
var ch = z3.childNodes[i];
if(ch.nodeName.toUpperCase()=='A')
{
ch.style.fontSize = '9px';
ch.style.color = null;
}
}
}
