function initShop()
{
	initBuyForms();
	initAsyncBasket();
	initAlert();
	initQuestion();
	initIndex();
	if($('smallSearchForm'))initFormFields("smallSearchForm");
	if($('smallLoginForm'))initFormFields("smallLoginForm"); 
	if($('smallNewsletterForm'))initFormFields('smallNewsletterForm');
}

var ajaxCategories = new Array();

function showSubCategories(parentId, level){
	var divElement = $('categoriesParent' + parentId);
	//if(divElement.className == 'categoriesParentClose'){
		var imageLoading = "<img src='" + shop.templatePath + "/images/smallLoading.gif'>";
		document.getElementById('categoriesTreeLoadingParent'+parentId).className = "categoriesTreeLoadingParentOpen";
		document.getElementById('categoriesTreeLoadingParent'+parentId).innerHTML = imageLoading;
		// alert(document.getElementById('categoriesTreeLoadingParent'+parentId).innerHTML)
		hideSubCategories();
		cancelAjaxCategories();
		//clearTimeout(timeoutCategories);

		//timeoutCategories[parentId] = setTimeout(function(){ajaxLoad(shop.url + '/ajaxTemplates/common/categoriesContent.cfm?categoryId='+parentId+'&deepLevel=1&level='+level, divElement, 'actionShowSubCategories('+parentId+');hideLoadingParent('+parentId+')', null)}, 0);
		
		ajaxCategories[ajaxCategories.length+1] = ajaxLoad(shop.url + '/ajaxTemplates/common/categoriesContent.cfm?categoryId='+parentId+'&deepLevel=1&level='+level, divElement, 'actionShowSubCategories('+parentId+');hideLoadingParent('+parentId+')', null);
		
//	}
	//else{
//		hideSubCategoriesByParentId(parentId);
//	}
}

function cancelAjaxCategories(){
	for(var i=0; i<ajaxCategories.length;i++){
		if(ajaxCategories[i] != undefined) ajaxCancel(ajaxCategories[i]);
		delete ajaxCategories[i];
	}
	
}

function actionShowSubCategories(parentId){
	var divElement = $('categoriesParent' + parentId);
	divElement.className = 'categoriesParentOpen';
	topPosition = $('containerLeft').offsetTop - $('categoriesParent' + parentId).offsetTop;
	if($('subCategoriesTreeMain'+parentId)) $('subCategoriesTreeMain'+parentId).style.top = (topPosition + 10) + 'px';
	divElement.style.display = '';
}

function hideSubCategoriesByParentId(parentId){
	var divElement = document.getElementById('categoriesParent' + parentId);
	divElement.innerHTML = "";
	divElement.className = "categoriesParentClose";
}

function hideLoadingParent(parentId){
	document.getElementById('categoriesTreeLoadingParent'+parentId).innerHTML = "";
	document.getElementById('categoriesTreeLoadingParent'+parentId).className = "categoriesTreeLoadingParent";
}

function hideSubCategories(){
	//$$('.categoriesTreeLoadingParentOpen').each(function(el){el.className = 'categoriesTreeLoadingParent'; el.innerHTML = "";});
	$$('.categoriesParentOpen').each(function(el){el.className = 'categoriesParentClose'; el.innerHTML = "";});
}


function hideSubCategoriesAll(){
	$$('.categoriesParentOpen').each(function(el){el.className = 'categoriesParentClose'; el.innerHTML = "";});
}

function initIndex(){
	if($('bannersIndex')){
		var V2 = new viewer($$('#bannersIndexBox img)'),{
			mode: 'alpha',
			interval: 3000
		});
		V2.play(true);
		//$(window).addEvent('domready', V2.play.bind(V2,[false]));
	}
}

function validateAddProduct(req){
		validateAddProductShowMessage(req);
}

function showPriceByOption(form, option){
	showPriceByOptionWithImage(form, option);
}

function showArrowOption(objId){
	var obj = $(objId);
	$$('.productOptionValueTextSelected').each(function(el){el.removeClass("productOptionValueTextSelected");
		el.addClass("productOptionValueText");
	});
	
	obj.removeClass("productOptionValueText");
	obj.addClass("productOptionValueTextSelected");
}

function showArrowOptionGroup(objId){
	var obj = $(objId);

	if(obj.hasClass("productOptionValueText")){
		obj.removeClass("productOptionValueText");
		obj.addClass("productOptionValueTextSelected");
	}else{
		obj.removeClass("productOptionValueTextSelected");
		obj.addClass("productOptionValueText");
	}
}

function initProduct(){
	if(document.getElementById('productInfoBuyForm')){
		initFormFields('productInfoBuyForm');
	}
}

