/******************************************************************
* Functions for ProductDetailPage *
*******************************************************************/

			function popup(url) {
				window.open(url, 'Popup','width=795,height=600,scrollbars=yes,toolbar=no');
			}


			function removeAllOptionsFromSelectbox(from) {
				for (var i=(from.options.length-1); i>=0; i--) {
					from.options[i] = null;
				}
				from.selectedIndex = -1;
			}

			function getVariant(s_id, p_id, a1_id, a2_id) {
				try {

				if (a2_id) { // genaue variante
					if (!a1_id) {
						a1_id = '';
					}
					return variants_by_click["via_sid"][s_id]["via_pid"][p_id]["via_a1"][a1_id]["via_a2"][a2_id]["first"];
				}
				else if (a1_id) { // erste anhand attribut 1
					if (variants_by_click["via_sid"][s_id]["via_pid"][p_id]["via_a1"][a1_id]["first_available"]) {
						return variants_by_click["via_sid"][s_id]["via_pid"][p_id]["via_a1"][a1_id]["first_available"];
					}
					else {
						return variants_by_click["via_sid"][s_id]["via_pid"][p_id]["via_a1"][a1_id]["first"];
					}
				}
				else if (p_id) { // erste anhand des produkts
					if (variants_by_click["via_sid"][s_id]["via_pid"][p_id]["first_available"]) {
						return variants_by_click["via_sid"][s_id]["via_pid"][p_id]["first_available"];
					}
					else {
						return variants_by_click["via_sid"][s_id]["via_pid"][p_id]["first"];
					}
				}
				else if (s_id) { // erste in der saison
					if (variants_by_click["via_sid"][s_id]["via_pid"][p_id]["first_available"]) {
						return variants_by_click["via_sid"][s_id]["first_available"];
					}
					else {
						return variants_by_click["via_sid"][s_id]["first"];
					}
				}
				else {
					if (variants_by_click["via_sid"][s_id]["via_pid"][p_id]["first_available"]) {
						return variants_by_click["first_available"];
					}
					else {
						return variants_by_click["first"];
					}
				}

				} catch(e) {
					return null;
				}
			}


			function updateDetails(s_id, p_id, a1_id, a2_id) {
				var variant 		= getVariant(s_id, p_id, a1_id, a2_id);
				if (!variant) {
					$("a1_selectbox").value = $("attribute_id1").value;
					$("a2_selectbox").value = $("attribute_id2").value;
					alert(i18n_no_variant_found);
					return;
				}

				var variant_id		= variant["variant_id"];
				var product_id		= variant["product_id"];
				var product 		= products_array[product_id];
				var product_text 	= product_texts_array[product["text_hash"]];
				var season_id		= variant["season_id"];
				var season 		= seasons_array[season_id];
				var attribute_id1	= variant["attribute_id1"];
				var attribute_id2	= variant["attribute_id2"];

				$("product_title").update(product["title"]);
				$("product_code").update(product["code"]);
				$("season_description").update(season["desc"]);
				$("product_text").update(product_text);
				$("product_material").update(product["material"]);
				if (product["material"] == "") {
					$("product_material_block").style.display = "none";
				}
				else {
					$("product_material_block").style.display = "block";
				}
				$("a1_type_desc").update(product["a1_type_desc"]);
				$("a2_type_desc").update(product["a2_type_desc"]);

				$("variant_img_l").src = variant["variant_img_l"];
				$("variant_img_l").alt = product["title"];

				$("variant_img_xl_a").href = variant["variant_img_xl"];
				$("variant_img_xl_a").title = product["title"] + " - " + product["code"] + " - " + season["desc"];

				$("variant_list_price").update(variant["variant_list_price"]);
				//$("variant_customer_price").update(variant["variant_customer_price"]);
				$("variant_customer_price_1").update(variant["variant_customer_price_1"]);
				$("variant_customer_price_3").update(variant["variant_customer_price_3"]);
				$("variant_customer_price_4").update(variant["variant_customer_price_4"]);

				$("variant_available_no_offer_request_pending").style.display = "none";
				if (variant["variant_available"] == "yes") {
					$("variant_available_never").style.display 	= "none";
					$("variant_available_possible").style.display 	= "none";
					$("variant_available_no").style.display 	= "none";
					$("variant_available_from").style.display 	= "none";
					$("variant_available_yes").style.display 	= "block";
					$("variant_availibility_string").update(i18n_variant_available_yes_str + '<br>' + variant["variant_delivery_time"]);
					$("variant_availibility_string").className		= "a_d_preisanzeige_lieferbar";
				}
				else if (variant["variant_available"] == "no") {
					$("variant_available_never").style.display 	= "none";
					$("variant_available_possible").style.display 	= "none";
					$("variant_available_from").style.display 	= "none";
					$("variant_available_yes").style.display 	= "none";
					$("variant_available_no").style.display 	= "block";
					$("variant_availibility_string").update(i18n_variant_available_no_str);
					$("variant_availibility_string").className		= "a_d_preisanzeige_ausverkauft";
				}
				else if (variant["variant_available"] == "possible") {
					$("variant_available_never").style.display 	= "none";
					$("variant_available_from").style.display 	= "none";
					$("variant_available_yes").style.display 	= "none";
					$("variant_available_no").style.display 	= "none";
					$("variant_available_possible").style.display 	= "block";
					$("variant_availibility_string").update(i18n_variant_available_possible_str);
					$("variant_availibility_string").className		= "a_d_preisanzeige_lieferbarab";
				}
				else if (variant["variant_available"] == "never") {
					$("variant_available_from").style.display 	= "none";
					$("variant_available_possible").style.display 	= "none";
					$("variant_available_yes").style.display 	= "none";
					$("variant_available_no").style.display 	= "none";
					$("variant_available_never").style.display 	= "block";
					$("variant_availibility_string").update(i18n_variant_available_never_str);
					$("variant_availibility_string").className		= "a_d_preisanzeige_ausverkauft";
				}
				else if (variant["variant_available"] == "from") {
					$("variant_available_never").style.display 	= "none";
					$("variant_available_possible").style.display 	= "none";
					$("variant_available_yes").style.display 	= "none";
					$("variant_available_no").style.display 	= "none";
					$("variant_available_from").style.display 	= "block";
					if (language == 'de') {
						$("variant_availibility_string").update(i18n_variant_available_from_str + '<br>' + variant["variant_available_date"].replace(/^(\d+)\-(\d+)\-(\d+)/, '$3.$2.$1'));
					}
					else {
						$("variant_availibility_string").update(i18n_variant_available_from_str + '<br>' + variant["variant_available_date"]);
					}
					$("variant_availibility_string").className		= "a_d_preisanzeige_lieferbarab";
				}

				// selectboxen neu befuellen
				removeAllOptionsFromSelectbox($("a1_selectbox"));
				var i = 0;
				var visible_i = 0;
				for (var attr_id in product["possible_a1"]) {
					if (attr_id != "") {
						$("a1_selectbox").options[i] = new Option(product["possible_a1"][attr_id], attr_id);
						i++;
					}

					if (product["possible_a1"][attr_id] != "") {
						visible_i++;
					}
				}
				if (visible_i>0) {
					$("a1_selectbox").style.display = "block";
					$("a1_type_desc_block").style.display = "block";
				}
				else {
					$("a1_selectbox").style.display = "none";
					$("a1_type_desc_block").style.display = "none";
				}
				removeAllOptionsFromSelectbox($("a2_selectbox"));
				i = 0;
				visible_i = 0;
				for (var attr_id in product["possible_a2"]) {
					if (attr_id != "") {
						$("a2_selectbox").options[i] = new Option(product["possible_a2"][attr_id], attr_id);
						i++;
					}

					if (product["possible_a2"][attr_id] != "") {
						visible_i++;
					}
				}
				if (visible_i>0) {
					$("a2_selectbox").style.display = "block";
					$("a2_type_desc_block").style.display = "block";
				}
				else {
					$("a2_selectbox").style.display = "none";
					$("a2_type_desc_block").style.display = "none";
				}

				// more link anpassen
				if (language == "fr") {
					if (product["fr_text_set"] == "1") {
						$("more_link2").style.display = "none";
						$("more_link").update(i18n_more_link);
						$("more_link").href = 'JavaScript:show_more_detail($F(\'variant_id\'), \'fr\');';
					}
					else {
						$("more_link2").style.display = "inline";
						$("more_link").update(i18n_more_link_en);
						$("more_link").href = 'JavaScript:show_more_detail($F(\'variant_id\'), \'en\');';
						$("more_link2").update(i18n_more_link_de);
						$("more_link2").href = 'JavaScript:show_more_detail($F(\'variant_id\'), \'de\');';
					}
				}

				$("a1_selectbox").value = attribute_id1;
				$("a2_selectbox").value = attribute_id2;
				$("attribute_id1").value = attribute_id1;
				$("attribute_id2").value = attribute_id2;
				$("product_id").value = product_id;
				$("season_id").value = season_id;
				$("variant_id").value = variant_id;

			}

			function updateDetailsBySelectbox() {
				updateDetails($F("season_id"), $F("product_id"), $F("a1_selectbox"), $F("a2_selectbox"));
			}


			function validateEmail(email) {
					if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)) {
						return true;
					}
					else {
						return false;
					}
			}


			function sendOfferRequest(quant) {
				var email = $F('email');
				if (validateEmail(email)) {
					$("variant_available_no").style.display = "none";
					new Ajax.Request('likecms.php?site=ajax.html', {
						method:		'post',
						parameters:	{
										'get':		'offer_request',
										'email':		email,
										'qt':		quant,
										'vid':		$F('variant_id')
									},
						onCreate:		function() {
										$('ajax_loader').show();
									},
						onSuccess:	function(transport) {
										$("variant_available_no_offer_request_pending").style.display = "block";
										$('ajax_loader').hide();
										//alert(transport.responseText);
									}
					});
				}
				else {
					alert(i18n_offer_request_wrong_email_string);
				}
			}




