/* 
	Title: Webadmin
*/

String.prototype.truncate = function(length, truncation){
	length = length || 30;
	truncation = truncation === undefined ? '...' : truncation;
	return this.length > length ?  this.slice(0, length - truncation.length) + truncation : this;
};

String.prototype.ucFirst = function(){
	var c = this.charAt(0);
	if(parseInt(this.length,10)==1){
		return c.toUpperCase();
	}else{
		return c.toUpperCase() + this.slice(1).toLowerCase();
	}
}
String.prototype.toArray = function(s){return this.split(s);};
String.prototype.trim = function() {return (this.replace(/^[\s\xA0]+/, "").replace(/[\s\xA0]+$/, ""));};
String.prototype.camelize = function(){return this.replace(/\-(\w)?/g, function(a,b){return b.toUpperCase();});};
Array.prototype.inArray = function(value){for (var i=0; i < this.length; i++){if(this[i] == value){return true;break;}}return false;};

function is_ignorable(nod){
	return ( nod.nodeType == 8) || // A comment node
         ( (nod.nodeType == 3) && is_all_ws(nod) ); // a text node, all ws
}

function is_all_ws(nod){
  // Use ECMA-262 Edition 3 String and RegExp features
  return !(/[^\t\n\r ]/.test(nod.data));
}



var Webadmin = window.Webadmin || {};

Webadmin.Flash={};

Webadmin.Locale = {
	'validate-required':{},
  	'validate-number':{},
  	'validate-digits':{},
  	'validate-alpha':{},
  	'validate-alphanum':{},
  	'validate-date':{},
 	'validate-email':{},
  	'validate-url':{}	
};

/**
 * Utility which adds Mozilla's new methods to Array for legacy browsers.
 * See http://developer.mozilla.org/en/docs/New_in_JavaScript_1.6#Array_extras for a full details.
 *
 * The original implementations of 'forEach', 'every', 'some', 'filter', 'map', 'indexOf' and 'lastIndexOf' methods were created by Dustin Diaz
 * See http://www.dustindiaz.com/basement/sugar-arrays.html for full details.
 */
Webadmin.Array = function(){
	var forEach = function(callback, object) {
		var scope = object || window;
	    for(var i=0, j=this.length; i<j; ++i){
			callback.call(scope, this[i], i, this);
	   }
	};
	var every = function(callback, object) {
	    var scope = object || window;
	    for(var i=0, j=this.length; i<j; ++i ){
	        if(!callback.call(scope, this[i], i, this)){
	            return false;
	        }
	    }
	    return true;
	};
	var some = function(callback, object) {
	    var scope = object || window;
	    for(var i=0, j=this.length; i<j; ++i){
	        if(callback.call(scope, this[i], i, this)){
	            return true;
	        }
	    }
	    return false;
	};
	var map = function(callback, object) {
		var scope = object || window;
	    var a = [];
	    for(var i=0, j=this.length; i<j; ++i){
	        a.push(callback.call(scope, this[i], i, this));
	    }
	    return a;
	};
	var filter = function(callback, object) {
	    var scope = object || window;
	    var a = [];
	    for(var i=0, j=this.length; i<j; ++i){
	        if(!callback.call(scope, this[i], i, this)){
	            continue;
	        }
	        a.push(this[i]);
	    }
	    return a;
	};
	var indexOf = function(element, start) {
	    start = start || 0;
	    for(var i=0, j=this.length; i<j; ++i) {
	        if(this[i]===element){
	        	return i;
	        }
	    }
	    return -1;
	};
	var lastIndexOf = function(element, start) {
	    start = start || this.length;
	    if(start >= this.length){
	        start = this.length;
	    }
	    if(start<0){
	    	start = this.length + start;
	    }
	    for(var i=start; i >= 0; --i){
	        if(this[i]===element){
	            return i;
	        }
	    }
	    return -1;
	};
	var extend = function(method, callback){
		if(!Array[method]){
			Array.prototype[method]=callback;
			Array[method]=function(o, c, s){
				return callback.call(o, c, s);
			};
		}
	};
	extend('forEach', forEach);
	extend('every', every);
	extend('some', some);
	extend('map', map);
	extend('filter', filter);
	extend('indexOf', indexOf);
	extend('lastIndexOf', lastIndexOf);
	return {
		force : function(a, s){
			s = s||' ';
			if(a.toArray){
				a = a.toArray(s);
			}
			return a;
		}
	};
}();

