(function(){
	function MK(ls){
		this.els = [];
		for(var i = 0; i < ls.length;i++){
			var l = ls[i];
			if(typeof l === 'string'){
				l = $i(l);
			}
			this.els.push(l);
		}
		return this;
	}

	MK.prototype = {
		push:function(a){
			for(var j = 0; j < a.length; j++){
				this.els.push(a[j]);
			}
			return this;
		},
		
		all:function(f){
			for (var i = 0, xn = this.els.length; i < xn; i++){
				f.call(this, this.els[i]);
			}
			return this;
		},

		on:function(t, f){
			var lsn = function(el){
				if(window.addEventListener){
					el.addEventListener(t, f, false);
				} else if (window.attachEvent){
					el.attachEvent('on' + t, function(){
							f.call(el, window.event);
						}
					);
				}
			};
			this.all(function(el){
				lsn(el);
			});
			return this;
		},

		style:function(p, v){
			this.all(function(el){
				var u = v;
				if(p == 'opacity'){
					el.style['filter'] = 'alpha(opacity='+ u +')';		
					u = u / 100;
				}
				el.style[p] = u;
			});
			return this;
		},

		css:function(o){
			var that = this;
			this.all(function(el){
				for(var p in o){
					that.style(p, o[p]);
				}
			});
			return this;
		},

		anim:function(f, b, e, t, c){
			var that = this;
			for(var p in b){			
				if(p != 'opacity' || p != 'zIndex'){
					e[p] = (e[p] - b[p]);
				}
			} 
			var nd = new Date().getTime() + t;
			var _a = window.setInterval(function(){
				var k = (t - (nd - new Date().getTime()));
				if(t <= k){
					window.clearInterval(_a);
					k = t;
				}
				that.all(function(el){
					for(var p in b){
						if(p == 'scrollLeft' || p == 'scrollTop'){
							el[p] = Math.floor(f(k, b[p], e[p], t));
						} else {
							var prt = (p == 'zIndex' || p == 'opacity') ? '' : 'px';
							that.style(p, Math.floor(f(k, b[p], e[p], t)) + prt);
						}
					}
				});
				if(t === k && c){
					c();
				}
			}, 15);
			return this;
		}
	};
	
	window.$ = function(){
		return new MK(arguments);
	};

	$i = function(o){
		if(typeof o === 'string'){
			return document.getElementById(o);
		}
		return o;
	};

	$e = function(i, e){
		var d = e ? $i(i) : document;
		return d.getElementsByTagName(e);
	};

	$c = function(c,e){
		var d = e ? $i(e) : document;
		if(!document.getElementsByClassName){
			var r = [];
			c = new RegExp('\\b' + c + '\\b');
			d = d.getElementsByTagName('*');
			for(var i = 0, j = d.length; i < j; i++){
				if(c.test(d[i].className)){
					r.push(d[i]);
				}
			}
			return r;
		}
		return d.getElementsByClassName(c);
	};

	xhr = function(u, p, s, f){
		var X = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
		if(p == ''){
			X.open('GET', u, true);
		} else {
			X.open('POST', u, true);
			X.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		}
		X.onreadystatechange = function(){
			if(X.readyState == 4){
				var r = X.responseText;
				if(X.status == 200){
					if(s){
						s(r, X);
					}
				} else {
					if(f){
						f(r, X);
					}
				}
			}
		};
		X.send(p);
	};

	load = function(s,c){
		var f = document.createElement('script');
		if(c){
			f.onload = function(){c()};
			f.onreadystatechange = function(){
				if(this.readyState == 'complete'){
					c();
				}
			};
        }
		f.src = s;
		$e(document, 'head')[0].appendChild(f);
	};

	offSet = function(o){
		var l = 0;
		var t = 0;
		if(o.offsetParent){
			do{l += o.offsetLeft; t += o.offsetTop;} while(o = o.offsetParent);
			return [l, t];
		}
	};
		
	if(!Array.indexOf){
		Array.prototype.indexOf = function(o,i){
			for(var j = this.length, i = i < 0 ? i + j < 0 ? 0 : i + j : i || 0; i < j && this[i] !== o; i++);
			return j <= i ? -1 : i;
		}
	}
	
	preventDefault = function(e){
		if (!e) e = window.event;
		e.cancelBubble = true;
		e.returnValue = false;
		if(e.preventDefault){
			e.preventDefault();
		}
	};

	ease = {
		cubic : function(t, b, c, d){
			if((t /= d / 2)<1){
				return (c / 2 * t * t * t + b) * 1;
			}
			return (c / 2 * ((t -= 2) * t * t + 2) + b) * 1;
		},
		
		bounce : function(t, b, c, d){
			if((t /= d) < (1 / 2.75)){
				return c * (7.5625 * t * t) + b;
			} else if(t < (2 / 2.75)){
				return c * (7.5625 * (t -= (1.5/2.75)) * t + .75) + b;
			} else if(t < (2.5 / 2.75)){
				return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
			}else{
				return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
			}
		}
	};

	MKAvail = true;
})();

$(window).on('load', function(){
	var body = $e(document, 'body')[0];

	var nBg = new Image();
	nBg.onload = function(){
		$('container').css({backgroundPosition: 'center top', backgroundImage: 'url(/media/img/v2_lbg.png)', backgroundColor: 'transparent'});
		$().push($e('container', 'h1')).push($e('container', 'h2')).push($c('box')).css({backgroundColor: 'transparent'});
	};
	nBg.src = 'v2_lbg.png';
	
	// LOGOS
	var lgo  = new Image();
	lgo.onload = function(){
		$(lgo).css({position: 'absolute', top: '31px', left: offSet($i('content'))[0] + 'px'});
		body.appendChild(lgo);
	};
	lgo.src = '/media/img/v2_logo2.png';
	var dl  = new Image();
	dl.onload = function(){
		$(dl).css({position: 'absolute', top: '-22px', left: (offSet($i('content'))[0] + 640) + 'px'});
		body.appendChild(dl);
	};
	dl.src = '/media/img/v2_download.png';
	$().push($e('hdr', 'h1')).push($e('hdr', 'h2')).css({display: 'none'});

	
	// SEARCH
	var srch = $('search');
	//overflow: 'hidden', height: '5px', 
	srch.css({opacity: 70})
	$('sTrm').on('focus', function() {
		if (this.value === 'Search') {
			this.value = '';
		}
	});

	// NAV
	var nvlks = $().push($e('nav', 'a'));
	nvlks.all(function(el){
		$(el).css({top: offSet(el)[1] + 'px', left: offSet(el)[0] + 'px'});
	}).all(function(el){
		el.parentNode.removeChild(el);
		el.className = 'nava';
		$i('hdr').appendChild(el);
	}).css({position: 'absolute'});
	var nv = $('nav');
	nv.css({opacity: 70});

	// BG
	var bdy = $(body);
	var bOS = 300;
	setInterval(function(){
		bdy.css({backgroundPosition: '0% ' + bOS + 'px'});
		bOS--;
	}, 30); //100
});