function add2basket(quant){																/* aktuelle Variation in den Warenkorb werfen */
	new Ajax.Request(ajax_url, {
		method: 'post',
		parameters: {	get:		'basket_add',
						add_prod:	$F('variant_id'),
						qt:			quant
					},
		onCreate:	function(){
			$('ajax_loader').show();
		},
		onSuccess:	function(transport){
			$('ajax_loader').hide();

			$('popup_container_schatten').show();
			$('popup_container').show();

			$('pc_2').update('<p>'+$('product_title').innerHTML+'</p>');

			if($('a1_selectbox')) {
				if($('a1_selectbox').visible()) {
					var vari_str_1 = $('a1_type_desc').innerHTML + ': ' + $('a1_selectbox')[$('a1_selectbox').selectedIndex].text;
					$('pc_3').update('<p>'+vari_str_1+'</p>');
					$('pc_3').show();

				} else { $('pc_3').hide();}
			} else { $('pc_3').hide();}

			if($('a2_selectbox')) {
				if($('a2_selectbox').visible()) {
					var vari_str_2 = $('a2_type_desc').innerHTML + ': ' + $('a2_selectbox')[$('a2_selectbox').selectedIndex].text;
					$('pc_4').update('<p>'+vari_str_2+'</p>');
					$('pc_4').show();

				} else { $('pc_4').hide();}
			} else { $('pc_4').hide();}

			$('pc_5').update('<p>' + i18n_count_str + ': '+quant+'</p>');

			$('minibasket').update(transport.responseText);


		}
	});
}
function add2wishlist(){																/* aktuelle Variation in den Warenkorb werfen */
	document.location.href	= $F('basket_url') + '&wl_add_prod='+$F('variant_id');
}

