//Do everything once the DOM has loaded
$(function() {
	
    //Read more link functionality on home page
    var $readmore = $('#offer-read-more');
    var height = $readmore.height();
    $readmore.hide().css({
        height: 0
    });
    $('.read-more-less-link').show();
                
    $('.read-more-less-link').click(function (e) {
        
        e.preventDefault();
        
        if ( $readmore.is(':visible') ) {
            $readmore.animate({
                height: 0
            }, {
                complete: function () {
                    $readmore.hide();
                    $('.read-more-less-link').css('background-position', 'left top');
                } 
            });
        } else {
            $readmore.show().animate({
                height : height
            }, {
                complete: function() {
                    $('.read-more-less-link').css('background-position', 'left bottom');
                }
            });
    }
    
    });

	//Cycle featured content	
	$('#slides').cycle({
		fx:			'scrollDown',
		speed:		800,
		timeout:	5000,
		easing:		'easeOutBounce',
		pager:		'#slider-pages',
		next:		'#slider-next',
		prev:		'#slider-prev',
		pause:		   true,
		pauseOnPagerHover: true,
		after: onAfter
	});
        
              
   //Print fancybox
   var printlinks = $('.print-link');
                
   if(printlinks != null) {
       
       printlinks.fancybox();
       
   }
   
});

function onAfter() { 
    $('#slider-overlay a').attr("href", this.href); 
}