function checkUserType(type){
	if(type == 1){
		userFieldsRequired = 1;
		userFieldsDisplay = '';
		companyFieldsRequired = 0;
		companyFieldsDisplay = 'none';
	}
	else if(type == 2){
		userFieldsRequired = 0;
		userFieldsDisplay = 'none';
		companyFieldsRequired = 1;
		companyFieldsDisplay = '';
	}
	else if(type == 3){
		userFieldsRequired = 1;
		userFieldsDisplay = '';
		companyFieldsRequired = 1;
		companyFieldsDisplay = '';
	}
	
	document.getElementById('userInformationFirstName').style.display = userFieldsDisplay;
	if(document.getElementById('userInformationLastName'))document.getElementById('userInformationLastName').style.display = userFieldsDisplay;
	if(document.getElementById('userInformationLastName1'))document.getElementById('userInformationLastName1').style.display = userFieldsDisplay;
	if(document.getElementById('userInformationLastName2'))document.getElementById('userInformationLastName2').style.display = userFieldsDisplay;
	document.getElementById('userInformationNif').style.display = userFieldsDisplay;
	document.getElementById('userInformationCompany').style.display = companyFieldsDisplay;
	document.getElementById('userInformationVat').style.display = companyFieldsDisplay;
	
	document.getElementById('userInformationFirstNameField').setAttribute('requiredField', userFieldsRequired);
	if(document.getElementById('userInformationLastNameField'))document.getElementById('userInformationLastNameField').setAttribute('requiredField', userFieldsRequired);
	if(document.getElementById('userInformationLastName1Field'))document.getElementById('userInformationLastName1Field').setAttribute('requiredField', userFieldsRequired);
	if(document.getElementById('userInformationLastName2Field'))document.getElementById('userInformationLastName2Field').setAttribute('requiredField', userFieldsRequired);
	document.getElementById('userInformationNifField').setAttribute('requiredField', userFieldsRequired);
	document.getElementById('userInformationCompanyField').setAttribute('requiredField', companyFieldsRequired);
	document.getElementById('userInformationVatField').setAttribute('requiredField', companyFieldsRequired);
	
}


function requireSignIn(value){	
	document.getElementById('userInformationPasswordField').setAttribute('requiredField', value);	
	document.getElementById('userInformationConfirmPasswordField').setAttribute('requiredField', value);	
	//document.getElementById('userCheckoutType').value = value;		
	if(value == 0){
		document.getElementById('userInformationSubscribed').style.display = 'none';
		document.getElementById('userInformationPasswords').style.display = 'none';
	}	
	if(value == 1){		
		document.getElementById('userInformationSubscribed').style.display = '';		
		document.getElementById('userInformationPasswords').style.display = '';
	}	
}

function requireShipTo(value){	

	if(document.getElementById('userInformationFirstNameShippingField'))document.getElementById('userInformationFirstNameShippingField').setAttribute('requiredField', value);	
	if(document.getElementById('userInformationLastName1ShippingField'))document.getElementById('userInformationLastName1ShippingField').setAttribute('requiredField', value);	
	if(document.getElementById('userInformationLastName2ShippingField'))document.getElementById('userInformationLastName2ShippingField').setAttribute('requiredField', value);	
	if(document.getElementById('userInformationLastNameShippingField'))document.getElementById('userInformationLastNameShippingField').setAttribute('requiredField', value);	
	if(document.getElementById('userInformationNifShippingField'))document.getElementById('userInformationNifShippingField').setAttribute('requiredField', value);	
	if(document.getElementById('userInformationAddressShippingField'))document.getElementById('userInformationAddressShippingField').setAttribute('requiredField', value);
	if(document.getElementById('userInformationAddress2ShippingField'))document.getElementById('userInformationAddress2ShippingField').setAttribute('requiredField', value);
	if(document.getElementById('userInformationNumberShippingField'))document.getElementById('userInformationNumberShippingField').setAttribute('requiredField', value);
	if(document.getElementById('userInformationCityShippingField'))document.getElementById('userInformationCityShippingField').setAttribute('requiredField', value);
	if(document.getElementById('userInformationStateShippingField'))document.getElementById('userInformationStateShippingField').setAttribute('requiredField', value);
	if(document.getElementById('userInformationZipShippingField'))document.getElementById('userInformationZipShippingField').setAttribute('requiredField', value);
	if(document.getElementById('userInformationCountryShippingField'))document.getElementById('userInformationCountryShippingField').setAttribute('requiredField', value);


	if(value == 1){
		display = '';
	}
	else{
		display = 'none';
	}
	
	if(document.getElementById('userInformationShipTo'))document.getElementById('userInformationShipTo').style.display = display;
	else if(document.getElementById('userInformationControlPanelShipTo'))document.getElementById('userInformationControlPanelShipTo').style.display = display;
	
	//reloadCountries(value);
	
}

function initWishlistTable(){$('informationBox').style.visibility = 'visible';	initFormFields("formWishlistToEmail");}
function initWishlistToEmail(obj){	$('informationBox').style.visibility = 'visible';	initFormFields("formWishlistToEmail");}

function selectAllItemsWishlist(){
	var value = document.getElementById('optionSelect').value;
	if(value == '1') newValue = '2';
	else newValue = '1';
	
	document.getElementById('optionSelect').value =  newValue;
	$$('.userControlPanelWishlistField').each(
																						function(el){
																							if(newValue == '1') el.checked = true;
																							else el.checked = false;
																						})
}

function reloadWishlist(){
	loadAjaxFile(shop.url +'/ajaxTemplates/users/wishlist.cfm?getTemplates=0', 'userControlPanelInfo', 'initWishlistTable()', null);
}

function reloadBasket(){
	loadAjaxFile(shop.url+'/ajaxTemplates/basket/basket.cfm','basketResume', null,null);
}

function initFormsUser(){
	if(document.getElementById('formLogin'))initFormFields('formLogin');
	if(document.getElementById('formUserInformation')){
		initFormFields('formUserInformation');
		onlybuyCheck = $('userInformationCheckoutTypeField');
		checkLogin(onlybuyCheck);
	}
	restartShadowbox();
}

function hideZipResult(shipTo){
	if(shipTo == 1) divId = "userInformationZipShipping_Result";
	else divId = "userInformationZip_Result";

	document.getElementById(divId).style.display='none';
}

function valueZipResult(zip, shipTo){
	if(shipTo == 1) divId = "userInformationZipShipping_Result";
	else divId = "userInformationZip_Result";
	
	document.getElementById(divId).innerHTML = "";
	if(zip == "") document.getElementById(divId).style.display='none';
	else document.getElementById(divId).style.display='';
	
	ajaxLoad(shop.url+'/ajaxTemplates/users/postalCodes.cfm?zip='+zip+'&country='+countryId+'&shipTo='+shipTo,$(divId),null);

}

