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




function product_recalculate()
{
	
var nb_item = $("#pr_item").val();	
if (nb_item != '' && isNaN(nb_item) == true)  
	{
	nb_item = 1;
	$("#pr_item").val('1');
	}


var  pr_total = parseFloat(price * nb_item);
$("#pr_value").html(pr_total.toFixed(2));
}



function add_cart(id)
{
var op_status = document.getElementById('cart_status');	
op_status.style.display = 'block';
$.post("/sklep/5002,add", { id:id, pr_item: document.getElementById('pr_item').value},
	function(data){
	 tmp = data.split("|");
	 op_status.innerHTML = tmp[1];
	 if (tmp[0] == 1) 
	 	{	
	 	document.getElementById('pr_item').value = 1;
	 	document.getElementById('cart_data').innerHTML = tmp[2];
	 	}
	 
	 product_recalculate();
	});	
}


function cart_del(pid)
{
$("#tr_"+pid + ' TD').addClass("TRSD");

if(confirm(tx.del  + '\r\n' + $("#pn_"+pid).text()))
 {
 $("#pr_item_" + pid).val('0');
 document.xs.submit(); 
 }
else $("#tr_"+pid + ' TD').removeClass("TRSD");
} 

function cart_edit(p, id)
{
var input_p = $("#pr_item_" + id);	
var nb_item = input_p.val();

if (nb_item != '' && isNaN(nb_item) == true)  
	{
	nb_item = 0;
	input_p.val('0');
	}
		
var price_ch = prices[p] * nb_item;	
$('#pr_value_' + id).text(price_ch.toFixed(2));

var total_price = 0;
i = 0
$('input[name*="pr_item"]').each(function(){ 
	   total_price += prices[i] * $(this).val();	
	   i++;
	  })

$('#cart_total').html('<b>' + total_price.toFixed(2) + '</b>')
}


function order_sub(txt)
{
if (confirm(txt))
	{
	document.xs.submit();		
	}
}

function go_url(id, param)
{
var urls = new Array('', 'obiekt_miesiaca', 'wystawy', 'oferta', 'edukacja', 'zbiory', 'aktualnosci', 'sklep');	
window.location = '/' + urls[id] + '/' + param;	
}


function hide_afav(id)
{
$("#afav_" + id).css('display', 'none');
}

function bprn()
{
var url = document.location.href.replace("#top", "");
if (url.indexOf('?') === -1) url += '?';
window.open (url + '&print=1', "bip_print", "menubar=1, scrollbars=yes,resizable=0,width=725,height=500"); 
}


$().ready(function() {
Cufon.replace('h1'); 
});
