// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

/* fade flashes automatically */
Event.observe(window, 'load', function() { 
  $A(document.getElementsByClassName('alert')).each(function(o) {
    o.opacity = 100.0
    Effect.Fade(o, {duration: 3})
  });
});

var attachmentCount = 1
function AddAttachment(){
  attachmentCount++;
  var attachments = document.getElementById('photos')
  attachments.style.display = ''
  var dt = document.createElement('dt')
  var dd = document.createElement('dd')
  dt.innerHTML = "Photo " + attachmentCount
  var newAttachment = document.createElement('input')
  newAttachment.type = 'file'
  newAttachment.name = 'photos[]'
  newAttachment.id = 'photos' + attachmentCount // para implementar link delete
  attachments.appendChild(dt)
  attachments.appendChild(dd)
  dd.appendChild(newAttachment)
}

function checkUncheckAll(theElement) {
     var theForm = theElement.form, z = 0;
	 for(z=0; z<theForm.length;z++){
      if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall' && theForm[z].id != 'user_accept_information' && theForm[z].id != 'user_accept_email_alerts'){
	  theForm[z].checked = theElement.checked;
	  }
     }
    }