var dvc_class="waterkoeler-list";
var dvc_open_close_speed=250;
var dvc_opacity_speed=200;

/* BEGIN LIST INFO */
var listIDs = ['sublimo','prestige','carbo','classic','tabletop'];
var widths =  new Array(); 
widths[0]=[70,140,420];
widths[1]=[70,140,420];
widths[2]=[70,140,420];
widths[3]=[70,140,420];
widths[4]=[76,146,426];
/* END LIST INFO */

var toOpenId="";
var openId="";

$(document).ready(function(){	
	$('.'+dvc_class+' > li').mouseenter(function(){
		//$(':animated').stop(true,false);
		toOpenId=$(this).attr('id');

			$('.'+dvc_class+' > li').each(function(){
				if(toOpenId==$(this).attr('id'))
				{
					$('#'+$(this).attr('id')+' > .koeler-image a img').css('opacity',1);
					$('#'+$(this).attr('id')+' > .cooler_info_animate').animate({opacity:1},500);
					$(this).animate({width:getWidth($(this).attr('id'),2)+'px'},500,function(){
						openId=$(this).attr('id');
						$('#'+$(this).attr('id')+' > *').animate({opacity:0},500,function(){
							$('.'+dvc_class).parent().parent().addClass('open');
							$(this).parent().addClass('selected');
							$(this).animate({opacity:1},500);
						});
					});
				}
				else
				{
					if($('#'+$(this).attr('id')).hasClass('selected')==false)
						$('#'+$(this).attr('id')+' > .koeler-image a img').css('opacity',0);
					$('#'+$(this).attr('id')+' > .cooler_info_animate').animate({opacity:0},500);
					$(this).animate({width:getWidth($(this).attr('id'),0)+'px'},500);	
				}
			});
		
	})
	.mouseleave(function(){
		$(':animated').stop(true,false);				 
		if(openId=="") return true;
		$('#'+openId+' > *').animate({opacity:0},500,function(){
			$('.'+dvc_class).parent().parent().removeClass('open');
			$(this).parent().removeClass('selected');
			if($(this).hasClass('koeler-image'))
			{
				$(this).children().children().css('opacity',0);
				$(this).animate({opacity:1},500);
			};													  
		});
	})
	.click(function(){
		window.location=$("#"+$(this).attr("id")+" .button:first a").attr("href");
	});
	$('.'+dvc_class).mouseleave(function(){ 
			$('.'+dvc_class+' > li').each(function(){
				$(this).animate({width:getWidth($(this).attr('id'),1)+'px'},500,function(){
					$('#'+$(this).attr('id')+' > .koeler-image a img').css('opacity',1);
					$('#'+$(this).attr('id')+' > *').animate({opacity:1},500);
				});
			});

	});
});
function getIndexID(id) { for (i in listIDs) { if(id==listIDs[i]) return i; } return false; }
// states [ small=0, normal=1, big=2 ]
function getWidth(id,state) { var index=getIndexID(id); return widths[index][state]; }