
function playintro()
{      
	
	jQuery(function( $ ){	
			
			jQuery.preload( [ 'intro1' ], {
				base:'./css/images/intro/',
				ext:'.jpg',
				onComplete:function( data ){
					
					var img1 = new Image();
					img1.src = data.image;
					//jQuery('#s1').append(img1);
					
					
					
					jQuery.preload( [  'intro5' ], {
						base:'./css/images/intro/',
						ext:'.jpg',
						onComplete:function( data ){
							
							var img2 = new Image();
							img2.src = data.image;
							//jQuery('#s1').append(img2);
							
							
							jQuery.preload( [ 'intro4' ], {
								base:'./css/images/intro/',
								ext:'.jpg',
								onComplete:function( data ){
									
									var img3 = new Image();
									img3.src = data.image;
									//jQuery('#s1').append(img3);
									
										
									jQuery.preload( ['intro3' ], {
										base:'./css/images/intro/',
										ext:'.jpg',
										onComplete:function( data ){
											
											var img4 = new Image();
											img4.src = data.image;
										//	jQuery('#s1').append(img4);
											
											
											jQuery.preload( [ 'intro2' ], {
												base:'./css/images/intro/',
												ext:'.jpg',
												onComplete:function( data ){
													
													var img5 = new Image();
													img5.src = data.image;
													
													jQuery('#s1').append(img1);
													jQuery('#s1').append(img2);
													jQuery('#s1').append(img3);
													jQuery('#s1').append(img4);
													jQuery('#s1').append(img5);
													
													
													
													
												},
												
												onFinish:onFinish
												
												
											});
											
											
										}
										
										
									});
									
									
								}
								
								
							});
							
							
						}
						
						
					});
					
					
					
				}
				
				
			});
		});
		

		function onFinish()
		{
			
			
			jQuery('#s1').cycle({ 
					
					fx : 'fade' , 
					autostop:4 , 
					startingSlide: 0,
					speed: 3000, 
					end: entra,
					after:fadeloading
					
			} );
				
				function entra()
				{
					jQuery('#skipintro').fadeOut('slow');
					jQuery('#entra').fadeIn('slow');
					
				}
				function fadeloading()
				{
					document.getElementById('loadings').style.display='none';
					jQuery('#skipintro').fadeIn();
				}
		}
			
   		

	
}
function skip()
{

	

	Effect.toggle('menu', 'blind');
	Effect.toggle('footer', 'blind');
	Effect.toggle('areaprivata', 'blind');

	
	
	

	new Effect.Move('freccia', {x: 5, y: 6, mode: 'absolute', transition: Effect.Transitions.spring });
}

function apri()
{

	Effect.toggle('news','blind');
}
function eff(x)
{
	new Effect.Opacity(x, { duration: 0.5, transition: Effect.Transitions.linear, from: 1.0, to: 0.2 });
}
function effout(x)
{
	new Effect.Opacity(x, { duration: 0.5, transition: Effect.Transitions.linear, from: 0.2, to: 1.0 });
}

function atelier()
{
	jQuery.ajax({
		type: "POST",
		url: "funzioni.php",
		data: "funzione=atelier",
		success: function(html){
			jQuery("#main_c").html(html);
		}
	});
		
	new Effect.Move('freccia', { x: 165, y: 8, mode: 'absolute', transition: Effect.Transitions.spring });
	
}
function abito()
{

	
		jQuery.ajax({
		type: "POST",
		url: "funzioni.php",
		data: "funzione=abito",
		success: function(html){
			jQuery("#main_c").html(html);
		}
	});
	new Effect.Move('freccia', { x:6, y: 8, mode: 'absolute', transition: Effect.Transitions.spring} );
	
}

function galleria()
{	
		document.getElementById('news').style.visibility='visible';
		
		
		jQuery.ajax({
		type: "POST",
		url: "funzioni.php",
		data: "funzione=galleria",
		success: function(html){
			
			jQuery("#main_c").html(html);
			jQuery('#boxmenuh').accordion({ 
				active: false, 
				header: '.menuheader', 
				navigation: true, 
				event: 'click', 
				fillSpace: true, 
				alwaysOpen: false,
				animated: 'bounceslide' ,
				autoheight: false 
				
			});
			
		}
		
	});
	new Effect.Move('freccia', { x:262 , y:8, mode: 'absolute', transition: Effect.Transitions.spring});
			
				
}




function contattaci()
{
	
	jQuery.ajax({
		type: "POST",
		url: "funzioni.php",
		data: "funzione=contattaci",
		success: function(html){
			jQuery("#main_c").html(html);
		}
	});
	new Effect.Move('freccia', { x: 373, y: 8, mode: 'absolute', transition: Effect.Transitions.spring });
	
}

function guestbook()
{
	
	jQuery.ajax({
		type: "POST",
		url: "funzioni.php",
		data: "funzione=guestbook",
		success: function(html){
			jQuery("#main_c").html(html);
		}
	});
	new Effect.Move('freccia', { x: 488, y: 8, mode: 'absolute', transition: Effect.Transitions.spring});
}

