function testBillPCode () {
  var myPostCode = document.getElementById('BillPCode').value;
  if (checkPostCode (myPostCode)) {
    document.getElementById('BillPCode').value = checkPostCode (myPostCode)
//    alert ("Postcode has a valid format")
  } 
  else {alert ("Please check your billing post code.")};
}

function testShipPCode () {
  var myPostCode = document.getElementById('ShipPCode').value;
  if (checkPostCode (myPostCode)) {
    document.getElementById('ShipPCode').value = checkPostCode (myPostCode)
//    alert ("Postcode has a valid format")
  } 
  else {alert ("Please check your shipping post code.")};
}

/*
Functions for storing, retrieving and deleting cookies
*/

function getCookie(name) {
    var sPos = document.cookie.indexOf(name + "=");
    var len = sPos + name.length + 1;
    if((!sPos) && (name != document.cookie.substring(0, name.length))){
        return null;
    }
    if(sPos == -1){
        return null;
    }
    var ePos = document.cookie.indexOf(';', len);
    if(ePos == -1) ePos = document.cookie.length;
    return unescape(document.cookie.substring(len, ePos));
}

function setCookie(name, value, expires, path, domain, secure){
    var today = new Date();
    if(expires){
        expires = expires * 1000 * 3600 * 24 * 12;
    }
    document.cookie = name+'='+escape(value) +
        ((expires) ? ';expires=' + new Date(today.getTime() + expires).toGMTString() : '') +
        ((path) ? ';path=' + path : '') +
        ((domain) ? ';domain=' + domain : '') +
        ((secure) ? ';secure' : '');
}

function deleteCookie(name, path, domain){
    if(getCookie(name)){
        setCookie(name, '', -30, path, domain);
    }
}
function returnItems(){
    var c = parseInt(getCookie('Items'));
//    if(!c){
//        alert('No initial Value\nSetting New Cookie\nValue : 0');
//        setCookie('Items', goods);
//        var items = goods;
//    }else{
//        alert('Setting New Cookie\nValue : ' + (c + 1));
//        setCookie('Value', (c + 1));
//        var items = '' + c;
//    }
    //deleteCookie('Value');

	return c;

//    var c = parseInt(getCookie('Value'));
//    if(!c){
//        alert('No initial Value\nSetting New Cookie\nValue : 0');
//        setCookie('Value', goods);
//        var items = goods;
//    }else{
//        alert('Setting New Cookie\nValue : ' + (c + 1));
//        setCookie('Value', (c + 1));
//        var items = '' + c;
//    }
//    deleteCookie('Value');
//
//	document.write(items);

}



function testPostCode () {
  var myPostCode = document.getElementById('BillPCode').value;
  if (checkPostCode (myPostCode)) {
    document.getElementById('BillPCode').value = checkPostCode (myPostCode)
//    alert ("Postcode has a valid format")
  } 
  else {alert ("Please check your post code.")};
}
	
function checkMe(){
  if(document.forms[0].thecheck.checked==1){
	document.forms[0].test.disabled=false;
	document.forms[0].test.value='1';
  }
  else if(document.forms[0].thecheck.checked==0){
	document.forms[0].test.disabled=true;
  }
}	
	
function me_fe(f) {
   f.fe.value = f.me.value * 3.280839916
}
function fe_me(f) {
   f.me.value = f.fe.value * .3047999
}

function preLoad() {
  var images = new Array('./images/clear.gif','./images/black.gif','./images/delete12x12.gif','./images/pink.gif','./images/orange.gif','./images/grey.gif','contact_us_on118x20.gif','company_history118x20.gif','clients_on118x20.gif','site_map_on118x20.gif');
  preloadImages(images);
}

function preloadImages(images) {
  for(loop = 0; loop < images.length; loop++) {
    var image = new Image();
    image.src = images[loop];
  }
}

preLoad();

function quicksearch(object) {
  window.location.href = object.options[object.selectedIndex].value;
}

function decision(message, url){
  if(confirm(message)) window.location.href = url;
}


  function giveWarningAndFixValue(field) {
  //removes all non-numeric value and replaces
	alert("Please enter a whole number!");
	var value = parseInt(field.value);
	if(!isNaN(value)) {
	  field.value = value;
	}
	else {
	  field.value = "";
	  isValid = false;
	  //used for NS4.7 because when changing value the cursor is placed in front of the value, instead of behind
	  if(document.layers) field.select();
	}
  }

  function isNumericValue(str) {
	var isValid = true;
	if((str.search(/^[0-9]+$/) == -1) || (str < 0)) {
	  isValid = false;
    }
    return isValid;
  }

  function checkValue(field) {
	if(!isNumericValue(field.value)) {
	  giveWarningAndFixValue(field);
	}
  }

