// --------------------------
// Copyright 2007 dizler.com & Developed by noah@dizler.com
// --------------------------
//
// ALIASES
//
var D = document, W = window;
if( typeof Dizz == 'undefined' ) { var Dizz = {} };
function nully(){};
function $(id) { return typeof id =='string'?document.getElementById(id):false; }
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };
function trim(s) { return s.trim(); }
// FUNCTIONS
//
function $scroll() {
	var de = D.documentElement || D.body;
 	 if( de && typeof de.scrollTop  == 'number' && typeof w.pageYOffset  == 'undefined'  ) {
	    return {top:de.scrollTop,left:de.scrollLeft};	
	 } else if( typeof w.pageYOffset == 'number' ) {
	    return {top:w.pageYOffset,left:w.pageXOffset};
	 }
	 return {top:0,left:0};
}
//
function $size(e) {
	var wh = {w:600,h:500};
	if( typeof  w.innerWidth  == 'number' ) {
	    wh.w = w.innerWidth - 12;
	    wh.h = w.innerHeight - 12;
	} else {
		var de = D.documentElement || D.body;	
    	wh.w =de.clientWidth;
	    wh.h = de.clientHeight;
	}
	if( e ) {
		var lt = $scroll();	
		wh.top = Math.max(0,(Math.ceil((wh.h/2) - (e.offsetHeight/2))+lt.top));
		wh.left = Math.max(0,(Math.ceil((wh.w/2) - (e.offsetWidth/2))+lt.left));
		e.style.top = (isNaN(wh.top)?'100px':wh.top+'px');
		e.style.left = (isNaN(wh.left)?'100px':wh.left+'px');
	}
	return wh;
}
//
function $pos(e) {
    var pt = {x:0,y:0};
    do {
      pt.y += e.offsetTop  || 0;
      pt.x += e.offsetLeft || 0;
    } while (e=e.offsetParent);
    return pt;
}

//
function loadScript(js) {
	js = '/js/' + js + '.js';
	var h = document.getElementsByTagName('head')[0];
	var e = document.createElement('script');
	e.setAttribute('language','JavaScript');
	e.setAttribute('src',js);
	h.appendChild(e);
}


(function() { 
	window.NewTween = function(ele,p) { 
		var o = function(ele,prop) { this.ele = ele; this.p = p; this.negOK = false; this.speed = 3;};
		o.prototype.clear = function() {
			if( this.t !== null ) { clearInterval(this.t); this.neg = false; this.t = null; this.d = 3;}
		};
		o.prototype.run = function() {
			try {
				var x,xx;
			   x = this.getVal();
				if( this.neg ) { x *= -1; }
				this.d = (((x - this.to) / this.speed) + this.d) / 1.8;
				xx = Math.ceil(x - this.d);
				if( Math.abs(this.d)+Math.abs(x-this.to) < 3 ) { xx = this.to; clearInterval(this.t); this.t=null; }
		 		if( xx < 0 && !this.negOK ) { xx *= -1; this.neg = true; } else { this.neg = false; }
				this.setVal(xx);
				if( this.t === null && this.cb ) return this.cb();
			} catch(e) { clearInterval(this.t); err(e,'Tween'); }	
		};
		o.prototype.start = function(xyz) {
			this.clear.call(this);	
			this.d = 3;
			if( typeof ele == 'string' ) ele = $(ele);
			if( !this.ele ) return;
			this.to = parseInt(xyz);
			var ele = this.ele;
			if( this.p == 'scrollTop' ) {
				this.getVal = function() { return ele.scrollTop; };
				this.setVal = function(n) { ele.scrollTop = n; };
			} else {
				this.getVal = function() { return parseInt(ele.style[this.p]); };
				this.setVal = function(n) { ele.style[this.p] = n + 'px'; };			
				if( this.p == 'height' ) 	this.ele.style.height= this.ele.offsetHeight + 'px';
				else if( this.p == 'width' ) 	this.ele.style.width = this.ele.offsetWidth + 'px';	
			}
			var me = this;
			this.t = setInterval(function() { me.run.call(me); },50);
		};
		return new o(ele,p); }
})();
//
// AJAX PROTOTYPE

var HTTP = {ajax:null,busy:false,cb:null,cb2:null,ele:null,
cleanup:
			function() {	HTTP.cb = null; HTTP.cb2 = null; HTTP.ele = null; },
init:
			function() {
				if (window.XMLHttpRequest) { return new XMLHttpRequest(); }
				else if (window.ActiveXObject) { 
					var a = ['Msxml2.XMLHTTP','Microsoft.XMLHTTP','Msxml2.XMLHTTP.5.0',	'Msxml2.XMLHTTP.4.0','Msxml2.XMLHTTP.3.0'];
					for(var i = 0 ; i < 5 ; i++) {	try{ return new ActiveXObject(a[i]); } catch(e) { } }
				}
			  return false;	
			},
onrsc :
		function() {
			try {
					if( this.ajax === null ) return false;
					if (this.ajax.readyState != 4) { return true; }
					var r = true;
					if( this.cb !== null ) { r = this.cb.call(this.ele,this.ajax.responseText); } 
					if( this.ele !== null && r !== false) { this.ele.innerHTML = this.ajax.responseText; }
					if( this.cb2 !== null ) this.cb2.call(this.ele);
					this.cleanup.call(this);
				} catch(e) { this.busy = false; err(e,'ajax'); return false; }
				this.busy = false;
				return true;
		},
encode :
			function(o) {
				 if( typeof o != 'object' ) return '';
				 if( typeof o._r != 'undefined' ) { o._r = Math.random(); }
				 var a=[],enc = encodeURIComponent||escape;
				 for( var p in o ) { if( o[p] !== null ) { a.push(p+'='+enc(o[p])); } }
				 return a.join('&');
			},
Go :
		function( url, cb, ele, override ) {
			if( this.busy ) { 
				if( override ) { try { this.ajax.abort();  } catch(e) {} this.busy = false;  this.ajax = null; }
				else { return false; }
			}
			this.busy = true;
			this.cleanup();
			if( this.ajax === null ) { this.ajax = this.init();  if ( this.ajax === null ) { return err('ajax init'); } }
			if( url instanceof Array ) {
				url = url[0] + (url[0].indexOf('?') == -1 ? '?' : '') + this.encode(url[1]);
			}
			if( url.charAt(0) != '/'  ) { 
				if( url.indexOf('.dv8') != -1) { url = '/e/ajax/' + url; }
				else if( url.indexOf('.php') != -1) { url = '/w/' + url; }
			}
			if( typeof ele == 'function' ) {
				this.cb2 = ele; ele = cb;
			} else {
				this.cb = cb;
			}
			if(typeof this.cb != 'function' ) this.cb = null;
			if( ele === null || typeof ele == 'undefined' ) this.ele = null;
			else if( typeof(ele) == 'string' ) this.ele = $(ele);
			else this.ele = ele;
			this.ajax.open('GET', url, true);
			this.ajax.onreadystatechange = function() { HTTP.onrsc.apply(HTTP,arguments); };
			this.ajax.send(null);
		},
Get : function() { HTTP.Go.apply(HTTP,arguments); } };
