$(function() {	if($('.rate-form').length) {		$('.rate-form .alignLeft').hover(			function() {				$(this).find('.criteria').show()			},			function() {				$(this).find('.criteria').hide()			}		);		$('.star-rating-control').delegate('div', 'click', function() {			calcTotalRating();		});		calcTotalRating();	}	if($("#payment_block dt > input[type='radio']:checked").attr('id')!='field_payment_klarna_de') {		$('#klarna_de-desc').hide();		$('#klarna_de-field').hide();	} else {		$('#field_klarna_de_pnum_year').addClass('validate[funcCall[validateBirthday]]');		$('#field_klarna_de_phone').addClass('validate[required,custom[zeroStart]]');		$('#checkout_payment').validationEngine();	}	if($("a.thickbox").length) {		$("a.thickbox").colorbox();		$(".flv-video a").colorbox({iframe:true, width:710, height:450});		$(".thickbox-video").colorbox({iframe:true, width:710, height:580});		$(".thickbox-gallery").colorbox({iframe:true, width:840, height:660});	}	$('#cart_quantity #field_country').change(function() {		$('#cart_quantity').submit();	});	if($("#dresdner-cetelem-rates").length) {		$('#dresdner-cetelem-rates-box').hide();		$('#dresdner-cetelem-hint').show();		$('#dresdner-cetelem-rates').addClass('noborder');		$('a.dresdner-cetelem').colorbox({width:"450px", inline:true, href:"#dresdner-cetelem-rates"});	}	if($('.checkout textarea').length) {		$('.checkout textarea').elastic();	}	if($('.validate_form').length) {		$('.validate_form').each(function() {			$(this).validationEngine();		});	}	if($('#cop_login').length) {		$('#cop_login').validationEngine({			inlineValidation: false		});	}	if($('#state_dropdown').length && $('#field_country').length) {		$('#field_country').change(function() {			updateState(false);		});	}	if($('#shipping_state_dropdown').length && $('#field_shipping_country').length) {		$('#field_shipping_country').change(function() {			updateState('shipping_');		});	}	if($('#billing_state_dropdown').length && $('#field_billing_country').length) {		$('#field_billing_country').change(function() {			updateState('billing_');		});	}	if($('#cop_login').length) {		if(!$('#login_error').length) {			$('#cop_login').hide();			$('#login_here').click(function() {				$('#cop_login').slideDown();				window.setTimeout("$.scrollTo('#cop_login', 250, {easing:'swing'})", 250);				window.setTimeout("$('#cop_login').seekAttention({pulseSpeed: 800,paddingTop: 10,paddingLeft: 10,paddingBottom: 10,paddingRight: 10,blur: true,pulse: false});", 500);				return false;			});		} else {			$.scrollTo('#cop_login', 250, {easing:'swing'});		}	}	if($('#redeem_voucher').length) {		$('#redeem_voucher').click(function() {			window.setTimeout("$.scrollTo('#gift_coupon', 250, {easing:'swing'})", 250);			window.setTimeout("$('#gift_coupon').seekAttention({pulseSpeed: 800,paddingTop: 10,paddingLeft: 10,paddingBottom: 10,paddingRight: 10,blur: true,pulse: false});", 500);			return false;		});	}	if($('input[name=payment]').length) {		$('input[name=payment]').change(function() {			$('#payment_info_default').hide();			$('#payment_info .none').hide();			var fld = "#id"+this.id.replace(/field_payment/, '');			$(fld).show();			if($('#field_payment_ipaymentelv').is(':checked')) {				$('#field_ipayment_owner').addClass('validate[required]');				$('#field_ipayment_bank_name').addClass('validate[required]');				$('#field_ipayment_bank_code').addClass('validate[required,custom[onlyNumber],length[8,8]]');				$('#field_ipayment_bank_account').addClass('validate[required,custom[onlyNumber],length[3,12]]');				$('#checkout_payment').validationEngine();			} else {				$('#field_ipayment_owner').removeClass('validate[required]');				$('#field_ipayment_bank_name').removeClass('validate[required]');				$('#field_ipayment_bank_code').removeClass('validate[required,custom[onlyNumber],length[8,8]]');				$('#field_ipayment_bank_account').removeClass('validate[required,custom[onlyNumber],length[3,12]]');				$('#checkout_payment').validationEngine();			}			if($('#field_payment_klarna_de').is(':checked')) {				$('#klarna_de-desc').show();				$('#klarna_de-field').show();				$('.equalize').equalHeights();				$('#field_klarna_de_pnum_year').addClass('validate[funcCall[validateBirthday]]');				$('#field_klarna_de_phone').addClass('validate[required,custom[zeroStart]]');				$('#checkout_payment').validationEngine();			} else {				$('#klarna_de-desc').hide();				$('#klarna_de-field').hide();				$('#field_klarna_de_pnum_year').removeClass('validate[funcCall[validateBirthday]]');				$('#field_klarna_de_phone').removeClass('validate[required,custom[zeroStart]]');				$('#checkout_payment').validationEngine();			}		});	}	if($('.equalize').length) {		$('.equalize').equalHeights()	}	if($('#payment_info_default').length) {		newHeight = $('#payment_block_wrapper').height()-$('#shipping_block_wrapper').height()-32;		if(newHeight<200) {			$('#payment_info_default').height(200);			$('#payment_block_wrapper').height(271)			$('#payment_info .none').each(function(){				$(this).height(200);			});		} else {			$('#payment_info_default').height(newHeight);			$('#payment_info .none').each(function(){				$(this).height(newHeight);			});		}	}	if($('#new-shipping-field').length) {		if($('#new-shipping-field').is(':checked')) {			$('#shipping_address_wrapper .jsNone').show();		} else {			$('#shipping_address_wrapper').hide();		}		$('input[name=shipping]').change(function() {			if($('#new-shipping-field').is(':checked')) {				$('#shipping_address_wrapper').show();			} else {				$('#shipping_address_wrapper').hide();			}		});	}	if($('#new-billing-field').length) {		if($('#new-billing-field').is(':checked')) {		} else {			$('#billing_address_wrapper').hide();		}		$('input[name=billing]').change(function() {			if($('#new-billing-field').is(':checked')) {				$('#billing_address_wrapper').show();			} else {				$('#billing_address_wrapper').hide();			}		});	}	if($('#checkbox_account').length) {		if($('#checkbox_account').is(':checked')) {			$('#password_wrapper').show();		} else {			$('#password_wrapper').hide();		}		$('#checkbox_account').change(function() {			if($(this).is(':checked')) {				$('#password_wrapper').show();				$('#password_wrapper input').each(function() {					if(($('body').data($(this).attr('name')))!=null) {						$(this).val($('body').data($(this).attr('name')));					}				});			} else {				$('#password_wrapper').hide();				$('#password_wrapper input').each(function() {					$('body').data($(this).attr('name'), $(this).val());					if($(this).attr('type')!='radio' && $(this).attr('type')!='checkbox') {						$(this).val('');					}				});			}		});	}	if($('#checkbox_optional_shipping_address').length) {		$('#optional_shipping_address').show();		if(!$('#checkbox_optional_shipping_address').is(':checked')) {			$('#shipping_address').hide();			$('#address-billing').html($('#text_billing_shipping').val());		} else {			$('#shipping_address .jsNone').show();		}		$('#checkbox_optional_shipping_address').change(function() {			if($(this).is(':checked')) {				$('#shipping_address').show();				$('#address-billing').html($('#text_billing').val());				$('#shipping_address input').each(function() {					if($(this).attr('type')!='radio' && $(this).attr('type')!='checkbox') {						if(($('body').data($(this).attr('name')))!=null) {							$(this).val($('body').data($(this).attr('name')));						}					}				});				if($('body').data('field_shipping_country')) {					$('#field_shipping_country').val($('body').data('field_shipping_country'));				}				updateState('shipping_');			} else {				$('#shipping_address').hide();				$('#address-billing').html($('#text_billing_shipping').val());				$('#shipping_address input').each(function() {					$('body').data($(this).attr('name'), $(this).val());					if($(this).attr('type')!='radio' && $(this).attr('type')!='checkbox') {						$(this).val('');					}				});				$('body').data('field_shipping_country', $('#field_shipping_country').val());				$('body').data('field_shipping_state', $('#field_shipping_state').val());				$('#field_shipping_country').val('81');				updateState('shipping_');			}		});	}		$('.cop-confirmation .button input').click(function() {		if($('#checkout_confirmation_top').validationEngine({returnIsValid:true})==true) {			$('#checkout_confirm_button').hide();			$('#checkout_confirm_hint').show();			$('#checkout_confirm_button_top').hide();			$('#checkout_confirm_hint_top').show();		}	});	if($('#product-options').length) {		$('#product-options select').change(function() {			updatePrice();		});	}});function validateValidDate() {	gmonth = $('#field_cc_expdate_month').val();	gyear = parseInt($('#field_cc_expdate_year').val())+2000;	var currentTime = new Date();	month = currentTime.getMonth()+1;	if(month.length==1) {		month = "0"+month;	}	year = currentTime.getFullYear();	month = month.toString();	year = year.toString();	current = parseInt(year+month);	given = parseInt(gyear+gmonth);	if(given<current) {		return false;	} else {		return true;	}}function validateBirthday() {	gday = $('#field_klarna_de_pnum_day').val();	gmonth = $('#field_klarna_de_pnum_month').val();	gyear = $('#field_klarna_de_pnum_year').val();	gdate = gday.toString()+gmonth.toString()+gyear.toString();	if(gdate=='01011900') {		return false;	} else {		return true;	}}function updatePrice() {	var extras = 0;	var price = $('#default-price').html();	price = price.replace(/EUR/, "");	price = price.replace(/\./, "");	price = price.replace(/,/, ".");	price = $.trim(price);	$('#product-options select').each(function() {		id = $(this).attr('id');		textval = $('#'+id+' option:selected').html();		if(textval.match(/EUR/) && !textval.match(/^EUR/)) {			extraprice = textval.replace(/.*EUR/, "");			extraprice = extraprice.replace(".","");			extraprice = extraprice.replace(",",".");			extras += parseFloat(extraprice);		}	});	total = parseFloat(price)-parseFloat(extras);	retval = total.toFixed(2).replace(/\./,",");	if(retval.length>6) {		retval = retval.replace(/(...,..)/, ".$1");	}		$('.products-price').html("EUR "+retval);}function updateState(which) {	var lng = $("input[name=language]").val();	var url = $("base").attr('href');	var which = which==false ? '' : which;	$("#"+which+"state_dropdown").html('<img src="images/spinner.gif" alt="" />');	$.validationEngine.closePrompt(".formError",true);	$.post(url+'updateState.php', {'which': which, 'id': $('#field_'+which+'country').val()}, function(data) {		if(data=='') {			$('#optional_'+which+'state_dropdown').hide();			$("#"+which+"state_dropdown").html('<input type="hidden" name="'+which+'state" value="0"/>');		} else {			$('#optional_'+which+'state_dropdown').show();			$("#"+which+"state_dropdown").html(data);			$('.validate_form').each(function() {				$(this).validationEngine();			});			if(which!='' && $('body').data('field_'+which+'state')) {				$('#field_'+which+'state').val($('body').data('field_'+which+'state'));			}		}	});}function calcTotalRating() {	goods = $('input[name=bewertung_ware]:checked').val();	delivery = $('input[name=bewertung_versand]:checked').val();	service = $('input[name=bewertung_service]:checked').val();	website = $('input[name=bewertung_seite]:checked').val();	divider = 4;	if(typeof goods == 'undefined') { goods = 0; divider--;} else { goods = parseInt(goods); }	if(typeof delivery == 'undefined') { delivery = 0; divider--;} else { delivery = parseInt(delivery); }	if(typeof service == 'undefined') { service = 0; divider--;} else { service = parseInt(service); }	if(typeof website == 'undefined') { website = 0; divider--;} else { website = parseInt(website); }	total = (goods+delivery+service+website)/divider;	$('#field_bewertung_shoprating').val(Math.round(total));	if(divider==0) {		$('.rating-total-wording').html('<span class="red">Please rate at least 1 criteria</span>');	} else {		switch(Math.round(total)) {			case 1:			wording = "Very poor";			break;			case 2:			wording = "Poor";			break;			case 3:			wording = "Fair";			break;			case 4:			wording = "Good";			break;			case 5:			wording = "Excellent";			break;		}		$('.rating-total-wording').html("<strong>"+wording+"</strong><br/><small>("+total.toFixed(2)+" of 5.00)</small>");	}}
