/**
* Ajax version of postcode anywhere, must always include posycodeanywhere.js javascript before this file
**/

/**
* Postcode anywhere turboShop driver javascript
**/
function ajaxLookupAddress(formElementObj)
{
	if (!validateLookup(formElementObj))
	{
		return false;
	}
	var orgComd = '';
	orgComd = formElementObj.form.comd.value;
	formElementObj.form.comd.value = 'thirdparty';
	formElementObj.form.thirdparty.value = 'postcodeanywhere';

	tsPostFormXMLCallBack(formElementObj.form.id, 'j=thirdparty&thirdparty=postcodeanywhere', 'postcodeAnywhereContainer', 'postcodeAnywhereXML');
	formElementObj.form.comd.value = orgComd;
}



// override lookupAddress method
//var lookupAddressPrev = lookupAddress;
lookupAddress = ajaxLookupAddress;


var gTCcode = null;

//////
//xml callback methods used by ajax.js
///


function postcodeAnywhereXMLStart(XMLDOMObj)
{
	gTCcode = tsGetElementById('td').value;
}

function postcodeAnywhereXMLEnd()
{
	if (tsGetElementById('postcodeAnywhereContainer')!=null)
		tsGetElementById('postcodeAnywhereContainer').innerHTML='';
}

//
// called for each field in the data node of the XML doc
//
function postcodeAnywhereXMLNode(xmlNodeName, xmlNodeValue)
{
	if (tsGetElementById('ts_'+gTCcode+xmlNodeName)!=null)
	{
		if (xmlNodeName!='add7')
		{
			tsGetElementById('ts_'+gTCcode+xmlNodeName).value = xmlNodeValue;
		}

	}
}