function close_basket_info() {
	$('popup_container_schatten').hide();
	$('popup_container').hide();
}

function goto_basket() {
	document.location.href	= $F('basket_url') + '&show_b=1';
}


function show_more_detail(variant_id, lang) {

	var popup_url	= ajax_url + '&get=more_popup&v_id=' + variant_id + '&langu=' + lang;

	more_popup= window.open(popup_url,'more'+variant_id, 'width=430,height=550,status=yes,scrollbars=yes,resizable=yes');

	more_popup.focus();

}
/******************************************************************
* Functions for Basket
*******************************************************************/

function compare_country(){
	if($F('re_land') != $F('lieferlandauswahl')) {
		$('lieferadresse').selectedIndex=0;
		enableForm('lieferung');
	}
}

function enableForm(form) {
	var re_elements=new Array('re_anrede',
								're_name1',
								're_name2',
								're_ansprech',
								're_strasse',
								're_plz',
								're_ort',
								're_land',
								'email',
								'vorwahl1', 'telefon1',
								'vorwahl2', 'telefon2',
								'vorwahlmob', 'telefonmob',
								'vorwahlfax', 'fax',
								'lieferadresse',
								'validate_form');
	if(form == 'rechnung') {
		re_elements.each(function(s,index) {
			$(s).enable();
		});
		$('validate_form').removeClassName('disabled');
	}
	if(form == 'rechnung_disable') {
		if ($('liefer_adr').visible()) {
		re_elements.push('l_anrede',
								'l_name1',
								'l_name2',
								'l_ansprech',
								'l_strasse',
								'l_plz',
								'l_ort');
		}
		re_elements.each(function(s,index) {
			$(s).disable();
		});
		$('validate_form').addClassName('disabled');

	}
	if(form == 'lieferung') {

		var elements=new Array('l_anrede',
								'l_name1',
								'l_name2',
								'l_ansprech',
								'l_strasse',
								'l_plz',
								'l_ort');

		if ($F('lieferadresse') == 're_ad') {
			if (($F('re_land') == $F('lieferlandauswahl')) || ($F('re_land') == '') ) {
				$('liefer_adr').hide();

				elements.each(function(s,index) {
					$(s).disable();
				});
			} else if(!$('country_mism-E')){ // nur wenn der error noch nicht ausgegeben wurde
				var info_str = '<div id="country_mism-E" class="errMsg">'+$F('country_mism_error')+'</div>';
				new Insertion.After('lieferadresse',info_str);

			}
		} else if ($F('lieferadresse') == 'abw') {
			$('liefer_adr').show();

			elements.each(function(s,index) {
				$(s).enable();
			});
		}
	}
}

