//../js/darklight/darklight.js

var DL={
	'copy':'2009 Darklight Studio, Inc',
	'version':1.71
};

var Graphics = {};

var Colors = new Hash({
	white:'#fff',black:'#000',
	red:'#ff0000',orange:'#ff8800',yellow:'#ffff00',green:'#00ff00',
	cyan:'#0088ff',blue:'#0000ff',violet:'#4400ff',
	clear:{
		black:'rgba(0,0,0,0)',
		white:'rgba(255,255,255,0)'
	},
	gray:function(b,a){
		if(!a) return [b,b,b].rgbaStr();
		return [b,b,b,a].rgbaStr();
	}
});
var PixelImage = {
	black50:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIHWNgYGCoBwAAhACAfN85HgAAAABJRU5ErkJggg==",
	white50:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIHWP4//9/PQAJewN9rRtltAAAAABJRU5ErkJggg=="
};


function $anytype(obj,arr){
	for(i=0;i<arr.length;i++) if($type(obj) == arr[i]) return true;
	return false;
}

window.addEvent('domready',function(){
	if($$('.elementbars')) $$('.elementbars').each(function(b){
		if(b.getChildren().length<1) b.adopt(new Element('div'));b.adopt(new Element('div'));b.adopt(new Element('div'));
	});
	if($$('.textlogo')) $$('.textlogo').each(function(b){
		if (b.get('text').length < 1) {
			var txt = (b.hasClass('short')) ? 'DARKLIGHT<br/>STUDIO' : 'DARKLIGHT STUDIO';
			b.set('html',txt);
		}
	});
});


//../js/darklight/mooext/Native.js

Native.implement({
	isString:function(){ return ($type(this)=='string'); },
	isArray:function(){ return ($type(this)=='array'); },
	isObject:function(){
		var b = ($type(this)=='object');
		if($type(this)=='array') b=false;
		if($type(this)=='element') b=false;
		if($type(this)=='string') b=false;
		return b;
	}
});

Browser.Features.canvasImaging = (function(){
	var c = document.createElement("canvas");
	var val = false; var ctx;
	try {
		if (typeof c.getContext == "function" && (ctx = c.getContext("2d"))) {
			val = (typeof ctx.getImageData == "function");
		}
	} catch(e) { alert(e);	}
	return val;
})();

Date.implement({
	fmtTimeString:function(date){
		if(!date) date=new Date();
		var hrs = date.getHours().toString(10);
		var mins = date.getMinutes().toString(10);
		var secs = date.getSeconds().toString(10);
		if(hrs.length<2) hrs="0"+hrs;
		if(mins.length<2) mins="0"+mins;
		if(secs.length<2) secs="0"+secs;
		return hrs+":"+mins+":"+secs;
	}
});



String.implement({
	isLowerCase:function(){	return (this==this.toLowerCase());	},
	lastComponent:function(sep){
		return this.split(sep).getLast();
	},
	fileName:function(){
		return this.lastComponent("/");
	},
	fileExtension:function(){
		return this.lastComponent(".");
	}
});

Array.implement({
	rgbaStr:function(){
		return (this.length>3) ? "rgba("+this.join(",")+")" : "rgb("+this.join(",")+")";
	}
});


Window.implement({
	urlhash:$lambda(window.location.hash),
	globalElement:function(){
		if (arguments.length > 1) {
			for (i = 0; i < arguments.length; i++) 	this.globalElement(arguments[i]);
		} else {
			if ($(arguments[0])) this[arguments[0]] = $(arguments[0]);
			
		}
	},
	globalElements:function(){
		if (arguments.length > 1) {
			for(i=0;i<arguments.length;i++) this.globalElements(arguments[i]);
		} else {
			if($$(arguments[0])) this[arguments[0]]=$$(arguments[0]);
		}
	}
});

Document.implement({
	directory:window.location.pathname.substring(0,window.location.pathname.lastIndexOf('/')),
	filename:window.location.pathname.substring(window.location.pathname.lastIndexOf('/')+1)
});


//../js/darklight/core/Math.js
function $randomf(min,max){
	return (Math.random()*(max-min))+min;
}
function $rnd(num){	
	return Math.random()*num;
}

