$(document).ready( function(){
	// submenu
	$('#topMenu, #choosePassion').superfish({
		animation	: {height : 'show'},
		speed		: 'fast',
		delay		: 1000,
		dropShadows	: false,
		autoArrows	: false
	});

	// slider
	if($('#slides').length > 0){
		$('#sliderNavi a').click( function(){return false;});
		$('#slides').jFlow({
				slides: "#slides_container",
				width: "720px",
				height: "267px"
		});
	}

	// preload submenu images
	setTimeout(function(){
		$.preloadImages(TEMPLATE_URL + 'images/submenu.png',
						TEMPLATE_URL + 'images/submenu_hover.png',
						TEMPLATE_URL + 'images/submenu_bttm.png');
	}, 4000);

	// podcast table
	$('#podcast_table td.exp').click( function(){
		var tr = $(this).parent();
		// close
		if(tr.hasClass('opened')){
			podcast.close_table_all();
		}
		// open
		else{
			podcast.close_table_all();
			tr.addClass('opened')
				.removeClass('hover');
			tr.find('.full').show();
			tr.find('.intro').hide();
		}
	});

	// selectbox
	if($('.cformselect').length > 0){
		$('.cformselect').selectbox();
	}

	if($.browser.msie && $.browser.version == 6 && typeof(fix_buggy_ie6_png) == 'function'){
		fix_buggy_ie6_png();
	}
});

var podcast = {
	close_table_all : function(){
		$('#podcast_table tr.opened').each(function(){
			$(this).removeClass('opened')
				.addClass('hover');
			$(this).find('.full').hide();
			$(this).find('.intro').show();
		});
	}
};



(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preloadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery);
