/**
 * Include script for CHAI Friends website.
 * 
 * @author R.J.T. de Vries <rdevries@thirdwave.nl>
 * @version 1.00, 04/26/2007
 * @access public
 * @package AJAX Framework
 */
 
//------------------------------------------------------------------------------
// PHASE I: INCLUDE ALL NECESSARY JAVASCRIPT FILES.
//------------------------------------------------------------------------------
document.write("<script src='/cms/jscripts/cms.event.js'></script>");
document.write("<script src='/cms/jscripts/cms.functions.js'></script>");
document.write("<script src='/inc/jscripts/ddMenus.js'></script>");
document.write("<script src='/inc/jscripts/Formhandler.js'></script>");
document.write("<script src='/inc/jscripts/PregnancyCalculator.js'></script>");
document.write("<script src='/inc/jscripts/BMICalculator.js'></script>");
document.write("<script src='/inc/jscripts/ComplicationFormHandler.js'></script>");
document.write("<script src='/inc/jscripts/reactions.js'></script>");
document.write("<script src='/cms/jscripts/sarissa/sarissa.js'></script>");
document.write("<script src='/cms/jscripts/xmlhttp/XMLHttp.js'></script>");
document.write("<script src='/cms/jscripts/xmlhttp/XMLProcessor.js'></script>");
document.write("<script src='/cms/jscripts/xmlhttp/Data.js'></script>");

//------------------------------------------------------------------------------
// PHASE II: INITIALIZATION FUNCTION, CALLED ON DOCUMENT LOAD EVENT
//------------------------------------------------------------------------------

/**
 * Object instance of Formhandler.
 * @var object formhandler
 */
var formhandler;

/**
 * Object instance for handling the complication form.
 * @var object complicationFormHandler
 */
var complicationFormHandler;

/**
 * Object instance for handling VAS sliders.
 * @var object vas
 */
var vas;

/**
 * Instance of XMLHttp object, used for XML HTTP data communication.
 * @var object xmlhttp
 * @access global
 */
var xmlhttp = null;

/**
 * Instance of XMLProcessor object, used for XML data processing.
 * @var object xmlprocessor
 * @access global
 */
var xmlprocessor = null;

/**
 * Instance of Data object, used for saving form data.
 * @var object data
 * @access global
 */
var data = null;

/**
 * Instance of ddMenus object.
 * @var object ddmenus
 * @access global
 */
var ddmenus;

/**
 * Instance of PregnancyCalculator object.
 * @var object pregnancyCalculator
 * @access global
 */
var pregnancyCalculator = null;

/**
 * Instance of BMICalculator object.
 * @var object bmiCalculator
 * @access global
 */
var bmiCalculator = null;

/**
 * Initialize website. Called from <body> tag.
 *
 * Starts with calling the ddinit() function which initializes the dropdown
 * menus in the website. After that, the current document is checked for forms
 * in which special events need to be attached to form elements. (such as a
 * select element that needs an onchange event.) Finally, I.E. is instructed 
 * not to keep a background-image cache, as that keeps I.E. from flickering on
 * mouseover.
 * 
 * @return 	void
 * @access	public
 */
function init() {
	var title;

	ddmenus = new ddMenus;
	if ( !ddmenus.init() ) {
		alert('Dropdown menus kunnen niet worden geactiveerd');
	}
	
	formhandler = new Formhandler;
	formhandler.init();
	
	complicationFormHandler = new ComplicationFormHandler;
	complicationFormHandler.init();
	
	pregnancyCalculator = new PregnancyCalculator;
	pregnancyCalculator.init();
	
	bmiCalculator = new BMICalculator;
	bmiCalculator.init();
	
	// set objects required for AJAX-handling.
	xmlhttp = new XMLHttp();
	xmlhttp.init();
	
	xmlprocessor = new XMLProcessor();
	xmlprocessor.init();

	data = new Data();
	data.init();
	
	set_select_values();
	
	if ( typeof Vas != 'undefined' ) {
		vas = new Vas;
		vas.init();
	}
	
	if ( title = document.getElementByAttribute('className', 'topbar', 'div') ) {
		addEvent(title, 'click', function() { document.location = '/'; });
	}
} // init()

window.onload = init;

/* end of include script */
