function product_recalculate(c)
{
document.getElementById('min_prod').innerHTML = minimal_buy + ' ';
product_nb_obj = document.cn.product_nb;
if (product_nb_obj.value == '' && c == -1) return;
product_nb_val = parseInt(product_nb_obj.value);
if (isNaN(product_nb_val)) product_nb_val = 0;

if (product_nb_val < minimal_buy || product_nb_val > 32000)
	{
	alert('Należy podać liczbę zamawianych produktów.\nMożna zamówić: '+
	 minimal_buy + ' - 32000 sztuk tego produktu');
	return;	
	}
	
overprint_price = 0;
product_price = prod_price * product_nb_val;
// overprint
color_nb_val = document.cn.color_nb.value;

if (color_nb_val > 0)
	{
	if (product_nb_val <= lump_items_to) overprint_price = lump_price_pln * color_nb_val;
	else
		{
		for (i=0, i_cnt = items_f.length; i < i_cnt; i++)
			{
			if (product_nb_val >= items_f[i] && product_nb_val <= items_t[i])
				{
				ov_price = items_p[i];
				break;	
				}
			} // for				
	
		overprint_price += product_nb_val * ov_price * factor[color_nb_val];	
		} // else	
		
	overprint_price = Math.round(overprint_price*100)/100;	
	}		
// end overprint	

total_price = product_price + overprint_price;
document.getElementById('price_for_products').innerHTML = Math.round(product_price*100)/100;
document.getElementById('price_for_overprint').innerHTML = overprint_price;
document.getElementById('total').innerHTML = Math.round(total_price*100)/100;
document.getElementById('total_brutto').innerHTML = Math.round(total_price*122)/100;
}

function verify_calc()
{
if (document.cn.product_nb.value == '')
	{
	alert('Proszę podać liczbę produktów\nprzed wysłaniem zapytania!');	
	return false;	
	}	
if (confirm('Czy chcesz dodać powyższe wyliczenia do zapytania ofertowego?'))
	return true;
	
return false;	
}

function remove_cart(id)
{
z = document.getElementById('tr_'+id);	
z.style.backgroundColor = '#f0eeeb';	
if (confirm('Czy chcesz usun±ć z koszyka, zaznaczony produkt?'))
	location="koszyk.php?ac=delete&id="+id;		
else z.style.backgroundColor = '#ffffff';
} 

function switch_search(type)
{
hid_s_type = document.fs.s_type.value;	
if (type == -1) type = hid_s_type;
else document.fs.s_type.value = type;

div_af = document.getElementById('adv_form');
div_st = document.getElementById('stype');
if (type == 0)
	{
	div_af.style.display = 'none';
	div_st.innerHTML = '<b>' + s_type_txt[0] + '</b> / ' + '<a href="javascript:switch_search(1)">'
		+ s_type_txt[1] + '</a>';
 	}
else 
	{
	div_af.style.display = 'block';			
	div_st.innerHTML = '<a href="javascript:switch_search(0)">' + s_type_txt[0] +
		'</a> / ' + '<b>' + s_type_txt[1] + '</b>';
	}
}

function vm(m)
{
t='';
for (i=m.length-1; i >= 0; i--) if (m.charAt(i) == '*') t += '@'; else t +=m.charAt(i);
document.write('<a href="mailto:'+t+'">' + t +'</a>');
}  

function blurAnchors(){ 
if(document.getElementsByTagName) { 
var a = document.getElementsByTagName("a"); 
//collect all anchors A 
for(var i = 0; i < a.length; i++){ 
// mouse onfocus, blur anchors 
a[i].onfocus = function(){this.blur();}; 
} 
} 
} 
window.onload = blurAnchors;

 