$(document).ready(function() {
	$('#btn-check-points-bal').click(function(){
		var _this = $(this);
		if( !$('#fb_widget').is(":visible") ) {
			_this.fadeOut(100, function() {
				$(this).addClass('active').fadeIn(100);
				$('#fb_widget').slideDown();
				$('#fb_widget').fadeIn(100);
			});
		} else {
			
			$('#fb_widget').slideUp(300, function () {
				_this.fadeOut(100, function() {
					_this.removeClass('active').fadeIn(100);
				});
			} );			
		}
		return false;
	});
	
	if($('.flipper a').length>0) {
		int_sandw = window.setInterval(function sandw() {
			var indo = 1;
			var offset = 100;
			$('.flipper a').siblings('img').each(function() {
				var delayOffset = offset*indo;
				$(this).delay(delayOffset).animate({height: 'toggle'},200);
				//console.log(delayOffset);
				indo++;
			});
		},5000);
	}

	$('.expand-panel .inner').hide().parent('.expand-panel').removeClass('expand-panel-shown').children('h2').click(function(){
		$(this).parent('.expand-panel').toggleClass('expand-panel-shown').children('.inner').slideToggle();
	});

	$('.carousel').after('<div id="carousel-nav">').cycle({ 
		fx:     'fade',
		height:  309,
		speed:   500, 
		timeout: 5000,
		pause:   1,
		pager:  '#carousel-nav' 
	});	

	//PNG 'fix' for items that dont play nice
	if($.browser.msie && $.browser.version.substr(0,1)<7) {
		$('#footer .column').css('background','none');
		DD_belatedPNG.fix('.png_fix,.breadcrumbs,.overlay');
	}
	
	$(".noscript").remove();
	$('.showbyscript').css('display','block');
	$('.hidewithscript').hide();
});

// global page update function
function updatePage () {
	Cufon.replace('h1,h2,h3,#item_detail h3,.list_entry a.title,.cufon-din',{ fontFamily: 'DIN' });
	Cufon.replace('.cufon-accidents',{
		fontFamily: 'Accidents Grotesque',
		textShadow: 'rgba(20,20,20,.4) 1px 1px'
	});
}

// kick start all js page modifications
updatePage();
	