function valuesStateAndCity(postalCodeId, valueState, valueCity, shipTo){
	if(shipTo == 1) divId = "userInformationPostalCodeIdShippingField";
	else divId = "userInformationPostalCodeIdField";	
	document.getElementById(divId).value = postalCodeId;

	if(shipTo == 1) divId = "userInformationStateShippingField";
	else divId = "userInformationStateField";	
	document.getElementById(divId).value = valueState;
	
	if(shipTo == 1) divId = "userInformationCityShippingField";
	else divId = "userInformationCityField";	
	document.getElementById(divId).value = valueCity;	
}

function valueZip(valueZip, shipTo){
	if(shipTo == 1) divId = "userInformationZipShippingField";
	else divId = "userInformationZipField";	

	document.getElementById(divId).value = valueZip;
}

function reloadMiniBasket(){
	var loadNext = "ajaxLoad('"+shop.url+"/ajaxTemplates/basket/miniBasket.cfm', $('miniBasket'), 'initAsyncBasket();showMiniBasket();');";
	ajaxLoad(shop.url+ '/ajaxTemplates/basket/asyncBasket.cfm', $('asyncBasketBox'), loadNext);
}

function submitUserInformationStepBasket(){
	submitUserInformationForm('formUserInformation');
}

function reloadSmallLogin(){
	ajaxLoad(shop.url+ '/ajaxTemplates/common/smallLogin.cfm', $('smallLogin'));
}

function loadProductRelatedPageInfo(obj, objInfo){
	var clickClass = obj.getAttribute('clickClass');
	var obj = $(obj.id);
	alternateClass(obj, clickClass);
	
	var children = obj.getElementsByTagName('div');
	var objId = children[0].id;
	var obj = $(objId);
	var clickClass = obj.getAttribute('clickClass');
	alternateClass(obj, clickClass);

	var obj = $(objInfo);
	var clickClass = obj.getAttribute('clickClass');
	alternateClass(obj, clickClass);
}

function alternateClass(obj, nameClass){
	$$('.'+nameClass).each(function(el){el.removeClass(nameClass);});
	if(obj.hasClass(nameClass)) obj.removeClass(nameClass);
	else obj.addClass(nameClass);
}

function reloadStock(stock){}

function restartUserFormInformation(){
	initFormFields('formUserInformation');
}

function activeInvoiceAddress(obj){
	if(obj.checked){
		requireInvoiceAddress(1);
	}
	else
		requireInvoiceAddress(0);
		
	initFormFields('formInscription');
}

var conventionType = '';
var paymentType = 0;
var timeLimit = 0;

function requireInvoiceAddress(value){
	if(value == 1)	document.getElementById('invoiceDataContent').style.display = '';
	else document.getElementById('invoiceDataContent').style.display = 'none';
	
	if(document.getElementById('inscriptionCompanyShippingField'))document.getElementById('inscriptionCompanyShippingField').setAttribute('requiredField', value);	
	if(document.getElementById('inscriptionVatShippingField'))document.getElementById('inscriptionVatShippingField').setAttribute('requiredField', value);	
	if(document.getElementById('inscriptionAddressShippingField'))document.getElementById('inscriptionAddressShippingField').setAttribute('requiredField', value);	
	if(document.getElementById('inscriptionZipShippingField'))document.getElementById('inscriptionZipShippingField').setAttribute('requiredField', value);	
	if(document.getElementById('inscriptionCityShippingField'))document.getElementById('inscriptionCityShippingField').setAttribute('requiredField', value);	
	if(document.getElementById('inscriptionStateShippingField'))document.getElementById('inscriptionStateShippingField').setAttribute('requiredField', value);	
	if(document.getElementById('inscriptionPhoneShippingField'))document.getElementById('inscriptionPhoneShippingField').setAttribute('requiredField', value);	
	//if(document.getElementById('inscriptionFaxShippingField'))document.getElementById('inscriptionFaxShippingField').setAttribute('requiredField', value);	
	if(document.getElementById('inscriptionEmailShippingField'))document.getElementById('inscriptionEmailShippingField').setAttribute('requiredField', value);	
}

function showPaymentInfo(type){
	paymentType = type;
	if(type == 1){
		if(document.getElementById('inscriptionCreditCardTypes'))document.getElementById('inscriptionCreditCardTypes').style.display='';
		if(document.getElementById('creditCardPaymentInfo'))document.getElementById('creditCardPaymentInfo').style.display='';
		if(document.getElementById('inscriptionCreditCardCardField'))document.getElementById('inscriptionCreditCardCardField').setAttribute('requiredField', 1);	
		if(document.getElementById('transferPaymentInfo'))document.getElementById('transferPaymentInfo').style.display='none';
		//$$('#inscription input.inscriptionCreditCardTypeField').each(function(el){el.setAttribute('requiredField',1); el.checked = false;});
		
	}else if(type == 2){
		if(document.getElementById('inscriptionCreditCardTypes'))document.getElementById('inscriptionCreditCardTypes').style.display='none';
		if(document.getElementById('creditCardPaymentInfo'))document.getElementById('creditCardPaymentInfo').style.display='none';
		if(document.getElementById('inscriptionCreditCardCardField'))document.getElementById('inscriptionCreditCardCardField').setAttribute('requiredField', 0);	
		if(document.getElementById('transferPaymentInfo'))document.getElementById('transferPaymentInfo').style.display='';
		//$$('#inscription input.inscriptionCreditCardTypeField').each(function(el){el.setAttribute('requiredField',0); el.checked = false;});
	}
	Spry.Widget.Form.validate('formInscription');
	checkFractionalPay();
}

