
function getAjaxObject(){if(typeof XMLHttpRequest=="undefined"){request=new ActiveXObject(navigator.userAgent.indexOf("MSIE 5")>=0?"Microsoft.XMLHTTP":"Msxml2.XMLHTTP");}
else{request=new XMLHttpRequest();}
return request;}
var Ajax=function(callback){var request=null;var callback=(typeof callback=="undefined")?false:callback;var _init=function(){if(request!=null){alert("Previous Ajax request isn't finished!");return false;}
if(typeof XMLHttpRequest=="undefined"){request=new ActiveXObject(navigator.userAgent.indexOf("MSIE 5")>=0?"Microsoft.XMLHTTP":"Msxml2.XMLHTTP");}
else{request=new XMLHttpRequest();}
return true;};var _httpSuccess=function(){try{return!request.status&&location.protocol=="file:"||(request.status>=200&&request.status<300)||request.status==304||navigator.userAgent.indexOf("Safari")>=0&&typeof request.status=="undefined";}
catch(e){};return false;};var _getHttpData=function(typ){var ct=request.getResponseHeader("Content-Type");var data=!typ&&ct&&ct.indexOf("xml")>=0;data=typ=="xml"||data?request.responseXML:request.responseText;if(typ=="script"){eval.call(window,data);}
else if(typ=='json'){data=eval('('+data+')');}
return data;};var _onReadyStateChange=function(){if(request.readyState==4){if(_httpSuccess()){if(callback!==false&&typeof callback.onSuccess!="undefined"){callback.onSuccess(_getHttpData());}}
else{if(callback!==false&&typeof callback.onError!="undefined")callback.onError();else alert("Error on Ajax request!");}
request=null;}};var _open=function(method,url){request.open(method,url,true);request.onreadystatechange=_onReadyStateChange;if(method.toLowerCase()=="post"){request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");}
if(request.overrideMimeType){request.setRequestHeader("Connection","close");}};var _send=function(data){if(typeof data=="undefined"||data==null)request.send(null);else request.send(_serializeData(data));};var _serializeData=function(data){var s=[];if(data.constructor==Array){for(var j in data){if(data[j].prototype)continue;s.push(j+"="+encodeURIComponent(data[j]));}}
else{for(var i=0;i<data.length;i++){if(data[i].type=="radio"&&data[i].checked)s.push(data[i].name+"="+encodeURIComponent(data[i].value));else if(data[i].type=="radio"&&!data[i].checked)continue;else if(data[i].type=="checkbox"&&!data[i].checked)continue;else s.push(data[i].name+"="+encodeURIComponent(data[i].value));}}
return s.join("&");};this.connect=function(url){if(_init()){_open("GET",url,true);_send(null);}};this.connectForm=function(form,url){if(_init()){_open("POST",url,true);_send(form);}};this.connectData=function(data,url){if(_init()){_open("POST",url,true);_send(data);}};}