function show(nr)

{
	for (i = 1; i < 3; i++) {
		
		var Name = document.getElementById('number'+i);
		var button = document.getElementById('bot'+i);

		if(nr == i){
			Name.style.display = 'block';
			button.className = 'on';
		}
		else {
			Name.style.display = 'none';
			button.className = 'offf';
		}
	}
}

Event.onDOMReady( function(){ 

	
	if($('quantity'))
		Event.observe($('quantity'), 'change', function(){ $('showprice').innerHTML = parseInt(this.value) * $('price').value.replace(",", ".") + ' лв.' } );

	if($('add2cart'))
		Event.observe($('add2cart'), 'click', function(){
			
			if(parseInt($('quantity').value) > 0)
			{
				var url = 'ajax_cart.php';
				var pars = 'action=add&product_id=' + $('product_id').value + '&quantity=' + $('quantity').value;
				var myAjax = new Ajax.Request(
					url, 
					{
						method: 'post', 
						parameters: pars, 
						onComplete: function(originalRequest){ $('cartwrapper').innerHTML = originalRequest.responseText; }
					});
			}
		});

	$A($$('a.order-del-btn')).each( function(obj){
		Event.observe(obj, 'click', function(){
			var url = 'ajax_cart.php';
			var pars = 'action=delete&product_id=' + this.rel.replace("id", "");
			var myAjax = new Ajax.Request(
				url, 
				{
					method: 'post', 
					parameters: pars, 
					onComplete: function(originalRequest){ window.location.reload(); }
				});
		});
	});

	$A($$('.changeq')).each( function(obj){
		Event.observe(obj, 'change', function(){
			var url = 'ajax_cart.php';
			var pars = 'action=update&product_id=' + this.id.replace("id", "") + '&quantity=' + this.value;
			var myAjax = new Ajax.Request(
				url, 
				{
					method: 'post', 
					parameters: pars, 
					onComplete: function(originalRequest){ window.location.reload(); }
				});
		});
	});

	var url = 'ajax_cart.php';
	var pars = 'action=get';
	var myAjax = new Ajax.Request(
		url, 
		{
			method: 'post', 
			parameters: pars, 
			onComplete: function(originalRequest){ $('cartwrapper').innerHTML = originalRequest.responseText; }
		});
} );