var totalInscription = 0;
var discount = 15;
var symbol = '';

function onLoadInscription(){
	if(document.getElementById('inscriptionSubscribedField'))document.getElementById('inscriptionSubscribedField').checked = false;
	document.getElementById('inscriptionInvoiceDataCheckField').checked = false;
	
	$$('#inscription input.inscriptionTransferField').each(function(el){
		el.checked = false;
	});
	
	$$('#inscription input.inscriptionPreconventionField').each(function(el){
		symbol = el.getAttribute('symbol');	
		el.checked = false;
	});

	$$('#inscription input.inscriptionConventionField').each(function(el){
		el.checked = false;
	});
	
	$$('#inscription input.inscriptionCreditCardField').each(function(el){
		el.checked = false;
	});

	$$('#inscription input.inscriptionTransferField').each(function(el){
		el.checked = false;
	});

	$$('#inscription input.inscriptionCreditCardTypeField').each(function(el){
		el.checked = false;
	});

	$$('#inscription input.inscriptionSessionField').each(function(el){
		el.checked = false;
	});
	
	document.getElementById('inscriptionTotal').value = totalInscription + ' ' + symbol;
	timeLimit = document.getElementById('timeLimit').value;
	checkFractionalPay();
}

function reloadTotalInscription(obj){
	showTimetable(obj);
	reloadTotal(obj);
}

function getPricePreConventionByDuration(duration){
	var priceSession = 0;
	$$('input.inscriptionPreconventionField').each(function(elItem){
																													if(elItem.checked && elItem.getAttribute('duration') == duration){
																														priceSession = elItem.getAttribute('price');
																													}
																													});
 return priceSession;
}

function getApplyDiscountsPreConventionByDuration(duration){
	var applyDiscountsSession = 0;
	$$('input.inscriptionPreconventionField').each(function(el){
																													if(el.checked && el.getAttribute('duration') == duration){
																														applyDiscountsSession = el.getAttribute('applyDiscounts');
																													}
																													});
	return applyDiscountsSession;
}

function reloadTotal(obj){
	totalInscription = 0;
	var totalDiscounts = 0;
	var preconventionsDiscounts = 0;
	var conventionsDiscounts = 0;

	/*$$('#inscription input.inscriptionPreconventionField').each(function(el){
			if(el.checked){
				if(el.getAttribute('applyDiscounts') == 1){
					preconventionsDiscounts++;
					totalDiscounts = totalDiscounts + parseFloat(el.getAttribute('price'));
				}
				else{
					totalInscription = totalInscription + parseFloat(el.getAttribute('price'));
				}
			}
	});*/

	$$('#inscriptionTimetableFridayContent input.inscriptionSessionField').each(function(el){
			if(el.checked){
				var durationSession = el.getAttribute('duration');
				var priceSession = getPricePreConventionByDuration(durationSession);
				var applyDiscountsSession = getApplyDiscountsPreConventionByDuration(durationSession);
				if(applyDiscountsSession == 1){
					preconventionsDiscounts++;
					totalDiscounts = totalDiscounts + parseFloat(priceSession);
				}
				else{
					totalInscription = totalInscription + parseFloat(priceSession);
				}
			}
	});
	
	$$('#inscription input.inscriptionConventionField').each(function(el){
			symbol = el.getAttribute('symbol');
			if(el.checked){
				if(el.getAttribute('applyDiscounts') == 1){
					conventionsDiscounts++;
					totalDiscounts = totalDiscounts + parseFloat(el.getAttribute('price'));
				}
				else{
					totalInscription = totalInscription + parseFloat(el.getAttribute('price'));
				}
			}
	});

	if(preconventionsDiscounts > 0 && conventionsDiscounts > 0){
		totalInscription = totalInscription + parseFloat(totalDiscounts - (totalDiscounts*(discount/100)));
	}
	else{
		totalInscription = totalInscription + totalDiscounts;
	}

	document.getElementById('inscriptionTotal').value = totalInscription + ' ' + symbol;
}

function undoSelectionConventions(){
	$$('#inscription input.inscriptionConventionField').each(function(el){
		el.checked = false;
	});
	$$('#inscription div.conventionTimetable').each(function(el){el.innerHTML = ''});
	reloadTotal();
}

function showTimetable(obj){
	var day = obj.getAttribute('timetable');
	var newContent = document.getElementById('conventionContent_'+day);
	var contentFriday= document.getElementById('timetableFriday');
	var contentSaturday = document.getElementById('timetableSaturday');
	var contentSunday = document.getElementById('timetableSunday');
	var contentMasterclases = document.getElementById('timetableMasterclases');
	var contentAquafitness = document.getElementById('timetableAquafitness');
	
	conventionType = day;
	
	if(day == 'friday'){
		var preconventionChecked = 0;
		$$('#inscription input.inscriptionPreconventionField').each(function(el){
																														if(el.checked == true)preconventionChecked++;
																														});

		if(preconventionChecked == 1) newContent.innerHTML = contentFriday.innerHTML;
		else if(preconventionChecked == 0)	newContent.innerHTML = '';
		
		$$('#inscription input.inscriptionPreconventionField').each(function(itemPreconvention){
			var duration = itemPreconvention.getAttribute('duration');
			$$('#inscription table.inscriptionTimetableFriday input.inscriptionSessionField').each(function(itemSession){
				var durationItem = itemSession.getAttribute('duration');
				if(durationItem == duration){
					if(itemPreconvention.checked == true && itemSession.checked == false){
						itemSession.style.display = ''; itemSession.checked = false;
					}
					else if(itemPreconvention.checked == false){
						itemSession.style.display = 'none'; itemSession.checked = false;
					}
				}
			});
		});
	}
	else{
		if(obj.checked == true){
			$$('#inscription div.conventionTimetable').each(function(el){el.innerHTML = '';});
			if(day == 'saturday'){
				newContent.innerHTML = contentSaturday.innerHTML;
			}
			else if(day == 'sunday'){
				newContent.innerHTML = contentSunday.innerHTML;
			}
			else if(day == 'weekend'){
				newContent.innerHTML = contentSaturday.innerHTML + contentSunday.innerHTML;
			}
			else if(day == 'masterclases'){
				newContent.innerHTML = contentMasterclases.innerHTML;
			}
			else if(day == 'aquafitness'){
				newContent.innerHTML = contentAquafitness.innerHTML;
			}
		}
		else{
			newContent.innerHTML = '';
		}
	}
	checkFractionalPay();
}


