String.prototype.trim = function(){   return this.replace(/^\s*|\s*$/g,"");}String.prototype.isInt = function() {  var str = this.replace(/^0+/, '');  var i = parseInt(str);  if (isNaN(i)) return false;  i = i.toString();  if (i != str) return false;  return true;}onClickBrute = function(){	var brute = document.getElementById('paymentstep1-product-brute');	brute.checked = true;	var bruteLabel = document.getElementById('paymentstep1-product-brute-label');	bruteLabel.style.fontWeight = 'bold';	var sachetLabel = document.getElementById('paymentstep1-product-sachet-label');	sachetLabel.style.fontWeight = 'normal';	var bar = document.getElementById('ecommerce-bar');	bar.style.display = '';	var required = document.getElementById('ecommerce-required');	required.style.display = '';	document.paypal.item_name.value = document.paypal.item_name_brute.value;	set_amount();}onClickSachet = function(){	var sachet = document.getElementById('paymentstep1-product-sachet');	sachet.checked = true;	var sachetLabel = document.getElementById('paymentstep1-product-sachet-label');	sachetLabel.style.fontWeight = 'bold';	var bruteLabel = document.getElementById('paymentstep1-product-brute-label');	bruteLabel.style.fontWeight = 'normal';	var bar = document.getElementById('ecommerce-bar');	bar.style.display = '';	var required = document.getElementById('ecommerce-required');	required.style.display = '';	document.paypal.item_name.value = document.paypal.item_name_sachet.value;	set_amount();}validate_last_name = function(){	var lb = document.getElementById('paymentstep1-lastname-label');	var el = document.getElementById('paymentstep1-lastname-input');	if(el.value.trim()==''){	  lb.style.color='red';	  return false;	}else{	  lb.style.color='';	  return true;	}}validate_first_name = function(){	var lb = document.getElementById('paymentstep1-firstname-label');	var el = document.getElementById('paymentstep1-firstname-input');	if(el.value.trim()==''){	  lb.style.color='red';	  return false;	}else{	  lb.style.color='';	  return true;	}}validate_email = function(){	var lb = document.getElementById('paymentstep1-email-label');	var el = document.getElementById('paymentstep1-email-input');	if(el.value.trim()==''){	  lb.style.color='red';	  return false;	}else{	  lb.style.color='';	  return true;	}}validate_phone = function(){	var lb = document.getElementById('paymentstep1-phone-label');	var el = document.getElementById('paymentstep1-phone-input');	if(el.value.trim()==''){	  lb.style.color='red';	  return false;	}else{	  lb.style.color='';	  return true;	}}validate_address1 = function(){	var lb = document.getElementById('paymentstep1-address1-label');	var el = document.getElementById('paymentstep1-address1-input');	if(el.value.trim()==''){	  lb.style.color='red';	  return false;	}else{	  lb.style.color='';	  return true;	}}validate_city = function(){	var lb = document.getElementById('paymentstep1-city-label');	var el = document.getElementById('paymentstep1-city-input');	if(el.value.trim()==''){	  lb.style.color='red';	  return false;	}else{	  lb.style.color='';	  return true;	}}validate_areacode = function(){	var lb = document.getElementById('paymentstep1-areacode-label');	var el = document.getElementById('paymentstep1-areacode-input');	if(el.value.trim()==''){	  lb.style.color='red';	  return false;	}else{	  lb.style.color='';	  return true;	}}validate_country = function(){	var lb = document.getElementById('paymentstep1-country-label');	var el = document.getElementById('paymentstep1-country-select');	var countryCode = el.options[el.selectedIndex].value;	this.toggle_state();	if(countryCode==''){	  lb.style.color='red';	  return false;	}else{	  lb.style.color='';	  //this.validate_state();	  return true;	}}toggle_state = function(){	var el = document.getElementById('paymentstep1-country-select');	var countryCode = el.options[el.selectedIndex].value;	var stateEl = document.getElementById('paymentstep1-state');	//alert(paypal_require_states.indexOf(countryCode));	if(paypal_require_states.indexOf(countryCode)==-1){	  stateEl.style.display='none';	  document.getElementById('paymentstep1-state-input').value='';	}else{	  stateEl.style.display='';	}}validate_state = function(){	var lb = document.getElementById('paymentstep1-state-label');	var el = document.getElementById('paymentstep1-state');	var elInput = document.getElementById('paymentstep1-state-input');	if(el.style.display==''&&elInput.value.trim()==''){	  lb.style.color='red';	  return false;	}else{	  lb.style.color='';	  return true;	}}validate_currency = function(){	var lb = document.getElementById('paymentstep1-currency-label');	var el = document.getElementById('paymentstep1-currency-select');	var code=el.options[el.selectedIndex].value;	  set_amount();	if(code==''){	  lb.style.color='red';	  return false;	}else{	  lb.style.color='';	  return true;	}}validate_quantity = function(){	var lb = document.getElementById('paymentstep1-quantity-label');	var el = document.getElementById('paymentstep1-quantity-input');	if(!el.value.isInt()){	  lb.style.color='red';	  return false;	}else{	  lb.style.color='';	  set_amount();	  return true;	}}set_amount = function(){	var el = document.getElementById('paymentstep1-currency-select');	var code=el.options[el.selectedIndex].value;	var product = null;	if(document.paypal.product[0].checked)		product = document.paypal.product[0].value;	else if(document.paypal.product[1].checked)		product = document.paypal.product[1].value;	if(code&&product){		document.paypal.amount.value = prices[product][code];		el = document.getElementById('paymentstep1-price-input');		var quantity = document.paypal.quantity.value;		el.value = (Math.round(prices[product][code]*quantity*100)/100)+' '+code;		el = document.getElementById('paymentstep1-shipping_price-input');		var shipping = shipping_prices[product][code]['shipping-'+quantity];		if(shipping){			el.value = (Math.round(shipping*quantity*100)/100)+' '+code;			document.paypal.shipping.value = shipping*quantity;		}else{			shipping = shipping = shipping_prices[product][code]['shipping-all']||0;			shipping = (quantity*shipping);			el.value = shipping+' '+code;			document.paypal.shipping.value = shipping;		}	}else{		document.paypal.amount.value = '';		document.paypal.shipping.value = '';		el = document.getElementById('paymentstep1-price-input');		el.value ='';		el = document.getElementById('paymentstep1-shipping_price-input');		el.value ='';	}}validateForm = function(){	var isOk = true;	if(!validate_last_name())isOk=false;	if(!validate_first_name())isOk=false;	if(!validate_email())isOk=false;	if(!validate_phone())isOk=false;	if(!validate_address1())isOk=false;	if(!validate_city())isOk=false;	if(!validate_areacode())isOk=false;	if(!validate_country())isOk=false;	if(!validate_currency())isOk=false;	if(!validate_quantity())isOk=false;	if(!validate_state())isOk=false;	set_amount();	return isOk;}