function hypot(x,y){
	return Math.sqrt(x.sqrd()+y.sqrd());
}

function polarToCart(angle,radius){
	var rads = angle.toRadians();
	return {x:radius * Math.cos(rads),y:Math.sin(rads)};
}
function cartToPolar(x,y){
	var r = hypot(x,y);
	var a = Math.atan(y / x) + (x > 0) ? 0 : Math.PI;
    if (a < 0) a += 2 * Math.PI;
	return {radius:r,angle:a.toDegrees()};
}

var PixelConv = new Hash({'cm':28.35,	'mm':2.835,	'inch':72,	'pica':12	});

Number.implement({
	toPixels:function(unit){
		if(unit=='px' || unit=='pixel') return this;
		return Math.round(this*PixelConv[unit]);
	},
	sqrd:function(){
		return this*this;
	},
	toRadians:function(){
		return this*(Math.PI/180);
	},
	toDegrees:function(){
		return this*(180/Math.PI);
	},
	toHex:function(){
		var bit = (this - 0).toString(16);
		if(bit.length == 1) bit = "0"+bit;
		return bit;
	}
});

Number.implement({
	toSegments:function(count){
		var arr = [];
		for(i=1;i<(count+1);i++) arr.push((this/count)*i);
		return arr;
	}
});

//../js/darklight/core/Geometry.js
/**
 * @param {Number} x
 * @param {Number} y
 * @return {Point}
 * @type {Object}
 * @constructor
 */
var Point=function(x,y){
	this.x = x || 0;
	this.y = y || 0;
	return this;
};
Point.prototype = {
	constructor:Point,
	translate:function(x,y){
		this.x+=x; this.y+=y;
		return this;
	}
};

/**
 * @param {Number} width
 * @param {Number} height
 * @return {Size}
 * @type {Object}
 * @constructor
 */
var Size=function(width,height){
	this.width=width;this.heght=height;
	return this;
};
/**

 * @param {Number} x
 * @param {Number} y
 * @param {Number} width
 * @param {Number} height
 * @return {Rect}
 * @type {Object}
 * @constructor
 */
var Rect = function(x,y,width,height){
	this.origin = new Point(x,y);
	this.width = width; this.height = height;
	return this;
};
Rect.prototype = {
	constructor:Rect,
	translate:function(x,y){
		this.origin.translate(x,y);
		return this;
	},
	scale:function(){
		var sx=arguments[0];
		var sy=arguments[1] || sx;
		this.width*=sx;
		this.height*=sy;
		return this;
	},
	getSize:$lambda(new Size(this.width,this.height))
};

//../js/darklight/mooext/Event.js

Event.implement({
	local:function(){
		return {x:this.event.offsetX,y:this.event.offsetY};	
	},
	$target:($(this.target)),
});
Element.Events.altClick = {
	base: 'click',
	condition: function(event) {	event.alt = true;	}
};
Element.Events.shiftClick = {
	base: 'click',
	condition: function(event) {	event.shift = true;		}
};
Element.Events.controlClick = {
	base: 'click',
	condition: function(event) {	event.control = true;	}
};

Element.Events.drag = {
	base: 'mousemove',
	condition: function(event){
		event.event.button = 0;
	}
};

Element.implement({
	disableChildEvents:function(){
		this.getChildren().each(function(el){
			el.removeEvents();
			el.addEvent('mouseover',function(){return false;});
			el.addEvent('mouseout',function(){return false;});
			el.addEvent('mousemove',function(){return false;});
			el.addEvent('click',function(){return false;});
		});
		return this;
	},
	disableContextMenu:function(){
		this.removeEvent('contextmenu');
		this.addEvent('contextmenu',function(){return false;});
	}
});

//../js/darklight/mooext/Element.js
Element.implement({
	indexInParent:function(){
		return (this.getParent()) ? (this.getParent().getChildren()).indexOf(this) : -1;
	},
	attributesAsHash:function(){
		var h = new Hash();
		for(i=0;i<this.attributes.length;i++){
			var nm = this.attributes[i].name;
			var v = this.attributes[i].value;
			h.set(nm,v);
		} 
		return h;
	}
});


