/***
 * Mediasmarties interface behaviour
 * 
 * Author: Fabrique [brands, design & interaction] - DRA
 * Date: August 2010
 */



// var elHead = document.getElementsByTagName('head')[0];
// var elSheet = document.createElement('link');
// var mb = null;
// elSheet.setAttribute('href','/media/public/presentation/js_enhanced.css');
// elSheet.setAttribute('rel','stylesheet');
// elSheet.setAttribute('type','text/css');
// elSheet.setAttribute('media','screen');
// elHead.appendChild(elSheet);



/***
 * ##WEEKSELECTOR
 */
function Weekselector() {}
Weekselector.prototype = {
  el: null,
  firstPerson: null,

  init: function() {
    this.el = $(document.body).getElement('div.nav-primary');
    if(!this.el) {
      return false;
    }
    this.firstPerson = $(this.el).getElement('div.weekselection-person');
    if (!this.firstPerson) {
      return false;
    }
    var that = this;
    $(this.firstPerson).addEvent('click', function(e) {
      if(e.target.nodeName == 'A') {
          return true;
      }
      if($(that.el).hasClass('nav-weekselector-active')) {
        $(that.el).removeClass('nav-weekselector-active');
      }
      else {
        $(that.el).addClass('nav-weekselector-active');
      }
       
      e.stop();
    });
  }
}
/* end - weekselector */


/***
 * ##Homepage Caroussel
 */
function Caroussel() {}
Caroussel.prototype = {
    activeItem: 0,
    
  init: function() {
    if($$('.caroussel-item').length == 0){
        return;
    }
    $$('.caroussel-item').setStyle('cursor', 'pointer').setStyle('opacity', 0);
    $$('.caroussel-item').addEvent('click', function(e){
        location.href = this.getElements('a')[0].getProperty('href');
    });
    $$('.homepage-caroussel-block').setStyle('cursor', 'pointer');
    var caroussel = this;
    $$('.homepage-caroussel-block').addEvent('click', function(e){
        caroussel.activate(parseInt(this.id.split('-')[2]));
    });
    this.activate(this.activeItem);
  },
  
  setInterval: function(){
    if(this.interval){
        window.clearInterval(this.interval);
    }
    var caroussel = this;
    this.interval = window.setInterval(function(){
        var nextItem = caroussel.activeItem + 1;
        if(!$('caroussel-item-' + nextItem)){
            nextItem = 0;
        }
        caroussel.activate(nextItem);
    }, 5000);
  },
  
  activate: function(i){
    this.activeItem = i;
    // annoying: IE8 doesn't support fade on relative/absolute elements
    if(Browser.Engine.name == 'trident' && Browser.Engine.version <= 6 ){
    	$$('.caroussel-item.active').set('opacity','0').removeClass('active');
    } else {
    	$$('.caroussel-item.active').fade('out').removeClass('active');
    }
	$$('.homepage-caroussel-block.active').removeClass('active');
    $('caroussel-item-' + i).fade('in').addClass('active');
    $('caroussel-block-' + i).addClass('active');
    this.setInterval();
  }
}


/* end - weekselector */

function removeOvertext(){ // remove help text from query input
    var el = $('id_q');
    if(el.value == el.title){
        el.value = '';
        el.removeClass('query-overtext');
    }
}

function resetFilters(){
    $$('.searchoptions-more select').each(function(el){
        el.selectedIndex = 0;
    });
    $$('.searchoptions-more input').each(function(el){
        if(el.getProperty('type') == 'checkbox'){
            el.setProperty('checked', 'checked');
        }
    });
    if($('id_tv')){ // alleen op de aanbod pagina, niet homepage alle filters resetten
        $('id_tv').setProperty('value', 'on');
        $('id_game').setProperty('value', 'on');
        $('id_site').setProperty('value', 'on');
        $('id_tips').setProperty('value', '');
    }
}


function addAutocomplete(el, url){
    var autocomplete = new Meio.Autocomplete(el, url, {
        selectOnTab: true,
        onSelect: function(elements, value){
            $('id_q').value = value.name;
            resetFilters();
            $('searchform').submit();
        },
        cacheLength: 20,
        delay: 200,
        minChars: 2,
        maxVisibleItems: 15,
        filter: {
            type: 'contains',
            path: 'name'
        },
        urlOptions: {
            queryVarName: 'q',
            extraParams:[{'name':'tv', 'value':'on'},{'name':'game','value':'on'},{'name':'site','value':'on'}]
        },
        requestOptions: {
            method: 'GET'
        }
    });
    
    $('id_q').addEvent('keyup', function(){ //bugfix: toon de lijst niet als lengte < 2 is (bij gebruik backspace)
        if(this.value.length < 2){
            autocomplete.elements['list'].hide();
            autocomplete.active = 0;
        }
    });
}


