/**********************************************************************************
* phpComasy Web Content Management System                                         *
* http://www.phpcomasy.com                                                        *
*                                                                                 *
* Copyright (c) 2005 - 2012 indual GmbH (http://www.indual.ch)                    *
*                                                                                 *
* phpComasy is released under his own licence (http://www.phpcomasy.com/licence)  *
**********************************************************************************/

// some javascript functions

// confirmation function
function ask(question, href) {
	if (confirm(question) == true) {
		window.location.href = href;
	}
}

// include css files
function include_fontsize_css(fontsize, template_folder, reload_styles) {
	// mark current size
	if (reload_styles == true) {	
		change_fontsize_class_names(fontsize);
	}
	// create css link in html header
	var css	= document.createElement('link');
	css.rel = 'stylesheet'
	css.type = 'text/css';
	css.href = 'templates/'+template_folder+'/css/fontsize_switcher/'+fontsize+'.css';
	document.getElementsByTagName('head')[0].appendChild(css);
	// ajax request to save and keep chosen font size
	new Ajax.Request('ajax_handler.php?action=fontsize_switcher&new_font_size='+fontsize);
}

// activate/deactivate font size labels
function change_fontsize_class_names(fontsize) {
	// init every fontsize link
	$$('div#fontsize_switcher a').each(function(element) {
	  element.className = 'static';
	});
	// highlight current fontsize
	$('fontsize_switcher_'+fontsize).className = fontsize+' current';
}
