var flashcycle;
$(function(){
	$('.replace_this').each(function(){
		var $this = $(this);
		$.get('/image_replace/replace?text=' + $this.text(), function(data) {
			$this.replaceWith('<img src="' + data + '" alt="' + $this.text() + '" />');
		});
	});
	$('#menu ul li').dropdown();
	$('#language_select').sSelect();
	$('#language_select').change(function(){location.href=$(this).val()});
	if($('#flash .flash').length > 0){
	    $('#flash').append('<div id="flashman"><a id="flash-prev">' + gettext('Prev') + '</a> | <a id="flash-next">' + gettext('Next') + '</a></div>');
		flashcycle = $('#flash #flashcontainer').cycle({prev: '#flash-prev', next: '#flash-next', pause: 1});
	} else {
	    $('#flash').remove();
	};
	$('dl.faq dt').click(function(){
		// opens and closes dd elements b/w the current and the next dt
		var $this = $(this);
		var finished = false;
		$this.nextAll().each(function(){
			if ($(this).is('dt')) finished = true;
			if (finished) return; 
			$(this).slideToggle('slow');
		});
	});
    $.getScript(media_url + 'js/prettify.js', function(){
        prettyPrint();
    });
});

