function parseScript(_source) {
	var source = _source;
	var scripts = new Array();

	/* Strip out tags */
	while(source.indexOf('<script') > -1 || source.indexOf('</script') > -1) {
		var s = source.indexOf('<script');
		var s_e = source.indexOf('>', s);
		var e = source.indexOf('</script', s);
		var e_e = source.indexOf('>', e);

		/* Add to scripts array */
		scripts.push(source.substring(s_e+1, e));
		/* Strip from source */
		source = source.substring(0, s) + source.substring(e_e+1);
	}
	
	/* Loop through every script collected and eval it */
	for(var i=0; i<scripts.length; i++) {
		try {
			eval(scripts[i]);
		}
		catch(ex) {}
	}
	/* Return cleaned source */
	return source;
}

function addemail() {
	if(document.getElementById('emailaddy').value == '') {
		alert('Please enter a valid email address.');
	} else {
		if (window.XMLHttpRequest) {
			liveSearchReq = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			liveSearchReq = new ActiveXObject('Microsoft.XMLHTTP');
		}
	
		thestring = '';
	
		try {
			if (document.getElementById('emailaddy').value != '') {
				thestring = thestring+'&emailaddy='+document.getElementById('emailaddy').value;
			}
		} catch (err) {}
		
		thetime= '?thetime='+new Date().getTime();
		liveSearchReq.open('GET','emailsubscribe.cfm'+thetime+thestring,false);
		liveSearchReq.send(null);
	
		if (liveSearchReq.readyState == 4) {
			resultbox = document.getElementById('emailresponse');
			resultbox.innerHTML = parseScript(liveSearchReq.responseText);
		}
	}
}


function showimage(thestring) {
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject('Microsoft.XMLHTTP');
	}

	thetime= '?thetime='+new Date().getTime();
	liveSearchReq.open('GET','showimage.cfm'+thetime+'&theurl='+thestring,false);
	liveSearchReq.send(null);

	if (liveSearchReq.readyState == 4) {
		resultbox = document.getElementById('biglabel');
		resultbox.innerHTML = liveSearchReq.responseText;
	}
}


function enquiryform() {
	if(document.getElementById('enqfirstname').value == '' | document.getElementById('enqsurname').value == '' | document.getElementById('enqtel').value == '' | document.getElementById('enqemail').value == '') {
		alert('Please enter a valid email address and ensure all fields are complete.');
	} else {
		if (window.XMLHttpRequest) {
			liveSearchReq = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			liveSearchReq = new ActiveXObject('Microsoft.XMLHTTP');
		}
	
		thestring = '';
	
		try {
			if (document.getElementById('enqfirstname').value != '') {
				thestring = thestring+'&enqfirstname='+document.getElementById('enqfirstname').value;
			}
		} catch (err) {}

		try {
			if (document.getElementById('enqsurname').value != '') {
				thestring = thestring+'&enqsurname='+document.getElementById('enqsurname').value;
			}
		} catch (err) {}
		
		try {
			if (document.getElementById('enqtel').value != '') {
				thestring = thestring+'&enqtel='+document.getElementById('enqtel').value;
			}
		} catch (err) {}
		
		try {
			if (document.getElementById('enqemail').value != '') {
				thestring = thestring+'&enqemail='+document.getElementById('enqemail').value;
			}
		} catch (err) {}
		
		try {
			if (document.getElementById('enqcompany').value != '') {
				thestring = thestring+'&enqcompany='+document.getElementById('enqcompany').value;
			}
		} catch (err) {}		
		
		try {
			if (document.getElementById('enqaddress1').value != '') {
				thestring = thestring+'&enqaddress1='+document.getElementById('enqaddress1').value;
			}
		} catch (err) {}
		
		try {
			if (document.getElementById('enqaddress2').value != '') {
				thestring = thestring+'&enqaddress2='+document.getElementById('enqaddress2').value;
			}
		} catch (err) {}
		
		try {
			if (document.getElementById('enqtown').value != '') {
				thestring = thestring+'&enqtown='+document.getElementById('enqtown').value;
			}
		} catch (err) {}
		
		try {
			if (document.getElementById('enqpostcode').value != '') {
				thestring = thestring+'&enqpostcode='+document.getElementById('enqpostcode').value;
			}
		} catch (err) {}

		try {
			if (document.getElementById('enqcountry').value != '') {
				thestring = thestring+'&enqcountry='+document.getElementById('enqcountry').value;
			}
		} catch (err) {}

		try {
			if (document.getElementById('samplepack').value != '') {
				thestring = thestring+'&samplepack='+document.getElementById('samplepack').value;
			}
		} catch (err) {}
		
		try {
			if (document.getElementById('enqquant').value != '') {
				thestring = thestring+'&enqquant='+document.getElementById('enqquant').value;
			}
		} catch (err) {}

		try {
			if (document.getElementById('enqsize').value != '') {
				thestring = thestring+'&enqsize='+document.getElementById('enqsize').value;
			}
		} catch (err) {}
		
		try {
			if (document.getElementById('enqbg').value != '') {
				thestring = thestring+'&enqbg='+document.getElementById('enqbg').value;
			}
		} catch (err) {}
		
		try {
			if (document.getElementById('enqprint').value != '') {
				thestring = thestring+'&enqprint='+document.getElementById('enqprint').value;
			}
		} catch (err) {}
		
		try {
			if (document.getElementById('enqoverlam').value != '') {
				thestring = thestring+'&enqoverlam='+document.getElementById('enqoverlam').value;
			}
		} catch (err) {}
		
		try {
			if (document.getElementById('enqmaterial').value != '') {
				thestring = thestring+'&enqmaterial='+document.getElementById('enqmaterial').value;
			}
		} catch (err) {}
		
		try {
			if (document.getElementById('enquse').value != '') {
				thestring = thestring+'&enquse='+document.getElementById('enquse').value;
			}
		} catch (err) {}
		
		try {
			if (document.getElementById('enqquery').value != '') {
				thestring = thestring+'&enqquery='+document.getElementById('enqquery').value;
			}
		} catch (err) {}
		
		thetime= '?thetime='+new Date().getTime();
		liveSearchReq.open('GET','queryform.cfm'+thetime+thestring,false);
		liveSearchReq.send(null);
	
		if (liveSearchReq.readyState == 4) {
			resultbox = document.getElementById('queryresponse');
			resultbox.innerHTML = parseScript(liveSearchReq.responseText);
		}		
	}
}

function MM_jumpMenu(targ,selObj,restore){
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}