//therendstudio
//Version 0.2.7
Element.implement({
	nonSelectable :	function(){	//Make non-selectable
		this.onselectstart = function() {
			return false;
		};
		this.unselectable = "on";
		this.style.MozUserSelect = "-moz-none";
		return this;
	},
	nonDraggable : function(){
		this.addEvent('mousedown',function(e){e.preventDefault();});
		return this;
	}
});
if(!Browser.Engine.trident)
	Element.implement({
		selectNodes : function(xpath){
			try{
				var resultXPath = this.getDocument().evaluate(xpath,this,null,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);
			}catch(e){
				inter_Log(3,"selectNodes('",xpath,'"); raised=> ',e);
				return [];
			}
			var elNext,arElements = [];
			while(elNext = resultXPath.iterateNext())
				arElements.push(elNext);
			return arElements;
		},
		selectSingleNode : function(xpath){
			try{
				var resultXPath = this.getDocument().evaluate(xpath,this,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null);
			}catch(e){
				inter_Log(3,"selectSingleNode('",xpath,'"); raised=> ',e);
				return null;
			}
			return resultXPath.singleNodeValue;
		}
	});
function $$A(iterable){
	if($defined(iterable.length)){
		var l = iterable.length, array = new Array(l);
		while (l--) array[l] = iterable[l];
		return array;
	}
	return Array.prototype.slice.call(iterable);
};

_inter_options = new Hash({
	logLevel : 0,
	consoleZ : 10000,
	consoleColor : '#944'
});

inter_Image = new Class({
	initialize : function(path,onLoad){
		inter_Log(2,'Img Loading:',path);
		this._el = $(new Image());
		this.path = path;
		this._onLoad = onLoad;
		this.isLoaded = false;
		this._el.addEvent('load',function(){
			inter_Log(2,'Img Loaded:',this.path);
			this.isLoaded = true;
			if(this._onLoad)
				this._onLoad(this,this._el);
			this._el.removeEvents('load');
			this._onLoad = null;
		}.bind(this));
	},
	load : function(defer){
		(function(){
			this._el.src = this.path;
		}).delay(defer || 0,this);
		return this;
	},
	toElement : function(){
		return this._el;
	},
	destroy : function(){
		this._onLoad = null;
		this._el.src = '';
		this._el.destroy();
		this._el = null;
	 }
});
inter_Video = new Class({
	initialize : function(path,width,height,onLoad){
		inter_Log(2,'Video Loading:',path);
		this._el = new Element("EMBED",{
				width : width,
				height : height,
				controller : true,
				wmode : 'transparent',
				autostart : true
			});
		this.path = path;
		this._onLoad = onLoad;
		this.isLoaded = false;
	},
	load : function(defer){
		(function(){
			this._el.src = this.path;
			inter_Log(2,'Video Loading:',this.path);
			this.isLoaded = true;
			if(this._onLoad)
				this._onLoad(this);
			this._onLoad = null;
		}).delay(defer || 0,this);
		return this;
	},
	toElement : function(){
		return this._el;
	}
});
function inter_precacheImg(paths){
	if(!$type(paths) != 'array')
		paths = [paths];
	var images = [];
	while(paths.length){
		var img = new Image();
		img.src = paths.shift();
		images.push(img);
	}
}
function inter_Init(options){
	_inter_options.extend(options);
	if(_inter_options.logLevel){
		//Create the log console
		new Element("DIV",{id : 'int_console',styles : {
					position : 'fixed',
					left : 0,
					bottom : 0,
					zIndex : _inter_options.consoleZ,
					padding : '3px',
					width : 0,
					whiteSpace : 'nowrap',
					fontSize : '12px',
					color : _inter_options.consoleColor,
					fontFamily : 'Arial'
				}}).inject(document.body);
	}
}
function inter_Log(level){
	var args = $A(arguments);
	if($type(level) != 'number')
		level = 1;
	else
		args.shift();
	if(_inter_options.logLevel < level)
		return;
	$('int_console')
		.grab(new Element("DIV",{text : args.join(' '),
					styles : {
						padding : '2px',
						'float' : 'left',
						clear : 'left'
					}}));
}

/* taken from jquery */
// Determines if an XMLHttpRequest was successful or not taking into account file: calls
function _inter_request_is_success( xhr ) {
	try {
		// IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
		return !xhr.status && location.protocol === "file:" ||
			// Opera returns 0 when status is 304
			( xhr.status >= 200 && xhr.status < 300 ) ||
			xhr.status === 304 || xhr.status === 1223 || xhr.status === 0;
	} catch(e) {}

	return false;
}