Webadmin.Cookie = function(){
	return {
		set : function(name, value, expires, path, domain, secure) {
			var today = new Date();
			today.setTime( today.getTime() );
			if (expires) expires = expires * 1000 * 60 * 60 * 24;
			var expires_date = new Date( today.getTime() + (expires) );
			document.cookie = name + "=" +escape(value) + ((expires) ? ";expires=" + expires_date.toGMTString() : "") + ((path) ? ";path=" + path : "") +	((domain) ? ";domain=" + domain : "") + ((secure) ? ";secure" : "");
		},
		get : function(name) {
			var start = document.cookie.indexOf( name + "=" );
			var len = start + name.length + 1;
			if((!start)&&(name != document.cookie.substring(0, name.length))){
				return null;
			}
			if(start == -1) return null;
			var end = document.cookie.indexOf( ";", len);
			if(end == -1) end = document.cookie.length;
			return unescape(document.cookie.substring(len, end));
		},
		destroy : function(name, path, domain) {
			if (getCookie(name)) document.cookie = name + "=" +	((path) ? ";path=" + path : "") +	((domain) ? ";domain=" + domain : "") +	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
		}
	}
}();

	

/*
	Class: Webadmin.Dom
*/
Webadmin.Dom = function(){
	return {
		i:-1,
		childNodes : function(par){
			return Array.filter(par.childNodes, function(node){
				if(!is_ignorable(node)){
					return node;
				}
			});
		},
		firstChild : function(par){
			var res=par.firstChild;
			while (res){
				if(!is_ignorable(res)){
					return res;
				}
				res = res.nextSibling;
			}
			return null;
		},
		nextSibling : function(sib){
			while((sib=sib.nextSibling)){
				if(!is_ignorable(sib)){
					return sib;
				}
			}
			return null;
		},				
		/*
			Function: getElementsByClassName
			
			Gets an array of elements by class name.
			
			Parameters:
				
				className - The class name to match.
				tagName - The tag name to match.
				context - The root element to match.
		*/			
		getElementsByClassName : function(className, tagName, context){
			var elements = [];
			if(!context){
				context = document;
			}
			if(!tagName){
				tagName = '*';
			}			
			if(context==document||context.nodeType==1){
				/*Will use Xpath here if available for speedy DOM queries*/
		  	if(typeof document.evaluate=='function'){
		    	var xpath = document.evaluate(".//"+tagName+"[contains(concat(' ', @class, ' '), ' " + className + " ')]", context, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
		      for (var i = 0, l = xpath.snapshotLength; i < l; i++){
		      	elements.push(xpath.snapshotItem(i));
		      }
		      return elements;
		    }
		  }
			elements = Array.filter(context.getElementsByTagName(tagName), function(element){
				if(Webadmin.Dom.hasClass(element, className)){
					return element;
				}
			});
			return elements;
		},
		getElementsBySelector : function(selector, parent){
			if(!parent){
				parent = document;
			}
		},
		/* 
			Function: addClass
			
			Adds a CSS class to an element.
			
			Parameters: 
			
				element - The HTML element.
				className - The class name to be added to the element.
		*/
		addClass : function(element, className){
			if(typeof element == 'string'){
				element = document.getElementById(element);
			}
			if(this.hasClass(element, className)){
				return;
			}
			element.className = [element.className, className].join(' ');
		},
		hasClass : function(element, className){
			var regexp = new RegExp("(^|\\s)"+className+"(\\s|$)");
			if(regexp.test(element.className)){
				return true;
			}else{
				return false;
			}
		},
		/*
			Function: removeClass
			
			Removes a class name from an element.
			
			Parameters:
			
				element - The HTML element.
				className - The class name to be removed from the element.		
		*/
		removeClass : function(element, className){
			if(typeof element=='string'){
				element = document.getElementById(element);
			}
			if(!this.hasClass(element, className)){
				return;
			}
			var re=new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)', 'g');
			var c = element.className;
			element.className = c.replace(re, ' ');
			if(this.hasClass(element, className)){
				this.removeClass(element, className);
			}			
		},
		/* 
			Function: getClassNames
			
			Returns an array of class names on an element.
			
			Parameters:
				
				element - The HTML element.
				
			Returns:
			
				array - The class names on the element.
		*/			
		getClassNames : function(element){
			return element.className.split(' ');
		},
		/* 
			Function: generateId
		*/
		generateId : function(p){
			this.i++;
			if(p){
				return p+this.i;
			}else{
				return 'id_'+this.i;
			}
		},
		/* 
			Function: getOpacity
		*/
		getOpacity : function(element){
			if(typeof element=='string'){
				element = document.getElementById(element);
			}
			if(element.filters){
				try {
					return element.filters.item('alpha').opacity / 100;
				}catch(e){
					try {
						return (element.currentStyle.filter.match(/opacity=(\d*)/)[1]) / 100;
					} catch(e) {}				
				}
				return 1;
			}
			var o = this._getStyle(element, 'opacity');
			if(o!==undefined){
				return o;
			}
			o=this._getStyle(element, 'MozOpacity');
			if(o!==undefined){
				return o;
			}
			return this._getStyle(element, 'KhtmlOpacity');			
		},
		/* 
			Function: setOpacity	
		*/
		setOpacity : function(element, value){
			if(typeof element=='string'){
				element = document.getElementById(element);
			}
			if(value<0.00001){
				value=0;
			}
			var s = element.style;
			if(typeof s.filter=='string'){
				s.filter = s.filter.replace(/alpha\([^\)]*\)/gi,'') + ((value < 1) ? 'alpha(opacity='+value*100+')' : '');
				if(!element.currentStyle||!element.currentStyle.hasLayout){
					s.zoom = 1;
				}
			}else{
				s.opacity = value;
				//s.MozOpacity = value;
				//s.KhtmlOpacity = value;
			}
		},
		/* 
			Function: getStyle	
		*/
		getStyle : function(e,p){
			if(p=='opacity'){
				return this.getOpacity(e);
			}
			return this._getStyle(e, p);
			
		},
		/*
			Function: _getStyle	
		*/
		_getStyle : function(e,p){
			var s;
			if(typeof e=='string'){
				e=document.getElementById(e);
			}
			if(e.currentStyle){
				p=p.camelize();
				s = e.currentStyle[p];
			}else if(document.defaultView && document.defaultView.getComputedStyle){
				s = document.defaultView.getComputedStyle(e,"").getPropertyValue(p);
			}
			return s;
		},
		/* 
			Function: setStyle
		*/
		setStyle : function(element, property, value){
			if(property=='opacity'){
				this.setOpacity(element, value);
			}else{
				if(typeof element=='string'){
					element = document.getElementById(element);
				}
				element.style[property] = value;
			}			
		},
		/*
			Function: getPosition
			
			Gets the position of an element on the page.
			
			Parameters:
			
				element - The HTML element.
				
			Returns:
			
				array - The XY position of the element.
		*/			
		getPosition : function(element) {
			
			var curleft = curtop = 0;
			if (element.offsetParent) {
				curleft = element.offsetLeft;
				curtop = element.offsetTop;
				while (element = element.offsetParent) {
					curleft += element.offsetLeft;
					curtop += element.offsetTop;
				}
			}
			return [curleft,curtop];
		},
		append : function(element){			
			if(arguments.length>1){
				var el = this.create(arguments[1], arguments[2], arguments[3]);
				element.appendChild(el);
				return el;
			}else{
				return false;
			}
		},
		create : function(){
			if(arguments.length>0){
				if(typeof arguments[0]=='string'){
					var el = arguments[0];
					if(arguments[1]&&arguments[1].constructor==Array){
						arguments[1].forEach(function(attr, i){							
							var re = new RegExp('\\{'+i+'\\}', 'g');
							el = el.replace(re,attr);
						});
					}
					var tempEl = document.createElement('div');
					tempEl.innerHTML=el;
					el=tempEl.firstChild;
				}
			}
			return el;
		}	
	};
}();

