function  check_form2(strlink)
{
var email = $('email').value ;
var form = $('form2');

if (email == "")
{
alert('Il campo email è vuoto !');
$('email').focus();
return false;
}

if (!email.match(/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/)) 
{
alert('La email inserita non sembra corretta !');
$('email').focus();
return false;
}

  new Ajax.Request( '/comandi/add.newsletter.asp',{asynchronous:true,evalScripts:true, parameters:Form.serialize('form2'),
  onSuccess:function(transport)
  {
  	alert(transport.responseText);
  }
  
  });
 return false;
 
}

function  check_form1(strlink)
{
var conta = 0;
if ($('cal').selectedIndex == 0 )
{
$('data2').style.background = "#E3011B";
$('data2').style.color = "#ffffff";
conta = conta + 1 ;
}

if ($('weeks').selectedIndex == 0 )
{
$('durata').style.background = '#E3011B';
$('durata').style.color = "#ffffff";
conta = conta + 1 ;
}

if ($('regione') && $('regione').selectedIndex == 0 )
{
$('region').style.background = '#E3011B';
$('region').style.color = "#ffffff";
conta = conta + 1 ;
}

if (conta > 0 )
{
alert('I campi segnati in rosso sono obbligatori');
return false;
}

if ($('td_left'))
{
$('td_left').style.display ='none';
}

if ($('mappa'))
{
if ($('mappa').checked == true )
{

$('mainTarget').innerHTML = 'Attendi perfavore...<br><img src="/bb/images/loading.gif">';
$('form1').action = '/bb/map.test.asp' ;
$('form1').method = 'post' ;
$('form1').submit();
return false;

}
}

$('mainTarget').innerHTML = 'Attendi perfavore...<br><img src="/bb/images/loading.gif">';
  new Ajax.Updater('mainTarget', strlink,{asynchronous:true,evalScripts:true, parameters:Form.serialize('form1')});
  $('form1').reset();
  return false;
}

function delCookie() 
{
 
var cookie_date = new Date ( );  // current date & time
cookie_date.setTime ( cookie_date.getTime() - 1 );
document.cookie = "barca=;expires=" + cookie_date.toGMTString();
}

function favorites(id,del)
{
$('target2').innerHTML = '<img src="/bb/images/loading.gif"><br>Attendi perfavore...';
  new Ajax.Updater('target2','/bb/crea.preferiti.asp?id='+id+'&del='+del,
  {asynchronous:true,evalScripts:false,
  
  onFailure: function()
 {
   alert('Si è creato un errore durante la richiesta');
 }
   
  });
  return false;
}


function form1(strlink)
{
$('formMain').innerHTML = '<img src="/bb/images/loading.gif" height="40px"><br>Attendi perfavore...';
  new Ajax.Updater('formMain', strlink,{asynchronous:true,evalScripts:false});
} 

function universale(id,strlink)
{
$(id).innerHTML = '<img src="/bb/images/loading.gif" height="40px"><br>Attendi perfavore...';
 	new Ajax.Request(strlink,{asynchronous:true,evalScripts:true,
 	onSuccess: function(transport)
 	{
 	  $(id).innerHTML = transport.responseText;
 	}
 });
}

function apri_risultati(id,strlink)
{
	if ($("r"+id).style.display == 'none') 
	{
		new Effect.BlindDown("r"+id,{duration: 0.5});
		universale("r"+id,strlink);
		}
		else
		{
		new Effect.BlindUp("r"+id);
		}
	} 

function apri_faq(id)
{
new Effect.BlindDown(id,{duration: 0.5});
} 

function check_cus()
{ 
var form = $('formCus');
var conta = 0;

if ($('nome_cliente1').value == "" )
{
	conta = conta + 1;
	form.nome_cliente.style.background = "#ffff00";
} 
else
{

	form.nome_cliente.style.background = "";
} 

var email = $('email2');

if ( email.value == "" )
{
	conta = conta + 1;
	email.style.background = "#ffff00";
} 
else
{
	email.style.background = "";
} 


if (!email.value.match(/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/)) 
{
	conta = conta + 1;
	email.style.background = "#ffff00";
}
else
{
	email.style.background = "";
} 

if (form.dal.selectedIndex == 0)
{
	conta = conta + 1;
	form.dal.style.background = "#ffff00";
}
else
{
	form.dal.style.background = "";
}


if (form.weeks.selectedIndex == 0)
{
	conta = conta + 1;
	form.weeks.style.background = "#ffff00";
}
else
{
	form.weeks.style.background = "";
}


if (form.nome_base.selectedIndex == 0)
{
	conta = conta + 1;
	form.nome_base.style.background = "#ffff00";
}
else
{
	form.nome_base.style.background = "";
}


if (form.categoria.selectedIndex == 0)
{
	conta = conta + 1;
	form.categoria.style.background = "#ffff00";
}
else
{
	form.categoria.style.background = "";
}

/////////////

if (form.anno.selectedIndex == 0)
{
	conta = conta + 1;
	form.anno.style.background = "#ffff00";
}
else
{
	form.anno.style.background = "";
}



if (form.securitycode.selectedIndex == 0)
{
	conta = conta + 1;
	form.securitycode.style.background = "#ffff00";
}
else
{
	form.securitycode.style.background = "";
}

if ( conta > 0 )
{
	alert('Ci sono degli errori o alcuni campi non sono corretti\n Ti preghiamo di correggere');
	form.nome_cliente.focus();
	return false;
} 


  new Ajax.Request( '/comandi/add.richiesta.asp',{asynchronous:true,parameters:Form.serialize('formCus'),
  onSuccess:function(transport)
  {
  		 		
switch (transport.responseText)
//
{
  case "ok":
    alert('Il messaggio è stato inviato con successo\n ti risponderemo appena possibile');
  break; 
  
  case "err":
    alert('Si è creato un errore durante l\'invio del messaggio');
  break; 
  
    case "cod":
    alert('Il codice di sicurezza non è corretto');
  break; 

  case "nop":
    alert('I parametri inviati non sono corretti o sufficenti');
  break; 

}
//
  	
  }
  
  });
} 


function swap(n)
{

switch (n)
{
case 1 :
$('img1').src = "/bb/images/yacht.gif" ;
$('img2').src = "/bb/images/budget.gif" ;
$('img3').src = "/bb/images/newsletter_ypb.jpg" ;
$('img4').src = "/bb/images/myboat.gif" ;
break;
case 2 :
$('img1').src = "/bb/images/yacht_dw.jpg" ;
$('img2').src = "/bb/images/budget_up.gif" ;
$('img3').src = "/bb/images/newsletter_ypb.jpg" ;
$('img4').src = "/bb/images/myboat.gif" ;
break;
case 3 :
$('img1').src = "/bb/images/yacht_dw.jpg" ;
$('img2').src = "/bb/images/budget.gif" ;
$('img3').src = "/bb/images/newsletter_up.gif" ;
$('img4').src = "/bb/images/myboat.gif" ;
break;
case 4 :
$('img1').src = "/bb/images/yacht_dw.jpg" ;
$('img2').src = "/bb/images/budget.gif" ;
$('img3').src = "/bb/images/newsletter_ypb.jpg";
$('img4').src = "/bb/images/myboat_up.gif";
break;
} 

} 

