
/**

##########################################################################################################################

SLIDER

*/

var slider;


function slider(sliderID) {
    //alert(sliderID);
    slider = $(sliderID);
    slider.cycle({
    //fx: 'fadeZoom', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
    //fx: 'scrollLeft', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
        timeout: 8000,  // milliseconds between slide transitions (0 to disable auto advance)
        speed: 2000,
        delay: 1000,
        pause: 1,
        after: afterSlide,
        before: beforeSlide,
        random: true
    });

    slider.css("visibility", "visible");
}

function slider3(sliderID,fx) {
    //alert(sliderID);
    slider = $(sliderID);
    slider.cycle({
        //fx: 'fadeZoom', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
        fx: fx, // choose your transition type, ex: fade, scrollUp, shuffle, etc...
        timeout: 8000,  // milliseconds between slide transitions (0 to disable auto advance)
        speed: 2000,
        delay: 1000,
        pause: 1,
        after: afterSlide,
        before: beforeSlide,
        random: true
    });

    slider.css("visibility", "visible");
}

// demo immagine promo in basso a sx
var slider2;  
function slider2(sliderID) {
    //alert(sliderID);
    slider2 = $(sliderID);
    slider2.cycle({
        //fx: 'fadeZoom', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
//    fx:      'custom', 
//    cssBefore: {  
//        left: 115,  
//        top:  115,  
//        width: 0,  
//        height: 0,  
//        opacity: 1, 
//        zIndex: 1 
//    }, 
//    animOut: {  
//        opacity: 0  
//    }, 
//    animIn: {  
//        left: 0,  
//        top: 0,  
//        width: 328,  
//        height: 353  
//    }, 
//    cssAfter: {  
//        zIndex: 0
    //    },
        fx: 'scrollLeft',    
        timeout: 6000,  // milliseconds between slide transitions (0 to disable auto advance)
        speed: 1200,        
        pause: 1,
        after: afterSlide,
        before: beforeSlide,
        random: false
    });

    slider.css("visibility", "visible");
}

function prevSlide() {
    //console.log('prev');
    slider.cycle('prev');
}
function nextSlide() {
    slider.cycle('next');
}

function beforeSlide(currSlideElement, nextSlideElement, options, forwardFlag) {
    if (currSlideElement != nextSlideElement) {
        //$(currSlideElement).children('.label').fadeOut('slow');
        $(currSlideElement).children('.label').hide(0);
    }
}

function afterSlide(currSlideElement, nextSlideElement, options, forwardFlag) {
    //$(nextSlideElement).children('.label').fadeIn('slow');
    $(nextSlideElement).children('.label').show(0);
}


/*********************
//* jQuery Multi Level CSS Menu #2- By Dynamic Drive: http://www.dynamicdrive.com/
//* Last update: Nov 7th, 08': Limit # of queued animations to minmize animation stuttering
//* Menu avaiable at DD CSS Library: http://www.dynamicdrive.com/style/
*********************/

var jqueryslidemenu = {
    animateduration: { over: 200, out: 100 }, //duration of slide in/ out animation, in milliseconds
    buildmenu: function(menuid, arrowsvar) {
        jQuery(document).ready(function($) {
            var $mainmenu = $(menuid + ">ul")
            var $headers = $mainmenu.find("ul").parent()
            $headers.each(function(i) {
                var $curobj = $(this)
                var $subul = $(this).find('ul:eq(0)')
                this._dimensions = { w: this.offsetWidth, h: this.offsetHeight, subulw: $subul.outerWidth(), subulh: $subul.outerHeight() }
                this.istopheader = $curobj.parents("ul").length == 1 ? true : false
                $subul.css({ top: this.istopheader ? this._dimensions.h + "px" : 0 })
                /*
                $curobj.children("a:eq(0)").css(this.istopheader? {paddingRight: arrowsvar.down[2]} : {}).append(
                '<img src="'+ (this.istopheader? arrowsvar.down[1] : arrowsvar.right[1])
                +'" class="' + (this.istopheader? arrowsvar.down[0] : arrowsvar.right[0])
                + '" style="border:0;" />'
                )
                */
                $curobj.hover(
				function(e) {
				    var $targetul = $(this).children("ul:eq(0)")
				    this._offsets = { left: $(this).offset().left, top: $(this).offset().top }
				    var menuleft = this.istopheader ? 0 : this._dimensions.w
				    menuleft = (this._offsets.left + menuleft + this._dimensions.subulw > $(window).width()) ? (this.istopheader ? -this._dimensions.subulw + this._dimensions.w : -this._dimensions.w) : menuleft
				    if ($targetul.queue().length <= 1) //if 1 or less queued animations
				        $targetul.css({ left: menuleft + "px", width: this._dimensions.subulw + 'px' }).slideDown(jqueryslidemenu.animateduration.over)
				},
				function(e) {
				    var $targetul = $(this).children("ul:eq(0)")
				    $targetul.slideUp(jqueryslidemenu.animateduration.out)
				}
			) //end hover
            }) //end $headers.each()
            $mainmenu.find("ul").css({ display: 'none', visibility: 'visible' })
        }) //end document.ready
    }
}


