/*-----------------------------------------------------*\
 |                                                     |
 | jlib - 2009                                         |
 |                                                     |
\*-----------------------------------------------------*/

var jib = {

	ver: 		'0.1.0',
	path: 		'./js/',
	baseurl:	'./',
	params: 	'',
	ext: 		[],
	loaded:		false,
	isIE6:		Math.max(navigator.userAgent.indexOf('MSIE 6.0'), 0),

	/*-----------------------
	 |
	 | Initialize Function
	 | Loads the Settings file which then loads the Modules -> Build file.
	 |
	 |------------------------------------*/
	initialize: function()
	{
		// important
		if( js_url && js_url.length > 0 )
			this.path = js_url;
		
		// important
		if( base_url && base_url.length > 0 )
			this.baseurl = base_url;
			
		this.writeJavaScript('jib.settings.js');
	},

	/*-----------------------
	 |
	 | WriteJavascript Function
	 | Will append JS files either pre/post load.
	 |
	 |------------------------------------*/
	writeJavaScript: function($javascript, $removePath){
		
		// used for direct URLs like Google
		var path = this.path;
		if( $removePath )	path = '';
		
		if( !this.loaded ){
			document.write('<script type="text/javascript" src="'+ path + $javascript +'"><\/script>');
		}else{
			var js = document.createElement("script");
				js.setAttribute("type","text/javascript");
				js.setAttribute("src", path + $javascript);
			document.getElementsByTagName('body')[0].appendChild(js);
		}
	},
	
	/*-----------------------
	 |
	 | WriteJavascript Function
	 | Will append JS files either pre/post load.
	 |
	 |------------------------------------*/
	writeScript: function($content){
		if( !this.loaded ){
			document.write('<script type="text/javascript">'+ $content +'<\/script>');
		}else{
		/*	var js = document.createElement("script");
				js.setAttribute("type","text/javascript");
				js.setAttribute("src", this.path + $javascript);
			document.getElementsByTagName('body')[0].appendChild(js);*/
		}
	},
	
	/*-----------------------
	 |
	 | WriteCSS Function
	 | Will append CSS files to head same way every time.
	 |
	 |------------------------------------*/
	writeCSS: function($css) {
		var css = document.createElement("link");
			css.setAttribute("href",$css);
			css.setAttribute("rel","stylesheet");
			css.setAttribute("type","text/css");
			document.getElementsByTagName('head')[0].appendChild(css);		
	}
};

jib.initialize();