// JavaScript Engine

	$(document).ready(function(){
	
	// Accordion
	$('ul.accordion').accordion({
            header: 'h3.head',
            selectedClass: 'open',
            event: 'mouseover'
      });
    
    // Home fade
    $('#images ul').innerfade({
			speed: 1000,
			timeout: 4000,
			type: 'sequence',
			containerheight: '411px'
	});
	
	// News ticker
	$('#ticker').innerfade({
			speed: 2000,
			timeout: 5000,
			type: 'random',
			containerheight: '45px'
	});
	
	// Home kwicks box, please move to footer
	$('.kwicks').kwicks({
		max : 356,
		spacing: 17
	});
	
	// Slideview
	$("div#mygal").slideView();
	
	// Change lang
	$("#flag a").hover(function() {
	$(this).next("em").animate({opacity: "show", right: "40"}, "slow");
	}, function() {
	$(this).next("em").animate({opacity: "hide", right: "50"}, "slow");
	});
	
	// Fade links
	$('#credits a').fadeTo("fast",0.80);
	 $('#credits a').hover(function() {
		$(this).fadeTo("fast",1);
		},
		function () {
        $(this).fadeTo("fast",0.80);
     });
	
	// FB
	$("#fb a").hover(function() {
	$(this).next("em").animate({opacity: "show", right: "110"}, "slow");
	}, function() {
	$(this).next("em").animate({opacity: "hide", right: "120"}, "slow");
	});
	
	// Expand dt
	$('dl#club').find('dd').hide().end().find('dt').append('<span class="open">apri</span>').toggle(function(){
				$(this).find('span').attr('class','close').html('chiudi').end().next('dd').fadeIn();
			},function(){
				$(this).find('span').attr('class','open').html('apri').end().next('dd').fadeOut(); 
			});
	
	// Toggle a div with extra info		
	$(".extra1, .extra2").css("display","none");
		$("#toggle").click(function(){
			$('.extra1').toggle(400);
   			 return false;
		});	
		$("#toggle2").click(function(){
			$('.extra2').toggle(400);
   			 return false;
		});	
		
	// Back to top
	$(window).scroll(function () {  
        if ($(this).scrollTop() != 0) {  
            $('#top').fadeIn();  
        } else {  
            $('#top').fadeOut();  
        }  
    });  
    $('#top').click(function () {  
        $('body,html').animate({  
            scrollTop: 0  
        },  
        800);  
    });
    
    //Colorbox
    $(".lb a").colorbox();

    //Colorbox
    $(".vb a").colorbox({iframe:true, innerWidth:425, innerHeight:344});
		
	// Datepicker
		$('#dal,#al').focus(function(){$(this).val('');})
		.datepicker({minDate: new Date(2010, 5 - 1, 22), maxDate: new Date(2010, 9 - 1, 18), showOn: "both", dateFormat: "dd/mm/yy", showAnim: "fadeIn", speed: "fast", buttonImage: "/wp-content/themes/paradisov4/images/ico_calendar.gif", buttonImageOnly: true, hideIfNoPrevNext: true, changeMonth: false, changeYear: false });
	
	// submit form
 	$('#myForm').ajaxForm(function(data) {
            if (data==1){
                $('#success').fadeIn("slow");
                 $('#myForm').slideUp("slow");
                $('#myForm').resetForm();
            }
            else if (data==2){
                $('#badserver').fadeIn("slow");
            }
            else if (data==3)
            {
                $('#bademail').fadeIn("slow");
                setTimeout(function() { 
  				$('#bademail').fadeOut("slow"); 
				}, 10000);
            }
        });

});