function str_replace (search, replace, subject)
{
var result = "";
var oldi = 0;
for (i = subject.indexOf (search); i > -1; i = subject.indexOf (search, i))
{
result += subject.substring (oldi, i);
result += replace;
i += search.length;
oldi = i;
}
return result + subject.substring (oldi, subject.length);
}


//functions for populating select box from php/javascript array from mysql database 
//check for corresponding javascript in <head></head> for javascript array
function change_model_type(obj) {

	var checkvar = 0;
	if (obj.value == "") {
		var the_array = new Array(" -- Model");
		checkvar++;
	} 
	else {
		var the_array = new Array(" -- Model");
		for(i=0;i<designer[obj.value].length;i++) {
			the_array[i+1] = designer[obj.value][i];
		}
	}
	setOptionText(obj.form.model, the_array, checkvar);
}

function setOptionText(the_select, the_array, checkvar)
{
	the_select.options.length = the_array.length;
	if (checkvar==1) {
		for (i=0; i < the_array.length; i++) {
			the_select.options[i].value = "";
			the_select.options[i].text = the_array[i];
		}
	}
	else {
		the_select.options[0].value = "";
		the_select.options[0].text = the_array[0];
		for (i=1; i <= the_array.length; i++) {
			the_select.options[i].value = the_array[i];
			the_select.options[i].text = the_array[i];
		}
	}
}
// end select populate functions


function empty_box (obj) {
	obj.value = "";
}

