// page_init_wrapper.js
// -------------------------------------------------------------------------------------------------
// Handles page initialisation
//
// Project    > dmABS
// Revision   > $Rev: 77 $
// Date		  > $Date: 2009-06-17 16:45:34 +0100 (Wed, 17 Jun 2009) $
// Author     > RAK for DML
// Copyright  > (C) Digital Mail Limited (2005-2009)
// -------------------------------------------------------------------------------------------------

// Create library registration object, if not already present
if (typeof dmx_library != 'object') var dmx_library = new Object(); // Library registration object
if (typeof dmx_pg_init != 'object') var dmx_pg_init = new Object(); // Has page initialisation run?

// Set up page initialisation event handler
if (window.addEventListener)
{
	window.addEventListener('load', dmx_page_init, true); // W3C
}
else if (window.attachEvent)
{
	window.attachEvent('onload', dmx_page_init); // IE  - Quirks Mode
}
else
{
	window.onload = dmb1_page_init;
}

// -------------------------------------------------------------------------------------------------
// PAGE INITIALISATION

function dmx_page_init()
{	
	// Page initialisation wrapper function

	if (dmx_pg_init.b1_core) return;
	tst_debug.init || tst_debug.master ? tst_debuginfo.init += '<strong>dmx_page_init()</strong><br>\n' : '';
			
	if (dmx_library.tst)
	{
		tst_init();
		dmx_pg_init.tst = true;	
	}
	if (dmx_library.b0_interface)
	{
		b0_interface_init();
		dmx_pg_init.b0_interface = true;	
	}
	if (dmx_library.abs_interface && !dmx_pg_init.abs_interface)
	{
		abs_interface_init();
		dmx_pg_init.abs_interface = true;	
	}
	dmx_pg_init.b1_core = true;	// This is 'self'

	// Are we setting a Google Analytics e-commerce conversion?
	if (document.forms.utmform)
	{
		// Run __utmSetTrans() from urchin.js (Google javascript)
		if (document.forms.utmform.utmtrans && document.forms.utmform.utmtrans.value.replace('/\s/', '').length) __utmSetTrans();
		// If there's an extra field 'transfer_url' in the utmtrans form,  call __urmLinker
		if (document.forms.utmform.transfer_url) __utmLinker(document.forms.utmform.transfer_url.value);
	}

	// Show TST debugging?
	if (tst_debug_display)
	{
		var d = document.createElement('div');
		d.style.padding 	= '12px';
		d.style.display 	= 'block';
		d.style.textAlign 	= 'left';
		d.innerHTML 		= '<br><h1>TST DEBUGGING</h1>' + tst_debug_display;
		window.document.body.appendChild(d);
	}
}
