/**
 * General javascripts
 * @version $Id: scripts.js 220 2011-01-26 16:33:17Z rutger $
 */


/**
 * Placeholder class based on Prototype
 * @description: Make placeholder attributed work on all browsers
 */
document.observe('dom:loaded', function () {
  var Placeholder = Class.create({
    initialize: function (element) {
      this.element = element;
      this.placeholder = element.readAttribute('placeholder');
      this.blur();
      Event.observe(this.element, 'focus', this.focus.bindAsEventListener(this));
      Event.observe(this.element, 'blur', this.blur.bindAsEventListener(this));
    },
    focus: function () {
      if (this.element.hasClassName('placeholder'))
        this.element.clear().removeClassName('placeholder');
    },
    blur: function () {
      if (this.element.value === '')
        this.element.addClassName('placeholder').value = this.placeholder;
    }
  }); 

  // Activate placeholder elements on all inputs
  $$('input[placeholder]').each(function (input) {
      new Placeholder(input);
  });
  
  $$("#news_list li.full").each(function(elem){
    $(elem).observe('click',function(){
      window.location=$(this).down("a").href; return false;
    })
  });
  
  
});


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

/**
 * Duplicate navigation element into to footer
 */  
  var navigationNode = $('navigation');
  var copyNode = navigationNode.cloneNode(true);
  copyNode.id = "navigation_footer";
  $('footer').down('#address_info').insert({before:copyNode});



/**
 * Set images for location clickable
 */
  $$('#locations li img').each(function(node){
    node.onclick=function(){
      document.location=$(this).up('li').down('a').href
    }
  })

});
