var debug_return = 0;
var track_action = 0;
var track_action_str = "TRACK ACTION";


function do_debug_return(str)
{
	gi('marc_debug').innerHTML = '<input type="button" value="clear" onclick="clear_debug()"><br/>' + str.replace(/}/g, "}<br/>");
	gi('marc_debug').style.display = "block";
	gi('marc_debug').style.top = 0;
	gi('marc_debug').style.backgroundColor = '#ffffff';
}

function clear_debug()
{
	gi('marc_debug').style.display = "none";
}


function GetServerDest()
{
	return "competitor_hub.php";
}

function GetCodeDir()
{
	return "competitor/";
}

/* ..........................................*/
/*
hs_Transport.prototype.GetSocietyRegistrations = hs_Transport_GetSocietyRegistrations;
*/
hs_Transport.prototype.InitCompetitorPage = hs_Transport_InitCompetitorPage;
hs_Transport.prototype.GetCompetitorKeys = hs_Transport_GetCompetitorKeys;
hs_Transport.prototype.GetCompetitorDetails = hs_Transport_GetCompetitorDetails;
hs_Transport.prototype.AddRegistrationToDB = hs_Transport_AddRegistrationToDB;
hs_Transport.prototype.DeleteRegistrationFromDB = hs_Transport_DeleteRegistrationFromDB;
hs_Transport.prototype.GetRegistrationFromDB = hs_Transport_GetRegistrationFromDB;
hs_Transport.prototype.GetHorseRelatedFromDB = hs_Transport_GetHorseRelatedFromDB;
hs_Transport.prototype.GetHorseRegistrationsFromDB = hs_Transport_GetHorseRegistrationsFromDB;
hs_Transport.prototype.GetOwnerRegistrationsFromDB = hs_Transport_GetOwnerRegistrationsFromDB;

hs_Transport.prototype.DeleteHorseFromDB = hs_Transport_DeleteHorseFromDB;
hs_Transport.prototype.DeleteRiderFromDB = hs_Transport_DeleteRiderFromDB;

hs_Transport.prototype.AddOwnerToDB = hs_Transport_AddOwnerToDB;
hs_Transport.prototype.DeleteOwnerFromDB = hs_Transport_DeleteOwnerFromDB;
hs_Transport.prototype.SetOwnerForHorse = hs_Transport_SetOwnerForHorse;

hs_Transport.prototype.GetSectionsAndBasketForShow = hs_Transport_GetSectionsAndBasketForShow;
hs_Transport.prototype.GetClassesForSection = hs_Transport_GetClassesForSection;
hs_Transport.prototype.AddClassToBasket = hs_Transport_AddClassToBasket;
hs_Transport.prototype.AddAccomodationToBasket = hs_Transport_AddAccomodationToBasket;
hs_Transport.prototype.AddFirstAidToBasket = hs_Transport_AddFirstAidToBasket;
hs_Transport.prototype.AddMembershipToBasket = hs_Transport_AddMembershipToBasket;
hs_Transport.prototype.AddCatalogueToBasket = hs_Transport_AddCatalogueToBasket;
hs_Transport.prototype.Purchase = hs_Transport_Purchase;
hs_Transport.prototype.PrePurchase = hs_Transport_PrePurchase;
hs_Transport.prototype.RemoveFromBasket = hs_Transport_RemoveFromBasket;
hs_Transport.prototype.GetPrizesForShow = hs_Transport_GetPrizesForShow;
hs_Transport.prototype.RequestNewPwd = hs_Transport_RequestNewPwd;
hs_Transport.prototype.SetNewPwd = hs_Transport_SetNewPwd;
hs_Transport.prototype.ExitEmulation = hs_Transport_ExitEmulation;

hs_Transport.prototype.ResponseHandler = hs_Transport_ResponseHandler;

function hs_Transport_InitCompetitorPage()
{
	ar = new Array();
	ar.push('COMMAND');
	ar.push('init_competitor_page');
	this.RequestFromArray(ar);
	send_request(this);
}

function hs_Transport_GetCompetitorKeys()
{

	ar = new Array();
	ar.push('COMMAND');
	ar.push('get_competitor_keys');
	this.RequestFromArray(ar);
	send_request(this);
}

