var current_div_display = '.cycler-display-first';
var next_div_display = '.cycler-display-second';
var current_div_coupon = '.cycler-coupon-first';
var next_div_coupon = '.cycler-coupon-second';

$(document).ready(function() {
	init_display_cycler();
	init_coupon_cycler();
	init_news_rotator();
});

function init_news_rotator() {
	$('div.news-link > a').live("click", function() {
		var last = $('div.news-link > a.news-select:first');
		var next = $(this);
    last.removeClass('news-select');
		$('div#' + last.attr('rel')).fadeOut(500, function(t) {
     	$(next).addClass('news-select');
  		$('div#' + $(next).attr('rel')).fadeIn();
		});
  });
}

function init_display_cycler() {
  $('ul#navmenu li > a').live("click", function(ev) {
		var tmp_div = '';
		ev.preventDefault();
		$('ul#navmenu li > a').removeClass('selected');
		$(this).addClass('selected');
    $(next_div_display).load($(this).attr('href'), null, function() {
  		$(current_div_display).fadeOut(150, function() {
  			$(current_div_display).html($(next_div_display).html());
				$(current_div_display).fadeIn(1000);
  		});		
		});
  });
}

function init_coupon_cycler() {
  $('#coup-nav-contain > div > a').live("click", function(ev) {
		var tmp_div = '';
		ev.preventDefault();
		$('#coup-nav-contain > div > a').removeClass('select');
		$(this).addClass('select');
    $(next_div_coupon).load($(this).attr('href'), null, function() {
  		$(current_div_coupon).fadeOut(150, function() {
  			$(current_div_coupon).html($(next_div_coupon).html());
				$(current_div_coupon).fadeIn(1000);
  		});		
		});
  });
}