Elements.implement({
	addEvent:function(type,func){
		var rets = [];
		for (var i = 0; i < this.length; i++) {
			rets.push(this[i].addEvent(type,func));
		}
		return rets;
	},
	removeEvent:function(type,func){
		var rets = [];
		for (var i = 0; i < this.length; i++) {
			rets.push(this[i].removeEvent(type,func));
		}
		return rets;
	}
});

(function(){
	
Element.implement({
	updateTF:function(){
		if (this.getElements('canvas')[0] && window['_typeface_js']) {
			this.set('text', this.get('text'));
			_typeface_js.replaceText(this);
		}
		return this;
	}
});
	
})();

//../js/darklight/mooext/Element-Styles.js
Element.Properties.shadow = {
	set:function(color,blur,x,y,angle){
		if(Browser.Engine.trident) return this.setStyle("filter","shadow(color="+color+", direction="+Math.floor(angle)+")");
		return this.setStyle("-webkit-box-shadow",x+"px "+y+"px "+blur+"px");
	},
	get:function(){
		if(Browser.Engine.trident) return this.getStyle('filter');
		return this.getStyle("-webkit-box-shadow");
	}
}

//../js/darklight/mooext/Element-Dimensions.js
Element.implement({
	setX:function(val){	return this.setStyle('left',Math.floor(val));	},
	setY:function(val){	return this.setStyle('top',Math.floor(val));	},
	setPosition:function(x,y){
		return this.setStyles({'left':Math.floor(x),'top':Math.floor(y)});
	},
	setWidth:function(val){
		val=Math.floor(val);
		var tag = this.get('tag');
		if((tag=='img')||(tag=='canvas')||(tag=='iframe')){
			this.width=val;
		}else{
			this.setStyle('width',val);
		}
	},
	setHeight:function(val){
		val=Math.floor(val);
		var tag = this.get('tag');
		if((tag=='img')||(tag=='canvas')||(tag=='iframe')){
			this.height=val;
		}else{
			this.setStyle('height',val);
		}
	},
	setSize:function(w,h){
		this.setWidth(w);
		this.setHeight(h);
		return this;
	},
	setCoordinates:function(obj){
		var tag = this.get('tag');
		var coords = ($type(obj) == 'element') ? obj.getCoordinates() : obj;
		if($type(obj) == 'element'){
			var os = $(obj).getOffsets();
			coords.left+=os.x; coords.top+=os.y;
		}
		this.setPosition(coords.left,coords.top);
		this.setSize(coords.width,coords.height);
		return this;
	},
	fitElement:function(el){
		if(!el) el = this.getParent();
		if(!el) return;
		return this.setCoordinates(el);
	},
	matchSize:function(el){
		if(!el) el = this.getParent();
		if(!el) return;
		this.setSize(el.getWidth(),el.getHeight());
	},
	updateSize:function(){},
	scrollToElement:function(el){
		var p = el.getPosition();
		return this.scrollTo(p.x,p.y);
	}
});

Element.implement({
	centerXTo:function(el){
		if(!el) el = this.getParent();
		this.setStyle('left',Math.floor((el.getSize().x-this.getSize().x)/2));
		return this;
	},
	centerYTo:function(el){
		if(!el) el = this.getParent();
		this.setStyle('top',Math.floor((el.getSize().y-this.getSize().y)/2));
		return this;
	},
	centerTo:function(el){
		if(!el) el = this.getParent();
		this.setStyles({
			'top': Math.floor((el.getSize().y - this.getSize().y) / 2),
			'left':Math.floor((el.getSize().x-this.getSize().x)/2)
		});
		return this;
	}
});

//../js/darklight/mooext/Fx.js

//../js/darklight/graphics/SVG.js
var SVG = new Class({
	Implements:Events,
	initialize: function(tag, props){
		var svgelement;

		if(typeof tag == 'string'){
			svgelement = $.element(document.createElementNS("http://www.w3.org/2000/svg", tag));
		}else{
			svgelement = $(tag);
	
			svgelement.getChildren().each(function(child){
				new SVG(child);
			});
		}
		if(props) svgelement.set(props);
		if(svgelement.get('tag')=='svg'){
			svgelement.set("version","1.1");
			svgelement.set("baseProfile","full");
		}
		return $extend(svgelement,this);
	},
	load:function(file){
		this.floader = new Request({method:'get',url:file,onComplete:this.loaded.bind(this)}).send();
		console.log("loading "+file)
	},
	loaded: function(text,xml){
		var rootsvg = $(xml.getElement('svg'));
		console.log("loaded");
		this.floader=null;
		this.fireEvent('loaded',this);
	},
});

