function testCaca()
{
	alert('lalala');
}

function loadPics()
{
	for (var i = 0; i<=5; i++)
	{
		if ($('pic'+i))
		{
			$('pic'+i).style.visibility = 'visible';
			$('pic'+i).style.opacity = 0;
			$('pic'+i).style.filter = 'alpha(opacity=0)';
			
		
			new Effect.Opacity('pic'+i, {
				queue: 'end',
				duration: 0.5,
				from:0.0, 
				to:1.0
			});
		}
	}
}

function montre(id)
{
	for (var i = 0; i<=10; i++)
	{
		if ($('smenu'+i))
		{
			$('smenu'+i).hide();
		}
	}
	
	if ($('smenu'+id))
	{
		$('smenu'+id).show();
	}
}

var newWin = null;

function closeWin()
{
	if (newWin != null)
	{
		if(!newWin.closed) newWin.close();
	}
}

function popup()
{
	closeWin();
	var strOptions="status,height=200,width=300";
	newWin = window.open('retrieve_pass.php', 'newWin', strOptions);
	newWin.focus();
} 

function loadContent(page)
{
	//alert('appele : '+page);
	cache();
	/*if(page != 'login')
	{
		$('pageContent').className = '';
	}
	else
	{
		$('pageContent').className = 'login';
	}*/
	
	$('pageContent').className = 'whiteBG';
	
	
	new Ajax.Request('ajax.php', {
	method: 'get',
	onLoading: function()
	{
		//$('pageContent').innerHTML = "<div style='text-align:center; margin-top:80px'><img src='images/ajax-loader.gif' /></div>";
	},
	onComplete: function(reponse)
	{
	
			/*var aDebug	= new Array();
			
			for (var sDebug in reponse)
			{
				aDebug.push(sDebug + ' = ' + reponse[sDebug]);
			}
			alert(aDebug.join('\n'));*/

		if(reponse.responseXML)
		{
			//console.debug('oui reponsexml docelement');
			var xml = reponse.responseXML.documentElement;
			
			window.document.title = 'St. Paul\'s Episcopal Church - '+xml.childNodes[0].firstChild.nodeValue;
			$('pageContent').innerHTML = xml.childNodes[1].firstChild.nodeValue;
		}
	},
	parameters: {page: page}
	});
}


function cache()
{
	for (var i = 0; i<=10; i++)
	{
		if ($('smenu'+i))
		{
			$('smenu'+i).hide();
		}
	}
}


var picGallery = Class.create();

picGallery.prototype = {

	initialize: function(aElems)
	{
		this.aElems = aElems;
		this.message = 'survole !!!';
		//console.debug(aElems.length);
		
		for (var i = 0; i < this.aElems.length; i++)
		{
			//console.dir(this.aPics[ePic]);
			//this.aElems[i].observe('mouseover', this.mouseOver());
			//Event.observe('signinForm', 'submit', function(event)
			this.aElems[i].onmouseover = this.mouseOver.bindAsEventListener(this, i);
			this.aElems[i].onmouseout = this.mouseOut.bindAsEventListener(this, i);
		}
	},
	  
	mouseOver: function(event, numPic)
	{
		//alert(event.target);
		
			/*var aDebug	= new Array();
			
			for (var sDebug in event.toElement)
			{
				aDebug.push(sDebug + ' = ' +event.toElement[sDebug]);
			}
			alert(aDebug.join('\n'));*/
			
		//console.dir(event);
		
		/*if(event.toElement == $('pic'+numPic))
		{
			this.changeOpacity($('pic'+numPic), 1.0, 0.4);
		}*/
		$('pic'+numPic).style.opacity = 0.4;
		$('pic'+numPic).style.filter = 'alpha(opacity=40)';
		montre(numPic);

	},
	  
	mouseOut: function(event, numPic)
	{
		/*if(event.target == $('pic'+numPic))
		{
			this.changeOpacity($('pic'+numPic), parseFloat($('pic'+numPic).style.opacity), 1.0);
		}*/
		
		$('pic'+numPic).style.opacity = 1;
		$('pic'+numPic).style.filter = 'alpha(opacity=100)';
		
	},
	
	changeOpacity: function(ePic, deb, fin)
	{
		new Effect.Opacity(ePic, {
			duration: 0.3,
			from: deb, 
			to: fin
		});
	},
	
	sendConsole: function(evt)
	{
		console.debug(this.message + ' (' + evt.type + ')');
		console.debug(evt.target);
	}
};