// deziddon.com/mki0.93
(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 = {
		// Add additional elements
		push:function(a){
			for(var j=0;j<a.length;j++){
				this.els.push(a[j]);
			}
			return this;
		},
		
		// Apply to all elements  e.g. *.all(somefunction);
		all:function(f){
			for (var i = 0,xn = this.els.length;i < xn;++i){
				f.call(this, this.els[i]);
			}
			return this;
		},

		// Attach events e.g. *.on('mouseover', somefunction);
		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;
		},

		// Apply a specific style to elements e.g. *.style('opacity',90);
		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;
		},

		// Apply many styles to elements e.g. *.css({opacity:90,border:'1px #000 solid'});
		css:function(o){
			var that = this;
			this.all(function(el){
				for(var p in o){
					that.style(p, o[p]);
				}
			});
			return this;
		},

		// Tween between states e.g. *.anim(ease.bounce, {top:10, left:10}, {top:100, left:121}, 500);
		// Params: easing function, start state (object literal), end state (object literal), time to complete (in ms), callback function (optional)
		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();
				}
			},10);
			return this;
		}
	};
	window.$ = function(){
		return new MK(arguments);
	};

	// Grab an element
	$i = function(o){
		if(typeof o == 'string'){
			return document.getElementById(o);
		}
		return o;
	};

	// Grab specified elements from specific id
	$e = function(i, e){
		var d = e ? $i(i) : document;
		return d.getElementsByTagName(e);
	};

	// GetElementsByClassName
	$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;i < d.length;i++){
				if(c.test(d[i].className)){
					r.push(d[i]);
				}
			}
			return r;
		}
		return d.getElementsByClassName(c);
	};

	// XMLHTTP Call
	// PARAMS url, postdata, success function (optional, receives response text + xml obj), failure function (optional, receives response text + xml obj)
	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 additional javascript 
	load = function(s,c){
		var f = document.createElement('script');
		f.type = 'text/javascript';
		f.onloadDone = false;
		if(c) {
            f.onload = function(){
	     		f.onloadDone = true;            
            	c();
            };
	     	f.onreadystatechange = function() {
	     		if (('loaded' === f.readyState || 'complete' === f.readyState) && !f.onloadDone) {
		     		f.onloadDone = true;
	     			c();
	     		}
	     	};
        }
		f.src = s;
		$e(document, 'head')[0].appendChild(f);
	};

	// Get X/Y position of an element
	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];
		}
	};
	
	preventDefault = function(e){
		if (!e) e = window.event;
		e.cancelBubble = true;
		e.returnValue = false;
		if(e.preventDefault){
			e.preventDefault();
		}
	};
	
	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
		}
	}

	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;
})();

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-6327430-2']);
_gaq.push(['_trackPageview']);

$(window).on('load', function() {
	$e(document.getElementsByTagName('header')[0], 'h1')[0].onclick = function() {
		document.location = '/';	
	};
	
	setTimeout(function() {
		var ga = document.createElement('script');
		ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
		ga.setAttribute('async', 'true');
		$e(document, 'head')[0].appendChild(ga);	
	}, 100);
});
