// PLwizard.js - A jQuery Plugin
// Version 1.0.1
// Written by Andy Tennison

(function($) {
	$.fn.PLwizard = function(options) {
		var opts = $.extend({}, $.fn.PLwizard.defaults, options);
		return this.each(function() {
			var $formStep = [];
			var curIndex = 0;

			$(this).find('.form-step').each(function(i){
				$formStep[i] = $(this);
				if(i == 0){
					$formStep[i].addClass('current')
				} else {
					$formStep[i].addClass('incomplete');
					$formStep[i].find('input').attr('disabled', 'disabled')
				}
				
				$formStep[i].find('input').click(function(){
					$formStep[i].removeClass('current').addClass('complete');
					if(curIndex == i){
						curIndex++;
						$formStep[curIndex].removeClass('incomplete').addClass('current')
						$formStep[curIndex].find('input').removeAttr('disabled')
					}
				});
				
				$formStep[i].bind("mouseenter", function(e){
					if($(this).hasClass('complete')){
        				$(this).addClass("hover");
					}
    			}).bind("mouseleave", function(e){
					if($(this).hasClass('complete')){
        				$(this).removeClass("hover");
					}
				});
				
				
			}); // end each 'formStep'
			
				
		});


		
	}; // end plugin PLwizard


// end of closure
})(jQuery);

$.fn.PLwizard.defaults = {
	//duration: 800
};
