$(document).ready(function(){
	var orbitCfg = {
		 animation: 'fade',                  // fade, horizontal-slide, vertical-slide, horizontal-push
		 animationSpeed: 1000,                // how fast animtions are
		 timer: true, 			 // true or false to have the timer
		 advanceSpeed: 4000, 		 // if timer is enabled, time between transitions 
		 pauseOnHover: false, 		 // if you hover pauses the slider
		 startClockOnMouseOut: false, 	 // if clock should start on MouseOut
		 startClockOnMouseOutAfter: 1000, 	 // how long after MouseOut should the timer start again
		 directionalNav: true, 		 // manual advancing directional navs
		 captions: true, 			 // do you want captions?
		 captionAnimation: 'fade', 		 // fade, slideOpen, none
		 captionAnimationSpeed: 800, 	 // if so how quickly should they animate in
		 bullets: false,			 // true or false to activate the bullet navigation
		 bulletThumbs: false,		 // thumbnails for the bullets
		 bulletThumbLocation: '',		 // location from this file where thumbs will be
		 afterSlideChange: function(){} 	 // empty function 
	};
	$('.slideshow').each(function(){
		// get current ul
		var $ul = $(this);
		// get array of list items in current ul
		var $liArr = $ul.children('img');
		// sort array of list items in current ul randomly
		$liArr.sort(function(a,b){
			  // Get a random number between 0 and 10
			  var temp = parseInt( Math.random()*10 );
			  // Get 1 or 0, whether temp is odd or even
			  var isOddOrEven = temp%2;
			  // Get +1 or -1, whether temp greater or smaller than 5
			  var isPosOrNeg = temp>5 ? 1 : -1;
			  // Return -1, 0, or +1
			  return( isOddOrEven*isPosOrNeg );
		})
		// append list items to ul
		.appendTo($ul);            
      });

	
	
	
	setTimeout(function() { $('#slideshow-sx').orbit(orbitCfg); }, 1500);
	setTimeout(function() {	$('#slideshow-c').orbit(orbitCfg); }, 3000);
	setTimeout(function() {	$('#slideshow-dx').orbit(orbitCfg); }, 4500);
	
	$("a.lb").colorbox();
	$("a.info").colorbox({width:"650px", height:"600px", iframe:true});
	$(document).pngFix();
	
	$(".menu_2 li a").hover(
		function () { $(this).closest("li").addClass("over"); },
		function () { $(this).closest("li").removeClass("over");}
	);
	
	$(".t_ricerca_orari tr, .t_abbonamenti tr, .t_punti_vendita tr").hover(
		function () { $(this).addClass("hilite"); },
		function () { $(this).removeClass("hilite");}
	);
	
	
	$(".f_newsletter").validate({
		rules: {
        	email: {
				required: true,
				email: true
			}
		},
		messages: {
			email: ""
		}
	});
	
	$("#part").autocomplete(
        "/Ricerca_Autocomplete_Json.aspx",
    {matchSubset:false,cacheLength:1,minChars: 0,max:100,width: 310,matchContains: "word",autoFill: false,formatItem: function(row, i, max){return row[0];}});
    
    $("#dest").autocomplete(
        "/Ricerca_Autocomplete_Json.aspx",
    {matchSubset:false,cacheLength:1,minChars: 0,max:100,width: 310,matchContains: "word",autoFill: false,formatItem: function(row, i, max){return row[0];}});
	
	$(".f_viaggia").validate({
			rules:{
				part: "required",
				dest: "required",
				giorno: {
				    required: true,
				    range: [1, 31],
				    numberInteger: true
				},
				mese:{
				    required: true,
				    range: [1, 12],
				    numberInteger: true
				},
				anno:{
				    required: true,
				    range: [1900, 2999],
				    numberInteger: true
				},
				ora:{
            	    required: true,
            	    range: [0, 23],
            	    numberInteger: true
				},
				minuti:{
            	    required: true,
            	    range: [0, 59],
            	    numberInteger: true
    			}
			},
			messages: {
				part:"",
				dest:"",
				giorno:"",
				mese:"",
				anno:"",
				ora:"",
				minuti:""
				
			}
		});
});	
