pp_ajax_url = '/staticfiles/mls/index.php';
function ajax_box(mlsn, search_type, search_area, box_type) {	
	if( $(box_type) )
		$(box_type).remove();
		
	f = function(o) {
		hide_loader(box_type);		
		
		box.replace(o.responseText);	
		$(box_type).show();
		
		set_center(box_type);
	}

	box = Builder.node('div', { style: 'width: 300px; height: 100px;', className: 'popup_box', id: box_type });
	document.body.appendChild(box);
	set_center(box_type);
	
	show_loader(box_type, 'Loading...', 'loader.gif');	
	
	rurl = location.href;
	
	new Ajax.Request(pp_ajax_url, { 
		postBody: 'box=' + box_type + '&type=' + search_type + '&area=' + search_area + '&mlsn=' + mlsn + '&rurl=' + rurl, 
		method: 'post', 
		onSuccess: f 
	}); 	
}

function show_box(box) {	
	b_obj = $(box);
	
	b_obj.parentNode.removeChild(b_obj);	
	document.body.appendChild(b_obj);
	
	$(box).toggle();				
	set_center(box);
	
	new Draggable(box, { endeffect: false, starteffect: false } );	
}

function hide_box(box) {
	$(box).remove();	
}

function send_request_form(frm, cb) {
	f = function(o) {
		xmlDoc 		= create_xml_doc(o.responseText);

		// oh IE and your crazy reserved js variables
		mssage		= getText(xmlDoc, 'message');
		sttus 		= getText(xmlDoc, 'status');
		
		if(sttus == 'true') {
			custom_alert(mssage);
			
			if(typeof cb == 'function')
				cb();
		}
	}
	
	if(check_required(frm))
		new Ajax.Request(pp_ajax_url + '?j=' + ut(), { postBody: 'action=send_message&' + frm.serialize(), method: 'post', onSuccess: f}); 	
	
	return false;
}
