// Variable definition
pt2="it";
pt1="sviluppo";
pt6="info";
pt5="navicelli";
pt3=".";
pt4="@";



$(document).ready(function()
{

	jQuery('.email-address').html('<a href="mailto:'+pt6+pt4+pt1+pt5+pt3+pt2+'">'+pt6+pt4+pt1+pt5+pt3+pt2+'</a>');
	

	//Font replacement
	Cufon.replace("h1,h2,h4,h3,#navigation a,#logo,.cday,.cmonth,.cyear,.avanzamento .title,.avanzamento .author,.news .title,.news .author,.news .link,.more_news,#alert .title,#alert #errors p,.show-photo a,.content div.table, .small.content-half a", { hover: "true" });
	//Fancybox init for thumbs preview
	jQuery(".linked-box").fancybox({ overlayShow: true });
	
	//Cu3er init
	var flashvars = {};
	flashvars.xml = "swf/config.xml";
	flashvars.font = "swf/miso_font.swf";
	var attributes = {};
	attributes.wmode = "transparent";
	attributes.id = "slider";
	swfobject.embedSWF("swf/cu3er.swf", "cu3er-container", "600", "300", "9", "js/expressInstall.html", flashvars, attributes);
	
	
	// hides the slickbox as soon as the DOM is ready
	// (a little sooner than page load)
	jQuery('.gallery').hide();
	jQuery('a.gallery-show').show();
	jQuery('a.gallery-hide').hide();
	
	// shows the slickbox on clicking the noted link
	jQuery('a.gallery-show').click(function()
	{
		jQuery('a#gallery-hide-'+jQuery(this).attr('rel')).show();
		jQuery('a#gallery-show-'+jQuery(this).attr('rel')).hide();
		
		jQuery('#gallery'+jQuery(this).attr('rel')).show('slow');
		return false;
	});
	
	// hides the slickbox on clicking the noted link
	jQuery('a.gallery-hide').click(function()
	{
		jQuery('a#gallery-hide-'+jQuery(this).attr('rel')).hide();
		jQuery('a#gallery-show-'+jQuery(this).attr('rel')).show();
		
		jQuery('#gallery'+jQuery(this).attr('rel')).hide('fast');
		return false;
	});
	
		jQuery('#captcha-change').click(function()
		{
			jQuery('#captcha').attr('src','captcha.php?'+Math.random());
			jQuery('#captcha-form').focus();
		});
		
		jQuery("#tab-contatti #invia").click(function()
		{
			form=jQuery('#contatti-form');
			err="";
			if (jQuery.trim(jQuery('#nome').val())=="") { err=err+"<p>&bull;&nbsp;&nbsp;&nbsp;Inserire il nome.</p>"; }
			if (jQuery.trim(jQuery('#cognome').val())=="") { err=err+"<p>&bull;&nbsp;&nbsp;&nbsp;Inserire il cognome.</p>"; }
			if (jQuery.trim(jQuery('#indirizzo').val())=="") { err=err+"<p>&bull;&nbsp;&nbsp;&nbsp;Inserire l'indirizzo.</p>"; }
			if (jQuery.trim(jQuery('#citta').val())=="") { err=err+"<p>&bull;&nbsp;&nbsp;&nbsp;Inserire la citt&agrave;.</p>"; }
			if (jQuery.trim(jQuery('#captcha-form').val())=="") { err=err+"<p>&bull;&nbsp;&nbsp;&nbsp;Inserire la parola di controllo.</p>"; }
			
			var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
			if (jQuery.trim(jQuery('#email').val())=="") { err=err+"<p>&bull;&nbsp;&nbsp;&nbsp;Inserire l'email.</p>"; }
			if (jQuery('#email').val()!="" && !filter.test(jQuery('#email').val())) { err=err+"<p>&bull;&nbsp;&nbsp;&nbsp;Inserire un indirizzo e-mail valido.</p>" }
			if (jQuery('#privacy').attr('checked')!=true) { err=err+"<p>&bull;&nbsp;&nbsp;&nbsp;Devi dare il permesso al trattamento dei dati personali.</p>"; }
			
			if (err!="")
			{
				   jQuery('#alert').colorbox({width:'50%', inline:true, href:'#alert'});
				   jQuery('#errors').html(err);
				   jQuery('#alert').click();
			}
			else
			{
					form.submit();
			}
		});

		jQuery("#tab-manifestazione #invia").click(function()
		{
			form=jQuery('#manifestazione-form');
			err="";
			if (jQuery.trim(jQuery('#nome').val())=="") { err=err+"<p>&bull;&nbsp;&nbsp;&nbsp;Inserire il nome.</p>"; }
			if (jQuery.trim(jQuery('#cognome').val())=="") { err=err+"<p>&bull;&nbsp;&nbsp;&nbsp;Inserire il cognome.</p>"; }
			if (jQuery.trim(jQuery('#indirizzo').val())=="") { err=err+"<p>&bull;&nbsp;&nbsp;&nbsp;Inserire l'indirizzo.</p>"; }
			if (jQuery.trim(jQuery('#citta').val())=="") { err=err+"<p>&bull;&nbsp;&nbsp;&nbsp;Inserire la citt&agrave;.</p>"; }
			if (jQuery.trim(jQuery('#provincia').val())=="") { err=err+"<p>&bull;&nbsp;&nbsp;&nbsp;Inserire la provincia.</p>"; }
			if (jQuery.trim(jQuery('#telefono').val())=="") { err=err+"<p>&bull;&nbsp;&nbsp;&nbsp;Inserire il telefono.</p>"; }
			if (jQuery.trim(jQuery('#captcha-form').val())=="") { err=err+"<p>&bull;&nbsp;&nbsp;&nbsp;Inserire la parola di controllo.</p>"; }
			
			var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
			if (jQuery.trim(jQuery('#email').val())=="") { err=err+"<p>&bull;&nbsp;&nbsp;&nbsp;Inserire l'email.</p>"; }
			if (jQuery('#email').val()!="" && !filter.test(jQuery('#email').val())) { err=err+"<p>&bull;&nbsp;&nbsp;&nbsp;Inserire un indirizzo e-mail valido.</p>" }
			if (jQuery('#email').val()!=jQuery('#confemail').val()) { err=err+"<p>&bull;&nbsp;&nbsp;&nbsp;Le e-mail non corrispondono!.</p>"; }
			if (jQuery('#privacy').attr('checked')!=true) { err=err+"<p>&bull;&nbsp;&nbsp;&nbsp;Devi dare il permesso al trattamento dei dati personali.</p>"; }
			
			if (err!="")
			{
				   jQuery('#alert').colorbox({width:'50%', inline:true, href:'#alert'});
				   jQuery('#errors').html(err);
				   jQuery('#alert').click();
			}
			else
			{
					form.submit();
			}
		});

});


