﻿
	/**
	 * Display an error message for the checker
	 *
	 * @param		String		Text message to display
	 *
	 */

	function	displayError( txt )	{
		if( debugbba ) 	{
			alert( "Error : " + txt);
		}
	}

	/**
	 * Callback - called when the samknows call has started
	 *
	 * @param		Object		Currently unused - may change
	 *
	 */

	function	ml_start_callback()	{}

	function	ml_submit( formname, start_callback, end_callback, error_callback )	{

		dataquerystring	=	"";
		email	=	"";
		
		target		=	document.getElementById('ml_email_address');

		if( target )	{
			email	=	target.value;
		}
		
		dataquerystring	+=	"&email=" + email;

		return	ajax_submit( dataquerystring, start_callback, end_callback, error_callback );
	}
	/**
	 *
	 * @param		String		JSON Data
	 *
	 * @return		Boolean		false on error
	 *							Should forward the HTML page on suceess
	 *							depending on the data returned
	 */

	function	ml_end_callback( data )	{
		jsonContent = eval("(" + data + ")");

		xcomm	=	document.getElementById('maillist_container');
		if( xcomm )	{

			newcdata	=	'<p>Thankyou. You should receive a confirmation email very soon</p><p><a href="javascript:;" onclick="hidediv(\'maillist\');">Close</a>';
		
			xcomm.innerHTML	=	newcdata;
		}
	}


	/**
	 *
	 * @param		Number		error_code
	 *							-2 = no postcode and/or phone number
	 *							All other codes - assume can't connect to samknows
	 */

	function	ml_error_callback( error_code )	{

		if( error_code == -2 )	{
			displayError("Please enter data");
		}
		else	{
			displayError("Sorry. Big error.");
		}
	}

