var id_in_use;
var id_previous_html_value;
var category_array = new Array("T-Shirt", "CD", "Cap");
var access_level_array = new Array("Public", "Private");
var status_array = new Array("Published", "Unreleased");
var saved = false;
var approved_status = "0";

function trim(s){
  return s.replace(/^\s*(.*?)\s*$/,"$1");
}

function load_data() {
  var loader = new net.ContentLoader('retrieve_status.php', show_data);
}

function load_data_type(type_id) {
  switch(type_id) {
    case "0":
      $("waiting").style.textDecoration = "none";
      $("waiting").style.color = "#000";
      $("approved").style.textDecoration = "underline";
      $("approved").style.color = "blue";
      $("rejected").style.textDecoration = "underline";
      $("rejected").style.color = "blue";
    break;
    case "1":
      $("waiting").style.textDecoration = "underline";
      $("waiting").style.color = "blue";
      $("approved").style.textDecoration = "none";
      $("approved").style.color = "#000";
      $("rejected").style.textDecoration = "underline";
      $("rejected").style.color = "blue";
    break;
    case "2":
      $("waiting").style.textDecoration = "underline";
      $("waiting").style.color = "blue";
      $("approved").style.textDecoration = "underline";
      $("approved").style.color = "blue";
      $("rejected").style.textDecoration = "none";
      $("rejected").style.color = "#000";
    break;
  }
  var loader = new net.ContentLoader('retrieve_status.php?show=' + type_id, show_data);
}

function set_status(approved, log_id) {
  var confirmed = confirm("Are you Sure?");
  if(confirmed) {
    approved_status = approved;
    var loader = new net.ContentLoader('set_status.php?approved=' + approved + '&log_id=' + log_id, jnext_step);
  } else {
    return;
  }
}

function jnext_step() {
  load_data_type(approved_status);
}

function show_data() {
  var result = this.req.responseText;
  $("debug_window").innerHTML = result;
}

function determine_if_required_is_needed(dropdown_value) {
  if(dropdown_value.value == "US" || dropdown_value.value == "CA") {
    $("show_state_required").innerHTML = '<em style="color: #ef3c4b;">*</em>';
    $("cboState").className = "validate-selection";
    if(was_set > 0) {
      $("advice-validate-selection-cboState").innerHTML = "State is required.";
    }
  } else {
    if(was_set > 0) $("advice-validate-selection-cboState").innerHTML = "";
    $("show_state_required").innerHTML = '';
    $("cboState").className = "";
  }
  valid = new Validation('frmYour_Story', {useTitles:true});
}

function determine_if_other_is_needed(dropdown_value) {
  if(dropdown_value.value == 'other') {
    $("cboMetalsOther").innerHTML = '<div class="formItem"><label for="txtMetalOther">Other:</label> <input type="text" name="txtMetalOther" value="" class="formField wide required" style="width:150px;" /></div>';
  } else {
    $("cboMetalsOther").innerHTML = '';
  }
  valid = new Validation('frmYour_Story', {useTitles:true});
}
