var aLibraries = new Array();

Array.prototype.indexOf=function(obj){
	for(i=0;i<this.length;i++){
		if(this[i]==obj){
			return i;
		}
	}
	return -1;
}

Array.prototype.contains=function(obj){
	return this.indexOf(obj)!=-1;
}

/*function $include(libraryName) {
	if(aLibraries.contains(libraryName)){
		return;
	}
	aLibraries.push(libraryName)
	var scr = document.createElement("script");
	scr.src=libraryName+".js";
	document.body.appendChild(scr);
}*/

function $include(libraryName) {
	if(aLibraries.contains(libraryName)){
		return;
	}
	aLibraries.push(libraryName)
	var scr = document.createElement("script");
	scr.id=libraryName+"_js";
	scr.src=libraryName+".js";
	document.body.appendChild(scr);
}

function notifyLoad(name){
	//try{
		eval(name+"Load();");
	//}catch(e){}
}

function Is ()
{   
	// convert all characters to lowercase to simplify testing
	var agt=navigator.userAgent.toLowerCase();

	// *** BROWSER VERSION ***
	// Note: On IE5, these return 4, so use is.ie5up to detect IE5.

	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);

	this.ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	this.ie3    = (this.ie && (this.major < 4));
	this.ie4    = (this.ie && (this.major == 4) && (agt.indexOf("msie 4")!=-1) );
	this.ie4up  = (this.ie  && (this.major >= 4));
	this.ie5    = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")!=-1) );
	this.ie5_5  = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.5") !=-1));
	this.ie5up  = (this.ie  && !this.ie3 && !this.ie4);
	this.ie5_5up =(this.ie && !this.ie3 && !this.ie4 && !this.ie5);
	this.ie6    = (this.ie && (this.major == 4) && (agt.indexOf("msie 6.")!=-1) );
	this.ie6up  = (this.ie  && !this.ie3 && !this.ie4 && !this.ie5 && !this.ie5_5);
}

var is = new Is();

loadScript = function(url){
	
	myxmlhttp=null;
	if (window.XMLHttpRequest){
		myxmlhttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject){
		myxmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (myxmlhttp!=null){	
		myxmlhttp.open("GET",url,false);
		myxmlhttp.send();
		if(myxmlhttp.status==200){
			return myxmlhttp.responseText;
		}
	}
	return null;
}

String.prototype.trim=function(chars) {
    return this.ltrim(chars).rtrim(chars);
}

String.prototype.ltrim=function(chars) {
    chars = chars || "\\s";
    return this.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

String.prototype.rtrim=function(chars) {
    chars = chars || "\\s";
    return this.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
