var filter_form = {};

filter_form.change = function(obj){
	var table = obj.id;
	var record_id = obj.value;


	var ajax = new ajax_request();
	ajax.call_back = "filter_form.change_response";
	ajax.file_path = "templates/filter.php";
	ajax.class_name = "filter";
	ajax.method_name = "x_get_data";
	//ajax.Url = "orders.php";
	ajax.register_argument("table", table);
	ajax.register_argument("record_id", record_id);

	if(record_id != ""){
		ajax.send();
	}else{
		obj = document.getElementById("cityID");
		obj.innerHTML = "";
	}
}

filter_form.change_response = function(response, atrr){

	obj = document.getElementById("cityID");
	var select = document.createElement("select");
	select.name = "in_data[city]";
	select.id = "cityID";
	//	var option = document.createElement("option");
	//	option.value = "1";
	//	option.innerHTML = "a1";
	//	select.appendChild(option);
	//	option = document.createElement("option");
	//	option.value = "2";
	//	option.innerHTML = "a2";
	//	select.appendChild(option);
	//	option = document.createElement("option");
	//	option.value = "3";
	//	option.innerHTML = "a3";
	//	select.appendChild(option);

	obj.parentNode.appendChild(select);
	obj.parentNode.removeChild(obj.parentNode.firstChild);
	//obj.parentNode.innerHTML = response.responseText;
}

function show_submenu(item_id, total_items){
	for(count = 1; count <= total_items; count++){
		var display = (item_id == count) ? 'block' : 'none';
		document.getElementById('sub_' + count).style.display = display;
	}
}

function hide_submenu(item_id, total_items){
	for(count = 1; count <= total_items; count++){
		var display = (item_id == count) ? 'block' : 'none';
		document.getElementById('sub_' + count).style.display = display;
	}
}