function checkforblanks() {
  for (var i = 0; i < arguments.length; i += 2) {
    if (!arguments[i]) {
      alert("Please complete " + arguments[i+1] + ".");
      return false;
    }
  }
  return true;
}

function validate() {
  var isFull = checkforblanks(document.softfloor.BillName.value, "a billing name", document.softfloor.BillEmail.value, "a billing email address", document.softfloor.BillTel.value, "a billing telephone number", document.softfloor.BillAddress1.value, "the billing address", document.softfloor.BillTC.value, "the billing town/city", document.softfloor.BillCP.value, "the billing county/province", document.softfloor.BillPCode.value, "the billing post/zip code", document.softfloor.ShipName.value, "a delivery name", document.softfloor.ShipEmail.value, "a delivery email address", document.softfloor.ShipTel.value, "a delivery telephone number", document.softfloor.ShipAddress1.value, "the delivery address", document.softfloor.ShipTC.value, "the delivery town/city", document.softfloor.ShipCP.value, "the delivery county/province", document.softfloor.ShipPCode.value, "the delivery post/zip code");
  if (!isFull) {
    return false;
  }
}

function validateRefund  (vfld,   // element to be validated
                         ifld,   // id of element to receive info/error msg
                         reqd)   // true if required
{
//  var stat = commonCheck (vfld, ifld, reqd);
//  if (stat != proceed) return stat;

  var tfld = trim(vfld.value);  // value of field with whitespace trimmed off
  strlen=tfld;
  entry=tfld.toUpperCase();
  var refund = /^SFL[0-9]{7}$/
  if (!refund.test(tfld)) {
//    msg (ifld, "error", "ERROR: not a valid order ID");

	alert("Order ID should be in the form \"SFL1234567\"");
//	setfocus(vfld);
//	vfld.value = '000';
	  vfld.value = "";
    return false;
  }
  return true;
}

function isRefund(entry) {
validChar='0123456789SFL'; // characters allowed in Order ID
strlen=entry.length;          // how long is test string
if ((strlen > 0) && (strlen != 10)) {alert('Order ID should be in the format \"SFL1234567\"');return false;} // no check!
entry=entry.toUpperCase();          // in case of lowercase characters
// Now scan string for illegal characters
for (i=0; i < strlen; i++ ) {
    if (validChar.indexOf(entry.charAt(i)) < 0) {
       alert("Order ID should be in the format \"SFL1234567\"");
       return false;
       }
    } // end scanning loop
alert('ok!'); return true;
}

function countChoices(obj) {
max = 4; // max. number allowed at a time

box1 = document.SAMPLEPACK4.CHARCOAL.checked;  // your checkboxes here
box2 = document.SAMPLEPACK4.WHITE.checked;
box3 = document.SAMPLEPACK4.GLDBRN.checked;
box4 = document.SAMPLEPACK4.RYLBLUE.checked;
box5 = document.SAMPLEPACK4.FSTGREEN.checked;
box6 = document.SAMPLEPACK4.TERCOTTA.checked;
box7 = document.SAMPLEPACK4.PINK.checked;

count = (box1 ? 1 : 0) + (box2 ? 1 : 0) + (box3 ? 1 : 0) + (box4 ? 1 : 0) + (box5 ? 1 : 0) + (box6 ? 1 : 0) + (box7 ? 1 : 0);
// If you have more checkboxes on your form
// add more  (box_ ? 1 : 0)  's separated by '+'

if (count > max) {
alert("You can only choose up to " + max + " colours!");
obj.checked = false;
   }
}

  function checkforblanks() {
    var errormessage = new String();
    for (var i = 0; i < arguments.length; i += 2) {
      if ((!arguments[i]) || (arguments[i] == "your@email.com")) {
        alert("Please enter " + arguments[i+1] + ".");
        return false;
      }
    }
	
	if(!WithoutCheck(document.form.Contact)) {
	  if(WithoutContent(document.form.Telephone.value)) {
	    errormessage += "You have asked to be contacted but have not provided a telephone number.";
	  }
	}
	  
	if(errormessage.length > 2) {
	  alert('NOTE: ' + errormessage);
	  return false;
	}

    return true;
  }

  function WithoutContent(ss) {
    if(ss.length > 0) { return false; }
    return true;
  }

  function WithoutCheck(ss) {
    if(ss.checked) { return false; }
    return true;
  }


  function validateEnquiry() {
    var isFull = checkforblanks(document.form.Name.value, "your name", document.form.email.value, "a valid email address");
    if (!isFull) {
      return false;
    }
  }

  function checkforblanks() {
    var errormessage = new String();
    for (var i = 0; i < arguments.length; i += 2) {
      if ((!arguments[i]) || (arguments[i] == "your@email.com")) {
        alert("Please enter " + arguments[i+1] + ".");
        return false;
      }
    }
	
	if(!WithoutCheck(document.form.Contact)) {
	  if(WithoutContent(document.form.Telephone.value)) {
	    errormessage += "You have asked to be contacted but have not provided a telephone number.";
	  }
	}
	  
	if(errormessage.length > 2) {
	  alert('NOTE: ' + errormessage);
	  return false;
	}

    return true;
  }

  function WithoutContent(ss) {
    if(ss.length > 0) { return false; }
    return true;
  }

  function WithoutCheck(ss) {
    if(ss.checked) { return false; }
    return true;
  }

