var pathWebJS = '/js';

var spj_pathInclude = '/js';
var spj_dirNameImpoer = 'spj';

//spj = new Object();

spjClass = function()
{
	this.pathInclude = '/js';
	this.dirNameImport = 'spj';
	this.packagesImported = new Array();
	
	this.init();
}

spjClass.prototype.init = function()
{
	this._setNavigator();
	this._setOS();
	
}

spjClass.prototype._setNavigator = function()
{
	this.navigator = this.navigator || {
		
		userAgent   : null,
		isKHTML     : null,
		isSafari    : null,
		isKonqueror : null,
		isOpera     : null,
		isIE        : null,
		isMozilla   : null,
		
		init : function()
		{
			this.userAgent = navigator.userAgent;
			
			this.isKHTML = this.userAgent.indexOf("KHTML") > -1 
					|| this.userAgent.indexOf("Konqueror") > -1
					|| this.userAgent.indexOf("AppleWebKit") > -1;
					
			if(this.isKHTML){
				this.isSafari = this.userAgent.indexOf("AppleWebKit") > -1;
				this.isKonqueror = this.userAgent.indexOf("Konqueror") > -1;
			}
			else{
				this.isSafari = false;
				this.isKonqueror = false;
			}
							
			
			this.isOpera = this.userAgent.indexOf("Opera") > -1;
			this.isIE = this.userAgent.indexOf("compatible") > -1
						&& this.userAgent.indexOf("MSIE") > -1
						&& !this.isOpera;
			
			this.isMozilla = this.userAgent.indexOf("Gecko") > -1
							 && !this.isKHTML;	
		}
		
	}
	this.navigator.init();
					 
					 
}

spjClass.prototype._setOS = function()
{
	this.os = this.os ||  {
		
		isWin  : null,
		isMac  : null,
		isUnix : null,
		
		init : function()
		{
			this.isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows");
			this.isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC")
						  || (navigator.platform == "Macintosh");
			this.isUnix = (navigator.platform == "X11") && !this.isWin && !this.isMac;
		}
			
	}
	this.os.init();	
		
}



/*
spjClass.prototype.include = function(fileName)
{
	var html_doc = document.getElementsByTagName('head').item(0);
    var js = document.createElement('script');
    var includePath = this.pathInclude + "/" +fileName;
    //alert('including path: '+includePath);
    //js.setAttribute('language', 'javascript');
    js.setAttribute('type', 'text/javascript');
    js.setAttribute('src', includePath);
    html_doc.appendChild(js);
    return false;
}
*/
spjClass.prototype.include = function(fileName)
{
	var includePath = this.pathInclude + "/" +fileName;
	document.write('<' + 'script');
    //document.write(' language="javascript"');
    document.write(' type="text/javascript"');
    document.write(' src="' + includePath + '">');
    document.write('</' + 'script' + '>');
}

spjClass.prototype.includeInternal = function(dirPackage,fileName)
{
	var path = this.dirNameImport + "/" + dirPackage + "/" + fileName;
	//alert('path internal to include: '+path);
	this.include(path);
}


spjClass.prototype.register = function(packageName)
{
	var pathToInclude = this.dirNameImport + "/" + packageName + "/" + "init.js";
	//alert('registering: '+pathToInclude);
	this.include(pathToInclude);
}

spjClass.prototype.getClientBrowser = function()
{
	//returns 1 for Netscape, 2 for ie
	if (parseInt(navigator.appVersion)>3) {
	 if (navigator.appName=="Netscape") {
	  	return 1;  
	 }
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	 	return 2;
	 }
	}
	
}

spjClass.prototype.clone = function(obj)
{
	if( typeof(obj) != 'object'){
		return obj;
	}
	if(obj == null) {
		return obj;
	}

	var clonedObj = new Object();

	for(var i in obj){
		clonedObj[i] = this.clone(obj[i]);
	}
		

	return clonedObj;
	
}





var spj = new spjClass();

spj.register('core');
//alert('EEEEE');