/********************   tz1.core.en.js      ******************/
/*															 */
/*															 */
/*															 */
/*															 */
/*					 	READ THIS 							 */
/*-----------------------------------------------------------*/
/*															 */
/*  tz1.core.en.js javascript for VillaMariotti website      */
/*															 */
/*	Created by Emanuel Di Felice on Tue Feb 14 2006. 		 */
/*	Contact: info@tzfactory.it 							 	 */
/*	Homepage: http://www.tzfactory.com/ 				 	 */
/*															 */
/*---------------		MIT LICENSE        ------------------*/
/*															 */
/*															 */
/*************************************************************/
function roundCorner(id)
{
	if(id=='home')
	{
		window.onload=function()
		{
			Nifty("ul#nav a","normal transparent top bottom fixed-height");
			Nifty("#box_home","normal transparent top bottom fixed-height");
			Nifty("#box_lw_01","normal transparent top bottom fixed-height");
			Nifty("#box_lw_02","normal transparent top bottom some-height");
			Nifty("#box_lw_03","normal transparent top bottom some-height");
		}
		
	}		
	
	else if(id=='servizi')
	{
			window.onload=function()
			{
				Nifty("ul#nav a","normal transparent top bottom fixed-height");
				Nifty("#box_servizi","normal transparent top bottom fixed-height");
				Nifty("#box_lw_01","normal transparent top bottom fixed-height");
				Nifty("#box_lw_02","normal transparent top bottom some-height");
				Nifty("ul#servizi_m a","normal transparent top bottom fixed-height");
			
				
			}
		
		
	}
	else if(id=='about')
	{
			window.onload=function()
			{
				Nifty("ul#nav a","normal transparent top bottom fixed-height");
				Nifty("#box_about","normal transparent top bottom fixed-height");
				Nifty("#box_lw_01","normal transparent top bottom fixed-height");
				Nifty("#box_lw_02","normal transparent top bottom some-height");
			
				
			}
		
		
	}

	else if(id=='contact')
	{
			window.onload=function()
			{
				Nifty("ul#nav a","normal transparent top bottom fixed-height");
				Nifty("#box_contatti","normal transparent top bottom fixed-height");
				Nifty("#box_lw_01","normal transparent top bottom fixed-height");
				Nifty("#box_lw_02","normal transparent top bottom some-height");
				Nifty("#box_lw_03","normal transparent top bottom some-height");
				
			}
		
		
	}
	

}


/*-------------------------   START CHECK MAIL	-------------------------*/

function checkMail(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					
		}
		
/*-------------------------   FINE CHECKMAIL	-------------------------*/

/*-------------------------   INIZIO ACTIVEMENU	-------------------------*/
//
// Funzione per la gestione delle animazioni dei menu
//
//
function activeMenu(id_menu)
			{  	
				var tot_menu=4;
				var cont=1;
				while(cont<tot_menu+1)
						   {
						   Effect.Fade("menu"+cont,{ duration: 0.5 });
						   cont++;
						   }
				Effect.Appear("menu"+id_menu,{queue: 'end'});
				}					

/*-------------------------   FINE ACTIVEMENU	-------------------------*/

/*-------------------------   INIZIO INVIAMAIL	-------------------------*/
//
// Funzione per la gestione dell'invio della mail
//
//
function inviaMail()  
	{
	    //controllo corpo messaggio
		if($F('cmessage').length < 1)  
			{
	 		 	$('cerror').style.display = 'block';
				$('cerror').innerHTML = 'ERROR: message field required '; //inserire un messaggio.
				Effect.Pulsate('cerror');
				Effect.Fade('cerror',{queue: 'end'});

				return false;		
			}
	    
	    //controllo nome
		if($F('cname') == '')  
			{
	  			$('cerror').style.display = 'block';
				$('cerror').innerHTML = 'ERROR: name field required';//inserire il Nome.
				Effect.Pulsate('cerror');
				Effect.Fade('cerror',{queue: 'end'});
				return false;		
			}		
	    
	    //controllo subject
	//	if($F('csubject').length < 1)  
	//		{
	  //			$('cerror').style.display = 'block';
		//		$('cerror').innerHTML = 'ERRORE: oggetto richiesto'; //inserire l\'oggetto.
		//		Effect.Pulsate('cerror');
		//		Effect.Fade('cerror',{queue: 'end'});
		//		return false;		
		//	}
		
		//controllo email
		if(!checkMail($F('cemail')))  
			{
				$('cerror').style.display = 'block';
				$('cerror').innerHTML = 'ERROR: mail field required.';
				Effect.Pulsate('cerror');
				Effect.Fade('cerror',{queue: 'end'});
				return false;
			}

		else 
	
			{   
				$('cspinner').style.visibility = 'visible';
				var url = '../src/inviamail.php';
				pars =  '&email=' + $F('cemail') + '&name=' + $F('cname') +'&message=' + $F('cmessage');// 'subject=' + $F('csubject') '&url=' + $F('curl') + 
    			url=url+'?'+pars;
 				var myAjax = new Ajax.Request(
				url, 
				{
					method: 'post', 
					onComplete: finishMail
				});
 		
 		
	 		}
	 

	 
	}
/*-------------------------   FINE INVIAMAIL	-------------------------*/

/*-------------------------   INIZIO FINISHMAIL	-------------------------*/
//
// Funzione per la gestione del form dopo l'invio
//
//
	 function finishMail()  {
 		
			$('cspinner').style.visibility = 'hidden';
			$('cname').value='';
			$('cemail').value='';
			//$('csubject').value='';
		    $('cmessage').value='';
			$('cerror').style.display = 'block';
			$('cerror').innerHTML = 'MESSAGE SENT';
			Effect.Pulsate('cerror');
			Effect.Fade('cerror',{queue: 'end'});


		}
/*-------------------------   FINE FINISHMAIL	-------------------------*/

/*-------------------------   INIZIO RESETERROR	-------------------------*/
//
// Funzione per la gestione del box d'errore
//
//
function resetError()
{
	$('cname').value='';
	$('cemail').value='';
	//$('csubject').value='';
	$('cmessage').value='';
	$('cerror').style.display = 'none';

}
/*-------------------------   FINE RESETERROR	-------------------------*/
        
