function getHTTPObject() {
	var xmlHttp=null;
	try{
 		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}catch (e){
		try{ xmlHttp=ActiveXObject("Msxml2.XMLHTTP.6.0") }catch(e){}
		try{ xmlHttp=ActiveXObject("Msxml2.XMLHTTP.3.0") }catch(e){}
		try{ xmlHttp=ActiveXObject("Msxml2.XMLHTTP") }catch(e){}
		try{ xmlHttp=ActiveXObject("Microsoft.XMLHTTP") }catch(e){}
	}
	
	return xmlHttp;
}
function onProgress(e) {
	var percentComplete = (e.position / e.totalSize)*100;
}

function updateContent(response) {
	//alert(response);
	if (response == "" || response == null) {
		if(g_ajax_obj._dm_xmlhttprequestobject.readyState == 4) {
			if(g_ajax_obj._dm_xmlhttprequestobject.responseText) {
				if (g_ajax_obj._dm_xmlhttprequestobject.status == 200) {
					var jsonObject = eval('('+g_ajax_obj._dm_xmlhttprequestobject.responseText+')'); //convert string to JSON object
				}
			}
		}
	} else {
		var jsonObject = eval('('+response+')');
	}
	
	if (jsonObject) {
		if (jsonObject.ajax.dom) {
			var json_dom=jsonObject.ajax.dom;
			for (var i=0;i<json_dom.length;i++){
				value = json_dom[i].value;
				if (document.getElementById(json_dom[i].element)) {
					value = value.replace(/"/g,'\"');
					eval("document.getElementById('"+json_dom[i].element+"')."+json_dom[i].property+" = \""+unescape(value)+"\";");
				}
			}
			//need to update all heading tags again
			//eval("sIFR.replaceElement('h1', named({sFlashSrc: '/admin/fonts/vagrounded.swf', sColor: '#98bf0c', sCase: 'lower'}))");
			//eval("sIFR.replaceElement('h2', named({sFlashSrc: '/admin/fonts/vagrounded.swf', sColor: '#98bf0c', sCase: 'lower'}))");
		}
		
		if(jsonObject.ajax.jsalert) {
			var json_jsalert = jsonObject.ajax.jsalert;
			for (var i=0;i<json_jsalert.length;i++){
				alert(json_jsalert[i].message);
			}
		}
		
		if (jsonObject.ajax.functions) {
			var json_functions = jsonObject.ajax.functions;
			for (var i=0;i<json_functions.length;i++) {
				//eval(json_functions[i].method+"()");
				eval("var ajaxfunction = "+json_functions[i].method+";");
			}
		}
		
		if (jsonObject.ajax.variables) {
			var json_variables = jsonObject.ajax.variables;
			for (var i=0;i<json_variables.length;i++) {
				eval(json_variables[i].variable+" = '"+json_variables[i].value+"';");	
			}
		}
	}
}

function ajax_visit_log(object,objectid) {
	var url = document.location.href;
	new Ajax('/ajax/add_visit.php?url='+url+'&object='+object+'&objectid='+objectid, { method:'get'}).request();
	return false;
}

AIM = {

	frame : function(c) {

		var n = 'f' + Math.floor(Math.random() * 99999);
		var d = document.createElement('DIV');
		d.innerHTML = '<iframe style="display:none" src="about:blank" id="'+n+'" name="'+n+'" onload="AIM.loaded(\''+n+'\')"></iframe>';
		document.body.appendChild(d);

		var i = document.getElementById(n);
		if (c && typeof(c.onComplete) == 'function') {
			i.onComplete = c.onComplete;
		}

		return n;
	},

	form : function(f, name) {
		f.setAttribute('target', name);
	},

	submit : function(f, c) {
		AIM.form(f, AIM.frame(c));
		if (c && typeof(c.onStart) == 'function') {
			return c.onStart();
		} else {
			return true;
		}
	},

	loaded : function(id) {
		var i = document.getElementById(id);
		if (i.contentDocument) {
			var d = i.contentDocument;
		} else if (i.contentWindow) {
			var d = i.contentWindow.document;
		} else {
			var d = window.frames[id].document;
		}
		if (d.location.href == "about:blank") {
			return;
		}
		
		if (typeof(i.onComplete) == 'function') {
			i.onComplete(d.body.innerHTML);
		}
	}

}