var classPath = 'javascript/';
var tabFilePath = new Array();

var importClass = function (path) {
	if (path == undefined) {
		alert('Path not defined.');
		return null;
	}
	
	var classPathUrl = path.split('.').join('/');
	var filePath = classPath + classPathUrl + '.js';
	
	if (checkImportClass(filePath)) {
		tabFilePath.push(filePath);
	}
	else {
		return null;
	}
	
	var xmlHttpRequest = getXMLHttpRequest();

	xmlHttpRequest.open("GET", filePath, false);

	try{xmlHttpRequest.send(null);}
	catch(error) {
		alert(filePath + ' not found.');
		return null;
	}
	
	var output  = '\n';
	output += '<script type="text/javascript">';
	output += '<!--\n';
	output += xmlHttpRequest.responseText;
	output += '\n-->';
	output += '</script>';
	
	document.write(output);

	return true;
}

var checkImportClass = function (path) {
	var tabFilePathLength = tabFilePath.length;
	
	for (var i = 0 ; i < tabFilePathLength ; i++) {
		if (tabFilePath[i] == path) {
			return false;
		}
	}
	
	return true;
}

var setClassPath = function (path) {
	if (path.charAt(-1) != '/') {
		classPath = path + '/';
	}
	else {
		classPath = '/';
	}
}

var getXMLHttpRequest = function() {
		if (typeof XMLHttpRequest != 'undefined') {
			return new XMLHttpRequest();
		}
		else if (typeof ActiveXObject != 'undefined') {
			return new ActiveXObject("Microsoft.XMLHTTP");
		}
}