function checkFractionalPay(){
	if(document.getElementById('inscriptionFractionalPay')){
		if(paymentType == 1 && conventionType == 'weekend' && timeLimit == 1){
			document.getElementById('inscriptionFractionalPay').style.display = '';
			$$('#inscription input.inscriptionFractionalPayField').each(function(el){el.setAttribute('requiredField', 1);});
			
		}
		else{
			document.getElementById('inscriptionFractionalPay').style.display = 'none';
			$$('#inscription input.inscriptionFractionalPayField').each(function(el){el.setAttribute('requiredField', 0); el.checked=false;});
			document.getElementById('inscriptionCreditCardCardField').value='';
		}
		initFormFields('formInscription');
	}
}


function submitForm(form, divId, callBack, imageLoading){	
	
	Spry.Utils.submitForm(form, function(req){
																			 document.getElementById(divId).innerHTML = req.xhRequest.responseText; 
																			 eval(callBack);
																			 } );
}


function validateAndSubmitForm(form, divId, callBack, imageLoading){	
	initFormFields(form);

	if(Spry.Widget.Form.validate($(form))){
		if(imageLoading)
			document.getElementById(divId).innerHTML = "<img src='" + shop.templatePath + "/images/"+imageLoading+"'>";	
		
		Spry.Utils.submitForm(form, function(req){
					 document.getElementById(divId).innerHTML = req.xhRequest.responseText; 
					 eval(callBack);
					 } );
	}
	else{
		shop.cuteAlert.addMessage(languageSheet.lblError, languageSheet.lblErroneousData, 0, 0, messageWidthExtra,messageHeightExtra);
	}
}


var timeLimit = 0;
var program = 0;
var totalInscription = 0;
var totalSessions = 0;
function onLoadWorkshop(){
	if(document.getElementById('inscriptionSubscribedField'))document.getElementById('inscriptionSubscribedField').checked = false;
	document.getElementById('inscriptionInvoiceDataCheckField').checked = false;
	
	$$('#inscription input.inscriptionTransferField').each(function(el){
		el.checked = false;
	});
	
	$$('#inscription input.inscriptionPlaceField').each(function(el){
		el.checked = false;
	});

	$$('#inscription input.inscriptionProgramField').each(function(el){
		//symbol = el.getAttribute('symbol');	
		el.checked = false;
	});
	
	$$('#inscription input.inscriptionCreditCardField').each(function(el){
		el.checked = false;
	});

	$$('#inscription input.inscriptionTransferField').each(function(el){
		el.checked = false;
	});

	$$('#inscription input.inscriptionCreditCardTypeField').each(function(el){
		el.checked = false;
	});

	$$('#inscription input.inscriptionSessionField').each(function(el){
		el.checked = false;
	});
	
	reloadTotalWorkshop();
	checkFractionalPayWorkshop();
	checkSubmitForm();
}

function displayProgram(obj){
	program = obj.getAttribute('program');
	var date = obj.getAttribute('date');
	timeLimit = obj.getAttribute('timeLimit');
	timeLimit = timeLimit.replace(/^\s*|\s*$/g,"");

	document.getElementById('inscriptionPrograms').style.display = '';
	$$('div.inscriptionProgram').each(function(el){
																						 	el.style.display='none';
																							});
	if(program > 0){
		var programDiv = document.getElementById('inscriptionProgram_'+program);
		programDiv.style.display = '';
		var elements = programDiv.getElementsByTagName('input');
		for(var i=0;i<elements.length;i++){elements[i].checked=false;}
		totalInscription = 0;
		document.getElementById('inscriptionTotal').value = totalInscription + ' ' + symbol;
	}
	checkSubmitForm();
}

function reloadTotalWorkshop(obj){
	totalInscription = 0;
	totalSessions = 0;
	$$('#inscriptionProgram_'+program+' input.inscriptionProgramField').each(function(el){
		if(el.checked){ 
			totalSessions = totalSessions+1; 
			//totalInscription = totalInscription + parseFloat(el.getAttribute('priceTimeLimit'+timeLimit));
		}
	});
	if(totalSessions > 0 && timeLimit > 0) totalInscription = document.getElementById('prices_'+timeLimit+'_'+totalSessions).value;
	symbol = document.getElementById('symbol').value;
	document.getElementById('inscriptionTotal').value = totalInscription + ' ' + symbol;
	checkFractionalPayWorkshop();
	checkSubmitForm();
}

function checkFractionalPayWorkshop(){
	/*if(paymentType == 1 && totalSessions == 3 && timeLimit == 1){
		document.getElementById('inscriptionFractionalPay').style.display = '';
		$$('#inscription input.inscriptionFractionalPayField').each(function(el){el.setAttribute('requiredField', 1);});
		
	}
	else{
		document.getElementById('inscriptionFractionalPay').style.display = 'none';
		$$('#inscription input.inscriptionFractionalPayField').each(function(el){el.setAttribute('requiredField', 0); el.checked=false;});
		document.getElementById('inscriptionCreditCardCardField').value='';
	}
	initFormFields('formInscription');*/
}

