function mycarousel_initCallback(carousel) {
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function () {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function () {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function () {
        carousel.stopAuto();
    }, function () {
        carousel.startAuto();
    });
};

jQuery(document).ready(function () {
    jQuery('#mycarousel').jcarousel({
        auto: 0,
        wrap: 'last',
        duration: 'slow',

        initCallback: mycarousel_initCallback
    });
});

$(document).ready(function () {

    $(".signin").click(function (e) {
        e.preventDefault();
        $("fieldset#signin_menu").toggle();
        $(".signin").toggleClass("menu-open");
    });

    $("fieldset#signin_menu").mouseup(function () {
        return false
    });
    $(document).mouseup(function (e) {
        if ($(e.target).parent("a.signin").length == 0) {
            $(".signin").removeClass("menu-open");
            $("fieldset#signin_menu").hide();
        }
    });

});



$(function () {
    $('#forgot_username_link').tipsy({ gravity: 'n' });
    $('#aProfile').tipsy({ gravity: 'n' });
    $('.any').tipsy({ gravity: 'w' });
});


//$(document).ready(function () {
//    var currentPosition = 0;
//    var slideWidth = 886;
//    var slides = $('.slide');
//    var numberOfSlides = slides.length;

//    // Remove scrollbar in JS 
//    $('#slidesContainer').css('overflow', 'hidden');

//    // Wrap all .slides with #slideInner div 
//    slides
//    .wrapAll('<div id="slideInner"></div>')
//    // Float left to display horizontally, readjust .slides width 
//        .css({
//            'float': 'left',
//            'width': slideWidth
//        });

//    // Set #slideInner width equal to total width of all slides 
//    $('#slideInner').css('width', slideWidth * numberOfSlides);

//    // Insert controls in the DOM 
//    $('#slideshow')
//    .prepend('<span style="display:none" class="control" id="leftControl">Clicking moves left</span>')
//    .append('<span style="display:none" class="control" id="rightControl">Clicking moves right</span>');

//    // Hide left arrow control on first load 
//    manageControls(currentPosition);

//    // Create event listeners for .controls clicks 
//    $('.control')
//    .bind('click', function () {
//        // Determine new position 
//        currentPosition = ($(this).attr('id') == 'rightControl') ? currentPosition + 1 : currentPosition - 1;

//        // Hide / show controls 
//        manageControls(currentPosition);
//        // Move slideInner using margin-left 
//        $('#slideInner').animate({
//            'marginLeft': slideWidth * (-currentPosition)
//        });
//    });

//    window.setInterval(autoSlide, 10000);
//    var lastControl = "";
//    function autoSlide() {
//        if (lastControl == "" | lastControl == "r") {
//            $('#rightControl').click();
//            lastControl = "r";
//        }
//        else {
//            $('#leftControl').click();
//        }
//        if (currentPosition == numberOfSlides - 1) {
//            lastControl = "v";
//        }
//        if (currentPosition == 0) {
//            lastControl = "";
//        }
//    }

//    // manageControls: Hides and Shows controls depending on currentPosition 
//    function manageControls(position) {
//        // Hide left arrow if position is first slide 
//        if (position == 0) { $('#leftControl').hide() } else { $('#leftControl').show() }
//        // Hide right arrow if position is last slide 
//        if (position == numberOfSlides - 1) { $('#rightControl').hide() } else { $('#rightControl').show() }
//        $('#leftControl').hide();
//        $('#rightControl').hide();
//    }

//});

//$(function () {



//    $(".mouseWheel .jCarouselLite").jCarouselLite({
//        btnNext: ".mouseWheel .next",
//        btnPrev: ".mouseWheel .prev",
//        easing: "easeinout",
//        visible: 3,
//        mouseWheel: false
//    });




//});




$(function () {
    $(".anyClass2").jCarouselLite({
        btnNext: ".next2",
        btnPrev: ".prev2"
    });
});



$(document).ready(function () {



    $('#accordion >li').click(function () {

        //slideup or hide all the Submenu
        $('#accordion >li').children('ul').slideUp('fast');

        //remove all the "Over" class, so that the arrow reset to default
        $('#accordion >li > a').each(function () {
            if ($(this).attr('rel') != '') {
                $(this).removeClass($(this).attr('rel') + 'Over');
            }
        });

        //show the selected submenu
        $(this).children('ul').slideDown('fast');

        //add "Over" class, so that the arrow pointing down
        $(this).children('a').addClass($(this).children('li a').attr('rel') + 'Over');

    });
    $('#accordion >li >ul >li').click(function () {

        //slideup or hide all the Submenu
        $('#accordion >li >ul >li').children('ul').slideUp('fast');

        //remove all the "Over" class, so that the arrow reset to default
        $('#accordion >li >ul >li > a').each(function () {
            if ($(this).attr('rel') != '') {
                $(this).removeClass($(this).attr('rel') + 'Over');
            }
        });

        //show the selected submenu
        $(this).children('ul').slideDown('fast');

        //add "Over" class, so that the arrow pointing down
        $(this).children('a').addClass($(this).children('li a').attr('rel') + 'Over');

    });
    $('#accordion >li >ul >li >ul >li ').click(function () {

        //slideup or hide all the Submenu
        $('#accordion >li >ul >li >ul >li').children('ul').slideUp('fast');

        //remove all the "Over" class, so that the arrow reset to default
        $('#accordion >li >ul >li >ul >li > a').each(function () {
            if ($(this).attr('rel') != '') {
                $(this).removeClass($(this).attr('rel') + 'Over');
            }
        });

        //show the selected submenu
        $(this).children('ul').slideDown('fast');

        //add "Over" class, so that the arrow pointing down
        $(this).children('a').addClass($(this).children('li a').attr('rel') + 'Over');

    });

});



$(window).load(function () {
    $('#slider').nivoSlider({ effect: 'sliceDownLeft', //Specify sets like: 'fold,fade,sliceDown'
        slices: 12,
        animSpeed: 500, //Slide transition speed
        pauseTime: 5000,
        startSlide: 0, //Set starting Slide (0 index)
        directionNav: false, //Next & Prev
        directionNavHide: true, //Only show on hover
        controlNav: false, //1,2,3...
        controlNavThumbs: false, //Use thumbnails for Control Nav
        controlNavThumbsFromRel: false, //Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', //Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
        keyboardNav: true, //Use left & right arrows
        pauseOnHover: true, //Stop animation while hovering
        manualAdvance: false, //Force manual transitions
        captionOpacity: 0.8, //Universal caption opacity
        beforeChange: function () { },
        afterChange: function () { },
        slideshowEnd: function () { }, //Triggers after all slides have been shown
        lastSlide: function () { }, //Triggers when last slide is shown
        afterLoad: function () { } //Triggers when slider has loaded});
    })
});