function Tabs() {}
Tabs.prototype = {
  init: function() {

    // top 5 tabs
    $$('.top5 .tab').addEvent('click', function(event) {
        var parentdiv = this.getParent();
        var tabid = this.id;
        $$('.top5 .tab').each(function(e) { 
            e.removeClass('tabselected');
            parentdiv.removeClass(e.id+ 'tabactive');
          }
        );
        this.addClass('tabselected');
        $$('.top5 .tab_content').each(function(e) { 
            e.removeClass('tabactive');
          }
        );

        tabcontentid = '#'+tabid+'i';
        $$(tabcontentid).addClass('tabactive');
        parentdiv.addClass(tabid + 'tabactive');
        }
    );
    }
};
/* end - Tabs */





/***
 * ##AUTOSUBMIT
 */
function SearchOptions() {}
SearchOptions.prototype = {
    
  init: function() {
    $$('.searchoptions-more .fieldset-categories select').addEvent('change', function(event) {
      $('searchoptions-more-overlay').show();
      removeOvertext();
      this.form.submit();
    });
    $$('.searchoptions-more .fieldset-mediatype input[type=checkbox]').addEvent('click', function(event) {
       removeOvertext();
      this.form.submit();
    });
    var submit = $$('.searchoptions-more button[type=submit]');
    submit.setStyle('position', 'absolute').setStyle('top', '-9999em');
    $$('.searchoptions-more .to-moreoptions').addEvent('click', function(event) {
      setTimeout(function () {
          
          $$('.select-all').addEvent('click', function(event) {
            var elems = this.getParent('.checkboxes').getElements('input');
            chk = this.get('checked');
            var value = (chk == true) ? 'on' : '';
            if(this.hasClass('select-tv')) {
                $('id_tv').set('value', value);
            }
            if(this.hasClass('select-game')) {
                $('id_game').set('value', value);
            }
            if(this.hasClass('select-site')) {
                $('id_site').set('value', value);
            }
            for(var i=0; i<elems.length; i++) {
                elems[i].set('checked', chk);
            }
          });
          $('MultiBoxContentContainer').getElements('li input').addEvent('click', function(event) {
            if(this.get('checked') == true){
                var selectAll = this.getParent('.checkboxes').getElements('.select-all')[0];
                var value = (this.get('checked') == true) ? 'on' : '';
                if(selectAll.hasClass('select-tv')) {
                    $('id_tv').set('value',value);
                }
                if(selectAll.hasClass('select-game')) {
                    $('id_game').set('value',value);
                }
                if(selectAll.hasClass('select-site')) {
                    $('id_site').set('value',value);
                }
                selectAll.set('checked', this.get('checked'));
            }
          });
          $$('.cancel_mb').addEvent('click', function(event) {
            mb.close();
            event.stop();
          });

          var submit_lightbox = $$('.MultiBoxContent .fieldset-refinemediatype-inner button[type=submit]');
          submit_lightbox.setStyle('position', 'static').addEvent('click', function(event) {
            this.getParent('.fieldset-refinemediatype-inner').clone().replaces($$('.searchoptions-more .fieldset-refinemediatype-inner')[0]);
            removeOvertext();
            this.getParent('.fieldset-refinemediatype-inner').getElements('input[type=checkbox]').each(function(e){
                if(e.get('name')){ // zet de state van de checkboxes in het form, op basis van de multibox waardes
                    $$('.searchoptions-more .fieldset-refinemediatype-inner input[value='+e.get('value') + '][name='+e.get('name')+']')[0].set('checked', e.get('checked'));
                }
            });
            $$('.mediasearch-section form')[0].submit();
            event.stop();
          });
      }, 500); // Need timeout for lightbox animation completion
    });
    
    $$('#searchform').addEvent('submit', function(e) {
        removeOvertext();
        resetFilters();
    });
    
    $$('.productietopper-zoekfunctie #id_q').addEvent('focus', function(e){
        $('search-submit-button').addClass('focus');
    });
    $$('.productietopper-zoekfunctie #id_q').addEvent('blur', function(e){
        $('search-submit-button').removeClass('focus');
    });
    
    // new AJAX form submit
    
    /*$('searchform').addEvent('submit', function(e) {
        var el = $('id_q');
        console.log(el.value);
        if(el.value == el.title){
            el.value = '';
            el.removeClass('query-overtext');
        }
    });*/
    
    /*$('searchform').addEvent('submit', function(e) {
        new Event(e).stop();
        

        var log = $('mediaitems').empty().addClass('ajax-loading');

        this.send({
            update: log,
            url: '/aanbod_ajax',
            onComplete: function() {
                log.removeClass('ajax-loading');
            }
        });
    });*/
  }
};


