//keep the scope within jQuery
$.noConflict();

// Start jQuery
jQuery(document).ready(function($){
     // Sort out IE6's png problems
     //$(document).pngFix(); 
    
    // move the readmore's
    for (i = 0; i < $('.promo a').length; i++) {
        $('.promo a:eq(' + i + ')').appendTo($('.promo p:eq(' + i + ')'));
    }
    
    
    // move the readmore's
    for (i = 0; i < $('.exhibit a.readmore').length; i++) {
        $('.exhibit:eq(' + i + ') a.readmore').appendTo($('.exhibit:eq(' + i + ') p:last'));
    }
    
    // add the onclicks to the div
    $('.promo').click(function(event){
        //alert('link: ' + $(this).find('a.readmore').attr('href'));
        document.location.href = $(this).find('a.readmore').attr('href');
        
    });
    
    // Setup the home page slideshow
    $('#imagetray a:eq(0)').clone().appendTo('#imagetray a:last');
    var slidetop = Number('-' + (($("#imagetray img").length - 1) * 319));
    var slidesetup = slidetop;
    $("#imagetray img").fadeIn().css('display', 'block');
    
    function scrollpicsdown(){
        $('#imagetray').animate({
            top: slidesetup
        }, {
            duration: 300,
            easing: 'easeOutQuad',
            queue: false
        });
    }
    
    // run the slideshow
    if ($("#imagetray img").length > 0) {
        $("#imagetray").css('top', slidesetup);
        
        $.timer(6000, function(timer){
            slidesetup += 319;
            if (slidesetup < 319) {
                scrollpicsdown();
            }
            else {
                slidesetup = slidetop;
                $("#imagetray").css('top', slidesetup);
                slidesetup += 319;
                scrollpicsdown();
            }
        });
    }
   
});



