// Create accordion
$(document).ready(function(){ //Starts the accordion
	
	lastBlock = $("#a1");
	maxWidth = 745;
	minWidth = 25;	

	$("#slider ul li a").click(
	  function(){
		$(lastBlock).animate({width: minWidth+"px"}, { queue:false, duration:500 });
	$(this).animate({width: maxWidth+"px"}, { queue:false, duration:500});
	lastBlock = this;
	  }
	);

//Add event handlers for for accordion tabs to change images on mouseover and on click
	$("#workExperience").mouseover(function() { $("#workExperience").attr("src", "images/slider-work-experience-over.gif"); });
	$("#skills").mouseover(function() { $("#skills").attr("src", "images/slider-skills-over.gif"); });
	$("#skills").mouseout(function() { $("#skills").attr("src", "images/slider-skills.gif") });
	$("#education").mouseover(function() { $("#education").attr("src", "images/slider-education-over.gif"); });
	$("#education").mouseout(function() { $("#education").attr("src", "images/slider-education.gif") });
	$("#projects").mouseover(function() { $("#projects").attr("src", "images/slider-projects-over.gif"); });
	$("#projects").mouseout(function() { $("#projects").attr("src", "images/slider-projects.gif"); });
	$("#workExperience").click(function() { accordion("#workExperience","images/slider-work-experience-over.gif", "images/slider-work-experience.gif"); });
	$("#skills").click(function() { accordion("#skills","images/slider-skills-over.gif", "images/slider-skills.gif"); });
	$("#education").click(function() { accordion("#education","images/slider-education-over.gif", "images/slider-education.gif"); });
	$("#projects").click(function() { accordion("#projects","images/slider-projects-over.gif", "images/slider-projects.gif"); });	  

});

/* jFlow Plugin
 * Copyright (c) 2008 Kean Loong Tan http://www.gimiti.com/kltan
 * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * jFlow
 * Version: 1.1 (May 22, 2008)
 * Requires: jQuery 1.2+
 */
 
//Plugin for Work Experience Slider
(function(A){A.fn.jFlowOne=function(D){var E=A.extend({},A.fn.jFlowOne.defaults,D);var F=0;var B=A(".jFlowControl").length;A(this).find(".jFlowControl").each(function(G){A(this).click(function(){A(".jFlowControl").removeClass("jFlowSelected");A(this).addClass("jFlowSelected");var H=Math.abs(F-G);A(E.slides).animate({marginLeft:"-"+(G*A(E.slides).find(":first-child").width()+"px")},E.duration*(H));F=G})});A(E.slides).before('<div id="jFlowSlide"></div>').appendTo("#jFlowSlide");A(E.slides).find("div").each(function(){A(this).before('<div class="jFlowSlideContainer"></div>').appendTo(A(this).prev())});A(".jFlowControl").eq(F).addClass("jFlowSelected");var C=function(G){A("#jFlowSlide").css({position:"relative",width:E.width,height:E.height,overflow:"hidden"});A(E.slides).css({position:"relative",width:A("#jFlowSlide").width()*A(".jFlowControl").length+"px",height:A("#jFlowSlide").height()+"px",overflow:"hidden"});A(E.slides).children().css({position:"relative",width:A("#jFlowSlide").width()+"px",height:A("#jFlowSlide").height()+"px","float":"left"});A(E.slides).css({marginLeft:"-"+(F*A(E.slides).find(":first-child").width()+"px")})};C();A(window).resize(function(){C()});A(".jFlowPrevOne").click(function(){if(F>0){F--}else{F=B-1}A(".jFlowControl").removeClass("jFlowSelected");A(E.slides).animate({marginLeft:"-"+(F*A(E.slides).find(":first-child").width()+"px")},E.duration);A(".jFlowControl").eq(F).addClass("jFlowSelected")});A(".jFlowNextOne").click(function(){if(F<B-1){F++}else{F=0}A(".jFlowControl").removeClass("jFlowSelected");A(E.slides).animate({marginLeft:"-"+(F*A(E.slides).find(":first-child").width()+"px")},E.duration);A(".jFlowControl").eq(F).addClass("jFlowSelected")})};A.fn.jFlowOne.defaults={easing:"swing",duration:400,width:"100%"}})(jQuery);

