/**
 * @author SECI
 */

function salva_email(e)
	{			
		Event.stop(e);
		options = {
			method: 'post',
			postBody: 'email='+$F('email_newsletter')+'&action=iscriviti',
			onSuccess: conferma_salva_email
		};
			
			new Ajax.Request($F('lingua_newsletter')+'/modulo/newsletter.htm', options);
	}
		
function conferma_salva_email(t){
	alert(t.responseText);
	if (t.responseText == 'Iscrizione effettuata') 
		$('email_newsletter').value == '';
}

function indietro(e){
	Event.stop(e);
	history.back();
}

function on_load_event(e){
  
  var flashvars = {};
  var params = {loop: 'false'};
  var attributes = {};

	swfobject.embedSWF(
	  "webapp/files/banner-cs5.swf", 
		"lay_header", 
		"1000", 
		"150", 
		"8",
		"libs/SWFObject/expressInstall.swf",
		flashvars,
		params,
		attributes
	);	
	
	if($('home_presentazione'))
		swfobject.embedSWF(
		  "webapp/files/presentazione.swf", 
			"home_presentazione_flash", 
			"700", 
			"425", 
			"8",
			"libs/SWFObject/expressInstall.swf",
			flashvars,
      params,
      attributes
		);	
		
  if($('mappa_referenti'))
    swfobject.embedSWF(
      "webapp/files/italia.swf", 
      "mappa_referenti", 
      "700", 
      "425", 
      "8",
      "libs/SWFObject/expressInstall.swf",
      flashvars,
      params,
      attributes
    );  
	
	if($('gallery')) jQuery('#gallery').jcarousel({
		wrap: 'circular',
		auto: 3,
		scroll: 1	
	});

	if($('news')) jQuery('#news').jcarousel({
		wrap: 'circular',
		vertical: true,
		auto: 5,
		scroll: 1,
		visible: 1	
	});
		
  	nifty_start();
  
	if($('iscrizione_newsletter'))
		$('iscrizione_newsletter').observe('submit', salva_email);	
	
	if($('back'))
		$('back').observe('click', indietro);
}

function nifty_start(){
	Nifty("div#presentazione","big");
	Nifty("div.galleria","big");
	Nifty("div.lay_box","");
	Nifty("div#lay_footer","bottom");
}

Event.observe(window, 'load', on_load_event);
