﻿if(location.href.test('showform')) {
  // tinyMCE
  tinyMCE.init({
    // General options
  	mode:'textareas',
    language:'nl',
  	theme:'advanced',
  	plugins:'safari,inlinepopups,paste',
    entity_encoding:'raw',
    editor_deselector:'mceNoEditor',

    // Paste options
    paste_convert_headers_to_strong:true,
    paste_strip_class_attributes:'all',
    
  	// Theme options
  	theme_advanced_buttons1:'bold,italic,underline,strikethrough,|,sub,sup,|,bullist,numlist,|,link,unlink,|,cut,copy,paste,pastetext,pasteword,|,undo,redo,|,removeformat,|,charmap,|,code',
  	theme_advanced_buttons2:'',
  	theme_advanced_buttons3:'',
    theme_advanced_toolbar_location:'top',
  	theme_advanced_toolbar_align:'left',
  	theme_advanced_resizing:true
  });
}
  
window.addEvent('domready',function() {
  // PNG fix
  //$$('img[src$=.png]').setStyle('behavior','url(/_include/pngFix.htc)');
  
  // :before hack
  var cornerStone = new Element('span',{'class':'cornerstone'});
  $$('h1').each(function(h1) {
    cornerStone.clone().inject(h1,'before')
  });
  
  if($('ctl00_mainContent_imageScrub')) {
    new ImageScrubber($('ctl00_mainContent_imageScrub'),'/_include/latestAlbum_json.aspx');
  }
  
  if($('menubg')) {
    $('menubg').getChildren().each(function(pic) {
      var top = pic.getStyle('top');
      var left = pic.getStyle('left');

      var bounce = new Fx.Morph(pic,{duration:700,transition:Fx.Transitions.Elastic.easeOut});
      
      pic.makeDraggable({
        onSnap: function(el) {
          el.setStyle('z-index',50);
        },
        onComplete: function(el) {
          bounce.start({
            'top':top,
            'left':left
          });
          el.setStyle('z-index','');
        }
      });
    });
  }
  
  
  /* ---------- BACKOFFICE ---------- */
  if(location.href.test("/backoffice/")) boFunctions();
});



/* ------------------------------------------ */
/* ----------                      ---------- */
/* ---------- BACKOFFICE FUNCTIONS ---------- */
/* ----------                      ---------- */
/* ------------------------------------------ */
function boFunctions() {
  // Open FTP links in a new window
  $$('a[href^=ftp://]').addEvent('click',function(ev) {
    var e = new Event(ev);
    e.stop();
    
    window.open(this.getProperty('href','_blank','location=0,status=0,titlebar=0'))
  });

  // Zebra tables by mousover
  $$('table tr').addEvents({
    'mouseover': function() {this.addClass('zebra');},
    'mouseout': function() {this.removeClass('zebra');}
  });
  
  // Delete check
  $$('a[title=Verwijderen]').addEvent('click',function(ev) {
    var c = confirm('Weet u zeker dat u dit item wilt verwijderen?');
    if(c!=true) {
      var e = new Event(ev);
      e.stop();
    }
  });
  
  // Copy content to clipboard
  if($('ctl00_mainContent_copyButton')) {
    $('aspnetForm').addEvent('submit',function(ev) {
      var e = new Event(ev);
      e.stop();

      var myData = $('ctl00_mainContent_mailAddresses');
      myData.select();
    });
  }
}