$(document).ready(function(){
	jQuery.easing.def = "easeOutQuad";
	$("#accAlt").css("display","none");
	$(".accPanel").css("display","block");
	$(".accPanel").html("<ul class='accordion'><li class='one'><div><h2>YKS &#8211; Contact Details</h2><p>For further information on all YKS products, or to arrange an initial informal discussion, please:</p><div id='accContactPhone'>Call our friendly team on 01274 353535</div><a href='yks_enquiry.html' id='accContactForm'>Complete our form - Click here</a><a href='contact_yks.html' id='accContactClick'>Visit our contact section - Click here</a></div></li><li class='two'><div><h2>YKS Can Provide</h2><p>If you are considering any  of the above solutions, YKS can help right from the start. Based on our experience  we can provide to you ideas and insight into:</p><ul><li>Retail savings inflow expectations, on a product by product basis</li><li>Acquisition costs for  retail funds</li><li>Project Management</li><li>Quick delivery timescales</li></ul></div></li><li class='three'><div><h2>YKS &#8211; Here to help</h2><p>We operate in a highly consultative way, not just for the  duration of the project but during our entire business relationship. This means that we can provide support in areas not normally  associated with such projects. Using the experts and extensive experience within the Yorkshire  Building Society, we can add value in areas such as:</p><ul><li>Product pricing</li><li>Retention activities and strategies</li><li>Process management</li><li>Online marketing</li></ul><p>The solutions, processes and procedures offered by YKS are  operational now to meet your current business aspirations and are scalable to  ensure they meet your future needs.</p></div></li></ul>");
	
	function checkImage() {
		if (tabOneState == 1)
		{
			$(".one").css("background-image","url(assets/img/accContactTabOver.png)");
		}
		else
		{
			$(".one").css("background-image","url(assets/img/accContactTab.png)");
		}
		if (tabTwoState == 1)
		{
			$(".two").css("background-image","url(assets/img/accProvideTabOver.png)");
		}
		else
		{
			$(".two").css("background-image","url(assets/img/accProvideTab.png)");
		}
		if (tabThreeState == 1)
		{
			$(".three").css("background-image","url(assets/img/accHelpTabOver.png)");
		}
		else
		{
			$(".three").css("background-image","url(assets/img/accHelpTab.png)");
		}
	}
	
	$(".one div").hide();
	$(".two div").hide();
	$("#accInstructions").css("display","block");
	
	
	var tabOneState = 0;
	var tabOnePosition = -724;
	
	var tabTwoState = 0;
	var tabTwoPosition = -677;
	
	var tabThreeState = 1;
	var tabThreePosition = -629;
	
	checkImage();
	
	
	
	
	
	$(".one").click(function()
			{
				if (tabOneState == 0)
				{
					$(this).animate({left: "0px"}, 800 );
					
					tabOneState = 1;
					checkImage();
					$(".one div").fadeIn(200);
					
					
					 $(".two div").fadeOut(200);
					$(".two").animate({left: "50px"}, 800 );
					tabTwoState = 1;
					checkImage();
					
					$(".three div").fadeOut(200);
					$(".three").animate({left: "98px"}, 800 );
					tabThreeState = 1;
					checkImage();					
				}
				else if (tabOneState == 1)
				{
					$(this).animate({left: tabOnePosition}, 800 );
					tabOneState = 0;
					checkImage();
					
					setTimeout(
						function()
						{
							$(".two div").fadeIn(200);
						}, 600);
					
					$(".two").animate({left:"50px"}, 800 );
					tabTwoState = 1;
					checkImage();
					
					$(".three").animate({left: "98px"}, 800 );
					
					tabThreeState = 1;
					checkImage();
				}
			}
			
	);
	
	$(".two").click(function()
			{
				if (tabTwoState == 0)
				{
					$(".one div").fadeOut(200);
					$(".one").animate({left: tabOnePosition}, 800 );
					tabOneState = 0;
					checkImage();
					
					$(this).animate({left: "50px"}, 800 );
					
					$(".two div").fadeIn(200);
					tabTwoState = 1;
					checkImage();
					
					
					$(".three div").fadeOut(200);
					$(".three").animate({left: "98px"}, 800 );
					tabThreeState = 1;
					checkImage();
					
				}
				else if (tabTwoState == 1 && tabOneState == 1)
				{
					
					$(".one").animate({left: tabOnePosition}, 800 );
					tabOneState = 0;
					checkImage();
					setTimeout(
						function()
						{
							$(".two div").fadeIn(200);
						}, 600);
					
				}
				else if (tabTwoState == 1)
				{
					$(".one div").fadeOut(200);
					$(".one").animate({left: tabOnePosition}, 800 );
					tabOneState = 0;
					checkImage();
					
					if (tabOneState == 0)
					{
						$(".two div").fadeIn(200);
						$(this).animate({left: tabTwoPosition}, 800 );
						tabTwoState = 0;
						checkImage();
					}
					else if (tabOneState == 1)
					{
						setTimeout(
						function()
						{
							$(".two div").fadeIn(200);
						}, 600);		
					}
					
					$(".three").animate({left: "98px"}, 800 );
					setTimeout(
						function()
						{
							$(".three div").fadeIn(200);
						}, 600);
					tabOneState = 0;
					checkImage();
				}
			}
			
	);
	
	$(".three").click(function()
			{
				if (tabThreeState == 0)
				{
					$(".one").animate({left: tabOnePosition}, 800 );
					tabOneState = 0;
					checkImage();
					
					$(".two").animate({left: tabTwoPosition}, 800 );
					tabTwoState = 0;
					checkImage();
					
					$(".three div").fadeIn(400);
					$(this).animate({left: "98px"}, 800 );
					tabThreeState = 1;
					checkImage();
				}
				else if (tabThreeState == 1 && tabTwoState == 1 && tabOneState == 1)
				{
					$(".one").animate({left: tabOnePosition}, 800 );
					tabOneState = 0;
					checkImage();
					
					$(".two").animate({left: tabTwoPosition}, 800 );
					tabTwoState = 0;
					checkImage();
					
					setTimeout(
						function()
						{
							$(".three div").fadeIn(200);
						}, 600);
				}
				else if (tabThreeState == 1 && tabTwoState == 1)
				{
					$(".two").animate({left: tabTwoPosition}, 800 );
					tabTwoState = 0;
					checkImage();
					setTimeout(
						function()
						{
							$(".three div").fadeIn(200);
						}, 600);
					
				}
				
			}
			
	);
	
});
