function ajax_plus(Item, Max){
	if ($("#quant_input"+Item).val() == Max) return false;
	$("#loader_plus"+Item).show();
	$.ajax({
		type: 'POST',
		url: 'cart_action.php',
		dataType: 'json',
		data: {
			action: 'ajax-plus',
			item: Item
		},
		success: function(data){
			$('#waiting').hide();
			$('#submit').show();
			$("#loader_plus"+Item).hide();
			$("#quant_input"+Item).val(data.count);
			$("#total").html(data.total);
		},
		error: function(XMLHttpRequest, textStatus, errorThrown) {
			$("#loader_plus"+Item).hide();
		}
	});
	return false;
}
function ajax_minus(Item, Max){
	if($("#quant_input"+Item).val() == '1') return false;
	$("#loader_minus"+Item).show();
	$.ajax({
		type: 'POST',
		url: 'cart_action.php',
		dataType: 'json',
		data: {
			action: 'ajax-minus',
			item: Item
		},
		success: function(data){
			$('#waiting').hide();
			$('#submit').show();
			$("#loader_minus"+Item).hide();
			$("#quant_input"+Item).val(data.count);
			if (data.count <= Max){
				$("#persp_"+Item).hide();
			}
			$("#total").html(data.total);
		},
		error: function(XMLHttpRequest, textStatus, errorThrown) {
			$("#loader_minus"+Item).hide();
		}
	});
	return false;
}
function minus_amount(){
	var amount=document.getElementById('quant_input').value;
	amount--;
	if(amount<1){
		amount=1;
	}
	document.getElementById('quant_input').value=amount;
	check_amount();
}
function plus_amount(){
	var amount=document.getElementById('quant_input').value;
	amount++;
	document.getElementById('quant_input').value=amount;
	check_amount();
}
function check_amount(){
	var amount=document.getElementById('quant_input').value;
	var max=document.getElementById('count').value;
	amount = parseInt(amount);
	max = parseInt(max);
	if(amount<1){
		document.getElementById('quant_input').value=1;
	}
	if(amount>max){
		document.getElementById('persp').style.visibility  = "visible";
		document.getElementById('cart_pic').src = "images/prop_cart_add_off.gif";
		document.getElementById('cart_pic').disabled = true;
	}else{
		document.getElementById('persp').style.visibility  = "hidden";
		document.getElementById('cart_pic').src = "images/prop_cart_add.gif";
		document.getElementById('cart_pic').disabled = false;
	}
}
function mazink(){
	var max=document.getElementById('count').value;
	document.getElementById('quant_input').value = max;
	document.getElementById('persp').style.visibility  = "hidden";
	document.getElementById('cart_pic').src = "images/prop_cart_add.gif";
	document.getElementById('cart_pic').disabled = false;
}
function selectAll(){
	for (i = 0; i < groups.length; i++){
		var field = groups.elements[i];
		if (field.type == "checkbox"){
	 		field.checked=true;
		}	
	}	
}
function UnSelectAll(){
	for (i = 0; i < groups.length; i++){
		var field = groups.elements[i];
		if (field.type == "checkbox"){
	 		field.checked=false;
		}	
	}	
}
function showVoteForm(){
	document.getElementById('sendtofriendbar').style.display="none";
	document.getElementById('votebar').style.display="block";
}
function showRekomendForm(){
	document.getElementById('votebar').style.display="none";
	document.getElementById('sendtofriendbar').style.display="block";
}
function check_amount2(item){
	var maxcount=document.getElementById('max_amount_'+item).value;
	var inserted=document.getElementById('insert_'+item).value;
	maxcount = parseInt(maxcount);
	inserted = parseInt(inserted);
	if(inserted > maxcount){
		document.getElementById('desc_'+item).style.display="none";
		document.getElementById('err_'+item).style.display="block";
		inserted=document.getElementById('insert_'+item).className="fb_quant_input";
		change_addcart_url(item,0)
	}else{
		document.getElementById('err_'+item).style.display="none";
		document.getElementById('desc_'+item).style.display="block";
		inserted=document.getElementById('insert_'+item).className="quant_input";
		change_addcart_url(item,1)
	}
}
function change_amount(item){
	var maxcount=document.getElementById('max_amount_'+item).value;
	document.getElementById('insert_'+item).value=maxcount;
	check_amount2(item);
}
function showmore(){
	document.getElementById('ls_more').style.display="none";
	document.getElementById('hidden_vendors').style.display="block";
	document.getElementById('ls_less').style.display="block";
}
function showless(){
	document.getElementById('ls_more').style.display="block";
	document.getElementById('hidden_vendors').style.display="none";
	document.getElementById('ls_less').style.display="none";
}
function morebrands(){
	document.getElementById('br_more').style.display="none";
	document.getElementById('hidden_brands').style.display="block";
	document.getElementById('br_less').style.display="block";
}
function lessbrands(){
	document.getElementById('br_more').style.display="block";
	document.getElementById('hidden_brands').style.display="none";
	document.getElementById('br_less').style.display="none";
}