function hs_Transport_GetCompetitorDetails(id)
{
	ar = new Array();
	ar.push('COMMAND');
	ar.push('get_competitor_details');
	ar.push('db_ID');
	ar.push(id);
	this.RequestFromArray(ar);
	send_request(this);
}


function hs_Transport_AddRegistrationToDB( assoc_id, table, reg_id, reg_number, start, suppress_prompt)
{
	var table_str = "";
	switch (table)
	{	
		case COMPETITOR_REGISTRATION:
			table_str = "competitor";
			break;
		case HORSE_REGISTRATION:
			table_str = "horse";
			break;
		case RIDER_REGISTRATION:
			table_str = "rider";
			break;
		case OWNER_REGISTRATION:
			table_str = "owner";
			break;
	}
	ar = new Array();
	ar.push('COMMAND');
	ar.push('add_registration_to_db');
	ar.push('assoc_id');
	ar.push(assoc_id);
	ar.push("table");
	ar.push(table_str);
	ar.push('db_RegistrationID');
	ar.push(reg_id);
	ar.push('db_RegistrationNumber');
	ar.push(reg_number);
	ar.push('db_StartDate');
	ar.push(start);
	ar.push('db_suppress_prompt');
	ar.push(suppress_prompt);
	this.RequestFromArray(ar);
	send_request(this);
}



function hs_Transport_DeleteRegistrationFromDB(table, reg_id, assoc_id)
{

	var table_str = "";
	switch (table)
	{
		case COMPETITOR_REGISTRATION:
			table_str = "competitor";
			break;
		case HORSE_REGISTRATION:
			table_str = "horse";
			break;
		case RIDER_REGISTRATION:
			table_str = "rider";
			break;
		case OWNER_REGISTRATION:
			table_str = "owner";
			break;
	}
	ar = new Array();
	ar.push('COMMAND');
	ar.push('delete_registration_from_db');
	ar.push("table");
	ar.push(table_str);
	ar.push("reg_id");
	ar.push(reg_id);
	ar.push('assoc_id');
	ar.push(assoc_id);
	this.RequestFromArray(ar);
	send_request(this);
}

function hs_Transport_GetRegistrationFromDB(  table, assoc_id)
{
	var table_str = "";
	switch (table)
	{	
		case COMPETITOR_REGISTRATION:
			table_str = "competitor";
			break;
		case HORSE_REGISTRATION:
			table_str = "horse";
			break;
		case RIDER_REGISTRATION:
			table_str = "rider";
			break;
		case OWNER_REGISTRATION:
			table_str = "owner";
			break;
	}
	ar = new Array();
	ar.push('COMMAND');
	ar.push('get_registration_from_db');
	ar.push('assoc_id');
	ar.push(assoc_id);
	ar.push("table");
	ar.push(table_str);
	this.RequestFromArray(ar);
	send_request(this);
}



function hs_Transport_GetHorseRelatedFromDB(assoc_id)
{
	ar = new Array();
	ar.push('COMMAND');
	ar.push('get_horse_related_from_db');
	ar.push('assoc_id');
	ar.push(assoc_id);
	this.RequestFromArray(ar);
	send_request(this);
}

function hs_Transport_GetHorseRegistrationsFromDB(assoc_id)
{
	ar = new Array();
	ar.push('COMMAND');
	ar.push('get_horse_registrations');
	ar.push('assoc_id');
	ar.push(assoc_id);
	this.RequestFromArray(ar);
	send_request(this);
}

function hs_Transport_GetOwnerRegistrationsFromDB(assoc_id)
{
	ar = new Array();
	ar.push('COMMAND');
	ar.push('get_owner_registrations');
	ar.push('assoc_id');
	ar.push(assoc_id);
	this.RequestFromArray(ar);
	send_request(this);
}



function hs_Transport_AddHorseToDB(sex, dat, height, cert)
{
	ar = new Array();
	ar.push('COMMAND');
	ar.push('add_horse_to_db');
	var i = 0;
	for(i=0; i < Horse_AutoFields.length; i++)
	{
		ar.push(Horse_AutoFields[i]);
		ar.push(gbi(Horse_AutoFields[i]).value);
	}
	ar.push('db_SexID');
	ar.push(sex);
	ar.push('db_DOB');
	ar.push(dat);
	ar.push('db_HeightID');
	ar.push(height);
	ar.push('db_CertificateTypeID');
	ar.push(cert);
	this.RequestFromArray(ar);
	send_request(this);
}