SVG.Properties = $merge(Element.Properties,new Hash);



//../js/darklight/graphics/GContext.js
var GContext = new Class({
	initialize:function(ctx){
		return $extend(ctx,this);
	},
	setStyle:function(prop,val){
		if(this[prop]) this[prop] = val;
		return this;
	},
	setStyles:function(obj){
		for(var oprop in obj) this.setStyle(oprop,obj[oprop]);
	},
	setAlpha:function(val){
		return this.globalAlpha = val || 1;
	},
	setCompOp:function(val){
		return this.globalCompositeOperation = val || 'source-over';
	},
	setShadowOffset:function(x,y){
		return this.setStyles({'shadowOffsetX':x||0,'shadowOffsetY':y||0});
	},
	getShadow:function(){
		return {color:this.shadowColor,blur:this.shadowBlur,x:this.shadowOffsetX,y:this.shadowOffsetY};
	},
	createGradient:function(coords,colorstops){
		var cmd = (coords.length>4) ? 'createRadialGradient':'createLinearGradient';
		console.log(cmd);
		var grad = this[cmd].apply(this,coords);
		if(!colorstops) return grad;
		for(i=0;i<colorstops.length;i++){
			grad.addColorStop(colorstops[i][0],colorstops[i][1]);	
		}
		return grad;
	}
});


//../js/darklight/graphics/Transform.js
Graphics.Transform = new Class({
	transform:new Hash({
		position:{x:0,y:0},
		rotation:0,
		scale:{x:1,y:1},
		anchor:{x:0,y:0}
	}),
	setTransform:function(prop,val){
		if (arguments.length < 2) {
			var obj = arguments[0];
			for (var p in obj) 
				this.transform.set(obj[p]);
		}else{
			this.transform.set(prop,val);
		}
		return this;
	},
	setPosition:function(x,y){
		this.transform.set("position",{x:x,y:y});
		return this;
	},
	getPosition:function(){
		return this.transform.get('position');
	},
	translate:function(x,y){
		var cp = this.getPosition();
		cp.x+=x;
		cp.y+=y;
		this.setPosition(cp.x,cp.y);
		return this;
	},
	setRotation:function(angle){
		this.transform.set('rotation',angle);
	},
	getRotation:function(){
		return this.transform.get('rotation');
	},
	rotate:function(angle){
		var cr = this.getRotation();
		cr+=angle;
		if(cr<0){
			cr = 360-Math.abs(cr);
		}else if(cr>360){
			cr = cr - 360;
		}
		this.setRotation(cr);
		return this;
	},
	setScale:function(x,y){
		this.transform.set("scale",{x:x,y:y});
		return this;
	},
	getScale:function(){
		return this.transform.get('scale');
	},
	scale:function(x,y){
		var cs = this.getScale();
		cs.x+=x;
		cs.y+=y;
		this.setScale(cs.x,cs.y);
		return this;
	},
	setAnchor:function(x,y){
		this.transform.set('anchor',{x:x,y:y});
		return this;
	},
	getAnchor:function(){
		return this.transform.get('anchor');
	},
	applyTransform:function(ctx){
		var tp = this.transform.position;
		var tr = this.transform.rotation;
		var ts = this.transform.scale;
		
		ctx.translate(tp.x,tp.y);
		ctx.rotate(tr.toRadians());
	//	ctx.translate(-tp.x/2,-tp.y/2);
		ctx.scale(ts.x,ts.y);
		return this;
	}
});

