jQuery.noConflict();
jQuery(document).ready(function() {
   
   // object to hold cafe list
   var cafeHolder = {
	   "current" 	: 0,
	   "init" 		: function() {
		   this.current = Math.round(2 * Math.random());
		   this.next();
		   esCommon.timerRegistry
		   	.add({
				"name"	: "cafeRotator",
				"callback" : function () {
					cafeHolder.next();
				},
				"interval" : 10000
			});
	   },
	   "next"		: function() {
		   if (this.current == 3)
			   this.current = 0;
		   this.showCafeKind(this.current + 1);
		   this.current++;
	   },
	   "showCafeKind" : function (kind) {
		   jQuery(".left .l_second li a").removeClass("current");
		   jQuery(".left .l_second > a").hide();
		   jQuery(".left .l_second > a.kind_" + kind).show();
		   jQuery(".left .l_second li a.kind_" + kind).addClass("current");
	   }
   };

   // object to hold image list
   var imageHolder = {
	   "list" 		: jQuery(".right .r_first li"),
	   "current" 	: 0,
	   "init" 		: function() {
		   this.next();
		   esCommon.timerRegistry
	   		.add({
				"name"	: "imageRotator",
				"callback" : function () {
					imageHolder.next();
				},
				"interval" : 10000
			});
	   },
	   "next"		: function() {
		   this.list.hide();
		   var index = this.current;
		   for (var i = 0; i < 3; i++)
		   {
			   if (index == this.list.length)
				   index = 0;
			   this.list.eq(index).fadeIn();
			   index++;
		   }
		   this.current = index;
	   }
   };
   
   
   // init holders
   imageHolder.init();
   cafeHolder.init();
});
