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

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