<!--

  if(window.attachEvent)
    window.attachEvent("onload",setListeners);

  function setListeners(){
    inputList = document.getElementsByTagName("INPUT");
    for(i=0;i<inputList.length;i++){
      inputList[i].attachEvent("onpropertychange",restoreStyles);
      inputList[i].style.backgroundColor = "";
    }
    selectList = document.getElementsByTagName("SELECT");
    for(i=0;i<selectList.length;i++){
      selectList[i].attachEvent("onpropertychange",restoreStyles);
      selectList[i].style.backgroundColor = "";
    }
  }

  function restoreStyles(){
    if(event.srcElement.style.backgroundColor != "")
      event.srcElement.style.backgroundColor = "";
  }


function loopForm(form) {

//var randomnumber=Math.floor(Math.random()*150+500)


var rangenumber=500;
	
var amountFields=0;	
 var total =0;
 var businessEnt =0;
 var industry =0;
    var radioResults = 'Radio buttons: ';
    for (var i = 0; i < form.elements.length; i++ ) {

	
        if (form.elements[i].type == 'radio') {
            if (form.elements[i].checked == true) {
             
			 amountFields++;
			// document.write(i + "<BR>");
			
			// !!important if you add more fields on this form then these values will need amending. EVEN HIDDEN FIELDS!!!
			if (i<7) 
				{ businessEnt=parseFloat(form.elements[i].value); }
		    else if (i>12 && i<19)
				{ industry=parseFloat(form.elements[i].value); }
				else { total += parseFloat(form.elements[i].value); }
				
				radioResults += form.elements[i].value;
			
			
			
            }
        }
    }
	
	
 businessEnt+=parseFloat(businessEnt*industry);
 
 
total+=	businessEnt;

estimatedCost = total + rangenumber;

total=total.toFixed(0);

estimatedCost=estimatedCost.toFixed(0);

// real costing
totalOutput= "&pound;"+total;

//estimateBefore= "&pound;"+total;

//estimated costing



//cut off the pennies.
//estimatedCost=estimatedCost.toFixed(0);



if (form.Name.value && form.BusinessName.value && form.EmailAddress.value && form.ContactTelephone.value && amountFields==5) 
 { totalEstimate= totalOutput + " - " + "&pound;" + estimatedCost;
   
   
   document.getElementById("total").innerHTML = totalEstimate;
    //document.getElementById("radioResults").innerHTML = radioResults;
   
    // pass this to the hidded field in the form
    form.total2.value=totalEstimate;	
	//document.write(form.elements.length + "<BR>");

  }
else { document.getElementById("total").innerHTML= "please complete all sections";  }



}

function toggleLayer( whichLayer, onOroff )
{
	
		
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
  vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?onOroff:onOroff;
  vis.display = (vis.display==''||vis.display=='block')?onOroff:onOroff;
}


function prepareImageSwap(elem,mouseOver,mouseOutRestore,mouseDown,mouseUpRestore,mouseOut,mouseUp) { 
//Do not delete these comments. 
//Non-Obtrusive Image Swap Script V1.1 by Hesido.com 
//Attribution required on all accounts 
    if (typeof(elem) == 'string') elem = document.getElementById(elem); 
    if (elem == null) return; 
    var regg = /(.*)(_nm\.)([^\.]{3,4})$/ 
    var prel = new Array(), img, imgList, imgsrc, mtchd; 
    imgList = elem.getElementsByTagName('img'); 
    for (var i=0; img = imgList[i]; i++) { 
        if (!img.rolloverSet && img.src.match(regg)) { 
            mtchd = img.src.match(regg); 
            img.hoverSRC = mtchd[1]+'_hv.'+ mtchd[3]; 
            img.outSRC = img.src; 
            if (typeof(mouseOver) != 'undefined') { 
                img.hoverSRC = (mouseOver) ? mtchd[1]+'_hv.'+ mtchd[3] : false; 
                img.outSRC = (mouseOut) ? mtchd[1]+'_ou.'+ mtchd[3] : (mouseOver && mouseOutRestore) ? img.src : false; 
                img.mdownSRC = (mouseDown) ? mtchd[1]+'_md.' + mtchd[3] : false; 
                img.mupSRC = (mouseUp) ? mtchd[1]+'_mu.' + mtchd[3] : (mouseOver && mouseDown && mouseUpRestore) ? img.hoverSRC : (mouseDown && mouseUpRestore) ? img.src : false; 
                } 
            if (img.hoverSRC) {preLoadImg(img.hoverSRC); img.onmouseover = imgHoverSwap;} 
            if (img.outSRC) {preLoadImg(img.outSRC); img.onmouseout = imgOutSwap;} 
            if (img.mdownSRC) {preLoadImg(img.mdownSRC); img.onmousedown = imgMouseDownSwap;} 
            if (img.mupSRC) {preLoadImg(img.mupSRC); img.onmouseup = imgMouseUpSwap;} 
            img.rolloverSet = true; 
        } 
    } 
    function preLoadImg(imgSrc) { 
        prel[prel.length] = new Image(); prel[prel.length-1].src = imgSrc; 
    } 
} 
function imgHoverSwap() {this.src = this.hoverSRC;} 
function imgOutSwap() {this.src = this.outSRC;} 
function imgMouseDownSwap() {this.src = this.mdownSRC;} 
function imgMouseUpSwap() {this.src = this.mupSRC;}



//-->