function partner()
{
	
	jQuery.ajax({
		type: "POST",
		url: "funzioni.php",
		data: "funzione=partner",
		success: function(html){
			jQuery("#main_c").html(html);
			document.getElementById("mainfiori").style.display = 'none';
			jQuery('#accordion-1').easyAccordion({ 
			autoStart: true, 
			slideInterval: 4000,
			slideNum:false				
			}); 

		}
	});
	new Effect.Move('freccia', { x: 608, y: 8, mode: 'absolute', transition: Effect.Transitions.spring});
									
	
}

function news()
{
	
	//new Effect.Move('freccia', { x: 514, y: 116, mode: 'absolute', transition: Effect.Transitions.spring });
	if(document.getElementById("newsbox").style.display=='none')
	{
		jQuery.ajax({
			type: "POST",
			url: "funzioni.php",
			data: "funzione=news",
			beforeSend: function(){
				jQuery("#newsbox").html("<img style='margin-top:90px; margin-left:70px;' src='./css/images/lightbox/loading.gif'>");
			},
			success: function(html){
				
				jQuery('#newsbox').html(html);
			}
		});
	}

		Effect.toggle('newsbox','blind');
		new Effect.Opacity('newsbox', { duration: 0.5, transition: Effect.Transitions.linear, from: 1.0, to: 0.8 });
}

function shownews(chiudi)
{	jQuery.ajax({
		type: "POST",
		url: "funzioni.php",
		data: "funzione=shownews",
		success: function(html){
		
			jQuery("#main_c").html(html);
		}
	});
	if(chiudi==0)
	{
		Effect.toggle('newsbox','blind');
	}
	new Effect.Move('freccia', { x: 767, y: 8, mode: 'absolute', transition: Effect.Transitions.spring });


}


function transition()
{
	jQuery('#s1').cycle('fade')	

}

//Nuovo messaggio guestbook
function nuovomex(){
	jQuery.ajax({
		type: "POST",
		url: "funzioni.php",
		data: "funzione=nuovomex",
		success: function(html){
			
			jQuery("#main_c").html(html);
		}
	});

}
//Salvataggio messaggio guestbook
function salvamex(){

	var nome=document.getElementById('nome').value;
		var testo=document.getElementById('testo').value;
	jQuery.ajax({
		type: "POST",
		url: "funzioni.php",
		data: "funzione=salvamex&nome="+nome+"&testo="+testo,
		success: function(html){
			
			jQuery("#main_c").html(html);
		}
	});

}
//elimina messaggio guestbook
function eliminamex(id){

	
	jQuery.ajax({
		type: "POST",
		url: "funzioni.php",
		data: "funzione=eliminamex&id="+id,
		success: function(html){
		
			jQuery("#main_c").html(html);
		}
	});

}

function boxlogin()
{
	
	jQuery.ajax({
		type: "POST",
		url: "funzioni.php",
		data: "funzione=log",
		success: function(html){

			jQuery("#login").html(html);
		}
	});
	Effect.toggle('login','blind');
	new Effect.Opacity('login', { duration: 0.5, transition: Effect.Transitions.linear, from: 1.0, to: 0.8 });
}

function login()
{
	var user = document.getElementById('username').value; 
	var password = document.getElementById('password').value;
	jQuery.ajax({
		type: "POST",
		url: "funzioni.php",
		data: "funzione=login&username="+user+"&password="+password,
		success: function(html){
			
			jQuery("#login").html(html);
		}
	});

}

function nuovanews()
{
	
	jQuery.ajax({
		type: "POST",
		url: "funzioni.php",
		data: "funzione=inserimentonews",
		success: function(html){
			
			jQuery("#main_c").html(html);
		}
	});

}



function savenews()
{
	var titolo = document.getElementById('titolo').value; 
	var descrizione = document.getElementById('descrizione').value;
	jQuery.ajax({
		type: "POST",
		url: "funzioni.php",
		data: "funzione=savenews&titolo="+titolo+"&descrizione="+descrizione,
		success: function(html){
		
			jQuery("#main_c").html(html);
		}
	});
	
}