function validateForm(step) {
	wFORMS.showAlertOnError = false;
	wFORMS.behaviors['validation'].errMsg_notification	= "%% Fehler gefunden.\nBitte &uuml;berpr&uuml;fen Sie Ihre Angaben.";
  	wFORMS.behaviors['validation'].errMsg_required		= "Dies ist ein Pflichtfeld";
	wFORMS.behaviors['validation'].errMsg_alpha 		= "Bitte verwenden Sie nur Buchstaben (a-z, A-Z). Zahlen sind nicht erlaubt.";
	wFORMS.behaviors['validation'].errMsg_email 		= "Dies scheint keine korrekte E-Mail-Adresse zu sein.";
	wFORMS.behaviors['validation'].errMsg_integer 		= "Bitte verwenden Sie nur Ziffern.";
	wFORMS.behaviors['validation'].errMsg_alphanum 		= "Bitte verwenden Sie nur Buchstaben oder Ziffern [a-z 0-9].";
	wFORMS.behaviors['validation'].errMsg_custom		= "Dies ist keine g&uuml;ltige Eingabe.";
	var elements=new Array('re_anrede',
								're_name1',
								're_name2',
								're_ansprech',
								're_strasse',
								're_plz',
								're_ort',
								're_land',
								'email',
								'vorwahl1', 'telefon1',
								'vorwahl2', 'telefon2',
								'vorwahlmob', 'telefonmob',
								'vorwahlfax', 'fax',
								'lieferadresse',
								'l_anrede',
								'l_name1',
								'l_name2',
								'l_ansprech',
								'l_strasse',
								'l_plz',
								'l_ort');

	var errors = 0;

	elements.each(function(s,index) {
		if (!$(s).disabled) {
			if(wFORMS.behaviors['validation'].validateElement($(s)) == 1){
				errors++;
			}
		}
	});

	if((step == 'step1') && (errors == 0)) {
			if ($F('re_land') == $F('lieferlandauswahl')) {						// Rechnungsland gleich lieferland
				confirm_data();
			} else if ($('liefer_adr').visible() && (errors == 0)) {			// r_l ungleich l_l aber lieferland eingegeben felder sichtbar und kein Error
				confirm_data();
			} else {															// sonst - hinweis f�r nutzer
				$('lieferadresse').selectedIndex=0;
				enableForm('lieferung');
				if(!$('country_mism-E')) { 										// nur wenn der error noch nicht ausgegeben wurde
					var info_str = '<div id="country_mism-E" class="errMsg">'+$F('country_mism_error')+'</div>';
					new Insertion.After('lieferadresse',info_str);
				}

			}

	} else if((step == 'customer_data') && (errors == 0)) {
		$('change_customer_data').submit();
	}
}