//Create Work Experience Slider
$(document).ready(function() {	
	$("#slider-one").jFlowOne({
        slides: "#slides-one",
        width: "630px",
        height: "400px",
        duration: 200
    });

		   });

//Plugin for Projects Slider
(function(S){S.fn.jFlow=function(D){var E=S.extend({},S.fn.jFlow.defaults,D);var F=0;var B=S(".jFlowControlTwo").length;S(this).find(".jFlowControlTwo").each(function(G){S(this).click(function(){S(".jFlowControlTwo").removeClass("jFlowSelectedTwo");S(this).addClass("jFlowSelectedTwo");var H=Math.abs(F-G);S(E.slides).animate({marginLeft:"-"+(G*S(E.slides).find(":first-child").width()+"px")},E.duration*(H));F=G})});S(E.slides).before('<div id="jFlowSlideTwo"></div>').appendTo("#jFlowSlideTwo");S(E.slides).find("div").each(function(){S(this).before('<div class="jFlowSlideTwoContainer"></div>').appendTo(S(this).prev())});S(".jFlowControlTwo").eq(F).addClass("jFlowSelectedTwo");var C=function(G){S("#jFlowSlideTwo").css({position:"relative",width:E.width,height:E.height,overflow:"hidden"});S(E.slides).css({position:"relative",width:S("#jFlowSlideTwo").width()*S(".jFlowControlTwo").length+"px",height:S("#jFlowSlideTwo").height()+"px",overflow:"hidden"});S(E.slides).children().css({position:"relative",width:S("#jFlowSlideTwo").width()+"px",height:S("#jFlowSlideTwo").height()+"px","float":"left"});S(E.slides).css({marginLeft:"-"+(F*S(E.slides).find(":first-child").width()+"px")})};C();S(window).resize(function(){C()});S(".jFlowPrev").click(function(){if(F>0){F--}else{F=B-1}S(".jFlowControlTwo").removeClass("jFlowSelectedTwo");S(E.slides).animate({marginLeft:"-"+(F*S(E.slides).find(":first-child").width()+"px")},E.duration);S(".jFlowControlTwo").eq(F).addClass("jFlowSelectedTwo")});S(".jFlowNext").click(function(){if(F<B-1){F++}else{F=0}S(".jFlowControlTwo").removeClass("jFlowSelectedTwo");S(E.slides).animate({marginLeft:"-"+(F*S(E.slides).find(":first-child").width()+"px")},E.duration);S(".jFlowControlTwo").eq(F).addClass("jFlowSelectedTwo")})};S.fn.jFlow.defaults={easing:"swing",duration:400,width:"100%"}})(jQuery);

//Create Projects Slider
$(document).ready(function() {
	$("#slider-two").jFlow({
        slides: "#slides-two",
        width: "630px",
        height: "400px",
        duration: 200
    });
		   });

//Handle the clicking for the accordion tabs (Work Experience, Skills, Education, Projects)
var oldTab = "#workExperience";
var oldTabOutImage = "images/slider-work-experience.gif";
function accordion(clickedTab, overImage, outImage) {  
	   
	   $(oldTab).attr("src", oldTabOutImage); //Change the old image to the outimage
	   $(clickedTab).attr("src", overImage); //Change the new image to the overimge 
	   $(clickedTab).unbind("mouseout"); //unbind the mouse event from the new image
	   
	   if (oldTab == "#workExperience") {
		   $(oldTab).mouseout(function() { $("#workExperience").attr("src", "images/slider-work-experience.gif") }); //rebind the mouseout event for the old image
	   }
	   else if (oldTab == "#skills"){
		   $(oldTab).mouseout(function() { $("#skills").attr("src", "images/slider-skills.gif"); });
	   }
	   else if (oldTab == "#education"){
		   $(oldTab).mouseout(function() { $("#education").attr("src", "images/slider-education.gif"); });
	   }
	   else if (oldTab == "#projects"){
		   $(oldTab).mouseout(function() { $("#projects").attr("src", "images/slider-projects.gif"); });
	   }
	   else {
		   alert("There is a problem.  You clicked on a tab that doesn't exist.");
	   }
	   
	   oldTab = clickedTab; //Change the current tab to the one that was just clicked
	   oldTabOutImage = outImage; //Change the outimage to the outimage for the tab that was just clicked
}
