
function changeOrder(uri) {

	val = document.getElementById('orderbycombo').options[document.getElementById('orderbycombo').selectedIndex].value;
	uri=uri.replace('xxx',val);	
	document.location=uri;
}


function setComboBox(cb_name, cb_value){
	/*i=0;
	while(i<document.getElementById(cb_name).options.length&&cb_value!=document.getElementById(cb_name).options[i].value) {
		i++;
	}
	document.getElementById(cb_name).selectedIndex = i;*/
	if (document.getElementById(cb_name)!=null) document.getElementById(cb_name).value = cb_value;
}

function setManModelId(man_model_id_group){
	
	if (document.getElementById('man_id')!=null) {
		man_id = document.getElementById('man_id').options[document.getElementById('man_id').selectedIndex].value;
		//type_id = man_model_id_group.substring(0,1);
		//man_model_id_group_value = man_model_id_group.substring(1);
		randtail = getRandomTail();
		if (man_id!=0) doAjax("ajax/man_models.php?man_id="+man_id+"&man_model_id="+man_model_id_group+"&randtail="+randtail,'man_model_id_group_div');
	}

}

function setTextBox(tb_name, tb_value){
	if (document.getElementById(tb_name)!=null) document.getElementById(tb_name).value=tb_value;
}


function setCheckBox(cb_name, cb_value){
	if (document.getElementById(cb_name)!=null) {
		if (cb_value=='') document.getElementById(cb_name).checked = false;
		if (cb_value=='on') document.getElementById(cb_name).checked = true;
	}
}


function deleteCar(p_car_id) {
	var table = document.getElementById('table_cars');
	var rowCount = table.rows.length;

	if (confirm('Really delete this car?')) {
		xmlhttp = getHTTPObject();
		xmlhttp.open("GET", 'ajax/delete_car.php?car_id='+p_car_id);
		xmlhttp.send(null);
		
		for(var i=0; i<rowCount; i++) {
			var row = table.rows[i];
			if(row.id=='tr_'+p_car_id) {
				table.deleteRow(i);
				rowCount--;
			}
		}
	}
		
}