/*
	Class: Webadmin.Window
	
	A collection of methods for dealing with the dimensions of the window.
	
*/
Webadmin.Window = {
  /* 
  	Function: scrollTop
  	
  	Returns the current vertical scroll position of the document.
  	
  	Returns:
  	
  		int - The current vertical scroll position of the document.  	
  */
  scrollTop : function(){
	var y;
	if (self.pageYOffset){
		y = self.pageYOffset;
	}else if(document.documentElement && document.documentElement.scrollTop){
		y = document.documentElement.scrollTop;
	}else if (document.body){
		y = document.body.scrollTop;
	}
	return y;
  },
	/*
		Function: viewportHeight
		
		Returns the height of the viewport.
		
		Returns:
			
			int - The height of the viewport.		
	*/
  viewportHeight: function(){
      var windowHeight;
      if (self.innerHeight) {    // all except IE
          windowHeight = self.innerHeight;
      } else if (document.documentElement && document.documentElement.clientHeight) { // IE 6 Strict Mode
          windowHeight = document.documentElement.clientHeight;
      } else if (document.body) { // other IEs
          windowHeight = document.body.clientHeight;
      }
      return windowHeight;
  }, 
  /*
  	Function: viewportWidth
  	
  	Returns the width of the viewport.
  	
  	Returns:
  	
  		int - The width of the viewport.  		
  */
  viewportWidth: function(){
      var windowWidth;
      if (self.innerWidth) {    // all except IE
          windowWidth = self.innerWidth;
      } else if (document.documentElement && document.documentElement.clientWidth) { // IE 6 Strict Mode
          windowWidth = document.documentElement.clientWidth;
      } else if (document.body) { // other IEs
          windowWidth = document.body.clientWidth;
      }
      return windowWidth;
  }   
};

