/**
 * Include script for Aerodynamics website.
 * 
 * @author R.J.T. de Vries <rdevries@thirdwave.nl>
 * @version 1.00, 04/26/2007
 * @access public
 * @package Aerodynamics
 */
 
//------------------------------------------------------------------------------
// 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='/cms/jscripts/cms.dateinput.js'></script>");
document.write("<script src='/inc/jscripts/ddMenus.js'></script>");
document.write("<script src='/inc/jscripts/FormDependencies.js'></script>");
document.write("<script src='/inc/jscripts/jquery-1.5.2.min.js'></script>");
document.write("<script src='/inc/jscripts/jquery.placeholder.js'></script>");
document.write("<script src='/inc/jscripts/jquery.fancybox-1.3.4.js'></script>");
document.write("<script src='/inc/jscripts/jquery.cycle.all.js'></script>");

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

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

/**
 * Instance of Photoalbum object.
 * @var object changeImage
 * @access global
 */
var changeImage = false;

/**
 * Instance of the FormDependencies object.
 * @var object formDependencies
 * @access global
 */
var formDependencies = null;

/**
 * Date input management object, that takes care of automatically continuing to
 * next field input.
 * @var object dateInput
 * @access global
 */
var dateinput = null;

/**
 * The image zoom object, taking care of the expansion of the header image.
 * @var object imageZoom
 * @access global
 */
var imageZoom = null;

//------------------------------------------------------------------------------
// PHASE III: DEFINITION OF INITIALIZATION AND HELPER FUNCTIONS
//------------------------------------------------------------------------------

/**
 * Add a script dynamically
 */
function addScript(location, callback) {
	var script = document.createElement("script");
	script.setAttribute("type", "text/javascript");
	script.setAttribute("src", location);
	script.onload = function() {
		if ( callback && ((typeof callback) == (typeof function(){})) ) {
			callback();
		}
	};
	script.onreadystatechange = function() {
		if ( script.readyState == 'complete' || script.readyState == 'loaded' ) {
			script.onload();
		}
	};
	document.body.appendChild(script);
} // addScript();

/**
 * Initialize website. Called from <body> tag.
 *
 * Starts with calling the ddinit() function which initializes the dropdown
 * menus in the website.
 * 
 * @return 	void
 * @access	public
 */
function init() {
	ddmenus = new ddMenus;
	if ( !ddmenus.init() ) {
		alert('Dropdown menus kunnen niet worden geactiveerd');
	}
	
	set_select_values();
	
	addScript("/inc/jscripts/jquery.placeholder.js");

	
//	function slideSwitch() {
//		var $active = $('#slideshow IMG.active');
//	  if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

		// use this to pull the images in the order they appear in the markup
//		var $next =  $active.next().length ? $active.next()
//				: $('#slideshow IMG:first');

		// uncomment the 3 lines below to pull the images in random order

//		var $sibs  = $active.siblings();
//		var rndNum = Math.floor(Math.random() * $sibs.length );
//		var $next  = $( $sibs[ rndNum ] );


//		$active.addClass('last-active');

//		$next.css({opacity: 0.0})
//				.addClass('active')
//				.animate({opacity: 1.0}, 1000, function() {
//				    $active.removeClass('active last-active');
//				});
//	}

//	$(function() {
//	    setInterval( "slideSwitch()", 5000 );
//	});

	// set formdependencies.
	formDependencies = new FormDependencies;
	formDependencies.init();

	// initialize dateinput.
	dateinput = new Dateinput;
	dateinput.init();
} // init()

window.onload = init;

/* end of include script */
