window.addEvent('domready', function () {
									  
	$$('td.cTitolo').addEvent('click', function() {
		openLay.moveLayer(this);
	});

	

	


});


var openLayer = new Class({
	initialize: function(){

		

	    
	},


	moveLayer : function(elementoCorrente){

			$('lockLayer').setStyle('height','200px');
			starter = $$('div.contentOpen')[0];
			starter2 = $(elementoCorrente.getElement('span').id.replace("h3","l"));
			currentTitle = elementoCorrente.getElement('span');
			var myTransition = new Fx.Transition(Fx.Transitions.Expo , 3);                                         
			var fx = new Fx.Morph(starter,{duration: 1000, transition: myTransition.easeInOut});                       
			fx.start('.content');	
			fx.addEvent('onComplete', function() { 
											   
												var myTransition = new Fx.Transition(Fx.Transitions.Expo , 3);                                         
												var fx2 = new Fx.Morph(starter2,{duration: 500, transition: myTransition.easeInOut});                       
												fx2.start('.contentOpen');		
												fx2.addEvent('onComplete', function() { 
											   		starter2.set('class','contentOpen');
													starter.set('class','content');
													a = $('appoggio').get('html');
													$('appoggio').set('html', currentTitle.getParent().get('html'));
													currentTitle.getParent().set('html', a);
													$('lockLayer').setStyle('height','0px');

													
												})
												
											   })



	}	
});


function contatti()
{
			errore = false;
			if ($('formContatti').nome.value=="")
			{
				$('formContatti').nome.set('class','fldError');
				errore = true;
			}
			else
			{
				$('formContatti').nome.set('class','fld');
			}

			if ($('formContatti').cognome.value=="")
			{
				$('formContatti').cognome.set('class','fldError');
				errore = true;
			}
			else
			{
				$('formContatti').cognome.set('class','fld');
			}
			
			
			
			
			var emailID=$('formContatti').email;
			

			if (echeck(emailID.value)==false){
				emailID.value=""
				emailID.focus()
				errore = true;
			}

			
			
			
			if ($('formContatti').email.value=="")
			{
				$('formContatti').email.set('class','fldError');
				errore = true;
			}
			else
			{
				$('formContatti').email.set('class','fld');
			}			
			
			
			
			
			if (errore == true)
			{
				$('outputContatti').set('html', 'Completare correttamente i campi evidenziati.');
			}
			else
			{
			
				var text = $('outputContatti');
				var req = new Request.HTML({
					url: './sendmail.php',		// l'url da contattare
					update: 'outputContatti',			// l'elemento che verrą aggiornato al completamento della richiesta
					evalScripts: false,		// gli script contenuti nel responso non verranno azionati
					onRequest: function() {
						text.set('html', 'Invio in corso...');
						//lContatti.setStyle('opacity', 0.2);
					},
					onComplete: function(tree, elements, html, js) {
						text.set('html', html);
						//lContatti.setStyle('opacity', 1);
					},
					onFailure: function() {
						text.set('html', "Si &egrave; verificato un problema nell'invio della e-mail.");
						//lContatti.setStyle('opacity', 1);
					}
				});
				
				// azioniamo la richiesta passando qualche parametro
				req.post($('formContatti'));
			}
			return false;
	

}


function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}





function login()
{
	testo = '<strong>STOP!</strong> login e password errati.';
	$('outputLogin').set('html',testo);

}


openLay = new openLayer();


