if (typeof javascriptPath == 'undefined') javascriptPath = ''; if (typeof phpPath == 'undefined') phpPath = '';UniAjax = function(ags) {
if (ags != undefined) {this.uri = ags.uri || UniAjax.uri; this.ags = ags.ags || UniAjax.argums;
this.method = ags.method || UniAjax.method; this.oncomplete = ags.oncomplete || UniAjax.oncomplete;
this.onerror = ags.onerror || UniAjax.onerror; this.nocaching = ags.nocaching || UniAjax.nocaching;
this.form = ags.form || UniAjax.form; this.rT = ags.rT || UniAjax.rT;}};
(includeJS = function(src) {
var s = document.createElement('script'); s.type = 'text/javascript'; s.src = src;
var e = document.all || document.getElementsByTagName('*'); e[e.length - 1].parentNode.appendChild(s);
var nav = navigator.userAgent.toLowerCase();  
if (nav.indexOf('opera 7') > -1) document.write('<script type="text/javascript" src="'+src+'"><\/script>');
})(javascriptPath+'httprequest1.0.js');
UniAjax.prototype = {
request: function(args) {
var u = UniAjax._getFather(this); var argsDef = args != undefined; var nocaching = argsDef ? args.nocaching || u.nocaching : u.nocaching;
var useEXHR = !UniAjax._native; var form = argsDef ? args.form || u.form : u.form;
if (typeof form == 'string') form = document.getElementById(form);
if (form && Serializer.hasUploads(form)) useEXHR = true; var uri_ = (form ? form.action : '') || u.uri; var uri = argsDef ? args.uri || uri_ : uri_;
var i = document.createElement('img'); i.src = uri; var a = document.createElement('a'); a.href = i.src;
var crossDomain = window.location.hostname != a.hostname; 
if (crossDomain) { uri = phpPath+'request.php?url='+encodeURIComponent(uri); if (useEXHR) uri += '&html=1'; }
delete i, a; var argums = u instanceof UniAjax ? u.ags : u.argums;
if (argsDef)
if (args.ags != undefined) { for (var name in args.ags) argums[name] = args.ags[name]; }
var query = Serializer.objectToQueryString(argums);
if (nocaching) { if (query.length > 0) query += '&'; query += (new Date()).getTime(); }
if (!useEXHR) {
if (form) { if (query.length > 0)  query += '&'; if (form) query += Serializer.formToQueryString(form); }
if (method == 'GET') { uri += (uri.indexOf('?') > -1) ? '&' : '?'; uri += query; }}
var method_ = (form ? form.method : '') || u.method; var method = (argsDef ? args.method || method_ : method_).toUpperCase();
if (/*Iframe?*/!useEXHR && method != 'GET' && method != 'POST' || method != 'GET' && method != 'POST' && method != 'PUT')method = 'POST';
var oncomplete_ = u.oncomplete || UniAjax._emptyFunction; var oncomplete = argsDef ? args.oncomplete || oncomplete_ : oncomplete_;
var onerror_ = u.onerror || UniAjax._emptyFunction; var onerror = argsDef ? args.onerror || onerror_ : onerror_;
var rT = (argsDef ? args.rT || u.rT : u.rT).toLowerCase();if (rT != 'string' && rT != 'json' && rT != 'xml') rT = 'json';
var Request = HttpRequest(useEXHR);
if (Request) {var argus = ags;Request.onreadystatechange = function() {
if (Request.readyState == 4) {var response;if (rT == 'json') try { eval('response = '+Request.responseText); } catch(e) { response = null; }
else if (rT == 'xml') response = Request.responseXML;else response = Request.responseText;var e;
if (Request.status == 404) { e = 'onerror('; for (var i = 1; i < argus.length; i++) e += 'argus['+i+']'; e += ')'; }
else { e = 'oncomplete(response'; for (var i = 1; i < argus.length; i++) e += ', argus['+i+']'; e += ')'; }eval(e);}};
if (!useEXHR) {Request.open(method, uri, true);if (method == 'POST') Request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');Request.send((method == 'GET') ? null : query);}
else { Request.open(method, uri); Request.send(query, form); }
return Request;}
return null;}};
UniAjax.uri = ''; UniAjax.argums = {}; UniAjax.method = 'get';
UniAjax.oncomplete = UniAjax._emptyFunction; UniAjax.onerror = UniAjax._emptyFunction;
UniAjax.nocaching = true; UniAjax.form = null; UniAjax.rT = 'json';
UniAjax._getFather = function(object) { return (object instanceof UniAjax) ? object : UniAjax; };
UniAjax._emptyFunction = function() {}; UniAjax.request = UniAjax.prototype.request;