function confirm_data(){
	$('inprint_ra')		.show();
	$('t_shipping')		.hide();
	$('rechn_adr')		.hide();
	$('validate_form')	.up(2).hide();

	if($('loginstatus')) {
		$('loginstatus')	.disable();
		$('inp_c_'+$F('loginstatus')).show();
	}

	$('del_country')		.update($('lieferlandauswahl')	[$('lieferlandauswahl')	.selectedIndex].text);
	$('payment_type')		.update($('zahlungsart')		[$('zahlungsart')		.selectedIndex].text);

	$('inp_re_anrede')		.update($F('re_anrede'));
	$('inp_re_name1')		.update($F('re_name1'));
	$('inp_re_name2')		.update($F('re_name2'));							if($F('re_name2') == ''){							$('inp_re_name2').up().hide();}
	$('inp_re_ansprech')	.update($F('re_ansprech'));							if($F('re_ansprech') == ''){						$('inp_re_ansprech').up().hide();}
	$('inp_re_strassenummer').update($F('re_strasse'));
	$('inp_re_plz')			.update($F('re_plz'));
	$('inp_re_ort')			.update($F('re_ort'));
	$('inp_re_land')		.update($('re_land')			[$('re_land')			.selectedIndex].text);
	$('inp_re_email')		.update($F('email'));
	$('inp_telefon1')		.update($F('vorwahl1')	+'/'+$F('telefon1'));		if(($F('vorwahl1') == '')&&($F('telefon1') == '')){	$('inp_telefon1').up().hide();}
	$('inp_telefon2')		.update($F('vorwahl2')	+'/'+$F('telefon2'));		if(($F('vorwahl2') == '')&&($F('telefon2') == '')){	$('inp_telefon2').up().hide();}
	$('inp_telefonmob')		.update($F('vorwahlmob')+'/'+$F('telefonmob'));		if(($F('vorwahlmob') == '')&&($F('telefonmob') == '')){	$('inp_telefonmob').up().hide();}
	$('inp_fax')			.update($F('vorwahlfax')+'/'+$F('fax'));			if(($F('vorwahlfax') == '')&&($F('fax') == '')){	$('inp_fax').up().hide();}

	if ($('liefer_adr').visible()) {
		$('liefer_adr').hide();
		$('inprint_la').show();

		$('inp_l_anrede')		.update($F('l_anrede'));
		$('inp_l_name1')		.update($F('l_name1'));
		$('inp_l_name2')		.update($F('l_name2'));							if($F('l_name2') == ''){							$('inp_l_name2').up().hide();}
		$('inp_l_ansprech')		.update($F('l_ansprech'));						if($F('l_ansprech') == ''){							$('inp_l_ansprech').up().hide();}
		$('inp_l_strassenummer').update($F('l_strasse'));
		$('inp_l_plz')			.update($F('l_plz'));
		$('inp_l_ort')			.update($F('l_ort'));
	}

	var elements=new Array('newsletter', 'bekannt', 'anmerkung', 'delete_basket', 'change_data', 'agbs', 'widerruf', 'newsletterwiderruf', 'send_order');
	elements.each(function(s,index) {
		$(s).enable();
	});
	$('delete_basket').removeClassName('disabled');
	$('change_data').removeClassName('disabled');
	$('send_order').removeClassName('disabled');
}

