// JavaScript Document
var ajax = new sack();
var ratio_count = 0;
function loadRatioSelect(root)
{
	var oProductTreadWidth = document.getElementById('product_tread_width');
	var product_tread_width = oProductTreadWidth.options[oProductTreadWidth.selectedIndex].value;
	
	var oProductAspectRatio = document.getElementById('product_aspect_ratio');
	oProductAspectRatio.options.length = 0;	// Empty product_aspect_ratio select box
	if(product_tread_width.length > 0)
	{
		oProductAspectRatio.options[oProductAspectRatio.options.length] = new Option('Select','');
		var path = root + 'media/ajax/chain_select/product_aspect_ratio.php?product_tread_width=' + product_tread_width;
		//alert(path);
		ajax.requestFile = path;					// Specifying which file to get
		ajax.onCompletion = createActiveAspectRatios;	// Specify function that will be executed after file has been found
		ajax.runAJAX();								// Execute AJAX function
	}
	else
	{
		oProductAspectRatio.options[oProductAspectRatio.options.length] = new Option('^','');
		if(ratio_count++ < 10)
		{
			//oError = document.getElementById('Error2');
			//oError.innerHTML = oError.innerHTML  + count + "<br />";
			setTimeout('loadRatioSelect(\'' + root + '\')',500);
		}
	}
}

function createActiveAspectRatios()
{
	var obj = document.getElementById('product_aspect_ratio');
	var response = ajax.response;
	//alert(response);
	eval(response);	// Executing the response from Ajax as Javascript code	
}

function loadRatioSelectFront(root)
{
	var oProductTreadWidth = document.getElementById('product_tread_width_front');
	var product_tread_width = oProductTreadWidth.options[oProductTreadWidth.selectedIndex].value;
	
	var oProductAspectRatio = document.getElementById('product_aspect_ratio_front');
	oProductAspectRatio.options.length = 0;	// Empty product_aspect_ratio select box
	if(product_tread_width.length > 0)
	{
		oProductAspectRatio.options[oProductAspectRatio.options.length] = new Option('Select','');
		var path = root + 'media/ajax/chain_select/product_aspect_ratio.php?product_tread_width=' + product_tread_width;
		//alert(path);
		ajax.requestFile = path;					// Specifying which file to get
		ajax.onCompletion = createActiveAspectRatiosFront;	// Specify function that will be executed after file has been found
		ajax.runAJAX();								// Execute AJAX function
	}
	else
	{
		oProductAspectRatio.options[oProductAspectRatio.options.length] = new Option('^','');
		if(ratio_count++ < 10)
		{
			//oError = document.getElementById('Error2');
			//oError.innerHTML = oError.innerHTML  + count + "<br />";
			setTimeout('loadRatioSelectFront(\'' + root + '\')',500);
		}
	}
}

function createActiveAspectRatiosFront()
{
	var obj = document.getElementById('product_aspect_ratio_front');
	var response = ajax.response;
	//alert(response);
	eval(response);	// Executing the response from Ajax as Javascript code	
}

function loadRatioSelectRear(root)
{
	var oProductTreadWidth = document.getElementById('product_tread_width_rear');
	var product_tread_width = oProductTreadWidth.options[oProductTreadWidth.selectedIndex].value;
	
	var oProductAspectRatio = document.getElementById('product_aspect_ratio_rear');
	oProductAspectRatio.options.length = 0;	// Empty product_aspect_ratio select box
	if(product_tread_width.length > 0)
	{
		oProductAspectRatio.options[oProductAspectRatio.options.length] = new Option('Select','');
		var path = root + 'media/ajax/chain_select/product_aspect_ratio.php?product_tread_width=' + product_tread_width;
		//alert(path);
		ajax.requestFile = path;					// Specifying which file to get
		ajax.onCompletion = createActiveAspectRatiosRear;	// Specify function that will be executed after file has been found
		ajax.runAJAX();								// Execute AJAX function
	}
	else
	{
		oProductAspectRatio.options[oProductAspectRatio.options.length] = new Option('^','');
		if(ratio_count++ < 10)
		{
			//oError = document.getElementById('Error2');
			//oError.innerHTML = oError.innerHTML  + count + "<br />";
			setTimeout('loadRatioSelectRear(\'' + root + '\')',500);
		}
	}
}

function createActiveAspectRatiosRear()
{
	var obj = document.getElementById('product_aspect_ratio_rear');
	var response = ajax.response;
	//alert(response);
	eval(response);	// Executing the response from Ajax as Javascript code	
}
