function clsHTMLRPC(p_sModule) {
	
	this.m_sRequestUri = "/index.php?mod=" + p_sModule.toString() + "&com=doAjaxRequest&";
	this.m_sPlaceHolder = '';
	this.m_sLoadingPopup = '';
	this.m_aPostParams	= [];
	
	this.setLoadingPopup = function(p_sElemId) {
		if (typeof(p_sElemId) == 'string') {
			this.m_sLoadingPopup = p_sElemId;
		}
	}

	this.query = function (p_sRequest, p_sAdditionalParams, p_sPlaceHolder, p_bReturnConn) {
		var oHTTP = new clsHTTPRequest();
		var sUrl = this.m_sRequestUri;
		
		sUrl += "request=" + p_sRequest;
		if (p_sAdditionalParams != '') {
			sUrl +=  "&" + p_sAdditionalParams;
		}
		oHTTP.setRequestURI(sUrl);
		//document.getElementById(this.m_sPlaceHolder).innerHTML = "<img src=\"/templates/admincp/default/images/ajax-loader.gif\" /> Loading...";	;			
		this.showLoadingWindow();
		oHTTP.setHTML();
		
		if (typeof(p_sPlaceHolder) != 'undefined' && p_sPlaceHolder != '') {
			return oHTTP.getHTML(p_sPlaceHolder, p_bReturnConn);
			//this.setPlaceHolder(p_sPlaceHolder);
		} else {
			return oHTTP.getHTML(this.m_sPlaceHolder, p_bReturnConn);
		}
		//oAnim = new clsAnimate();
		//oAnim.scrollVertical(document.getElementById(this.m_sPlaceHolder), 0, 500, 3000, true);
		
	}
	
	this.closePopup = function() {
		var oPopup = $('xmlrpc_popup');
		if (typeof(oPopup) != 'undefined') {
			this._DOMRemoveChilds(oPopup);
		}
	}
	
	this.queryPopup = function(p_sRequest, p_aAdditionalParams, p_sPlaceHolder) {
		//create div
		var oDiv  = document.createElement("div");
		oDiv.id = "xmlrpc_popup";
		oDiv.className = "ajax_popup";
		document.getElementById('popup_attachment').appendChild(oDiv);
		//close button
		var oClose = document.createElement("A");
		var self= this;
		oClose.innerHTML = "X";
		oClose.href = "javascript:void(0);";
		oClose.onclick = function () {
			self._DOMRemoveChilds(oDiv);
		} 
		oDiv.appendChild(oClose);
		
		
		
		//placeholder div
		var oDivPlaceHolder = document.createElement('div');
		oDivPlaceHolder = oDiv.appendChild(oDivPlaceHolder);
		oDivPlaceHolder.className = 'mainAreaAjaxPopUp';
		oDivPlaceHolder.id = oDiv.id + "_placeholder";
		
		
		//position window
		var aSize = this.getWindowSize(); 
		var aPos = [0,0];
		
		
		aPos[0] = ((aSize[0]/2)-(oDiv.offsetWidth/2)) + "px";
	
		oDiv.style.left = aPos[0];
		
		this.query(p_sRequest, p_aAdditionalParams, oDivPlaceHolder.id, false);
		
		//apply effect
		//var oEffect = new clsEffect();
		//oEffect.FadeIn	(oDiv.id);
	}
	
	
	this.setRequestUri = function (p_sString) {
		this.m_sRequestUri = p_sString
	}
	
	this.setPlaceHolder = function(p_sPlaceHolder) {
		if (document.getElementById(p_sPlaceHolder)) {
			this.m_sPlaceHolder = p_sPlaceHolder;	
		} else {
			alert('invalid placeholder ' + p_sPlaceHolder);
		}
	}
	
	this.postForm  = function (p_oForm, p_sRequest, p_sAdditionalParams, p_sPlaceHolder) {
		if (typeof(p_oForm) == 'object') {
			p_oForm=p_oForm.name;
		}
		poststr = 'x=x';
		strcheck='';
		
		
		var oHTTP = new clsHTTPRequest();
		var sUrl = this.m_sRequestUri;
		sUrl += "request=" + p_sRequest;
		if (p_sAdditionalParams != '') {
			sUrl +=  "&" + p_sAdditionalParams;
		}
		oHTTP.setRequestURI(sUrl);
		oHTTP.setJavascript();
		oHTTP.addParam('POST', 'true');
		for (i=0; i< document.forms[p_oForm].elements.length; i++)
		{
			switch(document.forms[p_oForm].elements[i].type)
			{
				case 'button':
				break;

				case 'checkbox':
					if(document.forms[p_oForm].elements[i].checked==true)
					{
						
						oHTTP.addParam(document.forms[p_oForm].elements[i].name, encodeURIComponent(document.forms[p_oForm].elements[i].value));
						poststr=poststr+'&'+document.forms[p_oForm].elements[i].name+'='+encodeURIComponent(document.forms[p_oForm].elements[i].value);
					}
				break;

				case 'radio':
					if(document.forms[p_oForm].elements[i].checked)
					{
						oHTTP.addParam(document.forms[p_oForm].elements[i].name, encodeURIComponent(document.forms[p_oForm].elements[i].value));
						poststr=poststr+'&'+document.forms[p_oForm].elements[i].name+'='+encodeURIComponent(document.forms[p_oForm].elements[i].value);
					}
				break;

				default:
					
					oHTTP.addParam(document.forms[p_oForm].elements[i].name, encodeURIComponent(document.forms[p_oForm].elements[i].value));
					poststr=poststr+'&'+document.forms[p_oForm].elements[i].name+'='+encodeURIComponent(document.forms[p_oForm].elements[i].value);
					//strcheck=strcheck+'&'+document.forms[p_oForm].elements[i].name+'='+encodeURIComponent(document.forms[p_oForm].elements[i].value)+'\n';
			}

		}
		// Add additional param
		if (this.m_aPostParams.length) {
			for(var ii =0; ii < this.m_aPostParams.length; ii++) {
				oHTTP.addParam(this.m_aPostParams[ii][0], encodeURIComponent(this.m_aPostParams[ii][1]));
			}
		}	
		oHTTP.post();
		
		//xmlreqPOST('_Post/post.php',poststr);
	}
	
	this.showLoadingWindow = function() {
		if (this.m_sLoadingPopup != '') {       
			  var oDiv = document.getElementById(this.m_sLoadingPopup);
			  var oDivShadow = document.getElementById(this.m_sLoadingPopup + '_shadow'); 
			  
			  
			//  msgbox.innerHTML = message;
			  var aWindow = this.getWindowSize();
			  
			  oDivShadow.style.left = '0px';
			  oDivShadow.style.top = '0px';
			  oDivShadow.style.width = aWindow[0] + 'px';
			  oDivShadow.style.height = aWindow[1] + 'px';
			  oDivShadow.style.display = 'block';
			  
			  //var aPos = findPos(document.getElementById('calendar'));
			  oDiv.style.display = "block";	
			  oDiv.style.left = ((aWindow[0]/2) - (oDiv.offsetLeft / 2)) + 'px'; //  ((aWindow[0]/2) - (oDiv.offsetWidth / 2)) + 'px';
			  oDiv.style.top =  ((aWindow[1]/2) - (oDiv.offsetHeight / 2)) + 'px'; //  ((aWindow[1]/2) - (oDiv.offsetHeight / 2)) + 'px';
			  
		}
	}
	
	this.hideLoadingWindow = function() {
		if (this.m_sLoadingPopup != '') {
			var msgbox = document.getElementById(this.m_sLoadingPopup);
			var oDivShadow = document.getElementById(this.m_sLoadingPopup + '_shadow'); 
			//  msgbox.innerHTML = message;
			oDivShadow.style.display = 'none';
			msgbox.style.display = "none";	
		}
	}
	
	this.getWindowSize = function() {
		var myWidth = 0, myHeight = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		}
		return [myWidth, myHeight];
	}
	
	
	this._DOMRemoveChilds = function(p_oObj)  {
		if ( p_oObj.hasChildNodes() )
		{
			while ( p_oObj.childNodes.length >= 1 )
			{
				p_oObj.removeChild( p_oObj.firstChild );       
			} 
		}
		if (p_oObj.parentNode) {
			p_oObj.parentNode.removeChild(p_oObj);
		}
	}
	
	this.addPostParam = function(p_sKey, p_vValue) {
		this.m_aPostParams[this.m_aPostParams.length] = [p_sKey, p_vValue];
	}
}