   window.onload =initAll;      function initAll() {      var theprice = 249;      document.getElementById("promo").onchange = changeText;      document.getElementById("term").onchange = changeText;      document.getElementById("suboption").onchange = changeText;	  for (var i=0; i< document.forms.length; i++) {		document.forms[i].onsubmit = function() {return validForm();}	  }   }         function changeText() {	  var theprice = 249;	  var suboption = document.getElementById("suboption").value;	  	  switch(suboption) {      case "249":	     var theprice = 249;		 break;      case "195":	     var theprice = 195;	     break;      case "597":	     var theprice = 597;	     break;      case "495":	     var theprice = 495;		 break;      case "119":	     var theprice = 119;		 break;      }	  	  var textinside = document.getElementById("promo").value;	  	  switch(textinside) {      case "tbs101":	     var offername =" with the promotional code entered";         price = Math.floor(theprice * 0.85);	     break;      case "tbs102":	     var offername =" with the promotional code entered";         price = Math.floor(theprice * 0.9);	     break;      case "EA10":	     var offername =" with the promotional code entered";         if (theprice>400) {            price = Math.floor(theprice - 100);         } else {            price = theprice;         }	     break;      default:	     var offername ="";         price = theprice;      }	  	  var textinside2 = document.getElementById("term").value;	  	  switch(textinside2) {      case "one":	     var discount = 1;         var discountmess = "";		 var newprice = price;	     break;      case "two":	     var discount = 0.9;		 var newprice = Math.ceil((price * discount) * 2);		 var discountmess = "<br /><br />Subscribing for two years brings the annual subscription rate down to &#163;" + Math.ceil(price * discount) + " giving a total order value of &#163;" + newprice;	     break;      case "three":	     var discount = 0.78;		 var newprice = Math.ceil((price * discount) * 3);		 var discountmess = "<br /><br />Subscribing for three years brings the annual subscription rate down to &#163;" + Math.ceil(price * discount) + " giving a total order value of &#163;" + newprice;	     break;      default:      }	 	  	  document.getElementById("ordervalue").innerHTML="The price of the subscription order is &#163;" + price + offername + discountmess; 	  document.getElementById("subsub").value ="Please invoice my organisation for £" + newprice; 	  document.getElementById("hidden").value ="The total price of the subscription is £" + newprice;    }function validForm() {	var allGood = true;	var allTags = document.getElementsByTagName("*");	for (var i=0; i<allTags.length; i++) {		if (!validTag(allTags[i])) {			allGood = false;		}	}	    if (document.subform.terms.checked == false ) {	    document.getElementById("termsdisplay").innerHTML="Please check the terms and conditions box<br />";         allGood = false;    } 		if ((document.subform.terms.checked == true ) && (allGood == false)) {	    document.getElementById("termsdisplay").innerHTML=""; 	}		return allGood;		function validTag(thisTag) {		var outClass = "";		var allClasses = thisTag.className.split(" ");			for (var j=0; j<allClasses.length; j++) {			outClass += validBasedOnClass(allClasses[j]) + " ";		}			thisTag.className = outClass;			if (outClass.indexOf("invalid") > -1) {		    invalidLabel(thisTag.parentNode);			thisTag.focus();			if (thisTag.nodeName == "INPUT") {				thisTag.select();			}			return false;		}		return true;				function validBasedOnClass(thisClass) {			var classBack = "";					switch(thisClass) {				case "":				case "invalid":					break;				case "reqd":					if (allGood && thisTag.value == "") classBack = "invalid ";					classBack += thisClass;					break;				default:					classBack += thisClass;			}			return classBack;		}				function invalidLabel(parentTag) {		    if (parentTag.nodeName == "P") {			    parentTag.className += " invalid";			}		}			}}