// IE setTimeout/setInterval fix
/*@cc_on
(function(f){
 window.setTimeout =f(window.setTimeout);
 window.setInterval =f(window.setInterval);
})(function(f){return function(c,t){var a=[].slice.call(arguments,2);return f(function(){c.apply(this,a)},t)}});
@*/
var mouse_up_down = false;
var mouse_down_down = false;
var which = null;

$(function(){

	$(document).everyTime(1000, function(e) {
		if (mouse_down_down) {
			which.scrollTo('+=232px', 600);
		};
		if (mouse_up_down) {
			which.scrollTo('-=232px', 600);
		};
	});
	
	$('.scroll_box').each(function () {
		var divi = $(this);
		// scroll up - mouse down
		which = $(this).next('.scroller:first');
		
	  // scroll up - mouse down
	  $(this).children('.scroll_up').each(function () {
			$(this).mousedown(function () {
				mouse_up_down = true;
				which = $(this).parent().next('.scroller:first');
				var parent = $(this).parent();
				if ($(parent).hasClass('homepage_scroller_bottom') || $(parent).hasClass('right_scroller_blog_bottom')) {
					which = $(this).parent().parent().find('div.scroller');
				}
				which.scrollTo('-=232px', 600);
			})
		})
		// scroll down - mouse up
		$(this).children('.scroll_up').each(function () {
			$(this).mouseup(function () {
				mouse_up_down = false;
			})
		})
		// scroll down - mouse down
		$(this).children('.scroll_down').each(function () {
			$(this).mousedown(function () {
				mouse_down_down = true;
				which = $(this).parent().next('.scroller:first');
				var parent = $(this).parent();
				if ($(parent).hasClass('homepage_scroller_bottom') || $(parent).hasClass('right_scroller_blog_bottom')) {
					which = $(this).parent().parent().find('div.scroller');
				}
				which.scrollTo('+=232px', 600);
			})
		})
		// scroll down - mouse up
		$(this).children('.scroll_down').each(function () {
			$(this).mouseup(function () {
				mouse_down_down = false;
			})
		})
	})
	
	if ($('div.recommends_header').length > 0) {
	  var latest_month = $('div#current_month a:first');
	  if ($($('div.recommends_header').get(0)).next('div.layout').length == 0) {
	    window.location = latest_month.attr('href');
	  }
	}
	
	// gea - 2010-02-25
	// tinyMCE bug - font-family: mceinline
	$('span').each(function() {
		if ($(this).css('font-family') == "mceinline") {
			$(this).css('font-family', 'arial');
		}
	});
	
	// 2010-03-01
	$('span a').each(function() {
		var span_color = $(this).parent('span').css("color");
		if (span_color) {
			$(this).css("color", span_color);
		}
	});
	
});
