/*
Base JS pour Goupe Dubreuil
Copyright(c) 2008, Skalpel.

Author : Michael
michael@skalpel.fr

Note : 
	-
ToDo :
	- 
*/

var SKjs = { 
	version: '1.0',
	
	loaderAjax: 'javasript/ajax.php',
	loaderJSON: 'javasript/json.php',
	encoding: 'utf-8',
	
	activeCls: 'active'
};

window.addEvent('domready', function() {
	// Interface
	new SKjs.Interface();
	
	// Recommander & Partager
	if($$('ul.tools li.tool a')) new SKjs.LightBox($$('ul.tools li.tool a'), {size: {x: 350, y: 450}, showTitle: false, showNumbers: false, showNav: false});
  if($$('#page-tools li.tool a')) new SKjs.LightBox($$('#page-tools li.tool a'), {size: {x: 350, y: 450}, showTitle: false, showNumbers: false, showNav: false});
});


/* 
Class : Interface
	Gestion des �l�ments interactifs de l'interface
Arguments : 
	options {object} - Objet Options
Options :
*/
SKjs.Interface = new Class ({
	Implements: [Events, Options],
	options: {
		elmInputRecherche: 'rechercher'
	},
	
	initialize: function(options) {
		this.setOptions(options);
		
		this.initRecherche();
    this.initPrint();

    // Gestion des Targets "_blank"
    $$('a[rel=_blank]').each(function(link) {
      link.addEvent('click', function(e) {
        e = new Event(e);
        window.open(this.href);
        e.stop();
        return false;
      });
    });
	},
	
	/*
	Property :
	*/
	initRecherche: function() {
		var elm = $(this.options.elmInputRecherche);
		var value = elm.get('value');
		elm.store('value', value);
		
		elm.addEvents({
			'focus': function() {
				if(this.get('value') == value) this.set('value', '');
			},
			'blur': function() {
				if(this.get('value') == '') this.set('value', value);
			}
		}, this);
	},

  initPrint: function() {
    $$('a[rel=printLink]').each(function(link) {
      link.addEvent('click', function(e) { var event = new Event(e).stop(); window.print(); });
    });
  }
});