/*
 * MappaTo JavaScript Library v1.0.0
 * http://www.comune.torino.it/
 * Copyright (c) 2009 Comune di Torino
 * Module licensed under GNU Affero GPL licenses.
 * http://www.gnu.org/licenses/agpl.html
 * Date: 2009
 */
function EventContent()
{
	this.showLuogo = function(ev, obj)
	{
		if(!objLibs.isObj(obj)) obj = this;
		if(objLibs.isObj(obj))
		{
			var currId = obj.id.replace('__','');
			var dett = document.getElementById('dett'+currId);
			if(objLibs.isObj(dett))
			{
				if(dett.style.display == 'none')
					dett.style.display = 'block';
				else
					dett.style.display = 'none';
			}
		}
		return false;
	};
	this.showPeriodi = function(ev, obj)
	{
		//alert('obj.id:'+obj.id);
		if(!objLibs.isObj(obj)) obj = this;
		if(objLibs.isObj(obj))
		{
			var currId = obj.id.replace('__','');
			var dett = document.getElementById(currId+'Container');
			if(objLibs.isObj(dett))
			{
				if(dett.style.display == 'none')
					dett.style.display = 'block';
				else
					dett.style.display = 'none';
			}
		}
		return false;
	};
	this.initEvents = function()
	{
	};
	this.init = function()
	{
		this.initEvents();
		var allChilds = document.getElementsByTagName("a");
		//objLibs.printMsgBox("fotoNewEve:"+allChilds.length);
		for (var i=0; i < allChilds.length; i++)
		{
			var currChilds = allChilds.item(i);
			//objLibs.printMsgBox("id:"+currChilds.id);
			if(currChilds.id.indexOf('luogo_') != -1)
			{
				if(currChilds.id.indexOf('__') == -1)
					objEventContent.showLuogo(null, currChilds);
				currChilds.onclick = objEventContent.showLuogo;
			}
			else if(currChilds.id.indexOf('periodiApertura') != -1)
			{
				if(currChilds.id.indexOf('__') == -1)
					objEventContent.showPeriodi(null, currChilds);
				currChilds.onclick = objEventContent.showPeriodi;
			}
		}
	};
}

/* Initialize EventContent sigleton */
function initEventContent()
{
	objEventContent = new EventContent();
	objEventContent.init();
}

function initEventContentOnLoad()
{
	if (typeof oldOnLoadEventContent == 'function') oldOnLoadEventContent();
	initEventContent();
}

/* Var sigleton instance*/
var objEventContent;

/* Event initialize */
var oldOnLoadEventContent;
if (typeof window.onload == 'function') 
	oldOnLoadEventContent = window.onload;
window.onload = initEventContentOnLoad;
