jQuery(document).ready(function(){
    // This button will increment the value
    $('.qtyplus').click(function(e){
        // Stop acting like a button
        e.preventDefault();
        // Get the field name
        fieldName = $(this).attr('field');
        // Get its current value
        var currentVal = parseInt($(this).siblings('input[name='+fieldName+']').val());
        // If is not undefined
        if (!isNaN(currentVal)) {
            // Increment
            $(this).siblings('input[name='+fieldName+']').val(currentVal + 1);
        } else {
            // Otherwise put a 0 there
           $(this).siblings('input[name='+fieldName+']').val(0);
        }
    });
    // This button will decrement the value till 0
    $(".qtyminus").click(function(e) {
        // Stop acting like a button
        e.preventDefault();
        // Get the field name
        fieldName = $(this).attr('field');
        // Get its current value
        var currentVal = parseInt($(this).siblings('input[name='+fieldName+']').val());
        // If it isn't undefined or its greater than 0
        if (!isNaN(currentVal) && currentVal > 0) {
            // Decrement one
            $(this).siblings('input[name='+fieldName+']').val(currentVal - 1);
        } else {
            // Otherwise put a 0 there
            $(this).siblings('input[name='+fieldName+']').val(0);
        }
    });
	$(".big_image").click(function(){
		var index = $(this).css("z-index");
		$(this).css("z-index",index-2);
	});
});

function show_alert(alert_data) {
	 
	 $('#top').css('display','table-cell');
	 $('#alert').show().append(alert_data);
	 $('body').click(function(){
	 $('#top').hide();$('#alert').hide()});
 };

function show_Form(alert_data) {
	 
	 $('#top').css('display','table-cell');
	 $('#alert').show().append(alert_data);
	  };

function add_artikel(data) {
	 $.get('includes/add.inc.php?id=' + data,function(antwort){
	 $('#top').css('display','table-cell');
	 $('#alert').show().html(antwort);
	 $('body').click(function(){
	 $('#top').hide();$('#alert').hide()});
	 });
 };
 
function showInclude(include){
	$('#top').css('display','table-cell');
	$.ajax({ type: "GET",   
     url: include,   
     success : function(text)
     {
         
	 $('#include').html(text).prepend('<p style="position:absolute;top:2;right:2;"><img src="images/fancy_closebox.gif" onClick="$(\'#top\').hide();$(\'#include\').hide();">');
     }
});
	$('#include').show();
	
};
function showForm(include, position){
	$('#top').css('display','table-cell');
	$.ajax({ type: "GET",   
     url: include,   
     success : function(text)
     {
         
	 $('#include').css({top:position.top-450,left:position.left-250,'position':'absolute'}).html(text).prepend('<p style="position:absolute;top:2;right:2;"><img src="images/fancy_closebox.gif" onClick="$(\'#top\').hide();$(\'#include\').hide();">');
     }
});
	$('#include').show();
	
};
 $(function() {
    $('#agb_ceck').click(function() {
        if ($(this).is(':checked')) {
            $('#bestellung_absenden').removeAttr('disabled');
        } else {
            $('#bestellung_absenden').attr('disabled', 'disabled');
        }
    });
});