$(document).ready(function(){
	/* Colorbox für Bestelllinks */
	$(".colorbox_bestellen").colorbox({width:"400", height:"175", iframe:true, overlayClose:false, close:""});
	/* Colorbox für Detail Popup */
	$(".colorbox_detail").colorbox({width:"580", height:"450", iframe:true, overlayClose:false, close:""});
	/* Colorbox für Ausloggen */
	$(".colorbox_logout").colorbox({width:"400", height:"175", iframe:true, overlayClose:false, close:""});
	/* Colorbox für AGB */
	$(".colorbox_agb").colorbox({width:"600", height:"450", iframe:true, overlayClose:false, close:""});
	/* Colorbox für Adressen */
	$(".colorbox_adressen").colorbox({width:"580", height:"450", iframe:true, overlayClose:false, close:""});
	/* Wakoartikel entfernen */
	$("a.wako_del").click(function (){
		var id = $(this).attr("id").replace("wako_del_","");
		$("input[name=wako_anzahl_" + id +"]").val("0");
		$("input[name=wako_btn_submit_recalculate]").click();
	});
	/* Bestellung Details anzeigen */
	$("a.bestellungen_detail").click(function (){
		var id = $(this).attr("id").replace("bestellungen_detail_","");
		if ($("#wako_bestellungen_artikel_" + id).html() == '<hr>' || $("#wako_bestellungen_artikel_" + id).html() == '<HR>') {
			$("#wako_bestellungen_artikel_" + id).html('<div style="text-align:center;"><img src="/_images/wako_load.gif" alt="Bitte warten"/></div>');
			$.ajax ({
				type: 'GET',
				url: '/wako/ajax_bestellungen_details.cfm',
				data: 'bestellung_id=' + id,
				cache: false,
				success: function (html) {
					$("#wako_bestellungen_artikel_" + id).html(html);
				}
			});
		} else {
			$("#wako_bestellungen_artikel_" + id).html("<hr />");
		}
	});
});

function reload_adressen(type) {
	$('#adressen').html($('#wako_ajax_loader').html());
	$("#cboxClose").click();
	/*address_id = $('input[name=_address_id]:checked:first').val();*/
	$.ajax ({
			type: 'GET',
			url: '/wako/ajax_adressen.cfm',
			data: 'sub_step=' + type,
			cache: false,
			success: function (html) {
					$('#adressen').html (html);
					/* Rebind Colorbox für Adressen */
					$(".colorbox_adressen").colorbox({width:"580", height:"450", iframe:true, overlayClose:false, close:""});
			}
	});
}