function showPaymentInfoWorkshop(type){
	paymentType = type;
	if(type == 1){
		if(document.getElementById('inscriptionCreditCardTypes'))document.getElementById('inscriptionCreditCardTypes').style.display='';
		if(document.getElementById('creditCardPaymentInfo'))document.getElementById('creditCardPaymentInfo').style.display='';
		if(document.getElementById('inscriptionCreditCardCardField'))document.getElementById('inscriptionCreditCardCardField').setAttribute('requiredField', 1);	
		if(document.getElementById('transferPaymentInfo'))document.getElementById('transferPaymentInfo').style.display='none';
		//$$('#inscription input.inscriptionCreditCardTypeField').each(function(el){el.setAttribute('requiredField',1); el.checked = false;});
		
	}else if(type == 2){
		if(document.getElementById('inscriptionCreditCardTypes'))document.getElementById('inscriptionCreditCardTypes').style.display='none';
		if(document.getElementById('creditCardPaymentInfo'))document.getElementById('creditCardPaymentInfo').style.display='none';
		if(document.getElementById('inscriptionCreditCardCardField'))document.getElementById('inscriptionCreditCardCardField').setAttribute('requiredField', 0);	
		if(document.getElementById('transferPaymentInfo'))document.getElementById('transferPaymentInfo').style.display='';
		//$$('#inscription input.inscriptionCreditCardTypeField').each(function(el){el.setAttribute('requiredField',0); el.checked = false;});
	}
	Spry.Widget.Form.validate('formInscription');
	checkFractionalPayWorkshop();
}

function checkSubmitForm(){
	if(timeLimit > 0 && totalSessions > 0){
		document.getElementById('inscriptionSubmit').style.display = '';
	}
	else{
		document.getElementById('inscriptionSubmit').style.display = 'none';
	}
}

function showTimeTable3FIT(obj){
	
	if(!obj) return;
	
	$$('div.inscription input').each(function(el){
																						if(obj.type == 'radio' && el.checked == true && el.id != obj.id && el.name != 'useInvoiceData') el.checked = false;
																						});
	
	if(obj.type == 'radio')document.getElementById('inscriptionTotal').value = '0 ' + document.getElementById('symbol').value;
	
	var timetable = obj.getAttribute('timetable');
	
	var newContent = document.getElementById('sessionContent_'+timetable);
	var contentCourses= document.getElementById('timetableCourses');
	var contentBosu = document.getElementById('timetableBosu');
	var contentMasterclases = document.getElementById('timetableMasterclasses');
	var contentKettlebells = document.getElementById('timetableKettlebells');
	var contentCoursesAndMasterclasses = document.getElementById('timetableCoursesAndMasterclasses');
	
	
	if(obj.checked == true){
		if(obj.type == 'radio')$$('#inscription div.sessionTimetable').each(function(el){el.innerHTML = '';});
		if(timetable == 'courses'){
			newContent.innerHTML = contentCourses.innerHTML;
		}
		else if(timetable == 'bosu'){
			newContent.innerHTML = contentBosu.innerHTML;
		}
		else if(timetable == 'masterclasses'){
			newContent.innerHTML = contentMasterclases.innerHTML;
		}
		else if(timetable == 'kettlebells'){
			newContent.innerHTML = contentKettlebells.innerHTML;
		}
		else if(timetable == 'coursesAndMasterclasses'){
			newContent.innerHTML = contentCourses.innerHTML + contentMasterclases.innerHTML;
		}
	}
	else{
		newContent.innerHTML = '';
	}
	
	//numCourses = 0;
	//numMasterclasses = 0;
	//numBosu = 0;
	//numKettlebell = 0;
}

var numCourses = 0;
var numMasterclasses = 0;
var numBosu = 0;
var numKettlebell = 0;
var totalMasterclasses = 0;


function reload3FITTotal(obj){
	if(!obj) return;
	
	var totalInscription = 0;
	
	var type = obj.getAttribute('typeSession');
	var checked = obj.checked;
	if(type == 'masterclasses'){
		if(checked == true)	numMasterclasses = numMasterclasses + 1;
		else numMasterclasses = numMasterclasses - 1;
	}
	else if(type == 'courses'){
		if(checked == true)	numCourses = numCourses + 1;
		else numCourses = numCourses - 1;
	}
	if(type == 'bosu'){
		if(checked == true)	numBosu = numBosu + 1;
		else numBosu = numBosu - 1;
	}
	if(type == 'kettlebell'){
		if(checked == true)	numKettlebell = numKettlebell + 1;
		else numKettlebell = numKettlebell - 1;
	}
	
	if(numMasterclasses < 0) numMasterclasses = 0;
	if(numCourses < 0) numCourses = 0;
	if(numBosu < 0) numBosu = 0;
	if(numKettlebell < 0) numKettlebell = 0;

	if(numCourses > 0 && numMasterclasses > 0){
		if(numCourses == 1 && numMasterclasses == 3) totalInscription = totalInscription + parseInt(document.getElementById('courseAnd3Masterclasses').value);
		else if(numCourses == 1 && numMasterclasses == 6) totalInscription = totalInscription + parseInt(document.getElementById('courseAnd6Masterclasses').value);
		else if(numCourses == 2 && numMasterclasses == 3) totalInscription = totalInscription + parseInt(document.getElementById('2coursesAnd3Masterclasses').value);
		else if(numCourses == 2 && numMasterclasses == 6) totalInscription = totalInscription + parseInt(document.getElementById('2coursesAnd6Masterclasses').value);
		else if(numCourses == 3 && numMasterclasses == 3) totalInscription = totalInscription + parseInt(document.getElementById('3coursesAnd3Masterclasses').value);
		else if(numCourses == 3 && numMasterclasses == 6) totalInscription = totalInscription + parseInt(document.getElementById('3coursesAnd6Masterclasses').value);
	}
	else if(numCourses == 1) totalInscription = totalInscription + parseInt(document.getElementById('oneCourse').value);
	else if(numCourses == 2) totalInscription = totalInscription + parseInt(document.getElementById('twoCourses').value);
	else if(numCourses == 3) totalInscription = totalInscription + parseInt(document.getElementById('threeCourses').value);
	else if(numCourses == 4) totalInscription = totalInscription + parseInt(document.getElementById('fourCourses').value);
	else if(numMasterclasses >= totalMasterclasses) totalInscription = totalInscription + parseInt(document.getElementById('allMasterclasses').value);

	if(numBosu > 0) totalInscription = totalInscription + parseInt(document.getElementById('bosu').value);
	if(numKettlebell > 0) totalInscription = totalInscription + parseInt(document.getElementById('kettlebells').value);
	
	
	checkSubmitForm3FIT(totalInscription);
}

