var flash_obj = null;

/*
 * Init functie
 */
function init() {
	detect_flash();
	
	var init_page = $('framework').getAttribute('navid');
	var init_lang = $('framework').getAttribute('lang');
	var init_news = $('framework').getAttribute('news');
	
	load_flash('framework', '/swf/framework.swf?init_page=' + init_page + '&taal=' + init_lang + '&init_news=' + init_news + '&abspath=www.lawton.nl', '100%', '100%', 8, 'framework_flash');
}

function temp_taal() {
	open_popup('tijdelijke_taalkeuze');
}

/*
 * Flash object ophalen (alle browsers)
 */ 
function get_flash_obj(movie_id) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movie_id] : document[movie_id];
}

/*
 * Navigeer functie kruimelpad
 */ 
function ga_naar_pagina_func(navid) {
	if(flash_obj == null) flash_obj = get_flash_obj('framework_flash');
	flash_obj.menu_item_click_func(navid);
}

/*
 * Nieuws functie categorie selectie
 */ 
function select_nieuws_categorie_func(cat_id) {
	if(flash_obj == null) flash_obj = get_flash_obj('framework_flash');
	flash_obj.select_nieuws_categorie_func(cat_id);
}

/*
 * Nieuws functie toon nieuwsbrief
 */ 
function show_nieuwsbrief_func() {
	if(flash_obj == null) flash_obj = get_flash_obj('framework_flash');
	flash_obj.show_nieuwsbrief_func();
}

/*
 * Wijzig professional letter
 */ 
function wijzig_professional_letter(letter) {
	if(flash_obj == null) flash_obj = get_flash_obj('framework_flash');
	flash_obj.show_professionals_func(letter);
}

/*
 * Statistieken log
 */ 
function stat_logger(navid) {
	new Ajax.Updater('stat_logger', '/ajax/stat_logger.ajax.php', { method:'post', postBody:'page_id=' + navid, asynchronous:true, evalScripts:true }); 
}

/*
 * Popup openen
 */
function open_popup(navid) {
	stat_logger(navid);
	
	var handler_func = function(t) {
		var size = t.responseText.split('|');
		
		var link = document.createElement('A');
		link.className = 'lightwindow';
		link.href = '/popup/index.php?page_id=' + navid;
		link.setAttribute('params','lightwindow_width=' + size[0] + ',lightwindow_height=' + size[1]);
		
		myLightWindow.activate(null, link);
	}
	
	new Ajax.Request('/ajax/popup_settings.ajax.php', { method:'post', postBody:'page_id=' + navid, onSuccess: handler_func, asynchronous:true, evalScripts:true });
}

window.onload.actions.push(init);