//../js/darklight/graphics/Gradient.js
var Gradient = new Hash({
	type:'linear',
	start:{x:0,y:0},
	end:{x:0,y:0},
	radii:{inner:0,outer:100},
	colors:['white','black'],
	stops:[0,1],

	stopsForColors:function(){
		var arr = [];
		for(i=0;i<arguments.length;i++){
			var cs = (1 / (this.colors.length - 1)) * i;
			arr.push(cs);
		}
		return arr;
	},
	build:function(ctx,type){
		if(this.colors.length<1) return;
		if(type) this.type=type;
		var grad;
		if(this.type=='linear'){
			grad = ctx.createLinearGradient(this.start.x,this.start.y,this.end.x,this.end.y);
		}else{
			grad = ctx.createRadialGradient(this.start.x,this.start.y,this.radii.inner,this.end.x,this.end.y,this.radii.outer);
		}
		for (i = 0; i < this.colors.length; i++) {
			var s = (this.stops[i]) ? this.stops[i] : (1 / (this.colors.length - 1)) * i;
			this.stops[i] = s;
			grad.addColorStop(this.stops[i],this.colors[i]);
		}
		return grad;
	}
});


//../js/darklight/graphics/Styles.js
Graphics.Styles = new Class({
	style:new Hash({
		globalAlpha:1,globalCompositeOperation:'source-over',
		fillStyle:'transparent',
		strokeStyle:'black',
		lineWidth:1,lineCap:'butt',lineJoin:'miter',miterLimit:89,
		shadowColor:'transparent',shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0
	}),
	
	setStyle:function(name,val){
		this.style.set(name,val);
		return this;
	},
	setStyles:function(obj){
		for(var prop in obj){
			this.setStyle(prop,obj[prop]);
		}
		return this;
	},
	getStyle:function(name){
		return this.style.get(name);
	},
	setFill:function(color){
		this.setStyle('fillStyle',color || 'transparent');
		return this;
	},
	setStroke:function(color,width){
		return this.setStyles({
			'strokeStyle': color || 'transparent',
			'lineWidth':width || 1
		});
	},
	setShadow:function(color,blur,x,y){
		return this.setStyles({
			'shadowColor':color||'transparent',
			'shadowBlur':blur||0,
			'shadowOffsetX':x||0,
			'shadowOffsetY':y||0
		});
	},
	setAlpha:function(v){
		this.setStyle('globalAlpha',v);
	},
	alpha:function(){
		return this.styles.get('globalAlpha');
	},
	applyStyles:function(ctx){
		for(var prop in this.style) ctx[prop] = this.style.get(prop);
	}
});

//../js/darklight/graphics/Shape.js
var Shape = new Class({
	Implements:[Graphics.Transform,Graphics.Styles],
	clip:false,
	
	initialize:function(){
		return this;
	},
	apply:function(ctx){
		ctx.save();
		this.applyTransform(ctx);
		this.applyStyles(ctx);
		
		this.draw(ctx);
		ctx.fill();
		ctx.stroke();
		if (this.clip) ctx.clip();
		ctx.restore();
		return this;
	},
	draw:function(ctx){
		
	}
});

Shape.Rect = new Class({Extends:Shape,
	x:0,y:0,width:100,height:100,
	cornerRadius:0,
	initialize:function(x,y,w,h,cornerRadius){
		this.parent();
		this.x=x; this.y=y; this.width=w; this.height=h;
		if(cornerRadius) this.cornerRadius = cornerRadius;
		return this;
	},
	draw:function(ctx){
		ctx.beginPath();
		var x=this.x;var y=this.y;
		var width=this.width;var height=this.height;
		var radius=this.cornerRadius;
		if (radius == 0) {
			ctx.rect(x,y,width,height);
		}else{
			ctx.moveTo(x, y + radius);
			ctx.lineTo(x, y + height - radius);
			ctx.quadraticCurveTo(x, y + height, x + radius, y + height);
			ctx.lineTo(x + width - radius, y + height);
			ctx.quadraticCurveTo(x + width, y + height, x + width, y + height - radius);
			ctx.lineTo(x + width, y + radius);
			ctx.quadraticCurveTo(x + width, y, x + width - radius, y);
			ctx.lineTo(x + radius, y);
			ctx.quadraticCurveTo(x, y, x, y + radius);
		}
		ctx.closePath();
		return this;
	}
});