function onLoadInscription3FIT(){
	//showTimeTable3FIT();
	/*$$('table.inscription3FITTimetableMasterclasses input').each(function(el){
																																				if(el.getAttribute('typeSession') && el.getAttribute('typeSession') == 'masterclasses')totalMasterclasses = totalMasterclasses +1;
																																				});*/
	totalMasterclasses = 1;

	$$('div.inscription input').each(function(el){
																						if(el.checked == true) el.checked = false;
																						});
		
	//reload3FITTotal();
	checkSubmitForm3FIT(0);
}

function checkSubmitForm3FIT(totalInscription){
	document.getElementById('inscriptionTotal').value = totalInscription + ' ' + document.getElementById('symbol').value;
	if(totalInscription > 0){
		document.getElementById('inscriptionSubmit').style.display = '';
	}
	else{
		document.getElementById('inscriptionSubmit').style.display = 'none';
	}
}

function undoSelectionSession3FIT(){
	numMasterclasses = 0;
	numCourses = 0;
	numBosu = 0;
	numKettlebell = 0;
	$$('#inscription input.inscriptionSessionField').each(function(el){
		el.checked = false;
	});
	$$('#inscription div.sessionTimetable').each(function(el){el.innerHTML = ''});
	checkSubmitForm3FIT(0);
	
}

function reloadTotalInscriptionBAR2010(obj){
	showTimetableBAR2010(obj);
	reloadTotalBAR2010(obj);
}

function showTimetableBAR2010(obj){
	var day = obj.getAttribute('timetable');
	var newContent = document.getElementById('conventionContent_'+day);
	var contentFriday= document.getElementById('timetableFriday');
	var contentSaturday = document.getElementById('timetableSaturday');
	var contentSunday = document.getElementById('timetableSunday');
	
	conventionType = day;
	
	if(day == 'friday'){
		var preconventionChecked = 0;
		$$('#inscription input.inscriptionPreconventionField').each(function(el){
																														if(el.checked == true)preconventionChecked++;
																														});

		if(preconventionChecked == 1) newContent.innerHTML = contentFriday.innerHTML;
		else if(preconventionChecked == 0)	newContent.innerHTML = '';
		
		$$('#inscription input.inscriptionPreconventionField').each(function(itemPreconvention){
			var duration = itemPreconvention.getAttribute('duration');
			$$('#inscription div.inscriptionBAR2010TimetableFridayContent input.inscriptionSessionField').each(function(itemSession){
				var durationItem = itemSession.getAttribute('duration');
				/*if(durationItem == duration){
					if(itemPreconvention.checked == true && itemSession.checked == false){
						itemSession.style.display = ''; itemSession.checked = false;
					}
					else if(itemPreconvention.checked == false){
						itemSession.style.display = 'none'; itemSession.checked = false;
					}
				}*/
			});
		});
	}
	else{
		if(obj.checked == true){
			$$('#inscription div.conventionTimetable').each(function(el){el.innerHTML = '';});
			if(day == 'saturday'){
				newContent.innerHTML = contentSaturday.innerHTML;
			}
			else if(day == 'sunday'){
				newContent.innerHTML = contentSunday.innerHTML;
			}
			else if(day == 'weekend'){
				newContent.innerHTML = contentSaturday.innerHTML + contentSunday.innerHTML;
			}
			newContent.style.display = '';
		}
		else{
			newContent.innerHTML = '';
			newContent.style.display = 'none';
		}
	}
	checkOptionsBAR2010();
	checkFractionalPayBAR2010();
}

function checkFractionalPayBAR2010(){
	if(document.getElementById('inscriptionFractionalPay')){
		if(paymentType == 1 && conventionType == 'weekend' && timeLimit == 1){
			document.getElementById('inscriptionFractionalPay').style.display = '';
			$$('#inscription input.inscriptionFractionalPayField').each(function(el){el.setAttribute('requiredField', 1);});
			
		}
		else{
			document.getElementById('inscriptionFractionalPay').style.display = 'none';
			$$('#inscription input.inscriptionFractionalPayField').each(function(el){el.setAttribute('requiredField', 0); el.checked=false;});
			document.getElementById('inscriptionCreditCardCardField').value='';
		}
		initFormFields('formInscription');
	}
}