/***
 * ##WEEKSELECTIONLIGHTBOXES
 */
function WeekselectionLightboxes() {}
WeekselectionLightboxes.prototype = {
  init: function() {
/*
    // multiBox content not loading in IE x, so temporarily disabling multiBox overlay for IE for detail-page
    if (Browser.Engine.trident) {
      $$('a.mb').each(function(el){
        if (el.getAttribute('rel').split(']')[0] == '[production-gallery') {
          $$(el).removeClass('mb');
        }
        var link = el.getAttribute('href').split('?')[0];
        el.setAttribute('href', link); 
      });
    }
*/

    var initMultiBox = new multiBox({
		  mbClass: '.mb',//class you need to add links that you want to trigger multiBox with (remember and update CSS files)
		  container: $(document.body),//where to inject multiBox
		  descClassName: 'multiBoxDesc',//the class name of the description divs
		  path: './Files/',//path to mp3 and flv players
		  useOverlay: true,//use a semi-transparent . default: false;
		  maxSize: null, //{w:672, h:602},//max dimensions (width,height) - set to null to disable resizing
		  addRollover: false,//add rollover fade to each multibox link
		  addOverlayIcon: false,//adds overlay icons to images within multibox links
		  addChain: false,//cycle through all images fading them out then in
		  //recalcTop: true,//subtract the height of controls panel from top position
		  addTips: false,//adds MooTools built in 'Tips' class to each element (see: http://mootools.net/docs/Plugins/Tips)
          useKeyboard: false,
		  autoOpen: 0//to auto open a multiBox element on page load change to (1, 2, or 3 etc)
	  });

    mb = initMultiBox;
  }
};
/* end - weekselectionlightboxes */


/***
 * ##ORNAMENTS
 */
function Ornaments() {}
Ornaments.prototype = {
  init: function() {
    this.setupRoundedCorners();
    this.setupShadows();
    this.setupOrnaments();
  },

  setupRoundedCorners: function() {
    if(!Browser.Engine.trident) {
      return false;
    }

    var corners = ['corner-tl', 'corner-tr', 'corner-br', 'corner-bl'];
    $$('div.rounded', 'p.rounded', 'span.rounded', 'a.rounded', 'button.rounded').each(function(el) {
      for(var i=0, len=corners.length; i<len; i++) {
        var s = new Element('span', {
          'class':'corner ' + corners[i]
        });
        s.inject(el);
      }
    });
  },

  setupShadows: function() {
    var shadows = ['shadow-tl', 'shadow-t', 'shadow-tr', 'shadow-r', 'shadow-br', 'shadow-b', 'shadow-bl', 'shadow-l'];
    $$('.shadows').each(function(el) {
      for(var i=0, len=shadows.length; i<len; i++) {
        var s = new Element('span', {
          'class':'shadow ' + shadows[i]
        });
        s.inject(el);
      }
    });
  },

  setupOrnaments: function() {
    $$('body.writingreview-page div.media-summary-section').each(function(el) {
      var o = new Element('span', { 'class': 'ornament arrow' });
      o.inject(el);
    });

    $$('body.writingreview-page div.reviewform-section div.help-message-inner').each(function(el) {
      var o = new Element('span', { 'class': 'ornament arrow' });
      o.inject(el);
    });
  }
}
/* end - ornaments */


/***
 * ##ADD OR REMOVE PRODUCT FROM PROFILE
 */

function addProductToProfile(element) {
	var req = new Request({
		url: element.getProperty('data-url'), 
        onSuccess: function(html) {
            element.addClass('hidden');
            $$('.to-select-remove.' + element.getProperty('data-id')).removeClass('hidden');
            $$('.to-select-remove.' + element.getProperty('data-id') + ' .remove').setStyle('display', 'block')
			$$('#mediaitem-status').addClass('mediaitem-saved');
			element.getParents('.mediaitem').getElement('.mediaitem-saved').addClass('active');
			var counter = parseInt($$('.production_counter.current').get('html')[0].replace(/\D+/g,'')) + 1;
			$$('.production_counter.' + element.getProperty('data-user')).set('html', '(' + counter + ')');
        },
        onFailure: function() {
			alert('Request failed');
        }
    });
	req.send()
}
	
