var NOWjax = {};
NOWjax.xhr; 

/* -----------------------------
	Request
----------------------------- */
NOWjax.request = (function(){
			
	/** REQUEST SETUP **/
	var ie_try = ['MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP'];
		
	if(typeof window.XMLHttpRequest === 'function' || typeof window.XMLHttpRequest === 'object'){		
		NOWjax.xhr = new XMLHttpRequest();
	} else {
		for(var i = 0, l = ie_try.length; i < l; i++){
			try {
				NOWjax.xhr = new ActiveXObject(ie_try[i]);
				break;
			} catch(e){}
		}
	}
	
	/** REQUEST FUNCTION **/
	return function(url, callback){
		try {
			NOWjax.xhr.onreadystatechange = (function(myxhr){
				return function(){
					callback(myxhr);
				}
			})(NOWjax.xhr);
							
			NOWjax.xhr.open('GET', url, true);
			NOWjax.xhr.send('');			
		} catch(e){}
	}
			
})()

/* -----------------------------
	Set domain
----------------------------- */
NOWjax.setdomain = function(domain){
	
	try {		
		document.domain = domain;
	} catch(e){}
			
}

/* -----------------------------
	Empty
----------------------------- */
NOWjax.empty = function(id){
	while(document.getElementById(id).firstChild){
		document.getElementById(id).removeChild(document.getElementById(id).firstChild);
	}
}

/* -----------------------------
	Maxchar
----------------------------- */
NOWjax.maxlength = function(string, length){
	if(length < string.length){
		string = string.slice(0, length);
		if(string.lastIndexOf(' ') != -1){
			string = string.slice(0, string.lastIndexOf(' '));
		}
	}
	return string;
}
