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

  function l(l) {
    if(window.console) {
      window.console.log(l);
    } else {
      alert(l);
    }
  }


function highlightMe() {
  this.setStyle('background-color: #ffff99');
}
function unHighlightMe() {
  l(this);
  this.setStyle('background-color: #ffffff');
  new Effect.Highlight(this, {startcolor:'#ffff99', endcolor:'#ffffff'});
}

function editCaption() {
  this.hide();
  //this.insert('hi');
  this.next('form').show();
}
function showCaption() {
  this.up('form').hide();
  this.up('.photos').down('div[rel=caption]').show();
}

document.observe('dom:loaded', function(d) {

  var captions = $$('div[rel=caption]').each (function(caption){
    caption.observe('mouseover', function() { this.setStyle('background-color: #ffff99') });
    caption.observe('mouseout', function() { this.setStyle('background-color: #ffffff'); 
                                             new Effect.Highlight(this, {startcolor:'#ffff99', endcolor:'#ffffff'}) });
    caption.observe('click', editCaption);
  });
  
  var cancelButtons = $$('.cancelButton').each (function(button){
    button.observe('click',showCaption);
  });

//  var adminPhotos = $$('.photos img').each (function(photo) {
/*    removeLink = photo.up().down('small'); // photo.up().down('small').down('img');
    var photoX = photo.cumulativeOffset().first();
    var photoY = photo.cumulativeOffset().last();    
    var removeX = photoX + photo.getWidth() - removeLink.getWidth();
    var removeY = photoY;
  */  
    //l(photo.up().down('small').down('img'));
    //l(removeLink);
    //l(photoX + 'x' + photoY);
    //l(removeX + 'x' + removeY);
//    removeLink.setStyle('position:absolute; top:'+removeY+'px; left:'+removeX+'px');
//  });
});

//border: 1px solid rgb(204, 204, 204); top: 72px; left: 68px; position: absolute; z-index: 999; background-color: rgb(255, 255, 255);