function checkOptionsBAR2010(){
	
	var contentSaturday = document.getElementById('conventionContent_saturday').style.display;
	var contentSunday = document.getElementById('conventionContent_sunday').style.display;
	var contentWeekend = document.getElementById('conventionContent_weekend').style.display;
	
	if(contentSaturday != 'none' || contentSunday != 'none' || contentWeekend != 'none'){
		document.getElementById('inscriptionOptionsConventions').style.display = '';
	}
	else{
		document.getElementById('inscriptionOptionsConventions').style.display = 'none';
		$$('input.inscriptionOptionsConventionsItemField').each(function(el){el.checked = false});
	}
}

var lunchIncluded = 0;
function onLoadInscriptionBAR2010(){
	if(document.getElementById('inscriptionSubscribedField'))document.getElementById('inscriptionSubscribedField').checked = false;
	document.getElementById('inscriptionInvoiceDataCheckField').checked = false;
	
	$$('#inscription input.inscriptionTransferField').each(function(el){
		el.checked = false;
	});
	
	$$('#inscription input.inscriptionPreconventionField').each(function(el){
		symbol = el.getAttribute('symbol');	
		el.checked = false;
	});

	$$('#inscription input.inscriptionConventionField').each(function(el){
		el.checked = false;
	});
	
	$$('#inscription input.inscriptionCreditCardField').each(function(el){
		el.checked = false;
	});

	$$('#inscription input.inscriptionTransferField').each(function(el){
		el.checked = false;
	});

	$$('#inscription input.inscriptionCreditCardTypeField').each(function(el){
		el.checked = false;
	});

	$$('#inscription input.inscriptionSessionField').each(function(el){
		el.checked = false;
	});


	document.getElementById('inscriptionTotal').value = totalInscription + ' ' + symbol;
	timeLimit = document.getElementById('timeLimit').value;
	document.getElementById('inscriptionOptionsConventionsItem1Field').checked = true;
	lunchIncluded = document.getElementById('inscriptionOptionsConventionsItem1Field').value;
	checkFractionalPayBAR2010();
}


var discountBAR1010 = 10;
var dayBAR2010 = "";
function reloadTotalBAR2010(obj){
	checkOptionsBAR2010();
	//checkOnlyOption(obj);

	var price = 0;
	var totalConventions = 0;
	var totalPreconventions = 0;
	var conventionsDiscounts = 0;
	var pricePreConventions = 0;
	var priceConventions = 0;
	
	$$('div.inscriptionPreconventionsChecks input.inscriptionPreconventionField').each(function(el){
			if(el.checked){
				pricePreConventions = pricePreConventions + parseInt(el.getAttribute('price'));
			}
	});
	$$('div.preconventionTimetable input.inscriptionSessionField').each(function(el){
		if(el.checked)totalPreconventions++;
	});
	price = pricePreConventions * totalPreconventions;
	
	$$('#inscription input.inscriptionConventionField').each(function(el){
			symbol = el.getAttribute('symbol');
			if(el.checked){
				dayBAR2010 = el.getAttribute('timetable');
				priceConventions = priceConventions + parseFloat(el.getAttribute('price'));
				if(el.getAttribute('applyDiscounts') == 1){
					conventionsDiscounts++;
				}
				//totalConventions++;
			}
	});
	$$('div.conventionTimetable input.inscriptionSessionField').each(function(el){
		if(el.checked){
			totalConventions++;
		}
	});
	if(totalConventions > 0) price = price + priceConventions;

	var increasePrice = 0;
	if(totalConventions > 0 && lunchIncluded == 1){
		if(dayBAR2010 == 'weekend') increasePrice = 40;
		else if(dayBAR2010 == 'saturday' || dayBAR2010 == 'sunday') increasePrice = 20;
	}

	var totalInscription = price + increasePrice;
	if(totalPreconventions > 0 && totalConventions > 0 &&  conventionsDiscounts > 0){
		totalInscription = parseFloat(totalInscription - (totalInscription*(discountBAR1010/100)));
	}

	

	document.getElementById('inscriptionTotal').value = totalInscription + ' ' + symbol;
}

function checkOnlyOption(obj){
	onlyOption = obj.getAttribute('onlyOption');
	if(obj.checked && onlyOption && onlyOption.length > 0){
		disableOptionsRang(onlyOption, obj.id);
	}
	else{
		disableOptionsRang('','');
	}
}

function disableOptionsRang(nameClass, objId){

	$$('div.'+nameClass+' input[type=checkbox]').each(function(el){
		if(nameClass.length > 0 && el.id != objId){el.checked = false; /*el.style.display = 'none';*/}
		/*else el.style.display = '';*/
	});
}

function checkLunchIncluded(obj){
	lunchIncluded = obj.value;
}

function undoSelectionConventionsBAR2010(){
	$$('#inscription input.inscriptionConventionField').each(function(el){
		el.checked = false;
	});
	$$('#inscription div.conventionTimetable').each(function(el){el.innerHTML = ''; el.style.display = 'none'});
	reloadTotalBAR2010();
}

function undoSelectionPreConventionsBAR2010(){
	$$('#inscription input.inscriptionPreconventionField').each(function(el){
		el.checked = false;
	});
	$$('#inscription div.preconventionTimetable').each(function(el){el.innerHTML = ''});
	reloadTotalBAR2010();
}



$(window).addEvent('domready', function(){initShop(); initProduct();});
$(window).addEvent('click', function(){hideSubCategories()});


function Player(CD1,CD2,Name,No){
	ACD1=CD1; ACD2=CD2; AName=Name; ANo=No;
	myWnd = window.open('http://www.move-ya.de/belsonic/indexCD.php?Playlist1='+ACD1+'&Playlist2='+ACD2+'&Name='+AName+'&No='+ANo,'', 'height=470,width=310,menubar=0,resizable=0,scrollbars=no,status=0,titlebar=0,toolbar=0,left=100,top=0'); 
} 