// VALIDATE CALLBACK FORM

  function checkCallback() {
    var errormessage = new String();
    for (var i = 0; i < arguments.length; i += 2) {
      if (!arguments[i]) {
        alert("Please enter " + arguments[i+1] + ".");
        return false;
      }
    }
	
    return true;
  }

  function validateCallback() {
    var isFull = checkCallback(document.form.Name.value, "your name", document.form.Telephone.value, "your daytime telephone number");
    if (!isFull) {
      return false;
    }
  }

function openWindow(url,x,y){
	var winMedia
	var intWidth = x
	var intHeight = y
	var intWinLeft = (screen.width - intWidth) / 2
	var intWinTop = (screen.height - intHeight) / 2
	winFeatures = 'height='+y+',width='+x+',top='+intWinTop+',left='+intWinLeft+',scrollbars=no';
	win = window.open(url, 'Finshes', winFeatures);
}

/* BLINKING TEXT */

window.onerror = null;
 var bName = navigator.appName;
 var bVer = parseInt(navigator.appVersion);
 var NS4 = (bName == "Netscape" && bVer >= 4);
 var IE4 = (bName == "Microsoft Internet Explorer" 
 && bVer >= 4);
 var NS3 = (bName == "Netscape" && bVer < 4);
 var IE3 = (bName == "Microsoft Internet Explorer" 
 && bVer < 4);
 var blink_speed=750;
 var i=0;
 
if (NS4 || IE4) {
 if (navigator.appName == "Netscape") {
 layerStyleRef="layer.";
 layerRef="document.layers";
 styleSwitch="";
 }else{
 layerStyleRef="layer.style.";
 layerRef="document.all";
 styleSwitch=".style";
 }
}

//BLINKING
function Blink(layerName){
 if (NS4 || IE4) { 
 if(i%2==0)
 {
 eval(layerRef+'["'+layerName+'"]'+
 styleSwitch+'.visibility="visible"');
 }
 else
 {
 eval(layerRef+'["'+layerName+'"]'+
 styleSwitch+'.visibility="hidden"');
 }
 } 
 if(i<1)
 {
 i++;
 } 
 else
 {
 i--
 }
 setTimeout("Blink('"+layerName+"')",blink_speed);
}

/* BLINKING TEXT */

<!-- Begin
var ShipName = "";
var ShipComp = "";
var ShipEmail = "";
var ShipTel = "";
var ShipAddress1 = "";
var ShipAddress2 = "";
var ShipTC = "";
var ShipCP = "";
var ShipPCode = "";
var ShipCountryIndex = 0;

function InitSaveVariables(form) {
ShipName = form.ShipName.value;
ShipComp = form.ShipComp.value;
ShipEmail = form.ShipEmail.value;
ShipTel = form.ShipTel.value;
ShipAddress1 = form.ShipAddress1.value;
ShipAddress2 = form.ShipAddress2.value;
ShipTC = form.ShipTC.value;
ShipCP = form.ShipCP.value;
ShipPCode = form.ShipPCode.value;
}

