$(window).load(function() { //con document ready non funziona liquid canvas su IE


$("#mainWrapper").liquidCanvas("[shadow gradient{from:rgba(255, 255, 255,0.9); to:rgba(255, 255, 255,0.7);}] => roundedRect{radius:10}");
$("#menu_wrap").liquidCanvas("[shadow fill{color:#000000;} ] => roundedRect{radius:10}");
$(document).resize(function(){
    $("#mainWrapper").liquidCanvas("[shadow gradient{from:rgba(255, 255, 255,0.9); to:rgba(255, 255, 255,0.7);}] => roundedRect{radius:10}");
    $("#menu_wrap").liquidCanvas("[shadow fill{color:#000000;} ] => roundedRect{radius:10}");
});
var $j = jQuery.noConflict(); 
//DROPDOWN MENU INIT
ddsmoothmenu.init({
mainmenuid: "mainMenu", //menu DIV id
orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
classname: 'ddsmoothmenu', //class added to menu's outer DIV
//customtheme: ["#1c5a80", "#18374a"],
contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
});

//SHARE LINKS
$('.shareLinks a.share').click(function() {
		if ($(".shareLinks .icons").is(":hidden")) {
		$('.shareLinks').animate({width: "400"}, 500 );
		$('.shareLinks .icons').fadeIn();
		$(this).text('[-] Share & Bookmark');
		return false;
		}else {
		$('.shareLinks').animate({width: "130"}, 500 );
		$('.shareLinks .icons').fadeOut();
		$(this).text('[+] Share & Bookmark');
		return false;	
		}
});
     //avvio slider_home
    //Execute the slideShow, set 7 seconds for each images
    slideShow(9000);
  slider_nextEvents(9000);// SLIDER CREATO DA ME MIQUE
  slider_BestPictures(9000);// SLIDER CREATO DA ME MIQUE

});


function slider_nextEvents(intervallo){
  setInterval("circolo()", intervallo);
}
function circolo(){  // SLIDER CREATO DA ME MIQUE
    first=$('#slider_next_events div:first');
    first.slideUp('1700', function(){
        first=$('#slider_next_events div:first');
       // first.next().css({opacity: 0.0}).animate({opacity: 1.0}, 800);
        $('#slider_next_events').append(first);
        first.show();
    });
    first.next().css({opacity: 0.0}).animate({opacity: 1.0}, 800);
}

function slider_BestPictures(intervallo){
  setInterval("circolo_bestpictures()", intervallo);
  $('#slider_media_news div.video').click(function(){
      

  });
}
function circolo_bestpictures(){  // SLIDER CREATO DA ME MIQUE
    first=$('#slider_media_news div:first');
    first.fadeOut('1200', function(){
        first=$('#slider_media_news div:first');
        first.next().css({opacity: 0.0}).animate({opacity: 1.0}, 1200);
        $('#slider_media_news').append(first);
        //$('#slider_media_news div:first').fadeIn('1500');
        first.show();
    });
}

/* funzioni slider */
function slideShow(speed) {
    //append a LI item to the UL list for displaying caption
    $('ul.slideshow').append('<li id="slideshow-caption" class="caption"><div class="slideshow-caption-container"><h3></h3><p></p></div></li>');
 
    //Set the opacity of all images to 0
    $('ul.slideshow li').css({opacity: 0.0});
     
    //Get the first image and display it (set it to full opacity)
    $('ul.slideshow li:first').css({opacity: 1.0});
     
    //Get the caption of the first image from REL attribute and display it
    //$('#slideshow-caption h3').html( $('ul.slideshow a:first').find('img').attr('title') );
    //$('#slideshow-caption p').html( $('ul.slideshow a:first').find('img').attr('alt') );
    $('#slideshow-caption h3').html( $('ul.slideshow li:first').find('p').attr('title') );
    $('#slideshow-caption p').html( $('ul.slideshow li:first').find('span').attr('title') );
    
    //Display the caption
    $('#slideshow-caption').css({opacity: 0.8, bottom:10});
     
    //Call the gallery function to run the slideshow    
    var timer = setInterval('gallery()',speed);
    
}
 
function gallery() {
 
    //if no IMGs have the show class, grab the first image
    var current = ($('ul.slideshow li.show')?  $('ul.slideshow li.show') : $('#ul.slideshow li:first'));
 
    //Get next image, if it reached the end of the slideshow, rotate it back to the first image
    var next = ((current.next().length) ? ((current.next().attr('id') == 'slideshow-caption')? $('ul.slideshow li:first') :current.next()) : $('ul.slideshow li:first'));
         
    //Get next image caption
    var title = next.find('p').attr('title'); 
    var desc = next.find('span').attr('title');    
         
    //Set the fade in effect for the next image, show class has higher z-index
    next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 1200);
     
    //Hide the caption first, and then set and display the caption
    $('#slideshow-caption').fadeOut(1200, function () {
        $('#slideshow-caption h3').html(title); 
        $('#slideshow-caption p').html(desc); 
        $('#slideshow-caption').fadeIn(1200);
    }); 
 
    //Hide the current image
    current.animate({opacity: 0.0}, 1200).removeClass('show');
 
}
