var current = 2;
$(document).ready(function(){
	$('#flows').css('visibility','visible');
	if($('#flows').html() != undefined)
	{
		flow_effects();
	}
	$('.flow').parent().click(function(){
		return false;
	});
	$('.flow').each(function(index){
		$(this).click(function(){

			if($(this).hasClass('flow_current'))
			{
				self.location.href = $(this).parent().attr('href');
			}
			else
			{
				current = index;
				flow_effects();
			}
			return false;
		});
	});
});

function flow_effects()
{
	
	var flow_w = 290;
	var flow_y = 141;
	var flows = $('.flow');
	var count = flows.length;
	var width = 500;
	var half = width/2 - 300/2;
	//setting up spot
	var gap = 100;

	var center = (width-flow_w)/2;
	var onesidemax = 3;
	
	var zindex = 10;
	
	flows.each(function(){
		$(this).removeClass('flow_current');
	});
	
	//alert(current);
	for(var i=1;i<=current;i++)//process left hand side images
	{
		var flow = flows.eq(current-i);
		var width = flow_w * (0.9 - 0.11*i);
		var height = flow_y * (0.9 - 0.11*i);
		var top = (flow_y - height) / 2;
		var left = center - (i+0.1)*gap  + 85*(i);
		if(i<=onesidemax)
		{
			flow.css('zIndex',zindex--).show().animate({'left':left, 'top': top, 'width':width, 'height':height}, 200);
		}
		else
		{
			flow.css('zIndex',zindex--).show().animate({'left':left	, 'top': top, 'width':width, 'height':height}, 100).fadeOut(100);
		}
		
	}
	
	for(var i=1;i<=count-1-current;i++)//process right hand side images
	{
		var flow = flows.eq(current+i);
		var width = flow_w * (0.9 - 0.11*i);
		var height = flow_y * (0.9 - 0.11*i);
		var top = (flow_y - height) / 2;
		var left = center + (i+0.4)*gap  -52*(i);
		if(i<=onesidemax)
		{
			flow.css('zIndex',zindex--).show().animate({'left':left, 'top': top, 'width':width, 'height':height}, 200);
		}
		else
		{
			flow.css('zIndex',zindex--).show().animate({'left':left, 'top': top, 'width':width, 'height':height}, 100).fadeOut(100);
		}

	}

	flows.eq(current).addClass('flow_current').css('zIndex',100).show().animate({'left':center, 'top':0, 'width':'290', height:'141'}, 300);	
}