/*
	Class: Webadmin.Event
*/
Webadmin.Event = function(){
	return {
		/* 
			Function: init
			
			Initializes event delegation.
		*/			
		init : function(){
			this.listener.add(document, 'click', this.delegate.delegate, this.delegate);
			this.listener.add(document, 'dblclick', this.delegate.delegate, this.delegate);
			this.listener.add(document, 'keydown', this.delegate.delegate, this.delegate);
			this.listener.add(document, 'keypress', this.delegate.delegate, this.delegate);
			this.listener.add(document, 'keyup', this.delegate.delegate, this.delegate);
			this.listener.add(document, 'mousedown', this.delegate.delegate, this.delegate);
			this.listener.add(document, 'mouseup', this.delegate.delegate, this.delegate);
			this.listener.add(document, 'mousemove', this.delegate.delegate, this.delegate);
			this.listener.add(window, 'unload', this.listener.flush, this.listener);
		},
		custom : {},
		/*
			Group: Webadmin.Event.delegate
		*/
		delegate : {
			events : {
				'click' : {},
				'dblclick' : {},
				'keydown' : {},
				'keypress' : {},
				'keyup' : {},
				'mousedown' : {},
				'mouseup' : {},
				'mousemove' : {}
			},
			/*
				Function: add
				
				Adds a delegated event.
				
				Parameters:
				
					element - The HTML element
					event - The event type. Supported event types: click, dblclick, keydown, keypress, keyup, mousedown, mouseup
					callback - The method the event invokes.
					scope - The execution scope for the event.
			*/
			add : function(element, event, callback, scope){
				var id;
				scope = scope || window;
				if(element.nodeType==9){
					id='document';
				}else{
					id = element.id;
				}
				this.events[event][id]=[];
				this.events[event][id].push({'callback':callback,'scope':scope});		
			},
			/*
				Function: delegate
			*/
			delegate : function(e, el){
				var id;
				if(!el) {
					el = e.target;
					this.bubble=true;
				}
				if(el.nodeType==9){
					id='document';
				}else{
					id = el.id;
				}
				if(id&&this.events[e.type][id]){
					this.events[e.type][id].forEach(function(o){
						o.callback.call(o.scope, e);
					}, this);
				}
				if(this.bubble===true&&el.nodeType!=9){
					this.delegate(e, el.parentNode);
				}
			},
			/*
				Function: remove
			*/	
			remove : function(element, event, callback){
				var id;
				if(element.nodeType==9){
					id='document';
				}else{
					id = element.id;
				}				
				if(this.events[event][id]){
					this.events[event][id]=null;
				}
			}
		},
		/*
			Group: listener
		*/
		listener : {
			cache : [],
			/*
				Function: flush
			*/
			flush : function(){				
				for(var i=0; i<this.cache.length; i++){
					this.remove(this.cache[i].element, this.cache[i].type, this.cache[i]._fn);
				}				
			},
			/*
				Function: add
			*/
			add : function(element, event, callback, scope){
				scope = scope||window;
				var func = function(e){
					e = e || window.event;
					if(!e.target){
						e.target = e.srcElement;
					}
					if(!e.stopPropagation){
						e.stopPropagation = function(){this.returnValue=false;};
					}
					if(!e.preventDefault){
						e.preventDefault = function(){this.cancelBubble=true;};
					}
					e.stop = function(){
						/*'this' keyword refers to the event*/
						this.stopPropagation();
						this.preventDefault();
					};
					callback.call(scope, e);
				};
				if(element.addEventListener){
					element.addEventListener(event, func, false);
				}else if(element.attachEvent){
					element.attachEvent("on"+event, func);
				}
				this.cache.push({
					element:element,
					type:event,
					fn:callback,
					_fn:func
				});
			},
			/*
				Function: remove
			*/
			remove : function(element, event, func){
				var index=this.getCacheIndex(element, event, func);
				if(index!=null){
					var l = this.cache[index];
					if(l){
						if(l.element.removeEventListener){
							l.element.removeEventListener(l.type, l._fn, false);
						}else if(l.element.detachEvent){
							l.element.detachEvent("on"+l.type, l._fn);
						} 
					}
					delete this.cache[index];
					this.cache.splice(index, 1);
				}
			},
			stop : function(e){
				e.stopPropagation();
				e.preventDefault();
			},
			/*
				Function: purge
			*/
			purge : function(el, recurse, type){
				var listeners = this.getListeners(el, type);
				listeners.forEach(function(l){
					this.remove(l.element, l.type, l.fn);
				}, this);
				if(recurse&&el&&el.childNodes){
					Array.forEach(el.childNodes, function(element){
					    this.purge(element, recurse, type);	
					}, this);
				}
			},
			/*
				Function: getCacheIndex
			*/
			getCacheIndex : function(el, type, fn){
				this.index = null;
				this.cache.forEach(function(l, i){
					if(l.element==el&&l.type==type&&l.fn==fn){
						this.index = i;
					}
				},this);
				return this.index;
			},
			/*
				Function: getListeners
			*/
			getListeners : function(element, type){
				var listeners = [];
				this.cache.forEach(function(l){
					if(l.element==element){
						if(type&&l.type==type){
							listeners.push(l);
						}else{
							if(!type){
								listeners.push(l);
							}
						}
					}
				}, this);
				return listeners;
			},
    	getTarget : function(e){
    		if(e.target){
    			return e.target;
    		}else if(e.srcElement){
    			return e.srcElement;
    		}
    	}		
		}
	};
}();

