function fadeUp(e) {
    //note that this function could perform whatever you want on element e
    $(e).fadeIn(2000);
}

function nl2br(str, is_xhtml) {
    var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>';
    return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
}

jQuery.fn.slidethis = function (d) {
    $(this).delay(d).animate({
        opacity: 'toggle',
        "margin-top": ['0px', 'swing']
    })
}

function sortAlpha(a, b) {
    return a.firstChild.innerHTML - b.firstChild.innerHTML;
};


function buildingsGallery() {

    
    // Initially set opacity on thumbs and add
    // additional styling for hover effect on thumbs
    var onMouseOutOpacity = 0.27;
    $('#thumbs ul.thumbs li a').opacityrollover({
        mouseOutOpacity: onMouseOutOpacity,
        mouseOverOpacity: 1.0,
        fadeSpeed: 'fast',
        exemptionSelector: '.selected'
    });
    // Initialize Advanced Galleriffic Gallery
    var gallery = $('#thumbs').galleriffic({
        delay: 2500,
        numThumbs: 9,
        preloadAhead: 9,
        enableTopPager: false,
        enableBottomPager: true,
        imageContainerSel: '#slideshow',
        controlsContainerSel: '#controls',
        captionContainerSel: '#leftinfo',
        loadingContainerSel: '#loading',
        renderSSControls: false,
        renderNavControls: false,
        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 li').children().eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end().eq(nextIndex).fadeTo('fast', 1.0);
        }

    });
}

function furnitureGrid() {
    if (!cat) {
        cat = 'catalog';
    }

      if (cat != 'catalog') {
        $('ul.f-thumbs li img').not($('ul.f-thumbs li.' + cat + ' img')).fadeTo('fast', 0.1, 'linear', function () {
            // Animation complete.
            $(this).parent('a').addClass("disabled");
            $(this).parent('a').click(function () {
                return false;
            });
            $(this).desaturate();
        });
    }
   // $('ul.f-thumbs li').sort(sortAlpha).appendTo('ul.f-thumbs');
    if (cat == 'catalog') {
        var faders = $('ul.f-thumbs li a').children().hide();
        i = 0;

        function awesomeFaders() {
            //alert('t');
            $(faders[i++]).delay(1).fadeIn(5, arguments.callee);
        };
        awesomeFaders();
    }
}

function furnitureGallery() {

    var onMouseOutOpacity = 0.27;
    $('#thumbs ul.thumbs li a').opacityrollover({
        mouseOutOpacity: onMouseOutOpacity,
        mouseOverOpacity: 1.0,
        fadeSpeed: 'fast',
        exemptionSelector: '.selected'
    });
    // Initialize Advanced Galleriffic Gallery
    var gallery = $('#thumbs').galleriffic({
        delay: 2500,
        numThumbs: 8,
        preloadAhead: 5,
        enableTopPager: false,
        enableBottomPager: true,
        imageContainerSel: '#slideshow',
        controlsContainerSel: '#controls',
        captionContainerSel: '#leftinfo',
        loadingContainerSel: '#loading',
        renderSSControls: false,
        renderNavControls: false,
        enableHistory: false,
        autoStart: false,
        syncTransitions: false,
        defaultTransitionDuration: 900,
        onSlideChange: function (prevIndex, nextIndex) {
            // 'this' refers to the gallery, which is an extension of $('#thumbs')
            this.find('ul.thumbs li').children().eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end().eq(nextIndex).fadeTo('fast', 1.0);
        }
    });
}

$(document).ready(function () {
   
    $('body.home #logo').css({'margin-left':'30px'}).fadeTo(0,0).animate({'margin-left':'0','opacity': '1'},800,'swing');
    $('body.home #topline').animate({'width':'960px'},1000,'swing');

 
 $("#logo img").hover(
    function(){
        $(this).animate({
         opacity: 0.6
        }, 100 )
      },
     function(){
        $(this).animate({
     opacity: 1
    }, 200 )
  });

// $('#leftinfo #requestLink').css('opacity', '1')
 $('#leftnav li a.'+ navID +'').toggleClass('selected').prepend('> ');

});

//$('#leftinfo').ready(function () {
//  $(' #requestLink').css('opacity', '1');
//});
