function resend(){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var thetime= "?thetime="+new Date().getTime();
	liveSearchReq.open("GET","request_login.html"+thetime+"&fullname="+document.forms.requestform.fullname.value+"&email="+document.forms.requestform.email.value+"&membnum="+document.forms.requestform.membnum.value+"&postcode="+document.forms.requestform.postcode.value,false);
	liveSearchReq.send(null);

	if (liveSearchReq.readyState == 4) {
		var  res = document.getElementById("response");
		res.innerHTML = liveSearchReq.responseText;
	}
}


function remove(id){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var thetime= "?thetime="+new Date().getTime();
	liveSearchReq.open("GET","remove.html"+thetime+"&id="+id,false);
	liveSearchReq.send(null);

	if (liveSearchReq.readyState == 4) {
		document.location.href='http://www.nacoservices.com/caravanlist.html';
	}
}


function showemail(){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var thetime= "?thetime="+new Date().getTime();
	liveSearchReq.open("GET","add_email.html"+thetime,false);
	liveSearchReq.send(null);

	if (liveSearchReq.readyState == 4) {
		var  res = document.getElementById("emailine");
		res.innerHTML = liveSearchReq.responseText;
	}
}


function nothanks(){
	var  res = document.getElementById("ploitenote");
	res.innerHTML = '';
}


function addaddy(){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var thetime= "?thetime="+new Date().getTime();
	liveSearchReq.open("GET","add_email.html"+thetime+"&email="+document.forms.addemail.theemail.value,false);
	liveSearchReq.send(null);

	if (liveSearchReq.readyState == 4) {
		var  res = document.getElementById("emailine");
		res.innerHTML = liveSearchReq.responseText;
	}
}

function findemall(){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var thetime= "?thetime="+new Date().getTime();
	var thestring='';
	
	try {
		if (document.forms.searchform.model.value) {
			var thestring = thestring+"&model="+document.forms.searchform.model.value
		}
	} catch (err) {}
	try {
		if (document.forms.searchform.price.value) {
			var thestring = thestring+"&price="+document.forms.searchform.price.value
		}
	} catch (err) {}
	try {
		if (document.forms.searchform.crit.value) {
			var thestring = thestring+"&crit="+document.forms.searchform.crit.value
		}
	} catch (err) {}
	try {
		if (document.forms.searchform.county.value) {
			var thestring = thestring+"&county="+document.forms.searchform.county.value
		}
	} catch (err) {}	
	
	liveSearchReq.open("GET","find_matches.html"+thetime+thestring,false);
	liveSearchReq.send(null);

	if (liveSearchReq.readyState == 4) {
		var  res = document.getElementById("results");
		res.innerHTML = liveSearchReq.responseText;
	}
}


function checknumeric(){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var thetime= "?thetime="+new Date().getTime();
	liveSearchReq.open("GET","checknumeric.html"+thetime+"&theval="+document.forms.addform.price.value,false);
	liveSearchReq.send(null);

	if (liveSearchReq.readyState == 4) {
		var  res = document.getElementById("info");
		res.innerHTML = liveSearchReq.responseText;
	}
}

function page1(noval) {
	if (noval=='true') {
		// back button pressed
	} else {
		if (document.getElementById("member").value == '' | document.getElementById("firstname").value == '' | document.getElementById("surname").value == '' | document.getElementById("birthday").value == '' | document.getElementById("birthmonth").value == '' | document.getElementById("birthyear").value == '' | document.getElementById("email").value == '' | document.getElementById("address1").value == '' | document.getElementById("postcode").value == '') {
			alert('Please complete all details');
		} else {
			neprostep('2');
		}
	}
}

function page2(noval) {
	if (noval=='true') {
		// back button pressed
		neprostep('1');
	} else {	
		if (document.getElementById("cover").value == '') {
			alert('Please choose type of cover required.');			
		} else if (document.getElementById("vanyear").value == '') {
			alert('Please select the year of manufacture.');
		} else if (document.getElementById("model").value == '' | document.getElementById("dims").value == '' | document.getElementById("dims2").value == '' | document.getElementById("bedrooms").value == '' | document.getElementById("insureday").value == '' | document.getElementById("insuremonth").value == '' | document.getElementById("insureyear").value == '' | document.getElementById("tot_insure").value == '' | document.getElementById("cont_insure").value == '') {
			alert('Please complete all details.\nIf you do not require contents insurance please enter 0.');
		} else if (document.getElementById("cover").value == 'New_For_Old' && document.getElementById("tot_insure").value < 18000) {
			alert('We cannot insure on New For Old for '+document.getElementById("tot_insure").value+' it must be a minimum of 18000');
		} else if (document.getElementById("cover").value == 'Market_Value' && document.getElementById("tot_insure").value < 5000) {
			alert('We cannot insure at Market Value for '+document.getElementById("tot_insure").value+' it must be a minimum of 5000');
		} else {
			neprostep('3');
		}
	}
}

function page3(noval) {
	if (noval=='true') {
		// back button pressed
		neprostep('2');
	} else {	
		if (document.getElementById("parkname").value == '' | document.getElementById("pitch").value == '') {
			alert('Please choose a park and enter your pitch number');
		} else {
			neprostep('4');
		}
	}
}


