var ajax = new sack();

//pokazywanie modeli danej marki
function getModelsList(sel)
{

	var countryCode = sel.options[sel.selectedIndex].value;
	//document.getElementById('model').options.length = 0;	// Empty city select box
	document.forms['formGaleria'].model.options.length = 0;
	if(countryCode.length>0){
		ajax.requestFile = 'ajax.php?marka='+countryCode;	// Specifying which file to get
		ajax.onCompletion = createModels;	// Specify function that will be executed after file has been found
		ajax.runAJAX();		// Execute AJAX function
	}
}

function createModels()
{
	var obj = document.forms['formGaleria'].model;
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	
}

//pokazywanie wersji danego modelu
function getVersionsList(sel)
{
	var countryCode = sel.options[sel.selectedIndex].value;
	document.forms['formGaleria'].wersja.options.length = 0;	// Empty city select box
	if(countryCode.length>0){
		ajax.requestFile = 'ajax.php?model='+countryCode;	// Specifying which file to get
		ajax.onCompletion = createVersions;	// Specify function that will be executed after file has been found
		ajax.runAJAX();		// Execute AJAX function
	}
}

function createVersions()
{
	var obj = document.forms['formGaleria'].wersja;
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	
}

//pokazywanie silnikow danej wersji
function getEnginesList(sel)
{
	var countryCode = sel.options[sel.selectedIndex].value;
	document.forms['formGaleria'].silnik.options.length = 0;	// Empty city select box
	if(countryCode.length>0){
		ajax.requestFile = 'ajax.php?wersja='+countryCode;	// Specifying which file to get
		ajax.onCompletion = createEngines;	// Specify function that will be executed after file has been found
		ajax.runAJAX();		// Execute AJAX function
	}

}

function createEngines()
{
	var obj = document.forms['formGaleria'].silnik;
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	
}

//pokazywanie silnikow danej wersji
function getColorsList(sel)
{
	var countryCode = sel.options[sel.selectedIndex].value;
	document.forms['formGaleria'].kolor.options.length = 0;	// Empty city select box
	document.forms['formGaleria'].silnik.options.length = 0;	// Empty city select box
	if(countryCode.length>0){
		ajax.requestFile = 'ajax.php?wersjak='+countryCode;	// Specifying which file to get
		ajax.onCompletion = createColors;	// Specify function that will be executed after file has been found
		ajax.runAJAX();		// Execute AJAX function
	}

}

function createColors()
{
	var obj = document.forms['formGaleria'].kolor;
	var obj2 = document.forms['formGaleria'].silnik;
	eval(ajax.response);	// Executing the response from Ajax as Javascript code	
}

