/* neoarchaic.Core

*/


//Define the namespace
var neoarchaic;
if (neoarchaic == undefined){
	neoarchaic = {};
}
neoarchaic.setProp = function(propName, prop){
	neoarchaic[propName] = prop;
}
neoarchaic.getProp = function(propName){
	return neoarchaic[propName];
}

//Define the ObjectSwap class constructor and prototype functions
neoarchaic.Core = function(){
	//alert ("core")
}


neoarchaic.Core.prototype = {
	className: "Core",
	
	//Add window load events to the ObjectSwap prototype
	//The init function will be called multiple times, but only executed once 
	addLoadEvents: function(){
		if (document.addEventListener){
			//Firefox and other browsers that support addEventListener/DOMContentLoaded
			this.addEvent(document, "DOMContentLoaded", "init");
		}else{
			//IE - supports readystatechange event
			this.addEvent(document, "readystatechange", "init");
		}
		//Catch-all for browsers that don't support either
		this.addEvent(window, "load", "init");
	},
	//Register an event with a listener. Default listner is the current object
	//Event will be registered depending on browser capabilities
	addEvent: function(obj, evType, fn, listener){ 
		 //Assign this as default listener
		 if (listener == undefined){
			listener = this;
		 }
		 //Create a function that will execute the event in the scope of this object
		 //Pass a custom event object including target and type will be passed to the function 
		 var e = {target: obj, type:evType}
		 this["handle"+fn] = function(){
			 listener[fn](e); 
		 }	 
		  var handlefn = this["handle"+fn]
		 if (obj.addEventListener){
		   //Firefox, Safari, Opera, etc.
		   obj.addEventListener(evType, handlefn, false); 
		   return true; 
		 } else if (obj.attachEvent){
		   //IE
		   var r = obj.attachEvent("on"+evType, handlefn); 
		   return r; 
		 } else { 
		   return false; 
		 } 
	},
	
	init: function(){
	},
	
	getElementsByClassName: function(tagName, className, parentNode){
		// Fetch all the tagName elements in the document.
		if (!document.getElementsByTagName){
			return [];
		}
		if (parentNode == null){
			parentNode = document;
		}
		var elements = [];
		var tagElements = parentNode.getElementsByTagName(tagName);
		for (var i = tagElements.length; i != 0; i--) {			
			// Pull out the element for this iteration.
			var e = tagElements[i-1];
			if (e.className && e.className.indexOf(className) != -1){
				elements.push(e);
			}
		}
		return elements;
	},
	
	doLater: function (fn, t, ar1, arg2, arg3, arg4, arg5){
		var me = this;
		setTimeout(function () { me[fn](arg1, arg2, arg3)}, t);
	}
}

neoarchaic.Core.extend = function(subClass, superClass, protoObj){
	if (superClass == undefined){
		superClass = neoarchaic.Core;
	}
	subClass.prototype = new superClass();	
	neoarchaic.Core.addPrototypes(subClass, protoObj);	
}

neoarchaic.Core.addPrototypes = function (subClass, protoObj){
	for (var i in protoObj){
		subClass.prototype[i] = protoObj[i]		
	}
}

neoarchaic.Core.newObject = function(objName, className, arg1, arg2, arg3, arg4, arg5, arg6, arg7){
	if (typeof(className) == "string"){
		className = eval ("neoarchaic."+className)
	}
	var obj = new className(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
	neoarchaic[objName] = obj;
	return obj;
}




/*
registerClass: function(){
	},
	
	addObject: function(objName, class){
		var obj = new class();
		neoarchaic[objName] = obj;
		return obj;
	},
	
	extend: function(subClass, baseClass) {
	   function inheritance() {}
	   inheritance.prototype = baseClass.prototype;
	
	   subClass.prototype = new inheritance();
	   subClass.prototype.constructor = subClass;
	   subClass.baseConstructor = baseClass;
	   subClass.superClass = baseClass.prototype;
	}
*/
	
//var core = new neoarchaic.Core()

//alert (core)

















