// JavaScript Document
//adds javascripts to the head
//all scripts should be added here
//$("head").addscript({'scripts': ['myscript.js'], 'onComplete': function(){} });
if(jQuery)(
	function(jQuery) {
		jQuery.extend(jQuery.fn,{
			addscript: function(options) {
				jQuery(this).each(function() {
					settings = jQuery.extend({
						//options of the object		 
						scripts: [], // array of scripts
						onComplete: function() {} // function to run when completed
						
					}, options);
				});
				//everything goes below here
				var n = jQuery(settings.scripts).length;
				if(n > 0) {
					jQuery.each(settings.scripts, function(i) {
						//alert(settings.scripts[i]);
						jQuery("head:first").append("<script type=\"text/javascript\" src=\""+settings.scripts[i]+"\"></script>");					
					});
					jQuery(this).bind("complete", settings.onComplete).trigger("complete");
				}
			}
		});
	}
)(jQuery);
