function other_field() {
  if ($F('special_date_occasion') == 7) {
    $('other').show();
  } else {
    $('other').hide();
    $('special_date_other').clear();
  }
}

function view_terms() {
  var terms = $('terms');
  if (terms.visible()) {
    terms.hide();
  } else {
    terms.show();
  }
}

function check_categories(id) {
  var category = "li#category_" + id;
  if($$(category)[0]) {
    return true;
  }
}

function tableStripes() {
  var rows = $$('table tbody tr');
  var odd = true;
  rows.each(function(e) {
    if(odd == true) {
      e.addClassName('odd');
      odd = false;
    }else{
      odd = true;
    }
  })
}

function removeBorderOnLastNavItems() {
  var menus = $$('#admin_menu .accordion_content');
  menus.each(function(e) {
    var menu_length = e.descendants().length;
    if(menu_length > 1) {
      e.descendants().first().addClassName('first');
      e.descendants()[(menu_length - 2)].addClassName('last');
    }else if(menu_length == 1) {
      e.descendants().first().addClassName('single')
    }
  });
}

function add_recipient() {
  var fname = $('recipient_firstname');
  var lname = $('recipient_lastname');
  var eadd = $('recipient_email');
  var add = $F('recipient_add_to_addressbook');
  var image = $F('ecard_image_id')
  var recipient = new Ajax.Request('/ecards/add_recipient',
                  {parameters: {firstname: fname.value, lastname: lname.value, email: eadd.value, add_to_addressbook: add, image_id: image},
                  asynchronous: true, evalScripts: true});
  [fname, lname, eadd].invoke('clear')
}

function auto_complete_other_fields(e, v) {
  var user = new Ajax.Request('/ecards/get_user_names', {parameters: {value: e.value}, asynchronous: true, evalScripts: true});
}

function subscribe_alert() {
  alert("Click the Magnifying Glass icon to see a large photo.\r\nFollow the link to send a free ecard.\r\nOr join Quillcards to send this ecard.");
}

function favorite_alert() {
  alert("Click the Magnifying Glass icon to see a large photo.\r\nFollow the link to send a free ecard.\r\nOr join Quillcards to save this ecard to your Favorites.");
}

function clear_recipient_fields() {
  $('recipient_email').clear();
  $('recipient_firstname').clear();
  $('recipient_lastname').clear();
  
  new Ajax.Request('/contacts/show/' + $F('ecard_contact_id'), { 
    method: 'get',
    asynchronous: true, 
    evalJSON: true,
    onSuccess: function(transport) {
      var json = transport.responseText.split(",");
      $('recipient_firstname').value = json[0];
      $('recipient_lastname').value = json[1];
      $('recipient_email').value = json[2];
    }
  });
}

function set_recipient_fields(email, firstname, lastname) {
  var e = email;
  var fn = firstname;
  var ln = lastname;
  $('recipient_email').clear();
  $('recipient_firstname').clear();
  $('recipient_lastname').clear();
  $('recipient_email').value = e;
  $('recipient_firstname').value = fn;
  $('recipient_lastname').value = ln;
}

function redirect() {
  setTimeout('window.location.replace("http:\/\/quillcards.com\/")', 5000)
}

function fadeFlash() {
  setTimeout("new Effect.Fade('flash');", 3000);
}

// var album = { 
//   startup: function() { 
//     new PeriodicalExecuter(album.cycle, 5) // change image every 5 seconds 
//   }, 
//   cycle: function() { 
//     new Effect.Fade('image', { // the id of the <DIV> containing the photos 
//       duration: 1, 
//       fps: 50, 
//       afterFinish: function() { 
//         // new Ajax.Updater('image','/album/next', { // URL for next <IMG> tag 
//         //   asynchronous: true, 
//         //   onSuccess: function() { 
//         //     new Effect.Appear('image', {
//         //       duration: 1,
//         //       fps: 50,
//         //       queue:'end'
//         //     })
//         //   } 
//         // }) 
//       } 
//     }) 
//   } 
// } 
// 
// window.onload = album.startup