/*
	Group: custom
*/

/*
	Function: publisher
*/
Webadmin.Event.custom.publisher = function(){
	this.subscribers = [];
};

/* 
	Function: fire
*/
Webadmin.Event.custom.publisher.prototype.fire = function(o){
	this.subscribers.forEach(
		function(el) {
			el.fn.call(el.scope, o);
		}
	);
};
Function.prototype.subscribe = function(publisher, scope) {
	var that = this;
	scope=scope||window;
	var alreadyExists = publisher.subscribers.some(
		function(el){
			if(el.fn===that){
				return;
			}
		}
	);
	if(!alreadyExists){
		obj = {
			fn:this,
			scope:scope
		};
		publisher.subscribers.push(obj);
	}
	return this;
};
Function.prototype.unsubscribe = function(publisher) {
	var that = this;
	publisher.subscribers = publisher.subscribers.filter(
		function(el){
			if(el.fn!==that){
				return el;
			}
		}
	);
	return this;
};

Webadmin.Event.domReady = {
	onload : function() {
		if (Webadmin.Event.domReady.done) { return; }
		Webadmin.Event.domReady.done = true;
		for(var x = 0, al = Webadmin.Event.domReady.f.length; x < al; x++) {
			Webadmin.Event.domReady.f[x]();
		}
	},
	onavailable : function(callback, scope) {
		if(!scope){
			var scope = window;
		}
		if(typeof callback == 'function'){
			if (Webadmin.Event.domReady.done){
				callback.call(scope);
			}else{
				Webadmin.Event.domReady.f.push(function(){callback.call(scope)});
			}
		}
	},
	listen : function() {
		if (/WebKit|khtml/i.test(navigator.userAgent)) {
			Webadmin.Event.domReady.timer = setInterval(function() {
				if (/loaded|complete/.test(document.readyState)) {
					clearInterval(Webadmin.Event.domReady.timer);
					delete Webadmin.Event.domReady.timer;
					Webadmin.Event.domReady.onload();
				}}, 10);
		} else if (document.addEventListener) {
			document.addEventListener('DOMContentLoaded', Webadmin.Event.domReady.onload, false);
		} else if(!Webadmin.Event.domReady.iew32) {
			if(window.addEventListener) {
				window.addEventListener('load', Webadmin.Event.domReady.onload, false);
			} else if (window.attachEvent) {
				return window.attachEvent('onload', Webadmin.Event.domReady.onload);
			}
		}
	},
	f:[],
	done:false,
	timer:null,
	iew32:false
};
/*@cc_on @*/
/*@if (@_win32)
Webadmin.Event.domReady.iew32 = true;
document.write('<script id="__ie_onload" defer src="' + ((location.protocol == 'https:') ? '//0' : 'javascript:void(0)') + '"><\/script>');
document.getElementById('__ie_onload').onreadystatechange = function(){if (this.readyState == 'complete') { Webadmin.Event.domReady.onload(); }};
/*@end @*/
Webadmin.Event.domReady.listen();
Webadmin.Event.onavailable = Webadmin.Event.domReady.onavailable;
Webadmin.Event.onavailable(Webadmin.Event.init, Webadmin.Event);


