/*
$Id: ajaxnukeboot.js,v 1.1 2006/01/26 01:02:32 rafael Exp $
*/

function AjaxNukeBoot(){
	this.browser = this.getBrowserName();
	this.version = "1.0";
	this.path = "common/ajaxnuke/"
}
AjaxNukeBoot.prototype.getBrowserName = function (){
	var detect = navigator.userAgent.toLowerCase();
	var OS,browser,version,total,thestring;
	function checkIt(string)
	{
		place = detect.indexOf(string) + 1;
		thestring = string;
		return place;
	}
	if (checkIt('konqueror'))
	{
		browser = "Konqueror";
		OS = "Linux";
	}
	else if (checkIt('safari')) browser = "Safari"
	else if (checkIt('omniweb')) browser = "OmniWeb"
	else if (checkIt('opera')) browser = "Opera"
	else if (checkIt('webtv')) browser = "WebTV";
	else if (checkIt('icab')) browser = "iCab"
	else if (checkIt('msie')) browser = "Internet Explorer"
	else if (!checkIt('compatible'))
	{
		browser = "Netscape Navigator"
		thestring = 'mozilla';
		version = detect.charAt(8);
	}
	else browser = "An unknown browser";
	
	if (!version) version = detect.charAt(place + thestring.length);
	return thestring;
}
AjaxNukeBoot.prototype.getAjaxNukeAPI = function (){
	var apiFile = "ajaxnuke.";
	switch(this.browser){
		case 'msie' :
		apiFile += 'ie';
		break;
		default:
		apiFile += 'mz';
		break;
	}
	apiFile += '_' + this.version + '.js';
	this.loadJsFile(this.path + apiFile);
	this.loadJsFile(this.path + 'ajaxnukeengine.js');
	this.loadJsFile(this.path + 'ajaxnukeclasses.js');
	
}
AjaxNukeBoot.prototype.loadJsFile = function(path){
	if(!path){
		return;
	}
	var api = document.createElement('script');
	api.setAttribute('src', path);
	var head = document.getElementsByTagName('head').item(0);
	head.appendChild(api);
}
AjaxNukeBoot.prototype.startBoot = function (){
	this.getAjaxNukeAPI();
}
//start ajaxnuke engine
var anboot = new AjaxNukeBoot();
anboot.startBoot();