// Panic Serial Sender
// (C) 2007 Panic, Inc. / Cabel Sasser
// This one is gray. Migrate to XMlHttpRequest soon.
//
// All Rights Reserved. Must not be reproduced without express written permission of Panic, INc.

// Precache Spinner (again -- this one is gray)

sn_spinner_on   = new Image(16,16); sn_spinner_on.src   = "/images-global/spinner-gray.gif";
sn_spinner_off  = new Image(16,16); sn_spinner_off.src  = "/images-global/elist-error.png";
sn_spinner_done = new Image(16,16); sn_spinner_done.src = "/images-global/elist-ok.png";

// Set the spinner, and change the location of the hidden iFrame element. Poor man's XMLHttpRequest!

function serialSend() {
  document.images["serial-spinner"].src = sn_spinner_on.src;
  tempName = document.serial.email.value;
  tempStor = document.serial.pod_storeName.value;
  tempLang = document.serial.pod_language.value;

  document.getElementById('serialSubmit').src = '/pod-bin/serial.php?format=inline&pod_storeName='+tempStor+'&pod_language='+tempLang+'&email='+encodeURIComponent(tempName);

}

// Serials done -- Function called by the HTML loaded into the iFrame, once complete.

function serialDone(respMsg) {

  // Turn off the spinner, we're done processing

  document.images["serial-spinner"].src = sn_spinner_off.src;

  // Handle the response

  if (respMsg != "OK") {
    // Display an error, if returned
    alert(respMsg);
  } else {
    // Display a success graphic
    document.images["serial-spinner"].src = sn_spinner_done.src;
    // document.serial.email.value = "Serials Sent";
    // document.serial.email.style.color = "#777777";

    if (document.serial.pod_language.value == "jp") {
      document.serial.finish.value = "M";
    } else {
      document.serial.finish.value = "Serials Sent";
    }
    document.serial.finish.disabled = true;
  }

  // Clear out the iframe (in case of page reloads, etc.)

  document.getElementById('serialSubmit').src = '/global/blank.html';
}