function ShipToBillPerson(form) {
if (form.copy.checked) {
InitSaveVariables(form);
form.ShipName.value = form.BillName.value;
form.ShipComp.value = form.BillComp.value;
form.ShipEmail.value = form.BillEmail.value;
form.ShipTel.value = form.BillTel.value;
form.ShipAddress1.value = form.BillAddress1.value;
form.ShipAddress2.value = form.BillAddress2.value;
form.ShipTC.value = form.BillTC.value;
form.ShipCP.value = form.BillCP.value;
form.ShipPCode.value = form.BillPCode.value;
}
else {
form.ShipName.value = ShipName;
form.ShipComp.value = ShipComp;
form.ShipEmail.value = ShipEmail;
form.ShipTel.value = ShipTel;
form.ShipAddress1.value = ShipAddress1;
form.ShipAddress2.value = ShipAddress2;
form.ShipTC.value = ShipTC;
form.ShipCP.value = ShipCP;
form.ShipPCode.value = ShipPCode;
   }
}
//  End -->

<!-- Begin
// news ticker function
var newslist=new Array();
var cnt=0;			// current news item
var curr = "";
var i=-1;			// current letter being typed

newslist[0]=new Array("Welcome to Soft Floor UK!")
newslist[1]=new Array("We've removed our minimum order...")
newslist[2]=new Array("...so now everyone can enjoy the most comfortable floor on the market!")
newslist[3]=new Array("Thousands of people are now enjoying Soft Floor...")
newslist[4]=new Array("From tradeshow booths, gym's, excercise mats, school play mats, garages, recording studios, even horse stables!")

function newsticker()
{
  // next character of current item
  if (i < newslist[cnt][0].length - 1)
  {
    i++;
    temp1 = newslist[cnt][0];
    temp1 = temp1.split('');
    curr = curr+temp1[i];
    temp2 = newslist[cnt][1];
    mtxt.innerHTML = ""+curr+"_";
    setTimeout('newsticker()',50)
    return;
  }
  // new item
  i = -1; curr = "";
  if (cnt<newslist.length-1)
    cnt++;
  else
    cnt=0;
  setTimeout('newsticker()',2500)
}
//  End -->

	function MM_findObj(n, d) { //v4.01
      var p,i,x;
	  if(!d) d=document;
	  if((p=n.indexOf("?"))>0&&parent.frames.length) {
	    d=parent.frames[n.substring(p+1)].document;
		n=n.substring(0,p);
	  }
	  if(!(x=d[n])&&d.all) x=d.all[n];
	    for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
		for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n);
	  return x;
	}

	function MM_swapImage() { //v3.0
	  var i,j=0,x,a=MM_swapImage.arguments;
	  document.MM_sr=new Array;
	  for(i=0;i<(a.length-2);i+=3)
	  
	  if((x=MM_findObj(a[i]))!=null) {
	    document.MM_sr[j++]=x;
	    if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
	  }
	}

    function MM_showHideLayers() { //v6.0
      var i,p,v,obj,args=MM_showHideLayers.arguments;
      for (i=0; i<(args.length-2); i+=3)
	    if ((obj=MM_findObj(args[i]))!=null) {
		  v=args[i+2];
		  if (obj.style) {
		    obj=obj.style;
			v=(v=='show')?'visible':(v=='hide')?'hidden':v;
		  }
		  obj.visibility=v;
		}
    }

    function MM_hideAllLayers() { //v6.0
	  MM_showHideLayers('gallery1','','hide','gallery2','','hide','gallery3','','hide','gallery4','','hide','gallery5','','hide','gallery6','','hide','gallery7','','hide','gallery8','','hide','gallery9','','hide','gallery10','','hide');
}

function isFloat(argu_number)
{
	  var Number = "1234567890.";
	  var ii=0;
	  var L = argu_number.length;

	for (var i=0; i < L; i++) {
		ch1 = argu_number.substring(i,i+1);
		  if ( Number.indexOf(ch1) < 0 ) { ii = 0; break; }
		  else { ii=10; }
	}
    if ( ii == 10 ) { return true; } else { return false; }
}





