$(document).ready(function(){


	/*****************************************************************
		Produkt Optionen aktiv setzen
	*****************************************************************/
	$('input[@checktype=product_option]').each(function(){

		var id = this.id;
	 	$('#'+id).bind("click", function(e){
			
			$.post("../modules/shop/js_events.php", { 'form': 'product_option', 'id':id, 'active': $('#' + id).attr("checked") }, function(status){
				if (status != "ok"){
					alert('failed to save');
				}
			});
	 	})
	});


	/*****************************************************************
		Order Optionen aktiv setzen
	*****************************************************************/
	$('input[@checktype=order_option]').each(function(){

		var id = this.id;
	 	$('#'+id).bind("click", function(e){
			
			$.post("../modules/shop/js_events.php", { 'form': 'order_option', 'id':id, 'active': $('#' + id).attr("checked") }, function(status){
				if (status != "ok"){
					alert('failed to save');
				}
			});
	 	})
	});


	/*****************************************************************
		Produkt Optionswerte aktiv setzen
	*****************************************************************/
	$('input[@checktype=product_option_value_active]').each(function(){

		var id = this.id;
	 	$('#'+id).bind("click", function(e){
			
			$.post("../modules/shop/js_events.php", { 'form': 'product_option_value', 'id':id, 'active': $('#' + id).attr("checked") }, function(status){
				if (status != "ok"){
					alert('failed to save');
				}
			});
	 	})
	});


	/*****************************************************************
		Produkt Optionswerte als Default setzen
	*****************************************************************/
	$('input[@checktype=product_option_value_default]').each(function(){

		var id = this.id;
	 	$('#'+id).bind("click", function(e){
			
			$.post("../modules/shop/js_events.php", { 'form': 'product_option_value', 'id':id, 'default': $('#' + id).attr("checked") }, function(status){
				if (status != "ok"){
					alert('failed to save');
				}
			});
	 	})
	});



	/*****************************************************************
		Super Values aktiv setzen
	*****************************************************************/
	$('input[@checktype=super_value_active]').each(function(){

		var id = this.id;
	 	$('#'+id).bind("click", function(e){
			
			$.post("../modules/shop/js_events.php", { 'form': 'super_value', 'id':id, 'active': $('#' + id).attr("checked") }, function(status){
				if (status != "ok"){
					alert('failed to save');
				}
			});
	 	})
	});


	/*****************************************************************
		Super Values single match setzen
	*****************************************************************/
	$('input[@checktype=super_value_single_match]').each(function(){

		var id = this.id;
	 	$('#'+id).bind("click", function(e){
			
			$.post("../modules/shop/js_events.php", { 'form': 'super_value_single_match', 'id':id, 'single_match': $('#' + id).attr("checked") }, function(status){
				if (status != "ok"){
					alert('failed to save');
				}
			});
	 	})
	});

	/*****************************************************************
		Order Optionswerte aktiv setzen
	*****************************************************************/
	$('input[@checktype=order_option_value_active]').each(function(){

		var id = this.id;
	 	$('#'+id).bind("click", function(e){
			
			$.post("../modules/shop/js_events.php", { 'form': 'order_option_value', 'id':id, 'active': $('#' + id).attr("checked") }, function(status){
				if (status != "ok"){
					alert('failed to save');
				}
			});
	 	})
	});


	/*****************************************************************
		Order Optionswerte als Default setzen
	*****************************************************************/
	$('input[@checktype=order_option_value_default]').each(function(){

		var id = this.id;
	 	$('#'+id).bind("click", function(e){
			
			$.post("../modules/shop/js_events.php", { 'form': 'order_option_value', 'id':id, 'default': $('#' + id).attr("checked") }, function(status){
				if (status != "ok"){
					alert('failed to save');
				}
			});
	 	})
	});



	/*****************************************************************
		Order Optionen Typauswahl
	*****************************************************************/
	$('select[@checktype=order_option_type]').each(function(){

		var id = this.id;
	 	$('#'+id).bind("change", function(e){
			
			$.post("../modules/shop/js_events.php", { 'form': 'order_option_type', 'id':id, 'type_id': $('#' + id).val() }, function(status){
				if (status != "ok"){
					alert('failed to save');
				}
			});
	 	})
	});


	/*****************************************************************
		Default in Variationsliste
	*****************************************************************/
	$('input[@checktype=edition_default]').each(function(){

		var id = this.id;
	 	$('#'+id).bind("change", function(e){
			
			$.post("../modules/shop/js_events.php", { 'form': 'edition_default', 'id':id, 'default': $('#' + id).attr('checked') }, function(status){
				if (status != "ok"){
					alert('failed to save');
				}
			});
	 	})
	});

	
	/*****************************************************************
		Sonderangebot aktivieren
	*****************************************************************/
	$('input[@checktype=product_offer_active]').each(function(){

		var id = this.id;
	 	$('#'+id).bind("change", function(e){
			
			$.post("../modules/shop/js_events.php", { 'form': 'product_offer_active', 'id':id, 'active': $('#' + id).attr('checked') }, function(status){
				if (status != "ok"){
					alert('failed to save');
				}
			});
	 	})
	});


	/*****************************************************************
		Shop AGB bestätigen
	*****************************************************************/
 	$('#agb_check').bind("click", function(e){
 		if ($('#agb_check').attr('checked') == true){		
			$('#submit_order_button').fadeIn(300);
		}
		else
			$('#submit_order_button').fadeOut(300);
 	})




	/*****************************************************************
		Order Refund
	*****************************************************************/
	$('input[@checktype=refund]').each(function(){

		var id = this.id;
	 	$('#'+id).bind("change", function(e){
			
			$.post("../modules/shop/js_events.php", { 'form': 'refund', 'id':id, 'checked': $('#' + id).attr("checked") }, function(status){
				if (status != "ok"){
					alert('failed to save');
				}
			});
	 	})
	});


	/*****************************************************************
		Order Finished
	*****************************************************************/
	$('input[@checktype=order_finished]').each(function(){

		var id = this.id;
	 	$('#'+id).bind("change", function(e){
			
			$.post("../modules/shop/js_events.php", { 'form': 'order_finished', 'id':id, 'checked': $('#' + id).attr("checked") }, function(status){
				if (status != "ok"){
					alert('failed to save');
				}
			});
	 	})
	});


	/*****************************************************************
		Order Finished
	*****************************************************************/
	$('input[@checktype=datepicker]').each(function(){
		$('#'+this.id).datepicker({
			dateFormat: 'dd.mm.yy',
			onSelect: function(dateText){ 

				$.post("../modules/shop/js_events.php", { 'form': 'set_product_date', 'id':this.id, 'value': dateText }, function(status){
					if (status != "ok"){
						alert('failed to save');
					}
				});
    			
  			} 
		});
	
/*		var id = this.id;
	 	$('#'+id).bind("change", function(e){
			
			$.post("../modules/shop/js_events.php", { 'form': 'order_finished', 'id':id, 'checked': $('#' + id).attr("checked") }, function(status){
				if (status != "ok"){
					alert('failed to save');
				}
			});
	 	})
	 	*/
	});




});