// BASKET ######################################################################/
function confirm_item_delete (car, product) {
  if (confirm('Really delete this item from your basket?')) {
    document.location.replace('remove_item.html?model=' + car + ';id=' + product);
  }
}

// HOME COMBO BOXES ############################################################/
function getXMLHTTP() {
	var xmlhttp=false;

	try{
		xmlhttp=new XMLHttpRequest();
	}

	catch(e) {		
		try{			
			xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
		}

		catch(e) {
			try{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			}

			catch(e1){
				xmlhttp=false;
			}
		}
	}
		 	
	return xmlhttp;
}

function getModel(COMBO_manu_value) {		
	var strURL="/components/combo_car-model.html?COMBO_manu="+COMBO_manu_value;
	var req = getXMLHTTP();
		
	if (req) {
			
		req.onreadystatechange = function() {

			if (req.readyState == 4) {
				if (req.status == 200) {						
					document.getElementById("combo_model").innerHTML=req.responseText;						
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}		
}

function getYear(COMBO_manu_value,COMBO_model_value) {		
	var strURL="/components/combo_car-years.html?COMBO_manu="+COMBO_manu_value+";COMBO_model="+COMBO_model_value;
	var req = getXMLHTTP();
		
	if (req) {
			
		req.onreadystatechange = function() {

			if (req.readyState == 4) {
				if (req.status == 200) {						
					document.getElementById("combo_year").innerHTML=req.responseText;						
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}

			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}
}

function getComboReset() {		
	var strURL="/components/combo_reset.html";
	var req = getXMLHTTP();
		
	if (req) {
			
		req.onreadystatechange = function() {

			if (req.readyState == 4) {
				if (req.status == 200) {						
					document.getElementById("home_quick-search").innerHTML=req.responseText;						
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}

			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}
}

function getYearSpec(manu,model,year) {		
	var strURL="/components/specification_years.html?manu="+manu+";model="+model+";year="+year;
	var req = getXMLHTTP();
		
	if (req) {
			
		req.onreadystatechange = function() {

			if (req.readyState == 4) {
				if (req.status == 200) {						
					document.getElementById("specification").innerHTML=req.responseText;						
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}

			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}
}

function getBrandModel(brand,manu) {		
	var strURL="/components/brand_combo_car-model.html?brand="+brand+";manu="+manu;
	var req = getXMLHTTP();

	if (req) {
			
		req.onreadystatechange = function() {

			if (req.readyState == 4) {
				if (req.status == 200) {						
					document.getElementById("brand_combo_model").innerHTML=req.responseText;						
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}

			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}
}

function getBrandYear(brand,manu,model) {		
	var strURL="/components/brand_combo_car-years.html?brand="+brand+";manu="+manu+";model="+model;
	var req = getXMLHTTP();

	if (req) {
			
		req.onreadystatechange = function() {

			if (req.readyState == 4) {
				if (req.status == 200) {						
					document.getElementById("brand_combo_year").innerHTML=req.responseText;						
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}

			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}
}



function getBrandReset(brand) {		
	var strURL="/components/brand_combo_reset.html?brand="+brand;
	var req = getXMLHTTP();
		
	if (req) {
			
		req.onreadystatechange = function() {

			if (req.readyState == 4) {
				if (req.status == 200) {						
					document.getElementById("search-all").innerHTML=req.responseText;						
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}

			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}
}

function getCatModel(cat,manu) {		
	var strURL="/components/cat_combo_car-model.html?cat="+cat+";manu="+manu;
	var req = getXMLHTTP();

	if (req) {
			
		req.onreadystatechange = function() {

			if (req.readyState == 4) {
				if (req.status == 200) {						
					document.getElementById("brand_combo_model").innerHTML=req.responseText;						
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}

			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}
}

function getCatYear(cat,manu,model) {		
	var strURL="/components/cat_combo_car-years.html?cat="+cat+";manu="+manu+";model="+model;
	var req = getXMLHTTP();

	if (req) {
			
		req.onreadystatechange = function() {

			if (req.readyState == 4) {
				if (req.status == 200) {						
					document.getElementById("brand_combo_year").innerHTML=req.responseText;						
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}

			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}
}



function getCatReset(cat) {		
	var strURL="/components/cat_combo_reset.html?cat="+cat;
	var req = getXMLHTTP();
		
	if (req) {
			
		req.onreadystatechange = function() {

			if (req.readyState == 4) {
				if (req.status == 200) {						
					document.getElementById("search-all").innerHTML=req.responseText;						
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}

			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}
}

function getWheelModel(manu,wheel,dia,cat) {		
	var strURL="/components/wheel_combo_car-model.html?manu="+manu+";wheel="+wheel+";dia="+dia+";cat="+cat;
	var req = getXMLHTTP();

	if (req) {
			
		req.onreadystatechange = function() {

			if (req.readyState == 4) {
				if (req.status == 200) {						
					document.getElementById("wheel_combo_model").innerHTML=req.responseText;						
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}

			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}
}

// REFRESH TYRE SELECTION /////////////////////////////////////////////////////////////

function refreshSelection(value) {	

	var option1_package = document.getElementById('option1_package').value;
	var option2_package = document.getElementById('option2_package').value;
	var option3_package = document.getElementById('option3_package').value;
	var option4_package = document.getElementById('option4_package').value;
	var option5_package = document.getElementById('option5_package').value;
	var option6_package = document.getElementById('option6_package').value;
	var option7_package = document.getElementById('option7_package').value;
	var option8_package = document.getElementById('option8_package').value;
	var option9_package = document.getElementById('option9_package').value;
	var option10_package = document.getElementById('option10_package').value;
	
	var strURL="/components/tyres.html?"+value+";option1_package="+option1_package+";option2_package="+option2_package+";option3_package="+option3_package+";option4_package="+option4_package+";option5_package="+option5_package+";option6_package="+option6_package+";option7_package="+option7_package+";option8_package="+option8_package+";option9_package="+option9_package+";option10_package="+option10_package;
	var req = getXMLHTTP();

	if (req) {
			
		req.onreadystatechange = function() {

			if (req.readyState == 4) {
				if (req.status == 200) {						
					document.getElementById("tyre-selection").innerHTML=req.responseText;						
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}

			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}

}

// REFRESH WHEEL SPECS /////////////////////////////////////////////////////////////

function loadWheelSpecs(div_id,value) {		
	var strURL="/components/wheel_specs.html?BOX_count="+div_id+";"+value;
	var req = getXMLHTTP();

	if (req) {
			
		req.onreadystatechange = function() {

			if (req.readyState == 4) {
				if (req.status == 200) {						
					document.getElementById(div_id).innerHTML=req.responseText;						
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}

			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}
}

function hideWheelSpecs(div_id,value) {		
	var strURL="/components/hide_wheel_specs.html?BOX_count="+div_id+";"+value;
	var req = getXMLHTTP();

	if (req) {
			
		req.onreadystatechange = function() {

			if (req.readyState == 4) {
				if (req.status == 200) {						
					document.getElementById(div_id).innerHTML=req.responseText;						
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}

			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}
}

function showFinanceQuote(div_id,price) {		
	var strURL="/components/package_finance_quote.html?price="+price+"&div_id="+div_id;
	var req = getXMLHTTP();

	if (req) {
			
		req.onreadystatechange = function() {

			if (req.readyState == 4) {
				if (req.status == 200) {						
					document.getElementById(div_id).innerHTML=req.responseText;						
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}

			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);

	}
}

function hideFinanceQuote(div_id) {		
	var strURL="/components/hide_finance_quote.html";
	var req = getXMLHTTP();

	if (req) {
			
		req.onreadystatechange = function() {

			if (req.readyState == 4) {
				if (req.status == 200) {						
					document.getElementById(div_id).innerHTML=req.responseText;						
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}

			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}
}

function loadRepayments(div_id,price,deposit) {		
	var strURL="/components/load_repayments.html?price="+price+"&deposit="+deposit;
	var req = getXMLHTTP();

	if (req) {
			
		req.onreadystatechange = function() {

			if (req.readyState == 4) {
				if (req.status == 200) {						
					document.getElementById(div_id).innerHTML=req.responseText;						
				} else {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				}

			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}
}

function switchOption(option,value)	{

	document.getElementById(option + '_package').value = value;

	var total = document.getElementsByName(option);
	var input;

	for(var i=0;i<total.length;i++) {
		input = document.getElementsByName(option)[i];
		input.value = value;
	}
}

