
$(function() {
	$('.menu_level_0').mouseover(function() {
		$(this).addClass("active");
		$(this).find('div.sub_menu').show();
	});
	$('.menu_level_0').mouseout(function() {
		$(this).removeClass("active");
		$(this).find('div.sub_menu').hide();
	});
});

function plus(id_product, also_set_basket) {
	$("#pieces" + id_product).val(parseInt($("#pieces" + id_product).val()) + 1);
	if(also_set_basket) {
	
		$.ajax({
			type: "GET",
			url: "http://www.prestigereal.sk/scripts/small_basket.php",
			data: "set="+id_product+"&pieces="+$("#pieces"+id_product).val(),
			success: function(msg){
				$("#small_basket").html(msg);
				$.ajax({
					type: "GET",
					url: "http://www.prestigereal.sk/scripts/basket.php",
					data: "",
					success: function(msg){
						$("#basket").html(msg);
						$.ajax({
							type: "GET",
							url: "http://www.prestigereal.sk/scripts/order_submit.php",
							data: "url1=" + $('url1').text(),
							success: function(msg2){
								$("#order_submit").html(msg2);
							}
						});
					}
				});
			}
		});
		
	}
}

function minus(id_product, also_set_basket) {
	if(also_set_basket) {
		if($("#pieces" + id_product).val() > 0) $("#pieces" + id_product).val(parseInt($("#pieces" + id_product).val()) - 1);
		$.ajax({
			type: "GET",
			url: "http://www.prestigereal.sk/scripts/small_basket.php",
			data: "set="+id_product+"&pieces="+$("#pieces"+id_product).val(),
			success: function(msg){
				$("#small_basket").html(msg);
				$.ajax({
					type: "GET",
					url: "http://www.prestigereal.sk/scripts/basket.php",
					data: "",
					success: function(msg){
						$("#basket").html(msg);
						$.ajax({
							type: "GET",
							url: "http://www.prestigereal.sk/scripts/order_submit.php",
							data: "url1=" + $('url1').text(),
							success: function(msg2){
								$("#order_submit").html(msg2);
							}
						});
					}
				});
			}
		});
	}
	else {
		if($("#pieces" + id_product).val() > 1) $("#pieces" + id_product).val(parseInt($("#pieces" + id_product).val()) - 1);
	}
}

function to_basket(id_product) {
	$("#small_basket").fadeOut("fast");
	$.ajax({
		type: "GET",
		url: "http://www.prestigereal.sk/scripts/small_basket.php",
		data: "add="+id_product+"&pieces="+$("#pieces"+id_product).val(),
		success: function(msg){
			$("#small_basket").html(msg);
		}
	});
	$("#small_basket").fadeIn("fast");
}

function checkemail(str){
	var filter=/^.+@.+\..{2,3}$/
	
	if(filter.test(str)) testresults = true;
	else {
	    testresults = false;
	}
	return (testresults);
}

function mandatory_client() {
	var chyba = false;
											if(document.getElementsByName("agree_op")[0].checked == false) { document.getElementById("agree_op_label").className = "mandatory_input"; chyba = true; } else { document.getElementById("agree_op_label").className = ""; }
	
	if(chyba) return false;
	return true;
}