function pagernews(a)
{
	jQuery.ajax({
		type: "POST",
		url: "funzioni.php?pageID="+a,
		data: "funzione=shownews",
		success: function(html){
			
					jQuery("#main_c").html(html);
				}
	});
			
}
function pagerguestbook(a)
{
	jQuery.ajax({
		type: "POST",
		url: "funzioni.php?pageID="+a,
		data: "funzione=guestbook",
		success: function(html){
			
					jQuery("#main_c").html(html);
				}
	});
			
}
function aprinews(id,chiudi)
{
	jQuery.ajax({
		type: "POST",
		url: "funzioni.php",
		data: "funzione=aprinews&id="+id,
		success: function(html){
					
					jQuery("#main_c").html(html);
					
				}
	});
	if(chiudi==0)
	{
		Effect.toggle('newsbox','blind');
	}
	new Effect.Move('freccia', { x: 767, y: 8, mode: 'absolute', transition: Effect.Transitions.spring });
}
function eliminanews(id)
{
	jQuery.ajax({
		type: "POST",
		url: "funzioni.php",
		data: "funzione=eliminanews&id="+id,
		success: function(html){
			
					jQuery("#main_c").html(html);
				}
	});
}
function logout()
{
	jQuery.ajax({
		type: "POST",
		url: "funzioni.php",
		data: "funzione=logout",
		success: function(html){
			
					jQuery("#login").html(html);
				}
	});
	jQuery.ajax({
		type: "POST",
		url: "funzioni.php",
		data: "funzione=atelier",
		success: function(html){
			
					jQuery("#main_c").html(html);
				}
	});
	new Effect.Move('freccia', { x: 6, y: 8, mode: 'absolute', transition: Effect.Transitions.spring });
		Effect.toggle('login','blind');
}
function inviomail()
{
	
	var nome = document.getElementById('nome').value; 
	var cognome = document.getElementById('cognome').value;
	var email = document.getElementById('email').value; 
	var testo = document.getElementById('testo').value;
	jQuery.ajax({
		type: "POST",
		url: "funzioni.php",
		data: "funzione=inviomail&nome="+nome+"&cognome="+cognome+"&email="+email+"&testo="+testo,
		success: function(html){
			
					jQuery("#main_c").html(html);
				}
	});
}

//Funzione per limitare il numero di caratteri della textarea
function countAreaChars(areaName,counter,limit)
{
if (areaName.value.length>limit)
areaName.value=areaName.value.substring(0,limit);
else
counter.value = limit - areaName.value.length;
}

function marcaErrore(campo,colore)
{
	campo.style.borderColor = colore;
}

function conferma_news()
{
	var titolo = document.getElementById('titolo');
	var descrizione = document.getElementById('descrizione');
	
	document.getElementById('titolo_error').style.display='none';
	document.getElementById('descrizione_error').style.display='none';

	marcaErrore(titolo,"rgb(0,0,0)");
	marcaErrore(descrizione,"rgb(255,255,255)");
	
	if (titolo.value == '')
	{
		marcaErrore(titolo,"rgb(255,0,0)");
		document.getElementById('titolo_error').style.display='block';
	}	
	
	if (descrizione.value == '')  
	{
		marcaErrore(descrizione,"rgb(255,0,0)");
		document.getElementById('descrizione_error').style.display='block';
	}	
	if(document.getElementById('titolo_error').style.display=='block')
	{
		titolo.select();

	} 
	else
	{
		if(document.getElementById('descrizione_error').style.display=='none')
		{
			savenews();
		
		} 
				
	}
}

function conferma_guestbook()
{
	
	var nome = document.getElementById('nome');
	var testo = document.getElementById('testo');
	
	document.getElementById('nome_error').style.display='none';
	document.getElementById('testo_error').style.display='none';

	marcaErrore(nome,"rgb(0,0,0)");
	marcaErrore(testo,"rgb(255,255,255)");
	
	if (nome.value == '')
	{
		marcaErrore(nome,"rgb(255,0,0)");
		document.getElementById('nome_error').style.display='block';
	}	
	
	if (testo.value == '')  
	{
		marcaErrore(testo,"rgb(255,0,0)");
		document.getElementById('testo_error').style.display='block';
	}	
	if(document.getElementById('nome_error').style.display=='block')
	{
		nome.select();

	} 
	else
	{
		if(document.getElementById('testo_error').style.display=='none')
		{
			
			salvamex();
		
		
		}		
	}
}


function cerimonia()
{
	jQuery.ajax({
		type: "POST",
		url: "funzioni.php",
		data: "funzione=cerimonia",
		success: function(html){
				
					jQuery.fancybox(html);
					
					galleria_ad();
				}
	});
}
function sposa()
{
	jQuery.ajax({
		type: "POST",
		url: "funzioni.php",
		data: "funzione=sposa",
		success: function(html){
				
					jQuery.fancybox(html);
					
					galleria_ad();
				}
	});
}
function video()
{
	jQuery.ajax({
		type: "POST",
		url: "funzioni.php",
		data: "funzione=video",
		success: function(html){
				
				jQuery("#main_c").html(html);
				}
	});
}

function galleria_ad()
{
		var galleries = jQuery('.ad-gallery').adGallery();
			jQuery('#switch-effect').change(
			  function() {
				galleries[0].settings.effect = jQuery(this).val();
				return false;
			  }
			);
			jQuery('#toggle-slideshow').click(
			  function() {
				galleries[0].slideshow.toggle();
				return false;
			  }
			);
			jQuery('#toggle-description').click(
			  function() {
				if(!galleries[0].settings.description_wrapper) {
				  galleries[0].settings.description_wrapper = jQuery('#descriptions');
				} else {
				  galleries[0].settings.description_wrapper = false;
				}
				return false;
			  }
			);
			
}