function hs_Transport_DeleteHorseFromDB(horse_id)
{
	ar = new Array();
	ar.push('COMMAND');
	ar.push('delete_horse_from_db');
	ar.push('horse_ID');
	ar.push(horse_id);
	this.RequestFromArray(ar);
	send_request(this);
}

function hs_Transport_SetOwnerForHorse(owner_id, horse_id, displayed_horse_id)
{
	ar = new Array();
	ar.push('COMMAND');
	ar.push('set_owner_for_horse');
	ar.push('owner_ID');
	ar.push(owner_id);
	ar.push('horse_ID');
	ar.push(horse_id);
	ar.push('displayed_horse_ID');
	ar.push(displayed_horse_id);
	this.RequestFromArray(ar);
	send_request(this);
}


function hs_Transport_DeleteRiderFromDB(rider_id)
{
	ar = new Array();
	ar.push('COMMAND');
	ar.push('delete_rider_from_db');
	ar.push('rider_ID');
	ar.push(rider_id);
	this.RequestFromArray(ar);
	send_request(this);
}

function hs_Transport_AddOwnerToDB(owner_ar)
{
	ar = new Array();
	ar.push('COMMAND');
	ar.push('add_owner_to_db');
	array_append(ar, owner_ar);
	this.RequestFromArray(ar);
	send_request(this);
}

function hs_Transport_DeleteOwnerFromDB(owner_id, displayed_horse_id, displayed_owner_reg_id)
{
	ar = new Array();
	ar.push('COMMAND');
	ar.push('delete_owner_from_db');
	ar.push('owner_ID');
	ar.push(owner_id);
	ar.push('displayed_horse_ID');
	ar.push(displayed_horse_id);
	ar.push('displayed_owner_reg_ID');
	ar.push(displayed_owner_reg_id);
	this.RequestFromArray(ar);
	send_request(this);
}




function hs_Transport_GetSectionsAndBasketForShow(show_id)
{
	ar = new Array();
	ar.push('COMMAND');
	ar.push('get_showsections_and_basket');
	ar.push('show_id');
	ar.push(show_id);
	this.RequestFromArray(ar);
	send_request(this);
}

function hs_Transport_GetClassesForSection(section_id)
{
	ar = new Array();
	ar.push('COMMAND');
	ar.push('get_showclasses');
	ar.push('section_id');
	ar.push(section_id);
	this.RequestFromArray(ar);
	send_request(this);
}


function hs_Transport_AddClassToBasket(class_id, horse_id, rider_id)
{
	ar = new Array();
	ar.push('COMMAND');
	ar.push('add_class_to_basket');
	ar.push('class_id');
	ar.push(class_id);
	ar.push('horse_id');
	ar.push(horse_id);
	ar.push('rider_id');
	ar.push(rider_id);
	this.RequestFromArray(ar);
	send_request(this);
}

function hs_Transport_AddAccomodationToBasket(show_id, accom_type, accom_start, accom_end, vehicle)
{
	ar = new Array();
	ar.push('COMMAND');
	ar.push('add_accomodation_to_basket');
	ar.push('show_id');
	ar.push(show_id);
	ar.push('accom_type');
	ar.push(accom_type);
	ar.push('accom_start');
	ar.push(accom_start);
	ar.push('accom_end');
	ar.push(accom_end);
	ar.push('vehicle');
	ar.push(vehicle);
	this.RequestFromArray(ar);
	send_request(this);	
}

function hs_Transport_AddFirstAidToBasket(show_id)
{
	ar = new Array();
	ar.push('COMMAND');
	ar.push('add_first_aid_to_basket');
	ar.push('show_id');
	ar.push(show_id);
	this.RequestFromArray(ar);
	send_request(this);	
}

function hs_Transport_AddMembershipToBasket(show_id, level)
{
	ar = new Array();
	ar.push('COMMAND');
	ar.push('add_membership_to_basket');
	ar.push('show_id');
	ar.push(show_id);
	ar.push('level');
	ar.push(level);
	this.RequestFromArray(ar);
	send_request(this);	
}

function hs_Transport_AddCatalogueToBasket(show_id)
{
	ar = new Array();
	ar.push('COMMAND');
	ar.push('add_catalogue_to_basket');
	ar.push('show_id');
	ar.push(show_id);
	this.RequestFromArray(ar);
	send_request(this);	
}

