// JavaScript Document
$.noConflict();

jQuery(document).ready(function($) {

		/*simulazione first e last child*/
		$('.menu li:last-child').addClass('last-child');
	
		/*features home*/		
		$('#features-home .mod_placehere_features .mod_placehere_following').hover(function(){
				$("div.abstract", this).stop().animate({height:'107px'},{queue:false ,duration: 360});
			}, function() {
			$("div.abstract", this).stop().animate({height:'47px'},{queue:false, duration: 860});
		});
	
		$('#left .moduletable-offers-left .mod_placehere_following').hover(function(){
				$("div.abstract", this).stop().animate({top:'0px'},{queue:false ,duration: 360});
			}, function() {
			$("div.abstract", this).stop().animate({top:'114px'},{queue:false, duration: 860});
		});


/*		$('#features-home .mod_placehere_features .mod_placehere_following').addClass('box-shadow');*/		
		
		$('.mod_placehere-offers-left').addClass('box-shadow2');
	
	
	
		/*simulazione css3 input*/
		$('input[type="submit"]').addClass('submit');
	
	
	
		//menu
		$('#main-menu ul').superfish({
				delay: 1200, // one second delay on mouseout
				animation: {opacity:'show',height:'show'}, // fade-in and slide-down animation
				speed: 500, // faster animation speed
				autoArrows: true, // disable generation of arrow mark-up
				dropShadows: true // disable drop shadows
		}); 


		//risorse
		$('li.risorse').click(function() {
			$('.col-13.moduletable.moduletable-risorse').slideToggle('slow');
		});
		$('li.risorse').toggle (function (){
			$(this).addClass('active');
		}, function (){
			$(this).removeClass('active');
		
		});
		
		
		//offers - toglie il tag p dai tag img
		$('#left .moduletable-business img').each(function(){
			$(this).closest('a').unwrap();
		});
			
		//box alternati
		$('.mod_placehere_camere-col9 .mod_placehere_following:odd').addClass('box-alternate');

		
		
		//cycle headers
		$('.header .cycle p').cycle({ 
				fx:     'fade', 
				speed:   2000, 
				timeout: 1000
		});
		
		$('.mod_placehere-offers-left').cycle({ 
				fx:     'fade', 
				speed:   3500,
				delay:   1000,
				timeout: 2000,
				random:  true,
				pause:   true
		});



		//rimuove gli attributi style 
		$('.mod_placehere-list img, .mod_placehere-offers-left img, .header p.box-shadow').removeAttr('style');




		//pop-up
		$(".thumbnail-bg a, .fancybox-img").fancybox({
				'titleShow': true,
				'titlePosition': 'over',
				'autoScale': true,
				'zoomSpeedIn': 1500,
				'zoomSpeedOut' : 1500,
				'overlayOpacity': 0.7,
				'overlayColor':	'#23353F',
				'transitionIn': 'elastic',
				'transitionOut': 'elastic',
				'easingIn': 'easeOutBack',
				'easingOut': 'easeInBack'
		}); 


		//Fancybox
		$(".fancybox-popup").fancybox({
				'titleShow': false,
				'autoScale': false,
				'zoomSpeedIn' : 1500,
				'zoomSpeedOut' : 1500,
				'overlayOpacity': 0.7,
				'type': 'iframe',
        'width': 500,
				'height': 440,
				'overlayColor':	'#23353F',
				'transitionIn': 'elastic',
				'transitionOut': 'elastic',
				'easingIn': 'easeOutBack',
				'easingOut': 'easeInBack'
		});
		
		
		//video-tour a
		$(".video-tour a").fancybox({
				'autoScale': false,
				'titleShow': false,
				'zoomSpeedIn' : 1500,
				'zoomSpeedOut' : 1500,
				'overlayOpacity': 0.7,
				'type': 'iframe',
				'width': 550,
				'height': 575,
				'overlayColor':	'#23353F',
				'transitionIn': 'elastic',
				'transitionOut': 'elastic',
				'easingIn': 'easeOutBack',
				'easingOut': 'easeInBack'
		});	
		
			
		
		$ ('ul.jflanguageselection li.last-child a').each(function(){
			var $this = $(this);	   	
			var ancorlink = $this.attr('href');
			$('.moduletable-us ul li.last-child a').attr('href', ancorlink);
		});	

	if($.browser.msie){
			Printfix();
		} 

		var roundedboxes;

	function Printfix(){
		roundedboxes = $(".box-shadow");
		window.onbeforeprint = removeRoundedboxes;
		window.onafterprint = addRoundedboxes;
	}

	function removeRoundedboxes(){
		 $(roundedboxes).css("behavior","none");
		}
		
		function addRoundedboxes(){
		 $(roundedboxes).css("behavior","url(/templates/default/js/PIE.htc)");
		}



		
});