Webadmin.Ajax = function(method, url, params, callback){
	callback = callback||{};
	method = method.toUpperCase();
	var ajax = false;
	var context = callback.scope || window;
	var data = params || null;
	function onreadystatechange(){
		try {
			if(ajax.readyState==4){
				if (ajax.status == 200) {
					if(callback.success){
						callback.success.call(context, ajax);
					}
	            }else{
					if(callback.error){
						callback.error.call(context, ajax);
					}
				}
			}
		}catch(e){
			
		}
	}
	ajax = this.createXMLHTTPObject();
	if(!ajax){
		/* Unable to create request - bail out now! */
		return false;
	}
	if(method=='GET'&&data!=null){
		url=url+'?'+data;
	}
	ajax.open(method, url, true);
	//ajax.setRequestHeader('User-Agent','XMLHTTP/1.0');
	ajax.setRequestHeader('X_REQUESTED_WITH','XMLHttpRequest');
	ajax.onreadystatechange = onreadystatechange;
	if(method=='POST'){
		ajax.setRequestHeader('Content-type','application/x-www-form-urlencoded');
	}
	ajax.send(data);
};

Webadmin.Ajax.prototype = {
	factories : [
		function () {return new XMLHttpRequest()},
		function () {return new ActiveXObject("Msxml2.XMLHTTP")},
		function () {return new ActiveXObject("Msxml3.XMLHTTP")},
		function () {return new ActiveXObject("Microsoft.XMLHTTP")}
	],
	createXMLHTTPObject : function(){
		var xmlhttp = false;
		for (var i=0;i<this.factories.length;i++) {
			try {
				xmlhttp = this.factories[i]();
			}
			catch (e) {
				continue;
			}
			break;
		}
		return xmlhttp;
	}
}

Webadmin.Merge = function(subc, superc, overrides) {
    var F = function() {};
    F.prototype=superc.prototype;
    subc.prototype=new F();
    subc.prototype.constructor=subc;
    subc.superclass=superc.prototype;
    if (superc.prototype.constructor == Object.prototype.constructor) {
        superc.prototype.constructor=superc;
    }
    if (overrides) {
        for (var i in overrides) {
            subc.prototype[i]=overrides[i];
        }
    }
};

Webadmin.Extend = function(descendant, parent) { 
	var sConstructor = parent.toString(); 
	var aMatch = sConstructor.match( /\s*function (.*)\(/ ); 
	if ( aMatch != null ) { descendant.prototype[aMatch[1]] = parent; } 
	for (var m in parent.prototype) { 
		descendant.prototype[m] = parent.prototype[m]; 
	}
};

Webadmin.Include = function(urls, callback, scope){
	function error(o){
		if(callback.error){
			callback.error.call(context);
		}
	}
	function handle(o){
		if(o.responseText){
			code.push(o.responseText);
		}
		loaded++;
		if(loaded==load){
			code.forEach(function(c){
				// IE needs to use scope.execScript, so we check for this proprietry method here.
				if(scope.execScript){
					scope.execScript();
				}else{
					// Safari needs to use this line, so will need to add a browser check here, as eval.call is also supported, but broken.
					//scope.setTimeout(c,0);
					// Other browsers can use eval.call
					eval.call(scope, c);
				}
			},this);
			window.setTimeout(function(){
				if(callback.success){
					callback.success.call(context);
				}
			},0);
		}
	}
	var code = [];
	var context = callback.scope||window;
	urls = Webadmin.Array.force(urls);
	var loaded = 0;
	var load = urls.length;
	scope = scope||window;
	urls.forEach(function(url){
		var ajax = new Webadmin.Ajax('GET', url, null, {success:handle,error:error});
	}, this);
};

//$ = function(element){return document.getElementById(element);};

var $ = Webadmin.Element;

function debug(message){
	var d=$('debug');
	var e=document.createElement('div');
	e.innerHTML=message;
	d.appendChild(e);
}