function hs_Transport_RemoveFromBasket(db_id, table, show_id)
{
	ar = new Array();
	ar.push('COMMAND');
	ar.push('remove_from_basket');
	ar.push('db_id');
	ar.push(db_id);
	ar.push('table');
	ar.push(table);
	ar.push('show_id');
	ar.push(show_id);
	this.RequestFromArray(ar);
	send_request(this);	
}


function hs_Transport_GetPrizesForShow(show_id)
{
	ar = new Array();
	ar.push('COMMAND');
	ar.push('get_prizes');
	ar.push('show_id');
	ar.push(show_id);
	this.RequestFromArray(ar);
	send_request(this);
}


function hs_Transport_Purchase(show_id)
{
	ar = new Array();
	ar.push('COMMAND');
	ar.push('purchase');
	ar.push('show_id');
	ar.push(show_id);
	this.RequestFromArray(ar);
	send_request(this);
}

function hs_Transport_PrePurchase(show_id)
{
	ar = new Array();
	ar.push('COMMAND');
	ar.push('pre_purchase');
	ar.push('show_id');
	ar.push(show_id);
	this.RequestFromArray(ar);
	send_request(this);
}


function hs_Transport_RequestNewPwd(mail)
{
	ar = new Array();
	ar.push('COMMAND');
	ar.push('request_new_pwd');
	ar.push('email');
	ar.push(mail);
	this.RequestFromArray(ar);
	send_request(this);
}

function hs_Transport_SetNewPwd(pwd)
{
	ar = new Array();
	ar.push('COMMAND');
	ar.push('set_new_pwd');
	ar.push('pwd');
	ar.push(pwd);
	this.RequestFromArray(ar);
	send_request(this);
}

function hs_Transport_ExitEmulation()
{
	ar = new Array();
	ar.push('COMMAND');
	ar.push('exit_emulation');
	this.RequestFromArray(ar);
	send_request(this);
}




