
function myInit(){}

function msg(txt) {
	if (typeof(txt) != 'string') txt = 'www.scuoledinfanzia.net';
	$jq('#msgbox').text(txt);
}

function componi_lettera() {
	var casellario = 'maicontrollore@cancellinodalavagna.meltcontrollore@cancellinodalavagna.meo:' + GLOB_posta_pre + '@controllore@cancellinodalavagna.me' + GLOB_posta_post + 'controllore@cancellinodalavagna.me';
	document.location = casellario.replace(/controllore@cancellinodalavagna.me/g, '');
	return false;
}

$jq(document).ready(function() {
	$jq('#header .sc')
		.click(function() { document.location = GLOB_base + 'go.php?sc=' + GLOB_qs_sc; })
		.hover(function() { msg('Pagina iniziale di:' + GLOB_denominazione); }, msg)
	;

	$jq('#header .hp')
		.click(function() { document.location = GLOB_base + 'index.htm'; })
		.hover(function() { msg('Ritorna alla HOME PAGE'); }, msg)
	;

	$jq('a').filter(function(indexInJQueryObject) {
		$this = $jq(this);
		if (
				($this.hasClass('foto')) ||
				($this.attr('rel') && $this.attr('rel').match(/^lightbox/)) ||
				($this.find('img.foto','img[rel^=lightbox]').length > 0)
			) {
				var ret = $this.attr('href').match(/\.(png|gif|jpg)$/i);
				return ret;
		}
		return false;
	}).lightBox({
		 imageBaseDir: GLOB_lightbox
		,captionFunction: function (current,length,showGroup,groupName) {
			var $ret = 'Immagine <b>' + current + '</b> di <b>' + length + '</b>.';
			if (showGroup && groupName) $ret += ' Gruppo: <b>' + groupName + '</b>';
			return $ret;
		}
	}).addClass('foto-link').bind('mouseover mouseout', function() {
		$jq(this).toggleClass('foto-link-hover');
	});

	myInit();
});


//
// -------------------------------------------------------------------
//

var DEBUG_max_sub_level = 5;
var DEBUG_max_vars = 50;
var DEBUG_cur_vars = 0;
var DEBUG_tab = '\t';
function debug(o,prefix,level) {
	var init = (arguments.length == 1);
	var out = '';
	if (init) {
		DEBUG_cur_vars = 0;
		level = 0;
		prefix = '';
		var name = o.id || o.name || '';
		if (name.length > 0) {
			out = name;
			prefix = DEBUG_tab + prefix;
		}
	}
	switch (typeof(o)) {
		case 'string':
		case 'integer': out += prefix + o; break;
		case 'function': out += prefix + o + ' ** function **'; break;
		case undefined: out += prefix + o + ' ** undefined **'; break;
		case 'array':
		case 'object':
			for (var j in o) {
				DEBUG_cur_vars++;
				var br = '\n';
				if (DEBUG_cur_vars > DEBUG_max_vars) {
					out += '\n\n... and more (limit reached!)';
					break;
				} else {
					var sub = o[j];
					if (typeof(sub) == 'function') {
						txt = '   *** function';
					} else {
						if (typeof(sub) != 'object') {
							txt = ' : ' + sub;
						} else {
							level++;
							if (level > DEBUG_max_sub_level) {
								txt = '\n\n... and more sub-levels';
								break;
							} else {
								txt = '\n' + debug(sub, prefix + DEBUG_tab, level + 1);
								br = '';
							}
						}
					}
					out += prefix + '.' + j + txt + br;
				}
			}
			break;
	}
	if (init) {
		alert(out);
	} else {
		return out;
	}
}
