function model(){
	var tt = document.getElementById('modelid').value;
	window.alert(tt);
}

function loadAutoModel(){

var model_el = document.getElementById('modelid');
	model_el.innerHTML='загрузка...';
//	model_el.length=1;
	model_el.disabled=true;

	JsHttpRequest.query(
		"/ajax/getmodels.php",
		{
		  "pid": document.getElementById('make').value
		},
			function (result, errors) {
			//if ( errors) alert( errors); /* add */

			k = result.length;

			  var objSel = document.getElementById("modelid");

				addOption(objSel, 'Выберите модель', 0, true);
				
			for(k in result)
			{
				addOption(objSel, result[k]["model"], result[k]["id"], false);
			}
		},
		true
	)

//	model_el.length=1;
//	model_el[0].innerHTML='выберите модель';
	model_el.disabled=false;

}

function addOption (oListbox, text, value, isDefaultSelected, isSelected)
{
  var oOption = document.createElement("option");
  oOption.appendChild(document.createTextNode(text));
  oOption.setAttribute("value", value);

  if (isDefaultSelected) oOption.defaultSelected = true;
  else if (isSelected) oOption.selected = true;

  oListbox.appendChild(oOption);
}




function _getElementById(id){
  var item = null;

  if (document.getElementById){
    item = document.getElementById(id);
  } else if (document.all){
    item = document.all[id];
  } else if (document.layers){
    item = document.layers[id];
  }

  return item;
}