Shape.Circle = new Class({	Extends:Shape,
	x:0,y:0,radius:100,startAngle:0,endAngle:360,clockwise:true,
	initialize:function(x,y,radius,startAngle,endAngle,clockwise){
		this.parent();
		this.x=x; this.y=y; this.radius = radius;
		if(startAngle) this.startAngle = startAngle;
		if(endAngle) this.endAngle = endAngle;
		if($defined(clockwise)) this.clockwise = clockwise;
		return this;
	},
	draw:function(ctx){
		if(this.radius==0) return this;
		ctx.beginPath();
		var sa = this.startAngle.toRadians();
		var ea = this.endAngle.toRadians();
		ctx.arc(this.x, this.y, this.radius, sa, ea, this.clockwise);
		ctx.closePath();
		return this;
	}
});

Shape.Ellipse = new Class({	Extends:Shape,
	x:0,y:0,chordX:50,chordY:50,
	initialize:function(x,y,chordX,chordY){
		this.parent();
		this.x=x; this.y=y;
		this.chordX = chordX;
		this.chordY = chordY || this.chordX;
		return this;
	},
	draw:function(ctx){
		if (this.chordX == 0 || this.chordY == 0) return this;
	    var k = 0.5522847498;
	    var x = this.x;
	    var y = this.y;
	    var krx = k*this.chordX;
	    var kry = k*this.radiusY;
		ctx.beginPath();
	    ctx.moveTo(x+this.chordX, y);
	    ctx.bezierCurveTo(x+this.chordX, y-kry, x+krx, y-this.chordY, x, y-this.chordY);
	    ctx.bezierCurveTo(x-krx, y-this.chordY, x-this.chordX, y-kry, x-this.chordX, y);
	    ctx.bezierCurveTo(x-this.chordX, y+kry, x-krx, y+this.chordY, x, y+this.chordY);
	    ctx.bezierCurveTo(x+krx, y+this.chordY, x+this.chordX, y+kry, x+this.chordX, y);
		ctx.closePath();
		return this;
	}
});


Shape.Star = new Class({Extends:Shape,
	x:0,y:0,points:5,radius:100,inset:0.5,
	initialize:function(x,y,points,radius,inset){
		this.parent();
		this.x=x;this.y=y;
		this.points = points || 5;
		this.radius = radius || 100;
		this.inset = inset || 0.5;
		return this;
	},
	draw:function(ctx){
		ctx.beginPath()
		ctx.moveTo(r,0);
		var ec = (this.points*2) - 1;
		for (i=0;i<ec;i++){
			ctx.rotate(Math.PI/(this.points*2));
			if(i%2 == 0) {
				ctx.lineTo(this.radius*this.inset,0);
			} else {
				ctx.lineTo(this.radius,0);
			}
		}
		ctx.closePath();
	}
});


var ShapeGroup = new Class({
	Implements:Graphics.Transform,
	initialize:function(arr){
		if(!arr) arr=new Array();
		return $extend(arr,this);
	},
	addShape:function(shape){
		this.push(shape);
	},
	removeShape:function(shape){
		if($type(shape)=='number') shape=this[shape];
		this.erase[shape];
		return this;
	},
	setStyle:function(prop,val){
		if(this.length<1) return;
		this.each(function(item){
			item.setStyle(prop,val);
		});
		return this;
	},
	setStyles:function(obj){
		if(this.length<1) return;
		for(var prop in obj){
			this.setStyle(prop,obj[prop]);
		}
		return this;
	},
	apply:function(ctx){
		if(this.length<1) return;
		ctx.save();
		this.applyTransform(ctx);
		
		for(i=0;i<this.length;i++){
			this[i].apply(ctx);
		}
		ctx.restore();
		return this;
	}
});

//../js/darklight/ui/Canvas.js
var Canvas = new Class({
	Implements:Events,
	ctx:null,
	initialize:function(canvas,properties){
		if(!canvas) canvas = new Element("canvas");
		if(properties) canvas.set(properties);
		if($type(canvas)=='string') canvas = $(canvas);
		this.ctx = new GContext(canvas.getContext('2d'));
		return $extend(canvas,this);
	},
	clear:function(){
		this.width=this.width;
	},
	fill:function(clr){
		if(clr) this.ctx.fillStyle = clr;
		this.ctx.fillRect(0,0,this.width,this.height);
	},
	update:function(){
		
	},
	draw:function(){}
});

Canvas.Properties = $merge(Element.Properties,new Hash);