function verifyCompatibleBrowser(){ 
	this.ver=navigator.appVersion 
	this.dom=document.getElementById?1:0 
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0; 
	this.ie4=(document.all && !this.dom)?1:0; 
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0; 
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5) 
	return this 
} 
bw=new verifyCompatibleBrowser() 
lstart=120 
loop=true  
speed=50 
pr_step=1 
function ConstructObject(obj,nest){ 
    nest=(!nest) ? '':'document.'+nest+'.' 
	this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0; 
  	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0; 
	this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight 
	this.newsScroll=newsScroll; 
	this.moveIt=b_moveIt; this.x; this.y; 
    this.obj = obj + "Object" 
    eval(this.obj + "=this") 
    return this 
} 
function b_moveIt(x,y){ 
	this.x=x;this.y=y 
	this.css.left=this.y 
	this.css.top=this.x 
} 
//Makes the object scroll up 
function newsScroll(speed){ 
	if(this.y>-this.scrollHeight){ 
		this.moveIt(0,this.y-pr_step) 
		setTimeout(this.obj+".newsScroll("+speed+")",speed) 
	}else if(loop) { 
		this.moveIt(0,lstart) 
		eval(this.obj+".newsScroll("+speed+")") 
	  } 
} 
//Makes the object 
function InitialiseAutoScrollArea(){ 
	objContainer=new ConstructObject('divASContainer') 
	objContent=new ConstructObject('divASContent','divASContainer') 
	objContent.moveIt(0,lstart) 
	objContainer.css.visibility='visible' 
	objContent.newsScroll(speed) 
} 
// end absolutely positioned scrollable area object scripts 

var xlngth=0
var xwdth=0
var area=0
var b=0
var c=4
var i=0
var test=0

function calc_original(xlngth, xwdth) {
  document.floor.area.value = eval("document.floor.xlngth.value * document.floor.xwdth.value")
  document.floor.tiles.value = eval("(document.floor.xlngth.value * 2) * (document.floor.xwdth.value * 2)")
  return document.floor.tiles.value 
}

function calc_giant(xlngth, xwdth) {
  document.floor.area.value = eval("document.floor.xlngth.value * document.floor.xwdth.value")
  document.floor.tiles.value = eval("document.floor.xlngth.value * document.floor.xwdth.value")
  return document.floor.tiles.value 
}

function calc_grass(xlngth, xwdth) {
  document.floor.area.value = eval("document.floor.xlngth.value * document.floor.xwdth.value")
  document.floor.tiles.value = eval("(document.floor.xlngth.value * document.floor.xwdth.value) * 4")
  return document.floor.tiles.value 
}

function calc_oak(xlngth, xwdth) {
  document.floor.area.value = eval("document.floor.xlngth.value * document.floor.xwdth.value")
  document.floor.tiles.value = eval("(document.floor.xlngth.value * document.floor.xwdth.value) * 4")
  return document.floor.tiles.value 
}

function calc_mesh(xlngth, xwdth) {
  document.floor.area.value = eval("document.floor.xlngth.value * document.floor.xwdth.value")
  document.floor.tiles.value = eval("(document.floor.xlngth.value * document.floor.xwdth.value) / 9")
  return document.floor.tiles.value 
}

<!--
//*****************************************
// Random Quotes Script
//*****************************************

function randInt(min,max)
{
     var div = (max - min) + 1
     var randNum = Math.random()
     for (var i = 0; i <= div - 1; i++)
     {
          if (randNum >= i / div && randNum < (i+1) / div)
          {return i + min}
     }
}


function randQuote()
{

	var quote = randInt(1,5);

	if (quote == 1) {
		document.write("\"This is great! Playgroup children love it. We loved the service!\" - <b>FJ, Wales");
	}

	if (quote == 2) {
		document.write("<\"Your 2. HTML-Banner-Code\">");
	}

	if (quote == 3) {
		document.write("<\"Your 3. HTML-Banner-Code\">");
	}

	if (quote == 4) {
	    document.write("<\"Your 4. HTML-Banner-Code\">");
	}

	if (quote == 5) {
	    document.write("<\"Your 5. HTML-Banner-Code\">");
	}
}

function createWindow(what) {
    var URL = what.URL.value;

    var windowName = what.windowName.value;

    var features =
        'width='        + what.width.value +
        ',height='      + what.height.value +
        ',directories=' + (what.directories.checked - 0) +
        ',location='    + (what.location.checked - 0) +
        ',menubar='     + (what.menubar.checked - 0) +
        ',scrollbars='  + (what.scrollbars.checked - 0) +
        ',status='      + (what.status.checked - 0) +
        ',toolbar='     + (what.toolbar.checked - 0) +
        ',resizable='   + (what.resizable.checked - 0);

    window.open (URL, windowName, features);
}

/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

function agreeTerms(f) {
  if (f.terms.checked == false) {
    alert('Please read and agree to the terms to continue.');
    return false;
  } else
    return true;
}


function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}