function change_dat() {
	$('inprint_ra')		.hide();
	$('t_shipping')		.show();
	$('rechn_adr')		.show();
	$('validate_form')	.up(2).show();
	if($('loginstatus')) {
		$('loginstatus').enable();
	}

	if ($('inprint_la').visible()) {
		$('inprint_la').hide();
		$('liefer_adr').show();
	}

	var elements=new Array('newsletter',
							'bekannt',
							'anmerkung',
							'delete_basket',
							'change_data',
							'agbs',
							'widerruf',
							'newsletterwiderruf',
							'send_order');
	elements.each(function(s,index) {
		$(s).disable();
	});
	$('delete_basket').addClassName('disabled');
	$('change_data').addClassName('disabled');
	$('send_order').addClassName('disabled');
}

function updateBasket(action){
	switch (action) {
		case 'country':
			var customer_type_var = $F('customer_type');
/*
			if($('loginstatus')) {
				customer_type_var=$('loginstatus').selectedIndex;
			}
			else if($('customer_type')) {
				customer_type_var=$F('customer_type');
			}
*/
			var delivery_country=$('lieferlandauswahl').options[$('lieferlandauswahl').selectedIndex].text;

			if($F('lieferlandauswahl') != '') {
				new Ajax.Updater('basket_left', $F('ajax_url'), {
					method: 'get',
					parameters: {	get:		'basket_left',
									v_country:	$F('lieferlandauswahl'),
									customer_type: customer_type_var
								},
					onCreate:	function(){
						$('ajax_loader').show();
					},
					onSuccess:	function(){
						$('ajax_loader').hide();
					}
				});
				new Ajax.Updater('basket_right', $F('ajax_url'), {
					method: 'get',
					parameters: {	get:		'basket_right',
									v_country:	$F('lieferlandauswahl'),
									customer_type: customer_type_var
								},
					onCreate:	function(){
						$('ajax_loader').show();
					},
					onSuccess:	function(){
						$('ajax_loader').hide();
					},
					onComplete:	function(){
						if($('loginstatus')) {
							$('loginstatus').selectedIndex=customer_type;
						}
						$('l_country_info').update(delivery_country);
					}
				});

				if($F('zahlungsart') != '') {
					//updateBasket('payment');
				}

			} else {

				new Ajax.Updater('basket_left', $F('ajax_url'), {
					method: 'get',
					parameters: {	get:		'basket_left',
								customer_type: customer_type_var
								},
					onCreate:	function(){
						$('ajax_loader').show();
					},
					onSuccess:	function(){
						$('ajax_loader').hide();
					}
				});

				$('shipping').disable();
				$('zahlungsart').disable();
				//enableForm('rechnung_disable');
			}
			break;

		case 'coupon':

			$('zahlungsart').setValue('');	
/*			if ($('zahlungsart').options) {
				$('zahlungsart').options[0].selected = true;
			}
*/
		
		case 'payment':
			if(($F('shipping') != '')) {
				new Ajax.Updater('basket_left', $F('ajax_url'), {
					method: 'get',
					parameters: {	get:		'basket_left',
									v_country:	$F('lieferlandauswahl'),
									shipping:	$F('shipping'),
									payment:	$F('zahlungsart'),
									coupon:	$F('gutscheincode'),
									customer_type: customer_type_var
								},
					onCreate:	function(){
						$('ajax_loader').show();
					},
					onSuccess:	function(){
						$('ajax_loader').hide();
					},
					evalScripts:true
				});
				if(($F('zahlungsart') != '')) {
					enableForm('rechnung');
					enableForm('lieferung');
				}
				else {
					enableForm('rechnung_disable');
				}
			} else {
				enableForm('rechnung_disable');
			}
			break;
	}
}

