/* 	
*	Codigo JS
*	Autor: Daniel Mota Leiva // http://danielmota.com
*	Fecha: Fecha: 25/01/06
*/
var modulo = {
  path: null,
  getPath: function() {
    $A(document.getElementsByTagName("script")).findAll( function(s) {
      return (s.src && s.src.match(/prototype.js$/))
    }).each( function(s) {
      modulo.path = s.src.replace(/prototype.js/,'');
    });
  },
	include: function(nombre) {
		document.write('<script type="text/javascript" src="'+nombre+'"></script>');
	},
	js: function(nombre) {
	  if(modulo.path==null) modulo.getPath();
		document.write('<script type="text/javascript" src="'+modulo.path+nombre+'.js"></script>');
	}
};

/* 	
*	DOMReady 
*	aplicar Behaviour cuando el DOM esta cargado
*/
Object.extend(Event, {
  _domReady : function() {
    if (arguments.callee.done) return;
    arguments.callee.done = true;

    if (this._timer)  clearInterval(this._timer);
    
    this._readyCallbacks.each(function(f) { f() });
    this._readyCallbacks = null;
},
  onDOMReady : function(f) {
    if (!this._readyCallbacks) {
      var domReady = this._domReady.bind(this);
      
      if (document.addEventListener)
        document.addEventListener("DOMContentLoaded", domReady, false);
        
        /*@cc_on @*/
        /*@if (@_win32)
            document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
            document.getElementById("__ie_onload").onreadystatechange = function() {
                if (this.readyState == "complete") domReady(); 
            };
        /*@end @*/
        
        if (/WebKit/i.test(navigator.userAgent)) { 
          this._timer = setInterval(function() {
            if (/loaded|complete/.test(document.readyState)) domReady(); 
          }, 10);
        }
        
        Event.observe(window, 'load', domReady);
        Event._readyCallbacks =  [];
    }
    Event._readyCallbacks.push(f);
  }
});
/*
   Behaviour v1.1 by Ben Nolan, June 2005. Based largely on the work
   of Simon Willison (see comments by Simon below).

   Description:
   	
   	Uses css selectors to apply javascript behaviours to enable
   	unobtrusive javascript in html documents.
   	
   Usage:   
   
	var myrules = {
		'b.someclass' : function(element){
			element.onclick = function(){
				alert(this.innerHTML);
			}
		},
		'#someid u' : function(element){
			element.onmouseover = function(){
				this.innerHTML = "BLAH!";
			}
		}
	};
	
	Behaviour.register(myrules);
	
	// Call Behaviour.apply() to re-apply the rules (if you
	// update the dom, etc).

   License:
   
   	This file is entirely BSD licensed.
   	
   More information:
   	
   	http://ripcord.co.nz/behaviour/
   
*/   

var Behaviour = {
	list : [],
	
	register : function(sheet){
		Behaviour.list.push(sheet);
	},
	
	apply : function(){
		Behaviour.list.each(function(sheet) {
		  for (selector in sheet) {
		    var list = $$(selector);
		    list.each(function(e) {
		      sheet[selector](e);
		    });
	    }
		});
	}
}

/* 	
*	Carga de modulos
*	incluimos librerias necesarias
*/
//modulo.js('menu');
modulo.js('galery');
modulo.js('scroll');


//Event.observe(window, "load", Behaviour.apply,false);
Event.onDOMReady(Behaviour.apply);