$(document).ready(function() {
	
	jQuery(function($) {
		var sem = 0;
		var sem2 = 0;
		var name = 0;
		var tele = 0;
		var email = 0;
		var text = 0;
		
		$('input#name').click(function() { name =1;});
		$('input#tele').click(function() { tele =1;});
		$('input#email').click(function() { email =1;});
		$('textarea#message').click(function() { text =1;});
		
		$('input#name').click(function() { 
				$('input#name').attr('value','');
		});	
		$('input#tele').click(function() { 
				$('input#tele').attr('value','');
		});	
		$('input#email').click(function() { 
				$('input#email').attr('value','');
		});	
		$('textarea#message').click(function() { 
				$('textarea#message').html('');
		});	
		
		$('input').mouseleave(function() { 
			if (name!=1){
				$('input#name').attr('value','your name');
			}
			if (tele!=1){
				$('input#tele').attr('value','your telephone number');
			}
			if (email!=1){
				$('input#email').attr('value','your email');
			}
			if (email!=1){
				$('textarea#message').html('message');
			}
		});			


		$(window).resize(function() {
			var col= $('#eng,#slo,#ita');
			col.css("width", ($(window).width() - 10 ) + 'px');
			$('body').css("width", ($(window).width() * 3 ) + 'px');
			if ($(window).height() > 700)
				col.css('padding-top',$(window).height() / 10 + 'px');
		});

		var col= $('#eng,#slo,#ita');
		col.css("width", ($(window).width() - 10 ) + 'px');
		$('body').css("width", ($(window).width() * 3 ) + 'px');
		if ($(window).height() > 700)
			col.css('padding-top',$(window).height() / 10 + 'px');
		
		$('.foto').hover(function() { //start function when any link is clicked
		 	$('.foto .video .loadingvideo').slideDown();
			$('a.nyroModal').nyroModal({bgColor: '#000',closeButton: '<a href="#" class="nyroModalClose" id="closeBut" title="close">Chiudi</a>',});
			

		});			
		 $('.foto').mouseleave(function() { //start function when any link is clicked
		 	$('.foto .video .loadingvideo').slideUp();
		});	
		 /*BOX LINGUA*/
		if (sem2==0){
			$('.box').hover(function() { //start function when any link is clicked
				sem = 1;
				$('.box .boxOff').slideUp();
				$('.box .boxOn').slideDown();
			});	
			 $('.box').delay(1000).mouseleave(function() { //start function when any link is clicked
				$('.box .boxOn').slideUp();
				$('.box .boxOff').slideDown();
				sem = 0;
			});			
		}
		if (sem==0){
			$('.box2').hover(function() { //start function when any link is clicked
				sem2 = 1;
				$('.box2 .boxOff').slideUp();
				$('.box2 .boxOn').slideDown();
			});			
			 $('.box2').mouseleave(function() { //start function when any link is clicked
				$('.box2 .boxOn').slideUp();
				$('.box2 .boxOff').slideDown();
				sem2 = 0;
			});			
		}
		/*FINE BOX LINGUA */
		
		var div= $('#a0-it,#a0-si,#a0-en');
		if ($(window).height() > 700){
			var res ;
			res = $(window).height() / 21;
			res++;
			div.css("height", res + 'px');
		}
		var div= $('#a1-it,#a1-si,#a1-en');
		if ($(window).height() > 700){
			var res ;
			res = $(window).height() / 7;
			res = res + 1;	
			div.css("height", res + 'px');
		}
		var div= $('#a2-it,#a2-si,#a2-en');
		if ($(window).height() > 700){
			var res ;
			res = $(window).height() / 7;
				res = res + 0;	
			div.css("height", res + 'px');
		}
	var div= $('#a3-it,#a3-si,#a3-en');
		if ($(window).height() > 700){
			var res ;
			res = $(window).height() / 7;
			if (res%2 == 1){
				res = res + 1;	
			}
			div.css("height", res + 'px');
		}
/**/
		$('.menuportfolio a').click(function() { //start function when any link is clicked
						
						var content_show = $(this).attr("title"); //retrieve title of link so we can compare with php fil
					  	$(".port").hide();

						function showPortfolio(json){
						
							$(".loading").fadeIn("fast",function(){
										$(".portfolio-slo, .portfolio-ita, .portfolio-eng").hide();
										$(".port").html(json.port);
										$(".portfolio-slo").html(json.slo);
										$(".portfolio-ita").html(json.ita);
										$(".portfolio-eng").html(json.eng);
										$(".foto").html(json.foto);
										$(".portfolio-slo, .portfolio-ita, .portfolio-eng").fadeIn("slow");

								});
							$(".loading").fadeOut("fast");
															
						}						
						$.getJSON("scripts/data.php",{'page' : content_show}, showPortfolio); //End json 
						
/*						function showData(json){
						
								$(".loading").fadeIn("fast");
								$(".foto, .portfolio-slo, .portfolio-ita, .portfolio-eng").fadeOut("fast",function(){
										$(".foto").html(json.foto);
										$(".port").html(json.port);
										$(".portfolio-slo").html(json.slo);
										$(".portfolio-ita").html(json.ita);
										$(".portfolio-eng").html(json.eng);
		
										$(".loading").fadeOut("fast");
										$(".foto, .portfolio-slo, .portfolio-ita, .portfolio-eng").fadeIn("slow");

								});
															
						}						
*/								
		 }); //close click(
		 
		 $('.menuabout a').click(function() { //start function when any link is clicked

						var content_show = $(this).attr("title"); //retrieve title of link so we can compare with php file

						$.getJSON("scripts/data.php",{'page' : content_show}, showData); //End json 
						
						function showData(json){
						
								$(".loading").fadeIn("fast");
								$(".about-slo, .about-ita, .about-eng").fadeOut("fast",function(){
										$(".about-slo").html(json.slo);
										$(".about-ita").html(json.ita);
										$(".about-eng").html(json.eng);
		
										$(".loading").fadeOut("fast");
										$(".about-slo, .about-ita, .about-eng").fadeIn("slow");

								});
															

						}						
		 }); //close click(
	
	});

});
