/**
 * Initializes the User Interface. See code comments for actual initialization
 * order and setup
 */
function initUI($) {

	switch (window.pageId) {
	case "homepage": {
		// set up both view switches
		$(".view-switcher").viewSwitcher();

		// init the carousel
		initCarousel("#carousel1");

		// start keeping equal height
		equalHeight( [ $("#content-wrapper .col1of2:first"),
				$("#content-wrapper .col2of2:first") ], [
				$("#content-wrapper .col1of2:first .box:first"),
				$("#content-wrapper .col2of2:first .box:first") ], true);
		break;
	}
	case "thema": {
		// start keeping equal height
		equalHeight( [ $("#content-wrapper .col1of2:first"),
				$("#content-wrapper .col2of2:first") ], [
				$("#content-wrapper .col1of2:first .box:first"),
				$("#content-wrapper .col2of2:first .box:first") ], false);
		break;
	}
	case "content": {
		artikelSubnavigatie();
	}
	case "validated-form": {
		initFormValidation(".validated-form");
		addSpecialFormFieldHandlers();
	}
	default:
		break;
	}
	// style select box for search
	$("#search-area").customiseSelect( {
		optionsTop :"20px",
		functionOnChange :searchAreaChangeActionToSelectedVal
	});

	$(".box.no-ds").addBorderElements();
	$(".box").not("#search-side-info").addBorderElements( {
		type :$.fn.addBorderElements.CORNERS_AND_SIDES
	});

	initCollapsibleSections();
	initSearchFromWithinTabs();
	makePopupLinks();

	// Fix background image caching problem
	if (nza.globals.ieVersion == 6) {
		try {
			document.execCommand("BackgroundImageCache", false, true);
		} catch (err) {
		}
	}
}

/**
 * Initializes the application. See code comments for actual initialization
 * order and setup
 */
function initApp($) {
	// being 'handheld' is actually determined by the device's capability to
	// understand the css definitions for screens less wide than 640px (see css
	// last section)
	nza.globals.isHandheld = $("#smallscreen-trigger").css("display") == "block" ? true
			: false;
	nza.globals.ieVersion = ($.browser.msie) ? $.browser.version : 99;

	switch (window.pageId) {
	case "homepage": {
		break;
	}
	default:
		break;
	}
}

jQuery( function($) {

	window.pageId = $("body").get(0).id;

	initApp($);
	initUI($);
});

