var apAJAX={};apAJAX.getXmlHttp=function(){var xmlHttp=null;try{xmlHttp=new XMLHttpRequest()}catch(e){var progIds=['MSXML2.XMLHTTP','Microsoft.XMLHTTP','MSXML2.XMLHTTP.5.0','MSXML2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0'];var success=false;for(var iterator=0;(iterator<progIds.length)&&(!success);iterator++){try{xmlHttp=new ActiveXObject(progIds[iterator]);success=true}catch(e){}}if(!success){return null}}return xmlHttp};apAJAX.serialize=function(data){if(data==null){return'N;'}var type=typeof(data);var code='';var iterator=0;var length=null;var asciiCode=null;var key=null;if(type=='boolean'){code+='b:'+(data?1:0)+';'}else if(type=='number'){if(Math.round(data)==data){code+='i:'+data+';'}else{code+='d:'+data+';'}}else if(type=='string'){length=data.length;for(iterator=0;iterator<data.length;iterator++){asciiCode=data.charCodeAt(iterator);if((asciiCode>=0x00000080)&&(asciiCode<=0x000007FF)){length+=1}else if((asciiCode>=0x00000800)&&(asciiCode<=0x0000FFFF)){length+=2}else if((asciiCode>=0x00010000)&&(asciiCode<=0x001FFFFF)){length+=3}else if((asciiCode>=0x00200000)&&(asciiCode<=0x03FFFFFF)){length+=4}else if((asciiCode>=0x04000000)&&(asciiCode<=0x7FFFFFFF)){length+=5}}code+='s:'+length+':"'+data+'";'}else if(type=='object'){if(typeof(data.__class)=='undefined'){length=0;if((typeof(data.length)=='number')&&(data.length>0)&&(typeof(data[0])!='undefined')){for(iterator=0;iterator<data.length;iterator++){if(typeof(data[iterator])!='function'){code+=apAJAX.serialize(iterator);code+=apAJAX.serialize(data[iterator]);length++}}}else{for(key in data){if(typeof(data[key])!='function'){if(/^[0-9]+$/.test(key)){code+=apAJAX.serialize(parseInt(key))}else{code+=apAJAX.serialize(key)}code+=apAJAX.serialize(data[key]);length++}}}code='a:'+length+':{'+code+'}'}else{code+='O:'+data.__class.length+':"'+data.__class+'":'+data.__size+':{';if(data.__meta!=null){for(key in data.__meta){if(typeof(data[key])!='function'){code+=apAJAX.serialize(key);code+=apAJAX.serialize(data[key])}}}code+='}'}}else{code='N;'}return code};apAJAX.sendDataAsync=false;apAJAX.setAsync=function(tf){tf=tf||true;this.sendDataAsync=tf};apAJAX.sendData=function(w,d,b,u,a){var link=(typeof(u)=='string'&&u!='')?u:location.href;show=(a==1)?1:0;__xml=apAJAX.getXmlHttp();__xml.open("POST",link,this.sendDataAsync);__xml.setRequestHeader('Content-Type','APCMS/AJAX');data=apAJAX.serialize({opcode:w,block:b,data:d});__xml.send(data);if((__xml.responseText.indexOf('<b>Parse error</b>:')!=-1)||(__xml.responseText.indexOf('<b>Fatal error</b>:')!=-1)||(__xml.responseText.indexOf('<b>Warning</b>:')!=-1)||(__xml.responseText.indexOf('escdbsqlerror')!=-1)){alert("<B>ERROR IN CMS ENGINE:</b><br><br>"+__xml.responseText);return null}if(show){alert(__xml.responseText)}if(__xml.responseText!=''){try{eval('var $$$= '+__xml.responseText+';')}catch(e){var $$$=''}return $$$}};apAJAX.apRAND=function(min,max){if(min==null)min=10000;if(max==null)max=32767;return Math.floor(Math.random()*(max-min))+min};