function neprostep(thepage){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var thetime= "?thetime="+new Date().getTime();
	liveSearchReq.open("GET","insurance-quote_overrule"+thepage+".html"+thetime,false);
	liveSearchReq.send(null);

	if (liveSearchReq.readyState == 4) {
		var  res = document.getElementById("quotebox");
		res.innerHTML = liveSearchReq.responseText;
	}
	window.scrollTo(0,0);
}


function getmodels(themodel){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var thetime= "?thetime="+new Date().getTime();
	liveSearchReq.open("GET","get_models.html"+thetime+"&themodel="+themodel,false);
	liveSearchReq.send(null);

	if (liveSearchReq.readyState == 4) {
		var  res = document.getElementById("modeldrop");
		res.innerHTML = liveSearchReq.responseText;
	}
}


function getaddy(thepark){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var thetime= "?thetime="+new Date().getTime();
	liveSearchReq.open("GET","get_addy.html"+thetime+"&thepark="+thepark,false);
	liveSearchReq.send(null);

	if (liveSearchReq.readyState == 4) {
		var  res = document.getElementById("parkdata");
		res.innerHTML = liveSearchReq.responseText;
	}
}


function upd(thefield) {
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var thetime= "?thetime="+new Date().getTime();
	liveSearchReq.open("GET","make_session.html"+thetime+"&thefield="+thefield,false);
	liveSearchReq.send(null);
	
	if (liveSearchReq.readyState == 4) {
		var  res = document.getElementById("holder");
		res.innerHTML = parseScript(liveSearchReq.responseText);
	}
}



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) {
			// do what you want here when a script fails
		}
	}
	
	// Return the cleaned source
	return source;
	
	alert('source')
}


function callmeth(thenum,oid){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	var thetime= "?thetime="+new Date().getTime();
	liveSearchReq.open("GET","callbackprocess.html"+thetime+"&num="+thenum+"&oid="+oid,false);
	liveSearchReq.send(null);
	
	if (liveSearchReq.readyState == 4) {
		alert('Your callback request has been sent');
	}
}


var prov = 0;

function decs(rezero){
	if(rezero) {
		prov = 0;
	}
	
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var thetime= "?thetime="+new Date().getTime();
	liveSearchReq.open("GET","decs.html"+thetime,false);
	liveSearchReq.send(null);

	if (liveSearchReq.readyState == 4) {
		var res = document.getElementById("buydiv");
		res.innerHTML = liveSearchReq.responseText;
		
		var res2 = document.getElementById("contbut");
		res2.innerHTML = '';
	}
}

function dark(tid,otid){
	dkbox = document.getElementById("td"+tid);
	dkbox.style.backgroundColor='#cccccc';
	dkbox.style.color='#378B35';

	dkbox = document.getElementById("td"+otid);
	dkbox.style.backgroundColor='#ffffff';
	dkbox.style.color='#000000';
	
	var resultOfMod = tid % 2;
	
	if(resultOfMod == 1) {
		if(tid != 11) {
			prov++;
		}
	} else {
		if(tid == 12) {
			prov++;
		}
	}
	
	// if answered last question
	if(tid == 11 | tid == 12) {
		// if no errors remove stuff at top
		
		
		/*
		if(prov == 0){
			var res = document.getElementById("quotebox");
			res.innerHTML = '';
			window.scrollTo(0,0);
		}
		*/
		
		var res = document.getElementById("quotebox");
		res.innerHTML = '';
		window.scrollTo(0,0);
		
		prov3(prov);
	}
}

function prov3(ints){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var thetime= "?thetime="+new Date().getTime();
	liveSearchReq.open("GET","prov3.cfm"+thetime+"&ints="+ints,false);
	liveSearchReq.send(null);
	
	if (liveSearchReq.readyState == 4) {
		var res = document.getElementById("buydiv");
		res.innerHTML = liveSearchReq.responseText;
	}
}


function pay(){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var thetime= "?thetime="+new Date().getTime();
	liveSearchReq.open("GET","pay.html"+thetime,false);
	liveSearchReq.send(null);
	
	if (liveSearchReq.readyState == 4) {
		var res = document.getElementById("buydiv");
		res.innerHTML = parseScript(liveSearchReq.responseText);
	}
}


function getone(){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var thetime= "?thetime="+new Date().getTime();
	liveSearchReq.open("GET","new_row.html"+thetime,false);
	liveSearchReq.send(null);
	
	if (liveSearchReq.readyState == 4) {
		var res = document.getElementById("newrow");
		res.innerHTML = parseScript(liveSearchReq.responseText);
	}
}

function getboth(){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var thetime= "?thetime="+new Date().getTime();
	liveSearchReq.open("GET","new_row.html"+thetime+"&both=true",false);
	liveSearchReq.send(null);
	
	if (liveSearchReq.readyState == 4) {
		var res = document.getElementById("newrow");
		res.innerHTML = parseScript(liveSearchReq.responseText);
	}
}


function helpup(theURL,winName,features){
  window.open('helpup.html','help','resizable=yes,width=450,height=330,scrollbars=yes');
}

function installment(id){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var thetime= "?thetime="+new Date().getTime();
	liveSearchReq.open("GET","installmant.html"+thetime+"&id="+id,false);
	liveSearchReq.send(null);
}

function imgclick(id){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var thetime= "?thetime="+new Date().getTime();
	liveSearchReq.open("GET","click.html"+thetime+"&id="+id,false);
	liveSearchReq.send(null);
}
