jQuery(document).ready(function () {

    // nav
    jQuery('ul.sf-menu').superfish();

    // login
    if (jQuery("#demo6").length) {
        jQuery(document).ready(function () {
            jQuery("#demo6").floatdialog("dialog6", { move: 'down', effect: false })
        })
    };

    // email friend
    jQuery(document).ready(function () {
        if (jQuery("#slideEmailFriend").length) {
            jQuery(document).ready(function () {
                jQuery("#slideEmailFriend").floatdialog("dialogEmailFriend", { move: 'down', effect: false })
            })
        };
    });

    // enquiry
    jQuery(document).ready(function () {
        if (jQuery("#slideEnquire").length) {
            jQuery(document).ready(function () {
                jQuery("#slideEnquire").floatdialog("dialogEnquire", { move: 'down', effect: false })
            })
        };
    });


    // gallery images
    if (jQuery("#thumbs").length) {
        jQuery('div.content').css('display', 'block');
        // Initially set opacity on thumbs and add
        // additional styling for hover effect on thumbs
        var onMouseOutOpacity = 1.0;
        jQuery('#thumbs ul.thumbs li').opacityrollover({
            mouseOutOpacity: onMouseOutOpacity,
            mouseOverOpacity: 0.5,
            fadeSpeed: 'fast',
            exemptionSelector: '.selected'
        });

        // Initialize Advanced Galleriffic Gallery
        var gallery = jQuery('#thumbs').galleriffic({
            delay: 2500,
            numThumbs: 13,
            preloadAhead: 10,
            enableTopPager: false,
            enableBottomPager: false,
            maxPagesToShow: 7,
            imageContainerSel: '#slideshow',
            controlsContainerSel: '#controls',
            captionContainerSel: '#caption',
            loadingContainerSel: '#loading',
            renderSSControls: false,
            renderNavControls: false,
            playLinkText: 'Play Slideshow',
            pauseLinkText: 'Pause Slideshow',
            prevLinkText: '&lsaquo; Previous Photo',
            nextLinkText: 'Next Photo &rsaquo;',
            nextPageLinkText: 'Next &rsaquo;',
            prevPageLinkText: '&lsaquo; Prev',
            enableHistory: false,
            autoStart: false,
            syncTransitions: true,
            defaultTransitionDuration: 900,
            onSlideChange: function (prevIndex, nextIndex) {
                // 'this' refers to the gallery, which is an extension of $('#thumbs')
                this.find('ul.thumbs').children()
						.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
						.eq(nextIndex).fadeTo('fast', 0.5);
            },
            onPageTransitionOut: function (callback) {
                this.fadeTo('fast', 0.0, callback);
            },
            onPageTransitionIn: function () {
                this.fadeTo('fast', 1.0);
            }
        });
    }

    // thumbs
    if (jQuery("a[rel^='prettyPhoto']").length) {
        jQuery(document).ready(function () {
            // prettyPhoto
            jQuery("a[rel^='prettyPhoto']").prettyPhoto({ theme: 'facebook' });

            ///// codegrabber ////////////
            jQuery(".code a.code-icon").toggle(function () {
                jQuery(this).addClass("minus").next("p").slideDown();
            }, function () {
                jQuery(this).removeClass("minus").next("p").slideUp();
            })
        });
    }

    // slide downs
    jQuery(".slideDown dt").click(function () {
        jQuery(this).toggleClass("active").parent(".slideDown").find("dd").slideToggle();
    })
    jQuery("#clickslide").click(function () {
        jQuery("#testslide").slideToggle();
    })

});