Canvas.implement({
	setSize:function(w,h){
		this.width = w;
		this.height = h;
	},
	fixSize:function(){
		var csize = this.getSize();
		this.setSize(csize.x,csize.y);
	},
	fitElement:function(el){
		console.log('calling canvas fit');
		if(!el) el = this.getParent();
		if(!el) return;
		var csize = el.getSize();
		this.width = csize.x;
		this.height=csize.y;
		return this;
	}
});

var BGCanvas = new Class({
	initialize:function(container){
		var canvas = new Canvas().setStyles({
			'position':'absolute',
			'left':0,'top':0
		});
		if(container){
			canvas.inject(container,'top');
			canvas.fitElement();
		}
		return $extend(canvas,this);
	},
	update:function(){
		this.fitElement();
		this.draw();
	}
});

//../js/darklight/ui/UI.js
//	Generic Implementations for Elements



var Overlay = new Class({
	strength:0.75,color:'#fff',
	initialize:function(color,strength){
		this.strength = strength || 0.75;
		this.color=color || $(document.body).getStyle('background-color');
		var el = new Element('div').setStyles({
			'position':'absolute',
			left:0,top:0,'z-index':100,
			'background-color':color,
			display:'block'
		});
		return $extend(el,this);
	},
	setColor:function(v){
		this.color=v;
		return this.setStyle('background-color',this.color);
	},
	setStrength:function(v){
		return this.strength=v;
	},
	coverElement:function(el){
		if(!el) el=$(document.body);
		this.fade('hide');
		el.adopt(this);
		this.fitElement();
		this.fade(this.strength);
	},
	uncover:function(){
		this.fade('out');
	}
});

//../js/darklight/ui/Layout.js
Element.Layout = new Hash({
	anchors:{
		left:$empty,top:$empty,
		bottom:$empty,right:$empty,
	}
});

var LayoutManager = new Class({
	initialize:function(){
		return this;
	}
});

//../js/darklight/ui/DLFrame.js
var DLFrame = new Class({
	Implements:Events,
	wnd:null,doc:null,
	initialize:function(el){
		var iframe = new IFrame(el || 'iframe');
		return $extend(iframe,this);
	},
	setSrc:function(url){
		this.onload=this.loadcomplete.bind(this);
		this.set('src',url);
		this.fireEvent('loadstart');
	},
	
	loadcomplete: function(event) {
		this.onload = null;
		this.wnd = new Window(this.contentWindow);
		this.doc = new Document(this.contentDocument);
		this.fireEvent('loadcomplete')
	}
	
	
});

//../js/darklight/net/Gateway.js
Request.Gateway = new Class({
	Extends: Request,
	options: {
		baseurl:'amfphp/json.php',
		method:'get',
		secure: true,
		service:'amfphp.DiscoveryService.getServices'
	},
	initialize: function(options){
		this.parent(options);
		this.headers.extend({'Accept': 'application/json', 'X-Request': 'JSON'});
		if(Request.Gateway.Services.getLength()<1) this.getServices();
		return this;
	},
	setService:function(srvpath){
		this.options.service=srvpath;
	},
	callService:function(){
		if(!this.options.service) return;
		if(this.failure) this.failure = null;
		var furl = this.options.baseurl+"/"+this.options.service;
		
		if(arguments.length>0) furl += "/" + Array.flatten(arguments).join("/");
		
		this.options.url = furl;
		this.send();
	},

	getServices:function(){
		this.setService("amfphp.DiscoveryService.getServices");
	//	console.log("Retrieving Service List...");
		this.removeEvents();
		this.addEvent('success',(function(){
			//console.log(this.response.text);
			Request.Gateway.Services.extend(this.response.json);
			//console.log('Services Loaded');
		}).bind(this));
		this.callService();
	},
	onRuntimeError:function(json){
		this.failure = {"code":json['faultCode'],"service":this.options.service,"line":json["faultDetail"].split(" ").getLast(),"description":json['faultString']};
		this.fireEvent('runtimeFailure',this.failure);
	},
	success: function(text){
		this.response.json = JSON.decode(text, this.options.secure);
		if (this.response.json['faultCode']) {
			this.onRuntimeError(this.response.json);
		} else {
			this.onSuccess(this.response.json, text);
		}
	}
});

Request.Gateway.Services = new Hash;



