// Declare the new Class
function CAjaxRentRateDetails( ownerObj, boolIsInline ){

	var m_intCurrentRowId = null;

	var owner 				= ownerObj;
	var m_boolIsInline 		= boolIsInline;
	var m_aarstrOutputCache = new Array();
	var m_boolIsVisible 	= false;
	var m_strPostVars;
	var m_objCurrrentRow;
	var m_strLastOutput;
	var position;
	var m_strOldClassName;
	var m_boolIsLoad		= true; //newly added

	function getDetails( objCurrentRow, strModule, strAction, strClassName, intPropertyFloorplanId, intUnitSpaceId, intMinRentRateAmount, postVars ){
		if( intUnitSpaceId == m_intCurrentRowId ){
			return;
		}

		if( 0 == intMinRentRateAmount ) {
			hideDetails();
			return;
		}

		m_boolIsVisible = true;
		m_intCurrentRowId = intUnitSpaceId;
		if( m_objCurrrentRow ){
			m_objCurrrentRow.className = m_strOldClassName;
		}

		m_strPostVars = postVars;
		m_objCurrrentRow = objCurrentRow;
		m_strOldClassName = objCurrentRow.className;
		m_objCurrrentRow.className = strClassName;

		position('<div class="rowDetailInside" style="font-weight:bold; padding:15px;">Retrieving information. Please wait...</div>');

		// newly added
		if( true == m_boolIsLoad ) {
			var objGenericAjax = new Ajax.Request('/?', { evalScripts: true, parameters: '&module='+strModule+'&action='+strAction+'&property_floorplan[id]='+intPropertyFloorplanId+'&unit_space[id]='+intUnitSpaceId + m_strPostVars, onSuccess:display } );
		}
	}

	function display( objXmlHttpResponse ){
			if( 200 == objXmlHttpResponse.status ) {
				position( objXmlHttpResponse.responseText );

			} else {
				position('<div class="rowDetailInside" style="color:#990000; font-weight:bold; padding:15px;">Failed to retrieve data. Please try again later.</div>');
			}

	}

	if(m_boolIsInline){
		var inline_row = null;
	}

	var content_div = document.createElement('div');
	//owner.appendChild(content_div);
	content_div.style.display = 'none';
	content_div.className = 'rowDetail';

	if(!m_boolIsInline){
		content_div.style.position = 'absolute';
	}

	function autoPosition( output){
		content_div.innerHTML = output;
		position = get_abs_pos_from_elm(m_objCurrrentRow);
		content_div.style.left = String(position.x) + 'px';
		content_div.style.top = String(position.y + m_objCurrrentRow.clientHeight) + 'px';
		content_div.style.width = String(m_objCurrrentRow.clientWidth) + 'px';
		content_div.style.zIndex = 200;
		content_div.style.display = '';
		window.onresize = function(){
			autoPosition();
		}
	}

	function positionInline( output ){
		output = output.replace(/<\?xml version=\"1.0\"\?>/g,'');
		content_div.innerHTML = String(output);

		if(inline_row && inline_row.parentNode){
			inline_row.parentNode.removeChild(inline_row);
		}
		inline_row = document.createElement('tr');
		var newTd = document.createElement('td')
		newTd.colSpan = m_objCurrrentRow.getElementsByTagName('TD').length;
		newTd.style.padding = '0px;';
		newTd.style.borderBottomWidth = '1px';
		newTd.style.borderBottomStyle = 'dotted';
		newTd.style.borderBottomColor = '#A4A4A4';
		newTd.style.borderRightWidth = '1px';
		newTd.style.borderRightStyle = 'dotted';
		newTd.style.borderRightColor = '#A4A4A4';

		inline_row.appendChild(newTd);
		m_objCurrrentRow.parentNode.insertBefore(inline_row,m_objCurrrentRow.nextSibling);
		cloneContentDiv = content_div.cloneNode(true);
		cloneContentDiv.id = 'div_payment_' + m_intCurrentRowId;
		cloneContentDiv.style.display = (m_boolIsVisible)?'':'none';
		newTd.appendChild(cloneContentDiv);

	}

	function position(op){
		if(m_boolIsInline){
			positionInline(op);
		}else{
			autoPosition(op);
		}
	}

	function hideDetails(){
		m_intCurrentRowId = null;
		if( m_strOldClassName ) m_objCurrrentRow.className = m_strOldClassName;
		if( inline_row ) inline_row.style.display = 'none';
		m_boolIsVisible = false;
	}

	function setIsLoad( boolIsLoad ) {
		m_boolIsLoad = boolIsLoad;
	}

	this.getDetails = getDetails;
	this.autoPosition = autoPosition;
	this.hideDetails = hideDetails;
	this.setIsLoad	= setIsLoad; //newly added
}
