/* Input */
function JSDOM_create_input (HTML_type, HTML_id, HTML_css, HTML_name, HTML_value) {
  var input = document.createElement('input');
  if (HTML_id) input.id = HTML_id;
  if (HTML_css) input.className = HTML_css;
  if (HTML_name) input.name = HTML_name;
  if (HTML_type) input.type = HTML_type;
  if (HTML_value || HTML_value == '') input.value = HTML_value;
  return input;
}
function JSDOM_insert_input (HTML_type, HTML_id, HTML_css, HTML_name, HTML_value, parent_node, node_before) {
  var node = JSDOM_create_input(HTML_type, HTML_id, HTML_css, HTML_name, HTML_value);
  return JSDOM_insert_node(node, parent_node, node_before);
}


/* Textarea */
function JSDOM_create_textarea (HTML_id, HTML_css, HTML_name, HTML_value) {
  var textarea = document.createElement('textarea');
  if (HTML_id) textarea.id = HTML_id;
  if (HTML_css) textarea.className = HTML_css;  
  if (HTML_name) textarea.name = HTML_name;
  if (HTML_value) textarea.value = HTML_value;
  return textarea;
}
function JSDOM_insert_textarea (HTML_id, HTML_css, HTML_name, HTML_value, parent_node, node_before) {
  var node = JSDOM_create_textarea(HTML_id, HTML_css, HTML_name, HTML_value);
  return JSDOM_insert_node(node, parent_node, node_before);
}

/* Select */
function JSDOM_create_select (HTML_id, HTML_css, HTML_name) {
  var select = document.createElement('select');
  if (HTML_id) select.id = HTML_id;
  if (HTML_css) select.className = HTML_css;
  if (HTML_name) select.name = HTML_name;
  
  return select;
}
function JSDOM_insert_select (HTML_id, HTML_css, HTML_name, parent_node, node_before) {
  var node = JSDOM_create_select(HTML_id, HTML_css, HTML_name);
  return JSDOM_insert_node(node, parent_node, node_before);
}

function JSDOM_select_add_option (JS_ref_select, HTML_value, HTML_label, HTML_selected) {
  var option = document.createElement('option');
  option.value = HTML_value;
  if (HTML_label) {
    option.title = HTML_label;
    option.appendChild(document.createTextNode(HTML_label));
  }
  JS_ref_select.appendChild(option);
  if (HTML_selected === 1) option.selected = true;
  
  return option;
}
