var nxformatselection = {




	ajaxQuery: false,
	ajaxSuccessStack: [],



	initRadioSelection: function() {

		jQuery('.tx-nxformatselection-module').each(function(moduleId, moduleDomElement) {

			nxformatselection.validationInProgress = true;
			nxformatselection.validateRadioSelection(moduleDomElement);
			nxformatselection.validationInProgress = false;

			var changeFunction = {
				runner: false,
				waiter: false
			};
			changeFunction.runner = function(radioId, radioDomElement) {
				window.clearTimeout(changeFunction.waiter);
				changeFunction.waiter = window.setTimeout(function() {

					if (nxformatselection.validationInProgress) {
						return true;
					}
					nxformatselection.validationInProgress = true;
					nxformatselection.validateRadioSelection(moduleDomElement);
					nxformatselection.validationInProgress = false;

					nxformatselection.requestInfospace(moduleDomElement);

				}, 250);

			};

			jQuery(moduleDomElement).find('.tx-nxformatselection-orderform-matrix').change(changeFunction.runner);
			jQuery(moduleDomElement).find('.tx-nxformatselection-orderform-matrix').keyup(changeFunction.runner);
			jQuery(moduleDomElement).find('.tx-nxformatselection-orderform-matrix').click(changeFunction.runner);

		});

	},




	// Radio Selection part




	validateRadioSelection: function(moduleDomElement) {

		return false;

		var enabledRadios = nxformatselection.getEnabledRadios(moduleDomElement);
		var disabledRadios = nxformatselection.getDisabledRadios(moduleDomElement, enabledRadios);
		var radiosToSwitch = nxformatselection.markEnabledAndDisabledRadios(enabledRadios, disabledRadios);
		nxformatselection.reorganizeDisabledRadios(moduleDomElement, radiosToSwitch);

	},



	getPossibleRadios: function(moduleDomElement, flow, recursion, recursionObject, resultObject) {

		var innerRecursionObject = jQuery.extend({}, recursionObject);

		jQuery.each(flow['nextLevel'], function(attributeName, innerFlow) {
			innerRecursionObject[innerFlow['levelKey']] = attributeName;
			if (typeof innerFlow['nextLevel'] == 'object') {
				if (nxformatselection.selectionStillPossible(moduleDomElement, innerRecursionObject, recursion)) {
					nxformatselection.getPossibleRadios(moduleDomElement, innerFlow, recursion+1, innerRecursionObject, resultObject);
				}
			}
			// recursion limit reached
			else {
				resultObject.push(jQuery.extend({}, innerRecursionObject));
			}
		});

	},




	selectionStillPossible: function(moduleDomElement, possibleSelection, recursion) {

		var allAttributesPresent = true;
		var counter=0;

		jQuery.each(possibleSelection, function(checkKey, checkValue) {
			if (recursion == counter) {
				return true;
			}
			var singleAttributePresent = false;
			var groupSelection = jQuery(moduleDomElement).find('.tx-nxformatselection-orderform-matrix:checked[name='+checkKey+']');
			if (groupSelection.length == 0 || groupSelection.val() == checkValue) {
				singleAttributePresent = true;
			}
			if (singleAttributePresent == false) {
				allAttributesPresent = false;
			}
			counter++;
		});

		return allAttributesPresent;

	},




	getSelectableCombinations: function(moduleDomElement) {

		var resultObject = [];
		nxformatselection.getPossibleRadios(moduleDomElement, {nextLevel: nxformatselection.possibleClickFlows}, 0, {}, resultObject);
		return resultObject;

	},




	getEnabledRadios: function(moduleDomElement) {

		var selectableCombinations = nxformatselection.getSelectableCombinations(moduleDomElement);

		var selectableRadiosByGroup = {};
		var selectableRadios = {};
		jQuery.each(selectableCombinations, function(combinationId, combination) {
			jQuery.each(combination, function(groupName, groupValue) {
				if (typeof selectableRadiosByGroup[groupName] == 'undefined') {
					selectableRadiosByGroup[groupName] = {};
				}
				selectableRadiosByGroup[groupName][groupValue] = jQuery(moduleDomElement).find('.tx-nxformatselection-orderform-matrix[name='+groupName+'][value='+groupValue+']');
				selectableRadios[nxformatselection.getRadioIdentifier(selectableRadiosByGroup[groupName][groupValue])] = selectableRadiosByGroup[groupName][groupValue];
			});
		});

		return selectableRadios;

	},




	getDisabledRadios: function(moduleDomElement, enabledRadios) {

		var disabledRadios = {};
		jQuery(moduleDomElement).find('.tx-nxformatselection-orderform-matrix').each(function(radioId, radioDomElement) {
			if (typeof enabledRadios[nxformatselection.getRadioIdentifier(jQuery(radioDomElement))] == 'undefined') {
				disabledRadios[nxformatselection.getRadioIdentifier(jQuery(radioDomElement))] = jQuery(radioDomElement);
			}
		});
		return disabledRadios;

	},




	getRadioIdentifier: function(radioDomElement) {

		return radioDomElement.attr('name')+'-'+radioDomElement.val();

	},




	markEnabledAndDisabledRadios: function(enabledRadios, disabledRadios) {
		var radiosToSwitch = [];
		jQuery.each(enabledRadios, function(radioId, radioDomElement) {
			radioDomElement.attr('disabled', false);
			radioDomElement.addClass('tx-nxformatselection-orderform-matrix-enabled');
			radioDomElement.removeClass('tx-nxformatselection-orderform-matrix-disabled');
		});
		jQuery.each(disabledRadios, function(radioId, radioDomElement) {
			if (!radioDomElement.hasClass('tx-nxformatselection-orderform-matrixposition-0')) {
				if(radioDomElement.attr('checked')) {
					radiosToSwitch.push(radioDomElement);
				}
				radioDomElement.attr('disabled', true);
				radioDomElement.removeClass('tx-nxformatselection-orderform-matrix-enabled');
				radioDomElement.addClass('tx-nxformatselection-orderform-matrix-disabled');
			}
		});
		return radiosToSwitch;
	},




	reorganizeDisabledRadios: function(moduleDomElement, radiosToSwitch) {

		var didSomething = false;
		jQuery.each(radiosToSwitch, function(radioId, radioDomElement) {
			didSomething = true;
			radioDomElement.attr('checked', false);
		});
		if (didSomething) {
			nxformatselection.validateRadioSelection(moduleDomElement);
		}
		jQuery.each(radiosToSwitch, function(radioId, radioDomElement) {
			jQuery(moduleDomElement).find('.tx-nxformatselection-orderform-matrix[name='+radioDomElement.attr('name')+'][disabled=false]').each(function(newRadioId, newRadioDomElement) {
				jQuery(newRadioDomElement).attr('checked', true);
				return false;
			});
		});

	},




	setPossibleClickFlows: function(possibleClickFlows) {
		nxformatselection.possibleClickFlows = possibleClickFlows;
	},




	possibleClickFlows: {},




	validationInProgress: false,




	// delivery type part




	initDeliveryType: function() {

		var runner = {
			runner: false,
			waiter: false
		};
		runner.runner = function(type) {
			window.clearTimeout(runner.waiter);
			runner.waiter = window.setTimeout(function() {
				nxformatselection.initDeliveryType();
			}, 500);
		};

		jQuery('input.tx-nxformatselection-orderform-delivery-postal-code').each(function(zipId, zipDomElement) {
			jQuery('input.tx-nxformatselection-productconfiguration-delivery-type-writable, input.tx-nxformatselection-productconfiguration-delivery-type-readonly').each(function(radioId, radioDomElement){
				if(jQuery(radioDomElement).attr('checked')) {
					if (jQuery(radioDomElement).hasClass('tx-nxformatselection-productconfiguration-delivery-type-writable')) {
						jQuery(zipDomElement)
							.attr('readonly', false)
							.addClass('tx-nxformatselection-productconfiguration-postal-code-delivery-type-writable')
							.removeClass('tx-nxformatselection-productconfiguration-postal-code-delivery-type-readonly')
						;
					}
					else {
						jQuery(zipDomElement)
							.attr('readonly', 'readonly')
							.removeClass('tx-nxformatselection-productconfiguration-postal-code-delivery-type-writable')
							.addClass('tx-nxformatselection-productconfiguration-postal-code-delivery-type-readonly')
						;
					}
				}

				if (!jQuery(radioDomElement).hasClass('tx-nxformatselection-orderform-delivery-postal-code-ajax-performed')) {
					jQuery(radioDomElement).addClass('tx-nxformatselection-orderform-delivery-postal-code-ajax-performed');
					jQuery(radioDomElement).click(function() {
						runner.runner('click');
					});
					jQuery(radioDomElement).change(function() {
						runner.runner('change');
					});
				}

			});
		});

	},




	// Amount and date part




	initAmountAndDate: function() {

		jQuery('.tx-nxformatselection-module').each(function(moduleId, moduleDomElement) {
			jQuery(moduleDomElement).find('.tx-nxformatselection-orderform-amount, .tx-nxformatselection-orderform-production-date, .tx-nxformatselection-orderform-delivery-postal-code, .tx-nxformatselection-productconfiguration-delivery-type, .tx-nxformatselection-address-value-option input[type=radio]').each(function(selectId, selectDomElement) {
				var onChangeFunction = {
						run: function() {},
						schedule: function() {},
						timeout: false
					};
				onChangeFunction.schedule = function() {
					window.clearTimeout(onChangeFunction.timeout);
					onChangeFunction.timeout = window.setTimeout(onChangeFunction.run, 500);
				};
				onChangeFunction.run = function() {
					window.clearTimeout(onChangeFunction.timeout);
					nxformatselection.requestInfospace(moduleDomElement, function() {
						if (jQuery(selectDomElement).hasClass('tx-nxformatselection-orderform-production-date')) {
							var selectedDate = {
								arrival: '',
								delivery: ''
							};
							if(typeof nxformatselection.productionDates[jQuery(selectDomElement).val()] != 'undefined') {
								selectedDate = nxformatselection.productionDates[jQuery(selectDomElement).val()];
							}
							jQuery(moduleDomElement).find('.tx-nxformatselection-orderform-arrival-date').each(function(arrivalId, arrivalDomElement) {
								jQuery(arrivalDomElement).val(selectedDate['arrival']);
							});
							jQuery(moduleDomElement).find('.tx-nxformatselection-orderform-delivery-date').each(function(arrivalId, deliveryDomElement) {
								jQuery(deliveryDomElement).val(selectedDate['delivery']);
							});
						}
					});
				};
				jQuery(selectDomElement).click(onChangeFunction.schedule);
				jQuery(selectDomElement).change(onChangeFunction.schedule);
				jQuery(selectDomElement).keyup(onChangeFunction.schedule);
			});

		});

	},




	setProductionDates: function(productionDates) {
		nxformatselection.productionDates = productionDates;
	},




	productionDates: {},





	// zip code adjustment




	initZipCodeAdjustment: function() {

		jQuery('.tx-nxformatselection-module').each(function(moduleId, moduleDomElement) {
			jQuery(moduleDomElement).find('.nx-formvalidation-error-billing-postal-code').each(function(billingId, billingDomElement) {
				var onChangeFunction = {
					waiter: false,
					runner: false
				};
				onChangeFunction.runner = function() {
					window.clearTimeout(onChangeFunction.waiter);
					onChangeFunction.waiter = window.setTimeout(function() {
						jQuery(moduleDomElement).find('.nx-formvalidation-error-delivery-postal-code').each(function(deliveryId, deliveryDomElement) {
							if(jQuery(billingDomElement).val() != jQuery(deliveryDomElement).val()) {
								jQuery(moduleDomElement).find('.tx-nxformatselection-addresses-differ').each(function(differCheckId, differCheckDomElement) {
									jQuery(differCheckDomElement).attr('checked', true);
								});
							}
						});
					}, 250);
				};

				onChangeFunction.runner();
				jQuery(billingDomElement).change(onChangeFunction.runner);
				jQuery(billingDomElement).click(onChangeFunction.runner);
				jQuery(billingDomElement).keyup(onChangeFunction.runner);
			});
		});

	},





	// AJAX price request part




	requestInfospace: function(moduleDomElement, callbackFunction) {

		jQuery(moduleDomElement).find('form.tx-nxformatselection-form').each(function(formId, formDomElement) {

			var e = jQuery.Event("submit");
			if (!nxformvalidation.formSubmit(e, jQuery(formDomElement))) {
				return false;
			}

			var postVars = jQuery(formDomElement).serialize();
			if (typeof nxformatselection.infospaceCache[postVars] != 'undefined') {
				nxformatselection.fillInfospaceFromCache(formDomElement, postVars);
				nxformatselection.queryForInfospace(formDomElement, postVars, false, callbackFunction);
			}
			else {
				nxformatselection.queryForInfospace(formDomElement, postVars, true, callbackFunction);
			}

		});

	},




	fillInfospaceFromCache: function(formDomElement, cacheId) {

		jQuery(formDomElement).find('.tx-nxformatselection-infospace-viewport').each(function(viewportId, viewportDomElement) {
			jQuery(viewportDomElement).html(nxformatselection.infospaceCache[cacheId].content);
		});

	},




	queryForInfospace: function(formDomElement, cacheId, drawViewport, callbackFunction) {

		if (drawViewport) {
			jQuery(formDomElement).addClass('tx-nxformatselection-ajax-working');
		}

		var formAction = jQuery(formDomElement).attr('action');

		var successFunction = function(data, textStatus, XMLHttpRequest) {

			nxformatselection.infospaceCache[cacheId] = data;
			if (drawViewport) {
				nxformatselection.fillInfospaceFromCache(formDomElement, cacheId);
			}
			jQuery.each(data['overwriteInputValues'], function(cssSelector, newValue) {
				jQuery(formDomElement).find(cssSelector).each(function(inputId, inputDomElement) {
					jQuery(inputDomElement).val(newValue);
				});
			});
			if(typeof callbackFunction == 'function') {
				callbackFunction({
					queryInfoSpace: {
						formDomElement: formDomElement,
						cacheId: cacheId,
						drawViewport: drawViewport
					},
					success: {
						data: data,
						textStatus: textStatus,
						XMLHttpRequest: XMLHttpRequest
					}
				});
			}
			jQuery(formDomElement).removeClass('tx-nxformatselection-ajax-working');
		};

		if (typeof nxformatselection.ajaxQuery !== 'boolean') {
			while (iSuccessFunction = nxformatselection.ajaxSuccessStack.pop()) {
				iSuccessFunction = function() {};
			}
			nxformatselection.ajaxQuery.abort();
		}
		nxformatselection.ajaxQuery = jQuery.ajax({
			url: formAction,
			dataType: 'json',
			data: cacheId+'&tx_nxformatselection_pi1[request]=AJAX&tx_nxformatselection_pi1[action]=infospace',
			cache: false,
			success: successFunction
		});
		nxformatselection.ajaxSuccessStack.push(successFunction);

	},



	infospaceCache: {},





	// AJAX calendar part




	initCalendar: function() {

		jQuery('.tx-nxformatselection-module').each(function(moduleId, moduleDomElement) {

			jQuery(moduleDomElement).find('.tx-nxformatselection-productconfiguration-attribute-last-minute-button a').each(function(buttonId, buttonDomElement) {
				jQuery(buttonDomElement).click(function() {

					jQuery('.tx-nxformatselection-module').each(function(moduleId, moduleDomElement) {

						nxformatselection.requestInfospace(moduleDomElement, function() {

							var lightbox = nxformatselection.createLightbox();

							if (nxformatselection.ajaxQuery !== false) {
								try {
									nxformatselection.ajaxQuery.abort();
								} catch (e) {

								}
							}
							nxformatselection.ajaxQuery = jQuery.ajax({
								url: jQuery(buttonDomElement).attr('href'),
								dataType: 'json',
								cache: false,
								success: function(data, textStatus, XMLHttpRequest) {
									lightbox.removeClass('tx-nxformatselection-lightbox-loading');
									lightbox.html(data.content);
									nxformatselection.addClickHandlerToCalendar(moduleDomElement, lightbox);
									nxformatselection.addNoSlotsAvailableTooltip(moduleDomElement, lightbox);
								}
							});

						});

					});

					return false;
				});
			});

		});

	},




	addClickHandlerToCalendar: function(moduleDomElement, lightbox) {
		lightbox.find('.tx-nxformatselection-calendar-slot-free-link').each(function(linkId, linkDomElement) {
			jQuery(linkDomElement).click(function() {

				lightbox.destroy();

				var requestedTimeSlot = jQuery(linkDomElement).attr('rel');

				var productionDate = nxformatselection.calendarReservationSlotConfigs[requestedTimeSlot]['productionDateReadable'];
				var productionDateValue = '#LAST#'+nxformatselection.calendarReservationSlotConfigs[requestedTimeSlot]['productionDate'];
				var arrivalDate = nxformatselection.calendarReservationSlotConfigs[requestedTimeSlot]['arrivalDateReadable'];
				var deliveryDate = nxformatselection.calendarReservationSlotConfigs[requestedTimeSlot]['deliveryDateReadable'];

				nxformatselection.changeSelectedOptionsByAjaxCalendar(
					moduleDomElement,
					lightbox,
					linkDomElement,
					productionDate,
					productionDateValue,
					arrivalDate,
					deliveryDate
				);

				return false;

			});
		});
	},




	changeSelectedOptionsByAjaxCalendar: function(moduleDomElement,
		lightbox,
		linkDomElement,
		productionDate,
		productionDateValue,
		arrivalDate,
		deliveryDate
	) {
		nxformatselection.productionDates[productionDateValue] = {
			arrival: arrivalDate,
			production: productionDate,
			delivery: deliveryDate
		};

		jQuery(moduleDomElement).find('.tx-nxformatselection-orderform-production-date').each(function(productionId, productionDomElement) {

			var option = false;
			jQuery(productionDomElement).find('option[value='+productionDateValue+']').each(function(optionId, optionDomElement) {
				option = optionDomElement;
			});
			if (!option) {
				option = jQuery('<option />');
				option
					.val(productionDateValue)
					.html(productionDate)
				;
				jQuery(productionDomElement).append(option);
			}
			jQuery(productionDomElement).val(productionDateValue);
			jQuery(productionDomElement).trigger('change');

		});

		return false;

	},




	clearCalendarReservationSlotConfigs: function() {
		nxformatselection.calendarReservationSlotConfigs = {};
	},




	addCalendarReservationSlotConfig: function(slotName, slotConfig) {

		nxformatselection.calendarReservationSlotConfigs[slotName] = slotConfig;
		nxformatselection.addToolTip(slotName);

	},




	addToolTip: function(slotName) {

		jQuery('.tx-nxformatselection-calendar-wrapper-tooltip-storage').each(function(storageId, storageDomElement) {

			jQuery('a[rel='+slotName+']').each(function(linkId, linkDomElement) {

				jQuery(linkDomElement).find('.tx-nxformatselection-calendar-slot-free-tooltip').each(function(tooltipId, tooltipDomElement) {
					jQuery(storageDomElement).append(tooltipDomElement);
					nxformatselection.addToolTip_all(storageDomElement, tooltipDomElement, linkDomElement, 'free');
				});

			});
		});

	},




	addNoSlotsAvailableTooltip: function(moduleDomElement, lightbox) {

		var found = false;
		lightbox.find('.tx-nxformatselection-calendar-slot-free-link').each(function(linkId, linkDomElement) {
			found = true;
		});

		if (found) {
			return false;
		}

		lightbox.find('.tx-nxformatselection-calendar-slot-used-link').each(function(linkId, linkDomElement) {

			lightbox.find('.tx-nxformatselection-calendar-wrapper-tooltip-storage').each(function(storageId, storageDomElement) {

				lightbox.find('.tx-nxformatselection-calendar-slot-used-tooltip').each(function(tooltipId, tooltipDomElement) {
					nxformatselection.addToolTip_all(storageDomElement, tooltipDomElement, linkDomElement, 'used');
				});

			});

		});

	},




	addToolTip_all: function(storageDomElement, tooltipDomElement, linkDomElement, colorName) {

		var moveTimeoutObject = {
			timeout: false,
			runner: false,
			firstrun: true
		};
		moveTimeoutObject.runner = function(hoverEvent) {

			var position = jQuery(storageDomElement).position();
			var offset = jQuery(storageDomElement).offset();

			var  runner = function() {
				jQuery(tooltipDomElement).css({
					marginLeft: (hoverEvent.pageX - offset.left) + 10,
					marginTop: (hoverEvent.pageY - offset.top) - 55
				});
			};
			window.clearTimeout(moveTimeoutObject.timeout);
			if (moveTimeoutObject.firstrun) {
				moveTimeoutObject.timeout = window.setTimeout(runner, 500);
			}
			else {
				runner();
			}
			moveTimeoutObject.firstrun = false;
		};

		jQuery(linkDomElement)
			.hover(function(hoverEvent) {
				jQuery(tooltipDomElement)
					.addClass('tx-nxformatselection-calendar-slot-'+colorName+'-tooltip-mouseover')
					.removeClass('tx-nxformatselection-calendar-slot-'+colorName+'-tooltip-mouseout')
				;
			}, function() {
				jQuery(tooltipDomElement)
					.removeClass('tx-nxformatselection-calendar-slot-'+colorName+'-tooltip-mouseover')
					.addClass('tx-nxformatselection-calendar-slot-'+colorName+'-tooltip-mouseout')
				;
			})
			.mousemove(moveTimeoutObject.runner)
		;

	},




	createLightbox: function() {

		var lightboxContent;

		jQuery('body').each(function(bodyId, bodyDomElement) {

			var lightbox = jQuery('<div class="tx-nxformatselection-lightbox" />');
			jQuery(bodyDomElement).append(lightbox);

			var destroyLightbox = function() {
				lightbox.remove();
			};

			var lightboxShadow = jQuery('<div class="tx-nxformatselection-lightbox-shadow" />');
			lightboxShadow.click(destroyLightbox);
			lightbox.append(lightboxShadow);

			var lightboxContainer = jQuery('<div class="tx-nxformatselection-lightbox-container" />');
			lightbox.append(lightboxContainer);

			/*
			var lightboxIframe = jQuery('<iframe />');
			lightbox.append(lightboxIframe);
			*/

			var closeButton = jQuery('<a class="tx-nxformatselection-lightbox-closebutton">&#160;</a>');
			closeButton.click(destroyLightbox);
			lightboxContainer.append(closeButton);

			var lightboxContentWrapper = jQuery('<div class="tx-nxformatselection-lightbox-contentwrapper" />');
			lightboxContainer.append(lightboxContentWrapper);

			lightboxContent = jQuery('<div class="tx-nxformatselection-lightbox-content tx-nxformatselection-lightbox-loading" />');
			lightboxContentWrapper.append(lightboxContent);
			lightboxContent.destroy = destroyLightbox;

			if (jQuery.browser.msie) {
				lightboxShadow.css({
					opacity: 0.75
				});
				if(jQuery.browser.version.substr(0, 1) == 6) {
					lightbox.css({
						position: 'absolute',
						height: jQuery('body').height()
					});
					lightboxShadow.css({
						position: 'absolute',
						left: 0,
						height: jQuery('body').height()
					});
					lightboxContainer.css({
						height: 'auto'
					});
				}
			}

		});

		return lightboxContent;

	},




	calendarReservationSlotConfigs: {},




	// form ajax button




	initFormAjax: function() {

		jQuery('form.tx-nxformatselection-form').each(function(formDomElementId, formDomElement) {
			jQuery(formDomElement).submit(function(event) {
				var intervalObject = {};
				jQuery(formDomElement).addClass('tx-nxformatselection-ajax-working');
				intervalObject.timeout = window.setInterval(function() {
					if(event.isPropagationStopped()) {
						jQuery(formDomElement).removeClass('tx-nxformatselection-ajax-working');
						window.clearInterval(intervalObject.timeout);
					}
				}, 500);
			});
		});

	},




	// bootstrap




	init: function() {
		nxformatselection.initRadioSelection();
		nxformatselection.initDeliveryType();
		nxformatselection.initAmountAndDate();
		nxformatselection.initZipCodeAdjustment();
		nxformatselection.initCalendar();
		jQuery('.tx-nxformatselection-infospace-viewport').addClass('tx-nxformatselection-infospace-viewport-js');
		nxformatselection.initFormAjax();
	}




};
jQuery(nxformatselection.init);


jQuery(function() {
	nxformvalidation.init({
		validateOnChange: false
	});


	var nameArray = Array();

	jQuery('.tx-nxformatselection-orderform-matrix').each(function(matrixCounter, matrixItem){
		var name = jQuery(matrixItem).attr('name');
		nameArray.push(name + '');
	});

	for(item in nameArray){
		var counter = 0;
		jQuery('input[name="'+nameArray[item]+'"]').each(function(matrixCounter, matrixItem){
			counter = matrixCounter;
		});

		if(counter == 0){
			jQuery('input[name="'+nameArray[item]+'"]').each(function(matrixCounter, itemA){
				jQuery(itemA).attr("checked","checked");
			})
		}
	}

});

