$(document).ready( function(){  
//getData();
open_link('home_page');
curriculum();
} ); 


$(document).ready(function()
 {
  $("#photo_link").click(function()
   {
	   
	   load_gallery();
	   
   
    
   });
});

function load_gallery() {
	
	$("#gallery_photo").load("gallery.html",function(){slide_immagini();});
	}
	
	
	function show_gallery() {
	$(".div_loading").hide();
	$("#gallery_photo").fadeIn("slow");
	load_prettyPhoto();
	
	}
	




function load_prettyPhoto() {
			$("a[rel^='prettyPhoto']").prettyPhoto({
				animationSpeed: 'normal', /* fast/slow/normal */
				padding: 40, /* padding for each side of the picture */
				opacity: 0.35, /* Value betwee 0 and 1 */
				showTitle: false, /* true/false */
				allowresize: true, /* true/false */
				counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
				theme: 'dark_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
				callback: function(){}
			});
		};




//funzione per la data

function getData() {
        var gg = new Array('Domenica','Luned&igrave;','Marted&igrave;','Mercoled&igrave;','Gioved&igrave;','Venerd&igrave;','Sabato');
        var data = new Date();
		var mese = data.getMonth() + 1;
        document.getElementById("data").innerHTML = gg[data.getDay()] + '<br />'+ data.getDate().toString() + "/" + mese + "/" +
        data.getFullYear().toString() + "<br /> " + data.getHours().toString() + ":" + data.getMinutes().toString() + ":" +
        data.getSeconds().toString();
        setTimeout("getData()", 1000);
    }
	
	
	
function close_banner(){

$('.banner-outer').animate({top: '-238px'}, 1500);
$('#content').animate({top: '-258px'}, 1500);
$('#footer').animate({top: '-238px'}, 1500);
$('#closebanner').hide();
$('#openbanner').show();
}

function open_banner(){
$('.banner-outer').animate({top: '0px'}, 1500);
$('#content').animate({top: '-20px'}, 1500);
$('#footer').animate({top: '0px'}, 1500);
$('#closebanner').show();
$('#openbanner').hide();
}


function open_link(link_da_aprire) {
	$('.pages').hide();
	
$('#' + link_da_aprire).fadeIn("slow");

	}
	
	
	
	
	
	
function rispondi(risposta){
$('.risposte').hide();
$('*').removeClass('current');
$('.' + risposta).addClass('current');
$('#' + risposta).show();
}


/*
$(document).ready( function(){  
$('.photos ul').cycle({ fx: 'scrollDown', speed: 1000, timeout:  8000 });
$('photos ul').cycle(cleartypeNoBg = true);
} ); 
*/


function curriculum(){
	$('#list1a div').hide();
	$('#list1a div.info').show();
	
	$("#list1a a.info").bind("click", function(){
	   $('#list1a div').hide();
	   $('#list1a div.info').show();
	  });	
	
	$("#list1a a.lav").bind("click", function(){
	   $('#list1a div').hide();
	   $('#list1a div.lav').show();
	  });
	
	$("#list1a a.form").bind("click", function(){
	   $('#list1a div').hide();
	   $('#list1a div.form').show();
	  });
	
	$("#list1a a.comp").bind("click", function(){
	   $('#list1a div').hide();
	   $('#list1a div.comp').show();
	  });
	
	}

	
function slide_immagini(){ 
	$('.Slider').before('<ul id="mycarousel" class="jcarousel jcarousel-skin-tango" />');
	$('.Slider').cycle({ 
					   fx: 'scrollHorz', 
					   timeout: 0,
					   pager: '#mycarousel', 
					   slideExpr: '.myslide', 
					   next: '#next', 
					   prev: '#prev',
					   speedIn: 1000,
					   speedOut: 1000,
					   //easeIn: 'bounceout',
					   //easeOut: 'backin',
					   //delay: -2000,
					   
		pagerAnchorBuilder: function(idx, slide) {
			var src = $('img', slide).attr('src');
			var title = $('h4', slide).html();
			return '<li><a href="#" class="tip" title="' + title + '"><img src="' + src + '" alt="thumbnail image" /></a></li>';
			}
	}); 
	
	setTimeout("show_gallery()", 1500);
	};	
	
	
	
	
	
$(document).ready(function(){
$("#sendmail").click(function(){
							  
var valid = '';
var isr =  ' is required.';
var name = $("#name").val();
var mail = $("#mail").val();
var subject = $("#subject").val();
var text = $("#text").val();

$('.error_form').hide();
$('#formail .input').css("border","1px solid #BAB9B5");
$('#formail .textarea').css("border","1px solid #BAB9B5");


if (valid != '1'){
if (name.length<1) {
valid = '1';
$('#errore_name').fadeIn();
$('#name').css("border","1px solid red");
}
}

if (valid != '1'){
if (mail.length<1) {
valid = '1';
$('#errore_mail').fadeIn();
$('#mail').css("border","1px solid red");
}
}

if (valid != '1'){
if (!mail.match(/^([a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,4}$)/i)) {
valid = '1';
$('#errore_mail2').fadeIn();
$('#mail').css("border","1px solid red");
}
}

if (valid != '1'){
if (subject.length<1) {
valid = '1';
$('#errore_subject').fadeIn();
$('#subject').css("border","1px solid red");
}
}

if (valid != '1'){
if (text.length<1) {
valid = '1';
$('#errore_text').fadeIn();
$('#text').css("border","1px solid red");
}
}


if (valid == '') {
var datastr ='name=' + name + '&mail=' + mail + '&subject=' + subject + '&text=' + text;

$('.error_form').hide();
$('#formail .input').css("border","1px solid #BAB9B5");
$('#formail .textarea').css("border","1px solid #BAB9B5");

$("#sent_mail_load").fadeIn("slow");

send(datastr);

}
return false;
});
});


function send(datastr){
$.ajax({
type: "POST",
url: "mail.php",
data: datastr,
cache: false,
success: function(html){
	

$("#sent_mail h3").html(html);
$("#sent_mail").fadeIn("slow");


}
});
}




function scrivi_altra_mail(){
	
	$('#formail .input').val('');
$('#formail .textarea').val('');

$("#sent_mail_load").hide();
$('#sent_mail').fadeOut();

	
	};
	
	
	
	
	
	
	
	
	 var blank = new Image();
 blank.src = 'images/x.gif';
 
 $(document).ready(function() {
   var badBrowser = (/MSIE ((5\.5)|6)/.test(navigator.userAgent) && navigator.platform == "Win32");
   if (badBrowser) {
     // get all pngs on page
     $('img[src$=.png]').each(function() {
       if (!this.complete) {
         this.onload = function() { fixPng(this) };
       } else {
         fixPng(this);
       }
     });
   }
 });
 
 function fixPng(png) {
   // get src
   var src = png.src;
   // set width and height
   if (!png.style.width) { png.style.width = $(png).width(); }
   if (!png.style.height) { png.style.height = $(png).height(); }
   // replace by blank image
   png.onload = function() { };
   png.src = blank.src;
   // set filter (display original image)
   png.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
 }

	


