var theTable, theForm, js_model = [], js_make = [], lastLine = 0, gSelIdx, selectedItem, selectedMake;

function populateModel(makeIdx)
{
	var x = theForm.elements['model_1'], t;
	x.options.length = 0;
	var sel = 0;
	$.get("/getmodels.php",
		{ make: makeIdx },
		function(msg){
			t = msg.split(';;');
			x.options[0] = new Option(' - - Alle - - ', 0);
			for (i=1;i<=t.length;i++)
			{
				model = t[i-1].split('|');
				if(model[0] == selectedItem) {
					x.options[i] = new Option(model[0], model[0],false, true);
					sel = i;
				}
				else x.options[i] = new Option(model[0], model[0]);
			}
			if(sel > 0) document.forms['carsearch'].model_1.selectedIndex = sel;
	   }
	 );
}


function replacestring(str_normal,str_find,str_replace,int_case_insensitive)
{
	if (arguments.length<3 || str_find=="" || str_normal=="" ||
 typeof("".split)!="function")
		return(str_normal);

	//no parm means default, "case SENSITIVE"...
	if(!(int_case_insensitive))
		return(str_normal.split(str_find)).join(str_replace);

	str_find=str_find.toLowerCase();

	var rv="";
	var ix=str_normal.toLowerCase().indexOf(str_find);
	while(ix>-1)
	{
		rv+=str_normal.substring(0,ix)+str_replace;
		str_normal=str_normal.substring(ix+str_find.length);
		ix=str_normal.toLowerCase().indexOf(str_find);
	};
	return(rv+str_normal);
};