function removeProductFromProfile(element) {
	var req = new Request({
		url: element.getProperty('data-url'),
        onSuccess: function(html) {
            element.addClass('hidden');
            $$('.to-select-add.' + element.getProperty('data-id')).removeClass('hidden');
            $$('.to-select-add.' + element.getProperty('data-id') + ' .add').setStyle('display', 'block')
			$$('#mediaitem-status').removeClass('mediaitem-saved');
			element.getParents('.mediaitem').getElement('.mediaitem-saved').removeClass('active');
			var counter = parseInt($$('.production_counter.current').get('html')[0].replace(/\D+/g,'')) - 1;
			$$('.production_counter.' + element.getProperty('data-user')).set('html',  '(' + counter + ')');
        },
        onFailure: function() {
			alert('Request failed');
        }
    });
	req.send()
}


function AddProductToProfileButton() {}
AddProductToProfileButton.prototype = {
  init: function() {
    $$('.to-select-add').addEvent('click', function() {
      addProductToProfile($(this));
    });
  }
};


function RemoveProductFromProfileButton() {}
RemoveProductFromProfileButton.prototype = {
  init: function() {
    $$('.to-select-remove').addEvent('click', function() {
      removeProductFromProfile($(this));
    });
  }
};



/* end - add remove profile buttons */


/* start Comment Karma points */

function addKarmaPoints(url) {
	var req = new Request({
		url: url, 
        onSuccess: function(html) {
            alert(html);
        },
        onFailure: function() {
			alert('Request failed');
        }
    });
	req.send()
}
function AddKarmaPointsLink() {}
AddKarmaPointsLink.prototype = {
  init: function() {
    $$('.karma_report').addEvent('click', function() {
      addKarmaPoints($(this).getElements('a')[0].get('data-link'));
      return false;
    });
  }
};

/* end Comment Karma points */

/* start Add production rating */

function addProductionRation(url) {
	var req = new Request.JSON({
		url: url,
        onSuccess: function(rating) {
            $$('.rating li a').each(function(e) {e.addClass('not-selected');e.removeClass('selected');});
            $$('.rating_members')[0].innerHTML = rating['result']['members'] + '&nbsp;waarderingen';
            var j = 0;
            $$('.rating_result_stars li span').each(function(e) {
                e.removeClass('star0');
                e.removeClass('star25');
                e.removeClass('star50');
                e.removeClass('star75');
                e.removeClass('star100');
                e.addClass('star'+rating['result']['styles'][j])
                j++;
            });
            
            var i = 1;
            $$('.rating li a').each(function(e) {
                if(i <= rating['rating'])
                {
                    e.addClass('selected');
                    e.removeClass('not-selected');
                }
                i++;
            });
        },
        onFailure: function() {
			alert('Request failed');
        }
    });
	req.send()
}


var currentStarRating = null;
var hasVoted = false;


function AddProductionRationLink() {}
AddProductionRationLink.prototype = {
  init: function() {
    if($$('.media-item-own-rating').length == 0) return;
    $$('.media-item-own-rating li a').addEvent('click', function() {
      addProductionRation($(this).get('data-link'));
      currentStarRating = $$('.media-item-own-rating a.selected').length;// set rating to the original version
      $('rating-text').set('html', starText[6]);
      hasVoted = true;
      return false;
    });
    //$$('.rating li a').each(function(e) {e.addClass('not-selected');});
    currentStarRating = $$('.media-item-own-rating a.selected').length;// set rating to the original version
    $('rating-text').set('html', starText[currentStarRating]);
    $$('.media-item-own-rating li').addEvent('mouseenter', function(){
        $(this).getParent().getElements('a').removeClass('selected').removeClass('not-selected');
        var liNodes = $(this).getParent().getChildren('li');
        var currentNodePosition = $(this).getAllPrevious('li').length;
        $('rating-text').set('html', starText[currentNodePosition+1]);
        for(var i=0; i<liNodes.length; i++){
            if(i <= currentNodePosition){
                liNodes[i].getChildren('a').addClass('selected');
            } else {
                liNodes[i].getChildren('a').addClass('not-selected');
            }
        }
        // $(this).getAllPrevious('li').addClass('selected');
        // $(this).getAllNext('li').addClass('not-selected');
        // $(this).addClass('hover-select');
    });
    $$('.media-item-own-rating').addEvent('mouseleave', function(){
        if(currentStarRating == null) return;
        var liNodes = $(this).getElements('li');
        $(this).getElements('a').removeClass('selected').removeClass('not-selected');
        for(var i=0; i<liNodes.length; i++){
            if(i < currentStarRating){
                liNodes[i].getChildren('a').addClass('selected');
            } else {
                liNodes[i].getChildren('a').addClass('not-selected');
            }
        }
        $('rating-text').set('html', hasVoted ? starText[6] : starText[currentStarRating]);
    });
  }
};

