function displayTextServiceFormBt(obj,companyID,fixUrl,companyName,companyMobile,companyUrl,companyAddress,companyPhone,sendToCompany,requestDetails){
	var myHTML = '<b>Choose an SMS service</b><br /><br />';

	if(sendToCompany){
		myHTML += '<button type="button" onclick="javascript:displayTextFormBt(\''+obj+'\',\''+companyID+'\',\''+fixUrl+'send_company_txt_bt.php\'';
		myHTML += ', '+false;
		myHTML += ',\''+companyName+'\',\''+companyMobile+'\');">Text the company</button>';
	}

	if(requestDetails){
		myHTML += '<button type="button" onclick="javascript:showTextForm(\''+obj+'\',\''+companyID+'\',\''+fixUrl+'send_company_txt_bt.php?mode=1&amp;url='+companyUrl+'&amp;address='+companyAddress+'&amp;phone='+companyPhone+'\'';
		myHTML += ', '+true;
		myHTML += ',\''+companyName+'\');">Request company details</button>';
	}

	myHTML += '<button type="button" onclick="javascript:Element.hide(\''+obj+'\');">Close</button>';

	$(obj).innerHTML = wrapOutput(myHTML,false);
	Element.show(obj);

}

function displayTextFormBt(obj,companyID,formFile,paidListing,companyName,companyMobile) {
	Element.show(obj);
	var fixURL = fixURI(formFile);
	var numberObj = companyID + '_to_mobile';
	var messageObj = companyID + '_text_message';
	var description = '';
	var smsNumber = readCookie('sms_number');
	if (companyName != undefined) { description = '<span class="text_company"><b>Send a message to <i>'+ companyName +'</i>.</b></span>'; }
	var myHTML = description +'<div class="text_form"><div class="text_form_section"><span class="enter_number">Please enter a valid mobile number:- <br /></span>';
	myHTML += '<input id="'+ numberObj +'" type="text" name="mobile_number" size="14" class="text_number" value="'+ smsNumber +'" />&nbsp;';
	//myHTML += '<input id="'+ messageObj +'" type="text" name="text_message" size="14" class="text_number" value="" />&nbsp;';
	myHTML += '<div class="text_form_section"><span class="enter_number">Please enter your message:-</span>';
	myHTML += '<textarea id="'+ messageObj +'" type="text" name="text_message" rows="3" cols="11" class="text_message"/></textarea></div>';
	myHTML += '<div class="text_form_buttons">';
	myHTML += hoverImage(companyID + '_send','sms.gif','sms-over.gif',fixURL);
	myHTML += hoverImage(companyID + '_cancel','cancel.gif','cancel-over.gif',fixURL);
	myHTML += '</div></div>';
	myHTML += '<span class="text_only">';
	myHTML += ' <input type="button" id="'+ companyID +'_send_to" value="Send SMS">&nbsp;';
	myHTML += ' &nbsp;<input type="button" id="'+ companyID +'_cancel_to" value="Cancel">&nbsp;';
	myHTML += '</span>';
	$(obj).innerHTML = wrapOutput(myHTML,paidListing);
	Event.observe(companyID + '_send', 'click', function(){sendTextBt(obj,formFile,numberObj,messageObj,companyID,paidListing,companyMobile)});
	Event.observe(companyID + '_cancel', 'click', function(){hide(obj)});
	Event.observe(companyID + '_send_to', 'click', function(){sendTextBt(obj,formFile,numberObj,companyID,paidListing)});
	Event.observe(companyID + '_cancel_to', 'click', function(){hide(obj)});
}

function sendTextBt(obj,formFile,numberObj,messageObj,companyID,paidListing,companyMobile) {
	var mobileNumber = Form.Element.getValue(numberObj);
	var textMessage = Form.Element.getValue(messageObj);
	var myHTML = '<span class="enter_number">Attempting to send company details to your mobile...<br><br>If you see this message for more than 2 minutes then there may be problems with the network.  If this is the case, please click on the listing\'s "text" button to try again.</span>';
	$(obj).innerHTML = wrapOutput(myHTML,paidListing);
	var success = function(t){messageSentBt(t,obj,formFile,companyID,paidListing);};
	//var failure = function(){hide(obj);};
	var failure = function(){};
	var url = formFile;
	var pars = 'mobile_number='+ mobileNumber +'&text_message='+textMessage+'&company_id='+ companyID+'&company_number='+companyMobile;
	var myAjax = new Ajax.Request(url, {method:'post',postBody:pars,onSuccess:success,onFailure:failure});
}

function messageSentBt(t,obj,formFile,companyID,paidListing) {
	var fixURL = fixURI(formFile);
	var hideObj = companyID + '_cancel';
	var myHTML = t.responseText +'<br>'+ hoverImage(hideObj,'close.gif','close-over.gif',fixURL);
	myHTML += '<span class="text_only">';
	myHTML += '<input type="button" id="'+ hideObj +'_to" value="Close">';
	myHTML += '</span>';
	$(obj).innerHTML = wrapOutput(myHTML,paidListing);
	Event.observe(hideObj, 'click', function(){hide(obj)}, false);
	Event.observe(hideObj +'_to', 'click', function(){hide(obj)}, false);
	myHTML += '<span class="text_only">';
	myHTML += '<input type="button" id="'+ hideObj +'_to" value="Close">';
	myHTML += '</span>';
	$(obj).innerHTML = wrapOutput(myHTML,paidListing);
	Event.observe(hideObj, 'click', function(){hide(obj)}, false);
	Event.observe(hideObj +'_to', 'click', function(){hide(obj)}, false);
}
