var leaf = {
	version: '1.0.0',
	
	include: function(script) 
	{
		document.write('<script type="text/javascript" src="'+script+'"><\/script>');
	},

	load: function()
	{
		var leafScript = $$('head script[src]').findAll(function(scr){
			return (scr.src && scr.src.match(/leaf\.js(\?.*)?$/))
		});

		leafScript.each(function(scr){
			var path = scr.src.replace(/leaf\.js(\?.*)?$/,'');
			var includes = scr.src.match(/\?.*use=([a-z,]*)/);

			((includes && typeof includes[1] != 'undefined' && includes[1].length > 0)? includes[1].split(',') : ['accordion', 'modal', 'tabs', 'validator','browser', 'cookie']).each(function(file){
				leaf.include(path + 'leaf.' + file + '.js'); 
			});

			leaf.include(path + 'libs/effects.js');
			leaf.include(path + 'libs/dragdrop.js');
		});

	},

	isset: function(item)
	{
		return (typeof item != 'undefined');
	},

	empty: function(item)
	{
		return (typeof item == 'undefined' || item == '');
	},

	addslashes: function(str) 
	{
		str=str.replace(/\'/g,'\\\'');
		str=str.replace(/\"/g,'\\"');
		str=str.replace(/\\/g,'\\\\');
		str=str.replace(/\0/g,'\\0');
		return str;
	},

	stripslashes: function(str) 
	{
		str=str.replace(/\\'/g,'\'');
		str=str.replace(/\\"/g,'"');
		str=str.replace(/\\\\/g,'\\');
		str=str.replace(/\\0/g,'\0');
		return str;
	},
	
	trim: function(str)
	{
        return str.replace(/(?:^\s+|\s+$)/g, "");
	},
	
	reload: function()
	{
	    window.location.href = window.location.href;
	}

}

leaf.load();
