/***************************************************************************
Global Javascript 
-------------------------------------
Developed By Cory Caines
**************************************************************************/

/*Dom Functions */
var k9 = {};

k9.dom = {
	$w:function(){
		return window;
	}(),
	$d:function(){
		return window.document;
	}(),
	getEl:function(id){
		return this.$d.getElementById(id);	
	},
	tag:function(domTag){
		return this.$d.getElementsByTagName(domTag);
	},
	echo:function(txt){
		this.$d.write(txt);
	},
	jump:function(loc){
		this.$d.location.hash = loc;
	},
	mail:function(to,at){
		window.location = "mailto:"+to+"@"+at;
	}
}
var $ = k9.dom.getEl;
var $w = k9.dom.$w;
var $d = k9.dom.$d;
var tag = k9.dom.tag;
var echo = k9.dom.echo;
k9.util = {
	msg:function(txt){
		window.alert(txt);
	},
	popup:function(url,name,width,height){
		var posX = (screen.width - width) / 2;
		var posY = (screen.height - height) / 2;
		params = 'height='+height+',width='+width+',top='+posY+',left='+posX+',scrollbars=yes,status=0,resizable=1';
		var win =  window.open(url, name, params);
		win.focus();
	},
	browser:function(){
		this.IE    = false;
		this.NS    = false
		agent = navigator.userAgent;
		if ((i = agent.indexOf("MSIE")) >= 0) {
			this.IE = true;
			return;
		}
		if ((i = agent.indexOf("Gecko")) >= 0) {
			this.NS = true;
			return;
		}
		if ((i = agent.indexOf("Netscape6/")) >= 0) {
			this.NS = true;
			return;
		}	
	}
}
var msg = k9.util.msg;
k9.events = function(){
	var loadManager=[];
	return {
		addListener:function(obj,type,fn,capture){
			if(type == "pageLoaded"){
				this.addLoad(obj,"load",fn,capture);
				return;
			}
			this.addBasicListener(obj,type,fn,capture);
		},
		addLoad:function(obj,type,fn,capture){
			if(loadManager.length == 0){
				this.addBasicListener(obj,type,this.loadQue,capture);
			}
			loadManager.push(fn);
			
		},
		loadQue:function(){
			for(i=0;i<=loadManager.length-1;i++){
				var fn = loadManager[i];
				fn.call();
			}
		},
		addBasicListener:function(obj,type,fn,capture){
			if(window.addEventListener){
				obj.addEventListener(type, fn, capture);
			}else{
				obj.attachEvent("on"+type, fn);
			}
		}
	}
}();
