var win = null
function confirm_delete (type, id)
{
	if ( confirm("Are you sure you want to delete this "+type+"?  This operation is not undo-able!") )
	{
	window.location.href = "garage_"+type+".php?do=delete_"+type+"&id=" + id;
	}
}

function delete_image()
{

var msg = "Are you sure you want to delete this image?\nClick OK to continue or Cancel to not delete the image.";

input_box=confirm(msg);

	if (input_box==true)
	{
	return true;
	} else {
	return false;
	}
}

var win = null
function AddMake(sel)
{
var manCode = document.getElementById(sel).value;
LeftPosition = (screen.width) ? (screen.width-600)/2 : 0;
TopPosition = (screen.height) ? (screen.height-100)/2 : 0;
settings = 'height=100,width=600,top='+TopPosition+',left='+LeftPosition+', toolbar=no, menubar=no, scrollbars=auto, resizable=no, location=no, directories=no, status=no' 
winRef=window.open ('garage_popup.php?addtype=make', 'newwindow', settings)
if (window.focus) {winRef.focus()}
}

var win = null
function AddModel(sel)
{
var manCode = document.getElementById(sel).value;
LeftPosition = (screen.width) ? (screen.width-600)/2 : 0;
TopPosition = (screen.height) ? (screen.height-100)/2 : 0;
settings = 'height=100,width=600,top='+TopPosition+',left='+LeftPosition+', toolbar=no, menubar=no, scrollbars=auto, resizable=no, location=no, directories=no, status=no' 
winRef=window.open ('garage_popup.php?addtype=model&manCode='+manCode, 'newwindow', settings)
if (window.focus) {winRef.focus()}
}

var ajax = new Array();



function getMakeList(sel)
{

var manCode = sel;
document.getElementById('make_id').options.length = 0;
document.getElementById('model_id').options.length = 0;

	if(manCode.length>0)
	{
	var index = ajax.length;
	ajax[index] = new sack();
		
	ajax[index].requestFile = 'garage_ajax_items.php?makestart='+manCode;
	ajax[index].onCompletion = function(){ createmakes(index) };
	ajax[index].runAJAX();
	}
}

function createmakes(index)
{
var obj = document.getElementById('make_id');
eval(ajax[index].response);
}

function getModelList(sel)
{

var prodCode = document.getElementById(sel).value;
document.getElementById('model_id').options.length = 0;

	if(prodCode.length>0)
	{
	var index = ajax.length;
	ajax[index] = new sack();
	ajax[index].requestFile = 'garage_ajax_items.php?modelstart='+prodCode;
	ajax[index].onCompletion = function(){ createmodels(index) };
	ajax[index].runAJAX();
	}
}

function createmodels(index)
{
var obj = document.getElementById('model_id');
eval(ajax[index].response);
}