/* end Add production rating */


/***
 * ##APPLICATION
 */
function Application() {}
Application.prototype = {

  init: function() {
    $(document.body).addClass('js-enhanced');

    this.o = new Ornaments();
    this.o.init();
    this.setupHovers();
    //this.printPage();
    this.setupCheckboxes();
    //this.wSelector = new Weekselector();
    //this.wSelector.init();
    this.so = new SearchOptions();
    this.so.init();
    this.tabs = new Tabs();
    this.tabs.init();
    this.caroussel = new Caroussel();
    this.caroussel.init();
    this.wsLightboxes = new WeekselectionLightboxes();
    this.wsLightboxes.init();
    this.addProductToProfileButton = new AddProductToProfileButton();
    this.addProductToProfileButton.init()
    this.removeProductFromProfileButton = new RemoveProductFromProfileButton();
    this.removeProductFromProfileButton.init()
    this.addKarmaPointsLink = new AddKarmaPointsLink();
    this.addKarmaPointsLink.init();
    this.addProductionRationLink = new AddProductionRationLink();
    this.addProductionRationLink.init();
    this.setupPWDResetButtons();
    this.setupExternalLinks();
    this.setupOverText();
    this.removeSearchTerm();
    this.setMediavormButtons();
    this.setTerugNaarOverzichtLink();
  },
  
    setMediavormButtons: function(){
        $$('.fieldset-mediatype .checkboxes .checkbox label').addEvent('click', function(e){
            var el = $(this);
            var hiddenInput = $(el.getProperty('for'));
            if(hiddenInput.value != ''){
                el.removeClass('checked');
                hiddenInput.value = '';
            } else {
                el.addClass('checked');
                hiddenInput.value = 'on';
            }
            $('searchoptions-more-overlay').show();
            removeOvertext();
            $('searchform').submit();
        });
        
        $$('.fieldset-mediatype .checkboxes .checkbox label').each(function(el){
            var hiddenInput = $(el.getProperty('for'))
            if(hiddenInput.value != ''){
                el.addClass('checked');
            } else {
                //el.removeClass('checked');
            }
        });
    },
    
    setTerugNaarOverzichtLink: function(){
        $$('.to-media-aanbod a').addEvent('click', function(e){
            if(document.referrer.indexOf('/aanbod/') > -1){
                history.back(-1);
                e.stop();
            }
        });
    },
  
    removeSearchTerm: function(){
        $$('.verwijder-term').addEvent('click', function(e){
            var el = $('id_q');
            el.value = '';
            $('searchform').submit();
        });
    },

	printPage: function(){
		$$('div.print-tool a').addEvent('click', function(e) {
			print();
			e.stop();
		});
  },
  
  setupPWDResetButtons: function() {
		$$('button.password-reset').addEvent('click', function(e) {
			window.location = '/password_reset/';
			e.stop();
		});
  },
    
  setupCheckboxes: function() {
        $$('.select-tv').each(function(e) { if (!$('id_tv').get('value')) { e.set('checked', '') }});
        $$('.select-game').each(function(e) { if (!$('id_game').get('value')) { e.set('checked', '') }});
        $$('.select-site').each(function(e) { if (!$('id_site').get('value')) { e.set('checked', '') }});
  },
  
  setupOverText: function(){
        var el = $('id_q');
        
        if(!el) return;
        
        el.addEvent('focus', function(e) {
            if(this.value == this.title){
                this.value = '';
                $(this).removeClass('query-overtext');
            }
        });
        el.addEvent('blur', function(e){
            if(this.value == ''){
                this.value = this.title;
                $(this).addClass('query-overtext');
            }
        });
        if(el.value == '' || el.value == el.title){
            el.value = el.title;
            el.addClass('query-overtext');
        }
  },
	
  setupHovers: function() {
    // Navigation profile container
    $$('div.profile-container').each(function(el) {
      el.addEvent('mouseenter', function(e) {
        $(this).addClass('profile-container-hover');
        e.stop();
      });
      el.addEvent('mouseleave', function(e) {
        $(this).removeClass('profile-container-hover');
        e.stop();
      });
    });
	
    // Reviewform formfields
    $$('div.reviewform-section div.formfield-container').each(function(el) {
      el.addEvent('mouseenter', function(e) {
        $(this).addClass('formfield-container-hover');
        e.stop();
      });
      el.addEvent('mouseleave', function(e) {
        $(this).removeClass('formfield-container-hover');
        e.stop();
      });
    });

    // Formbuttons
    $$('button').each(function(el) {
      el.addEvent('mouseenter', function(e) {
        $(this).addClass('button-hover');
        e.stop();
      });
      el.addEvent('mouseleave', function(e) {
        $(this).removeClass('button-hover');
        e.stop();
      });
    });

    // Navitems
    $$('div.navigation li').each(function(el) {
      el.addEvent('mouseenter', function(e) {
        $(this).addClass('navitem-hover');
        e.stop();
      });
      el.addEvent('mouseleave', function(e) {
        $(this).removeClass('navitem-hover');
        e.stop();
      });
    });

    // Mediaitem
    var greyoutDiv;
    var greyoutTimer;
    $$('div.mediaitem').each(function(el) {
      el.addEvent('mouseover', function(e) {
    	  $(this).addClass('hover');
    	  e.stop();
      });
      el.addEvent('mouseleave', function(e) {
    	  $(this).removeClass('hover');
    	  e.stop();
       // $(this).getElements('.mediaitem-hover').hide();
       // $(this).getElements('.mediaitem-info').show();
      });
      el.addEvent('click', function(e){
        location.href = $(this).getElements('a')[0].getProperty('href');
      });
    });

    // Weekselection-person
    $$('div.personal-mediaitem').each(function(el) {
      el.addEvent('mouseenter', function(e) {
        $(this).addClass('hover');
        e.stop();
      });
      el.addEvent('mouseleave', function(e) {
        $(this).removeClass('hover');
        e.stop();
      });
    });

    // Helpinfo-container
    $$('div.helpinfo-container').each(function(el) {
      el.addEvent('mouseenter', function(e) {
        $(this).addClass('helpinfo-container-hover');
        e.stop();
      });
      el.addEvent('mouseleave', function(e) {
        $(this).removeClass('helpinfo-container-hover');
        e.stop();
      });
    });
    
    if(Browser.Engine.name == 'trident' && Browser.Engine.version <= 6 ){
        // hack to make titles show rounded in IE8. Combination of JS and CSS
        // I tried to set visibility with hover, but that didn't work..
        $$('.productietopper').each(function(el) {
          el.addEvent('mouseenter', function(e) {
            $(this).getChildren('.productietopper-titel').setStyle('visibility','visible');
            e.stop();
          });
          el.addEvent('mouseleave', function(e) {
            $(this).getChildren('.productietopper-titel').setStyle('visibility','hidden');
            e.stop();
          });
        });
    }
  },

  setupExternalLinks: function() {
    $$("a.external").each(function(el, nr) {

        el.addEvent('click', function(e) {
            $(this).set('target','_blank');
        });

    });
  }
}
/* end - application */

window.addEvent('domready', function() {
  app = new Application();
  app.init();
});


/***
 * ##HOMEPAGE ProductionsClickable
 */
/*window.addEvent('domready', function () {
	makeProductionsClickable();
});

function makeProductionsClickable () {
	$$('.mediaitem-info, .mediaitem-inner > img').setStyle('cursor', 'pointer').addEvent('click', function (event) {
		more = $(this).getParent().getElement('.to-more');
		if (more) {
			window.location = more.getProperty('href');
		}
		return false;
	});
}*/

window.addEvent('domready', function () {
    $$('.mediameter-counter').setStyle('display', 'none');
    
    $$('.mediameter').addEvent('mouseover', function (event) {
      $(this).getElement('.mediameter-counter').setStyle('display', '');
    });

    $$('.mediameter').addEvent('mouseout', function (event) {
      $(this).getElement('.mediameter-counter').setStyle('display', 'none');
    });
    
});