//debug_return = 1;
function hs_Transport_ResponseHandler(str)
{
if (debug_return)
	//do_debug_return(str);
	alert(str);

	this.ParseResponse(str);

	for (var i=0; i < this.phpObjArray.length; i++)
	{		
		if (track_action)
		{
			track_action_str += "<br/>" + this.phpObjArray[i].action;
			do_debug_return(track_action_str);
	//	alert(track_action_str);
		}

        switch (this.phpObjArray[i].action)
        {
			case 'title':
				TitleDropdown.push(this.phpObjArray[i].display);
				break;	

			case 'competitor_keys':
				competitor_dataObj.fillKeys(this.phpObjArray[i]);
				break;
			case 'competitor':
				competitor_dataObj.fillFieldsFromDB(this.phpObjArray[i]);
				show_home_profile_details();
				fill_profile_droplists();
				break;
				/*
			case 'competitor_registration':
				add_competitor_registration(this.phpObjArray[i]);
				break;
				*/
			case 'new_competitor_confirmed':
				alert("confirmed");
				break;
			case 'competitor_modified':
				competitor_dataObj.fillFieldsFromDB(this.phpObjArray[i]);
				competitor_dataObj.display();
				show_home_profile_details();
				fill_profile_droplists();
				alert('Your details have been updated');
				break;
			case 'update_registration_table':
				update_registration_table(this.phpObjArray[i]);
				break;
			case 'update_registration_table_complete':
				update_registration_table_complete(this.phpObjArray[i]);
				break;

/*......................................................................................*/
			case 'horse_height':
			case 'horse_height_cert':
			case 'horse_registrations':
			case 'horse_sex':
				add_option_from_server(this.phpObjArray[i]);
				break;

/*************************************************************************************/
			case 'registration_TO_competitor_DB_keys':
				competitor_registrations_auto_table.fill_keys_array(this.phpObjArray[i]);
				horse_registrations_auto_table.fill_keys_array(this.phpObjArray[i]);
				owner_registrations_auto_table.fill_keys_array(this.phpObjArray[i]);
				rider_registrations_auto_table.fill_keys_array(this.phpObjArray[i]);
				break;


			case 'start_registrations_list':
				switch(this.phpObjArray[i].type)
				{
					case 'competitor':
						competitor_registrations_auto_table.clear();
						break;
					case 'horse':
						horse_registrations_auto_table.clear();
						break;
					case 'rider':
						rider_registrations_auto_table.clear();
						break;
					case 'owner':
						owner_registrations_auto_table.clear();
						break;

				}
				break;
			case 'end_registrations_list':
				switch (this.phpObjArray[i].type)
				{
					case 'competitor':
						competitor_registrations_auto_table.display_all_records();
						if (competitor_registrations_auto_table.ar_filtered.length > 0 )
							gbi('competitor_registrations_table_panel').style.display = "block";
						else
							gbi('competitor_registrations_table_panel').style.display = "none";
						break;
					case 'horse':
						horse_registrations_auto_table.display_all_records();
						if (horse_registrations_auto_table.ar_filtered.length > 0 )
							gbi('horse_registrations_table_panel').style.display = "block";
						else
							gbi('horse_registrations_table_panel').style.display = "none";
							
						break;
					case 'rider':
						rider_registrations_auto_table.display_all_records();
						
						if (rider_registrations_auto_table.ar_unfiltered.length > 0 )
							gbi('rider_registrations_table_panel').style.display = "block";
						else
							gbi('rider_registrations_table_panel').style.display = "none";
						
						break;
					case 'owner':
						owner_registrations_auto_table.display_all_records();
						
						if (owner_registrations_auto_table.ar_filtered.length > 0 )
							gbi('owner_registrations_table_panel').style.display = "block";
						else
							gbi('owner_registrations_table_panel').style.display = "none";
							
						break;

				}
				break;


			case 'competitor_registration':
				competitor_registrations_auto_table.add_record(this.phpObjArray[i]);
				break;
			case 'horse_registration':
				horse_registrations_auto_table.add_record(this.phpObjArray[i]);
				break;
			case 'owner_registration':
				owner_registrations_auto_table.add_record(this.phpObjArray[i]);
				break;
			case 'rider_registration':
				rider_registrations_auto_table.add_record(this.phpObjArray[i]);
				break;
/*...................................................................................................*/						
			case 'horse_DB_keys':
				horse_dataObj.fillKeys(this.phpObjArray[i]);
				horse_auto_table.fill_keys_array(this.phpObjArray[i]);
				home_horse_auto_table.fill_keys_array(this.phpObjArray[i]);
				break;
			case 'start_horse_list':
				horse_auto_table.clear();
				home_horse_auto_table.clear();
				gi('enter_horse_droplist').options.length = 0;
				gi('horse_owner_droplist').options.length = 0;
				gi('select_horse_reg').options.length = 0;
				break;
			case 'end_horse_list':
				horse_dataObj.clearAllFields();
				horse_dataObj.display();
				horse_auto_table.display_all_records();
				home_horse_auto_table.display_all_records();				
				if (horse_auto_table.ar_filtered.length > 0 )				
					gbi('horse_table_panel').style.display = "block";
				else
					gbi('horse_table_panel').style.display = "none";
				if (gbi('enter_horse_droplist').options.length == 0 )	
				{							
					gbi('horse_owner_droplist').options[0] = new Option("none entered", -1);								
					gbi('select_horse_reg').options[0] = new Option("none entered", -1);								
					gbi('enter_horse_droplist').options[0] = new Option("none entered", -1);								
				}
				break;
			case 'horse':
				horse_auto_table.add_record(this.phpObjArray[i]);
				home_horse_auto_table.add_record(this.phpObjArray[i]);
				add_horse_to_droplist(this.phpObjArray[i]);
				break;

			case 'horse_details':
				horse_dataObj.fillFieldsFromDB(this.phpObjArray[i]);
				show_horse_details();
				break;

			case 'horse_table_select':
				horse_auto_table.select_last();
				break;

/*...................................................................................................*/	
					
			case 'rider_DB_keys':
				rider_dataObj.fillKeys(this.phpObjArray[i]);
				rider_auto_table.fill_keys_array(this.phpObjArray[i]);
				home_rider_auto_table.fill_keys_array(this.phpObjArray[i]);
				break;
			case 'start_rider_list':
				rider_auto_table.clear();
				home_rider_auto_table.clear();
				gi('enter_rider_droplist').options.length = 0;
				break;
			case 'end_rider_list':
				rider_auto_table.display_all_records();
				home_rider_auto_table.display_all_records();
				if (gbi('enter_rider_droplist').options.length == 0 )				
					gbi('enter_rider_droplist').options[0] = new Option("none entered", -1);								

				break;
			case 'rider':
				if (this.phpObjArray[i].db_IsCompetitor == 1)
					this.phpObjArray[i].db_LastName += " (YOU) ";

				rider_auto_table.add_record(this.phpObjArray[i]);
				home_rider_auto_table.add_record(this.phpObjArray[i]);
				add_rider_to_droplist(this.phpObjArray[i]);
				break;
			case 'rider_table_select':
				rider_auto_table.select_last();
				break;
				

/*...................................................................................................*/	
					
			case 'owner_DB_keys':
				owner_dataObj.fillKeys(this.phpObjArray[i]);
				break;

			case 'start_owner_list':
				gbi('owner_droplist').options.length = 0;
				gbi('delete_owner_droplist').options.length = 0;
				gbi('reg_owner_droplist').options.length = 0;
				break;
			case 'end_owner_list':
				handle_end_owner_list();
				break;
			case 'owner':	
				if (this.phpObjArray[i].db_IsCompetitor == 1)
					this.phpObjArray[i].db_LastName += " (YOU) ";
				add_owner_to_droplist(this.phpObjArray[i]);
				break;
			case 'start_owner_to_horse_list':
			break;
			case 'end_owner_to_horse_list':
			break;
			case 'scroll_owner_droplist_first':
				gbi('delete_owner_droplist').selectedIndex = 0;
				break;
			case 'scroll_owner_droplist_last':
				gbi('delete_owner_droplist').selectedIndex = gbi('delete_owner_droplist').options.length-1;
				break;

			case 'owner_to_horse':
				owner_display = get_title_string(this.phpObjArray[i]) + this.phpObjArray[i].db_FirstName + " " + this.phpObjArray[i].db_LastName;
				if (this.phpObjArray[i].db_IsCompetitor == 1)
					owner_display += " (YOU) ";

				break;
/*explicitly called from php when horse owner is set*/
			case 'redraw_horse_details':
				show_horse_details();
				break;
				
			


/*...................................................................................................*/						
			case 'horseshow_DB_keys':
				horseshow_auto_table.fill_keys_array(this.phpObjArray[i]);
				home_horseshow_auto_table.fill_keys_array(this.phpObjArray[i]);
				diary_auto_table.fill_keys_array(this.phpObjArray[i]);
				prizes_horseshow_auto_table.fill_keys_array(this.phpObjArray[i]);
				break;
			case 'start_horseshow_list':
				horseshow_auto_table.clear();
				diary_auto_table.clear();
				break;
			case 'end_horseshow_list':
				horseshow_auto_table.display_all_records();
				break;
			case 'horseshow':
			/*diary table gets all shows (cos competitor may have booked for a show which is currently 'unpublished'. horseshow table only gets published shows*/
				diary_auto_table.add_record(this.phpObjArray[i]);
				if (this.phpObjArray[i].db_Published > 0 )
					horseshow_auto_table.add_record(this.phpObjArray[i]);
				break;		

			case 'start_show_data':
				home_horseshow_auto_table.clear();
				break;
			case 'show_data':
			/*published shows only*/
				if (this.phpObjArray[i].published > 0 )
					home_horseshow_auto_table.add_record(this.phpObjArray[i]);
				break;
			case 'end_show_data':
				home_horseshow_auto_table.display_all_records();
				break;

/*...................................................................................................*/						
			case 'horseshow_section_DB_keys':
				showsection_auto_table.fill_keys_array(this.phpObjArray[i]);
				break;
			case 'start_showsection_list':
				showsection_auto_table.clear();
				break;
			case 'end_showsection_list':
				showsection_auto_table.display_all_records();
				if (showsection_auto_table.ar_filtered.length > 0 )
					gbi("showsection_table_panel").style.display = "block";
				else
					gbi("showsection_table_panel").style.display = "none";
				break;
			case 'showsection':
				showsection_auto_table.add_record(this.phpObjArray[i]);
				break;
			case 'server_today':
				server_today_str = this.phpObjArray[i].value;
				break;

		

/*...................................................................................................*/						
			case 'horseshow_class_DB_keys':
				class_auto_table.fill_keys_array(this.phpObjArray[i]);
				break;
			case 'start_showclass_list':
				class_auto_table.clear();
				break;
			case 'end_showclass_list':
				class_auto_table.display_all_records();
				gbi('showclass_table_panel').style.display = "block";
				break;
			case 'showclass':
				class_auto_table.add_record(this.phpObjArray[i]);
				break;
/*...................................................................................................*/						
			case 'basket_DB_keys':
				basket_auto_table.fill_keys_array(this.phpObjArray[i]);
				break;
			case 'start_basket':
				basket_auto_table.clear();
				set_div_text("basket_discount_panel", "");
				break;
			case 'end_basket':
			//	basket_auto_table.display_html_table();
				basket_auto_table.display_all_records();
				break;
			case 'basket':
				basket_auto_table.add_basket_record(this.phpObjArray[i]);
				break;		
			case 'basket_total':	
				basket_auto_table.add_record(this.phpObjArray[i]);
				break;		
			case 'basket_discount_notice':
				show_basket_discount_notice(this.phpObjArray[i]);
				break;
			case 'vehicle':
				add_vehicle_to_droplist(this.phpObjArray[i]);
				break;
			case 'stable':
				add_stable_to_droplist(this.phpObjArray[i]);
				break;				
			case 'purchase_confirmed':
				alert("Purchase confirmed");
				break;
			case "membership_duplicate":
				alert("You already have membership");
				break;
			case 'confirm_pre_purchase':
				do_paypal_purchase(this.phpObjArray[i]);
				break;
/*......................................................................................................*/
			case 'start_booking_list':
				booking_list.length = 0;
				diary_auto_table.ar_filtered.length = 0;
				break;
			case 'booking':
				booking_list.push(this.phpObjArray[i].value);
				break;
			case 'end_booking_list':
				show_diary_table();
				break;
/*......................................................................................................*/
			case 'start_diary_detail_list':
				detail_diary_auto_table.ar_unfiltered.length = 0;
				break;
			case 'diary_detail_list':
				detail_diary_auto_table.add_record(this.phpObjArray[i]);
				break;
			case 'end_diary_detail_list':
				detail_diary_auto_table.display_all_records();
				if (detail_diary_auto_table.ar_filtered.length == 0 )
					gbi('diary_empty').style.display = "block";
				else
					gbi('diary_empty').style.display = "none";
				break;

/*......................................................................................................*/
			case 'start_prizes_horseshow_list':
				prizes_horseshow_auto_table.ar_unfiltered.length = 0;
				break;
			case 'prizes_horseshow_list':
				prizes_horseshow_auto_table.add_record(this.phpObjArray[i]);
				break;
			case 'end_prizes_horseshow_list':
				prizes_horseshow_auto_table.display_all_records();
				if (prizes_horseshow_auto_table.ar_filtered.length == 0 )
					set_div_text("prizes_intro_text", "There are no records to display");
				else
					set_div_text("prizes_intro_text", "Select a show from the table to view prizes");
				break;


			case 'start_prize_details':
				start_prizes();
				break;
			case 'prize_section':
				prizes_add_section(this.phpObjArray[i]);
				break;
				
			case 'prize_class':
				prizes_add_class(this.phpObjArray[i]);
				break;
			case 'end_prize_details':
				prizes_display();
				break;



/*......................................................................................................*/
			case 'initialisation_complete':
				initialisation_complete();
				break;


			case 'request_new_pwd':
				alert("A new password has been sent to your email address");
				break;

			case 'set_new_pwd':
				alert("Your password has been set as requested");
				gbi('pwd1').value = "";
				gbi('pwd2').value = "";
				DisplayCollapsing('profile');
				break;

			case 'email_in_use':
				var email = this.phpObjArray[i].email;
				alert("Email address " + email + " is already being used. You can only have one account per email address");
				break;
				
			case 'forgot_pwd_fail':
				alert("Sorry - we cannot find that email address in our database");
				break;
			case 'forgot_pwd_showsec':
				alert("As a show organiser you cannot set your password automatically for security reasons. Your requested for a new password has been sent to MyShowEntries who will issue a new password shortly by email");
				window.location = "../index.html";
				break;
				
			case 'exit_emulation':
				window.location = "../showsec/showsec_index.html";
				break;
				
			case 'DEBUG':
			    alert(this.phpObjArray[i].msg);
			    break;
		}

	}
}