function change_customer_type(el) {

	$('customer_type').value = $F(el);

	if ($F(el) == 'ret') {
		$('returning_customer').show();
		$('k_password').enable();
		$('kundennummer').enable();

		$('lieferlandauswahl').selectedIndex = 0;
		$('lieferlandauswahl').disable();

		$('shipping').selectedIndex = 0;
		$('shipping').disable();

		$('zahlungsart').selectedIndex = 0;
		$('zahlungsart').disable();

	} else {
		$('returning_customer').hide();
		$('k_password').disable();
		$('kundennummer').disable();

		$('lieferlandauswahl').enable();
	}
}

function login(){

	wFORMS.showAlertOnError = false;
	wFORMS.behaviors['validation'].errMsg_notification	= "%% Fehler gefunden.\nBitte &uuml;berpr&uuml;fen Sie Ihre Angaben.";
  	wFORMS.behaviors['validation'].errMsg_required		= "Dies ist ein Pflichtfeld";
	wFORMS.behaviors['validation'].errMsg_alpha 		= "Bitte verwenden Sie nur Buchstaben (a-z, A-Z). Zahlen sind nicht erlaubt.";
	wFORMS.behaviors['validation'].errMsg_email 		= "Dies scheint keine korrekte E-Mail-Adresse zu sein.";
	wFORMS.behaviors['validation'].errMsg_integer 		= "Bitte verwenden Sie nur Ziffern.";
	wFORMS.behaviors['validation'].errMsg_alphanum 		= "Bitte verwenden Sie nur Buchstaben oder Ziffern [a-z 0-9].";
	wFORMS.behaviors['validation'].errMsg_custom		= "Dies ist keine g&uuml;ltige Eingabe.";
	var elements=new Array('kundennummer', 'k_password');

	var errors = 0;

	elements.each(function(s,index) {
		if (!$(s).disabled) {
			if(wFORMS.behaviors['validation'].validateElement($(s)) == 1){
				errors++;
			}
		}
	});

	if ( errors == 0) {
		var cust_nr		= $('kundennummer').value;
		var password	= $('k_password').value;

		new Ajax.Updater('basket_right', $F('ajax_url'), {
			method: 'get',
			parameters: {	get	: 'basket_right',
							cnr	: cust_nr,
							pw	: password
			},
			onCreate:	function(){
				$('ajax_loader').show();
			},
			onSuccess:	function(){
				new Ajax.Updater('basket_left', $F('ajax_url'), {
					method: 'get',
					parameters: {	get:		'basket_left'},
					onSuccess:	function(){
						$('ajax_loader').hide();
					}
				});
				new Ajax.Request('likecms.php?site=ajax.html', {
						method:		'post',
						parameters:	{	get:		'customer_menu'},
						onSuccess:	function(transport) {
										$('kundenmenue').replace(transport.responseText);
									}
					});
			}
		});
	}
}

function submit_order(){
	var elements=new Array('agbs', 'widerruf', 'newsletterwiderruf');

	var errors = 0;

	elements.each(function(s,index) {
		if (!$(s).disabled) {
			if(wFORMS.behaviors['validation'].validateElement($(s)) == 1){
				errors++;
			}
		}
	});

	if(errors == 0) {
		$('bestellform').submit();
	}
}
/** util */
Array.prototype.intersect =
  function() {
    if (!arguments.length)
      return [];
    var a1 = this;
    var a = a2 = null;
    var n = 0;
    while(n < arguments.length) {
      a = [];
      a2 = arguments[n];
      var l = a1.length;
      var l2 = a2.length;

      for(var i=0; i<l; i++) {
        for(var j=0; j<l2; j++) {
          if (a1[i] === a2[j])
            a.push(a1[i]);
        }
      }
      a1 = a;
      n++;
    }
    return unique(a);
  };
function unique(a) {
	tmp = new Array(0);
	for(i=0;i<a.length;i++){
		if(!contains(tmp, a[i])){
			tmp.length+=1;
			tmp[tmp.length-1]=a[i];
		}
	}
	return tmp;
}
function contains(a, e) {
	for(j=0;j<a.length;j++)if(a[j]==e)return true;
	return false;
}
isDefined = function(variable){
	return this[variable] === undefined ? false : true;
};

