/*
	
	Basic liteApps Javascript Prototypes
	
	(c)2006-2008 by CodeWizard Grafix LLC 
	(c)2006-2008 by Richard Campbell II
	
*/
 
var liteUI = function() {
	this.init();
}

liteUI.prototype = {
	init: function() {
		
	}
	
}


/*
	Simple AJAX Routines	(Syncronous Only Supported!)
*/
var liteAjax = function() {
	this.init();
}

liteAjax.prototype = {
	
	a: null,
		
	init: function() {
		try{
			a=new XMLHttpRequest();
		} catch(e) {
			a=new ActiveXObject("Microsoft.XMLHTTP");
		}
	},
	
	getText: function(u){
		if(a==null) this.init();
		
		if(typeof t=='undefined') t='GET';
		a.open('GET',u,false);
		a.send(null);
		return a.responseText;
	},
	
	getXML: function(u){
		if(a==null) this.init();

		if(typeof t=='undefined') t='GET';
		a.open('GET',u,false);
		a.send(null);
		return a.responseXML;
	}
};



/* 
	Simple Helper Routines
*/
var liteHelper = function() {
}

liteHelper.prototype = {

	addHandler: function(e,n,o){
		if(typeof e=='string'){
			e=this.getElement(e);
		}
		if(e.addEventListener){
			e.addEventListener(n,o,false);
		}else if(e.attachEvent){
			e.attachEvent('on'+n,o);
		}
	},
	
	centerElement: function(o) {
		if (typeof o=='string') {
			o=this.getElement(o);
		}
		var w=this.getWindowSize(),s=this.getElementSize(o);
		o.style.left=((w[0]-s[0])/2)+'px';
		o.style.top=((w[1]-s[1])/2)+'px';
	},
	
	cookieCreate: function(n,v,d) {
		if(d){
			var dt=new Date();
			dt.setTime(dt.getTime()+(d*24*60*60*1000));
			var e="; expires="+dt.toGMTString();
		}else{
			var e="";document.cookie=n+"="+v+e+"; path=/";
		}
	},
	
	cookieRead: function(n) {
		var nameEQ=n+"=",ca=document.cookie.split(';');
		for(var i=0;i<ca.length;i++){
			var c=ca[i];
			while(c.charAt(0)==' ')c=c.substring(1,c.length);
			if(c.indexOf(nameEQ)==0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	},
	
	cookieErase: function(n) {
		this.cookieCreate(n,"",-1);
	},
	
	getElement: function(n) {
		return document.getElementById?document.getElementById(n):document.all?document.all[n]:document.layers[n];
	},
		
	getElementPos: function(o) {
		if(typeof o=='string'){
			o=this.getElement(o);
		}
		var l=t=0;
		if(o.offsetParent){
			do{
				l+=o.offsetLeft;
				t+=o.offsetTop;
			}while(o=o.offsetParent);
		}
		return[l,t];
	},

	getElementsByClass: function(sc,n,t){if(n==null)n=document;if(t==null)t='*';var ce=new Array(),e=n.getElementsByTagName(t),el=e.length,p=new RegExp('(^|\\\\s)'+sc+'(\\\\s|$)');for(i=0,j=0;i<el;i++){if(p.test(e[i].className)){ce[j]=e[i];	j++;}}return ce;},

	/*
	getElementsByClass: function(searchClass, domNode, tagName) {
		if (domNode == null) domNode = document;
		if (tagName == null) tagName = '*';
		var el = new Array();
		var tags = domNode.getElementsByTagName(tagName);
		var tcl = " "+searchClass+" ";
		for(i=0,j=0; i<tags.length; i++) {
			var test = " " + tags[i].className + " ";
			if (test.indexOf(tcl) != -1)
				el[j++] = tags[i];
		}
		return el;
	},
 	*/


	getElementSize: function(o){
		if(typeof o=='string'){
			o=this.getElement(o);
		}
		return [o.offsetWidth,o.offsetHeight];
	},		

	getWindowSize: function() {
		var w=h=0;
		if(self.innerrWidth){
			w=self.innerWidth;
			h=self.innerHeight;
		}else if(document.documentElement&&document.documentElement.clientWidth){
			w=document.documentElement.clientWidth;
			h=document.documentElement.clientHeight;
		}else if(document.body){
			w=document.body.clientWidth;
			h=document.body.clientHeight;
		}
		return[w,h];
	}
	
};



