$(document).ready(function() {
	
	//Target blank
	$("a._blank").live('click',function(){this.target="_blank";});
	
	// Portfolio Fancybox
	$("a[rel=portfolio-group]").fancybox({
		'padding' 			: 10,
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'overlayShow'		: true,
		'overlayColor'		: '#000',
		'overlayOpacity'	: 0.7,
		'titlePosition'		: 'outside',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">' + (title.length ? '<a class="_blank" href="' + title + '">' + title + '</a>' : 'asda') + '</span>';
		},

	});
	
	
	// Testo Privacy Fancybox
	$("#privacy").fancybox({
		'type' 						: 'inline',
		'margin' 					: 10,	
		'width'						: 500,
		'height' 					: 100,
		'scrolling'					: 'no',
		'titleShow'					: false,
	});
	
	// Validazione ed Invio Form Email
	var ajax_options = { 
			        success			: function showResponse(responseText, statusText, xhr, $form)  { 
										$('#email-responce').html(responseText).delay(5000).fadeOut("slow");
										//setTimeout('$("#email-responce").fadeOut("slow");',2000);
					},   
			        //url				: 'email.php',      // override for form's 'action' attribute 
			        type			: 'post',        	// 'get' or 'post', override for form's 'method' attribute 
			        clearForm		: true,        		// clear all form fields after successful submit 
			        resetForm		: true       		// reset the form after successful submit 
	}; 
		    		
	var validate_options = {
					submitHandler	: function(form) {
								   	  	var x = $("#email-form").ajaxSubmit(ajax_options); 	
								 }
	}; 
	
	$("#email-form").validate(validate_options); 
	
	// Mascheramento Email
	var commercial 		= 'commerciale';
	var administration 	= 'amministrazione';
	var domain 			= 'an-soft.it'
	$("#commercial").append('<a href="mailto:' + commercial + '@' + domain +'">' + commercial + '@' + domain + '</a>'); 
	$("#administration").append('<a href="mailto:' + administration + '@' + domain +'">' + administration + '@' + domain + '</a>'); 

});


