////////
// create closure
//
(function($) {
  
    //
    // plugin definition
    //
  
    var blue_default_full = {
		left: '1132px',
		top: '270px'
	};
	
	

	////////////////////////////////////////////////
	// Blue Animations
	
	var RevoPaths = {};
	
	
		RevoPaths.blue = {
		
		slot_1:{
			enter:{
				crSpline: $.crSpline.buildSequence([
					[1300, 254], 
					[1233, 269],
					[1169, 257],
					[1092,243]
				])
				    
			},
			exit:{
				crSpline: $.crSpline.buildSequence([
					[1090,228],
					[1009,58]
				])
			},
			sele:{
				reposition :{
					left:1090,
					top:228
				}			    
			},
			hover_back:{
					crSpline: $.crSpline.buildSequence([
						[1092,243],
						[1098, 238]
					])

			},
			hover_forward:{
					crSpline: $.crSpline.buildSequence([
						[1098, 238],
						[1092,243]
					])

			}
			
		
		},
	
		
		
		
		slot_2:{
			enter:{
				crSpline: $.crSpline.buildSequence([
						[1619, 243], 
						[1515, 248],
						[1476, 284],
						[1504,263]
				])
			    
			},
			exit:{
				crSpline: $.crSpline.buildSequence([
					[1504, 263],
					[1734, 298]
				
				])
			    
			},
			hover_back:{
					crSpline: $.crSpline.buildSequence([
						[1504,263],
						[1486, 239]
					])

			},
			hover_forward:{
					crSpline: $.crSpline.buildSequence([
						[1486, 239],
						[1504,263]
					])

			}
		},
		
		slot_3:{
			enter:{
				crSpline: $.crSpline.buildSequence([
					[1867, 376], 
					[1786, 353],
					[1694, 339],
					[1727,305]
				])
			    
			},
			exit:{
				crSpline: $.crSpline.buildSequence([
					[1767,324],
					[1939,290]
				])
			    
			},
			hover_back:{
					crSpline: $.crSpline.buildSequence([
							[1727,305],
							[1711, 299]
					])

			},
			hover_forward:{
					crSpline: $.crSpline.buildSequence([
								[1711, 299],
							[1727,305]
					])

			}
		},
		
		slot_4:{
			enter:{
				crSpline: $.crSpline.buildSequence([
					[1366, 379], 
					[1332, 374],
					[1293, 360],
					[1275,348]
				])
			    
			},
			exit:{
				crSpline: $.crSpline.buildSequence([
					[1275,348],
					[1224,322]
				])
			    
			}
		}

		
	}
	
	///////////////////////////////////////////////////////////////
	//Red animations
	
	RevoPaths.red = {

		slot_1:{
			enter:{
				crSpline: $.crSpline.buildSequence([
					[1469, 254], 
					[1549, 264],
					[1573, 257],
					[1602,242]
				])

			},
			exit:{
				crSpline: $.crSpline.buildSequence([
					[1602,242],
					[1527,150]
				])
			},
			sele:{
				reposition :{
					left:1090,
					top:228
				}			    
			},
			hover_back:{
					crSpline: $.crSpline.buildSequence([
						[1092,243],
						[1098, 238]
					])

			},
			hover_forward:{
					crSpline: $.crSpline.buildSequence([
						[1098, 238],
						[1092,243]
					])

			}


		},


		slot_2:{
			enter:{
				crSpline: $.crSpline.buildSequence([
						[1209, 254], 
						[1293, 263],
						[1266, 277],
						[1246,288]
				])

			},
			exit:{
				crSpline: $.crSpline.buildSequence([
					[1246,288],
					[999, 274]
				])

			},
			hover_back:{
					crSpline: $.crSpline.buildSequence([
						[1504,263],
						[1486, 239]
					])

			},
			hover_forward:{
					crSpline: $.crSpline.buildSequence([
						[1486, 239],
						[1504,263]
					])

			}
		},

		slot_3:{
			enter:{
				crSpline: $.crSpline.buildSequence([
					[924, 394], 
					[1007, 349],
					[1082, 308],
					[1114,298]
				])

			},
			exit:{
				crSpline: $.crSpline.buildSequence([
					[1114,298],
					[865,266]
				])

			},
			hover_back:{
					crSpline: $.crSpline.buildSequence([
							[1727,305],
							[1711, 299]
					])

			},
			hover_forward:{
					crSpline: $.crSpline.buildSequence([
								[1711, 299],
							[1727,305]
					])

			}
		},

		slot_4:{
			enter:{
				crSpline: $.crSpline.buildSequence([
					[1366, 379], 
					[1332, 374],
					[1293, 360],
					[1275,348]
				])

			},
			exit:{
				crSpline: $.crSpline.buildSequence([
					[1275,348],
					[1224,322]
				])

			}
		}
	}
	

	
	
	////////////////////////////////////////////////
	// States
	
	var RevoStates = {};
	
	
	/// States
	RevoStates.sele = {
		width: '230px',
		height: '421px',
		opacity: 1.0
		
	};
	
	
	/// States
	RevoStates.onDeck = {
		width: '88px',
		height: '161px',
		opacity: 1.0
		
	};
	
	
	RevoStates.med = {
		width: '202px',
		height: '370px',
		opacity: 1.0
		
	};
	
	RevoStates.med_doc = {
		width: '175px',
		height: '319px',
		opacity: 1.0
		
	};
	
	RevoStates.med_hover = {
		width: '120px',
		height: '219px',
		opacity: 1.0
		
	};
	
	RevoStates.small = {
		width: '129px',
		height: '237px',
		opacity: 1.0
		
	};
	
	RevoStates.out = {
		width: '216px',
		height: '395px',
		opacity: 0
		
	};
	
	RevoStates.sele_out = {
		width: '366px',
		height: '670px',
		opacity: 0
		
	};
	
	RevoStates.off = {
		width: '0px',
		height: '0px',
		opacity: 0
		
	};
	
	
	
	
	var blue_default_med = {
		left: '1538px',
		top: '356px'
	};
	
	
	var small = {
		width: '38px',
		height: '108px',
		opacity: 0.4
		
	};



  
   var methods = {
   
	    init : function( options ) { 
	    	 // //////.log('INIT REVOMAn');
			 // //////.log(RevoStates);
	    // THIS 
	    },
	   
	    animate : function(step_1,step_2,step_class){
	    	
	    	if(!step_1)
	    		return false;
	    	
	    	 // //////.log('STARTING ANIMATION: %s',$(this).attr('id'));
			 // //////.log(step_1);
			 // //////.log($(this).position());
	    	
	  		reveal_animate = $.extend({},  RevoPaths[step_1.color][step_1.slot][step_1.action], RevoStates[step_1.state]);
	  		
	  		//// // //////.log(step_1.opacity);
	  		
	  		if(step_1.opacity > -1){
	  			// // //////.log('override opacity');
	  			reveal_animate.opacity = step_1.opacity;
	  		}  			 
	  		
			
			// remove opciaty from animations for ies
			if($.browser.msie){
				delete reveal_animate.opacity;
			}
	  		 					
	  		
	  		//// // //////.log(reveal_animate);
	  		
	  		//// // //////.log($(this).position());
				  		//// // //////.log(reveal_animate);
	  		return $(this).animate(
	  			reveal_animate,
	  		    250,
	  			"linear",
	  			function(arguments) {
						// // //////.log($(this).attr('id')+ 'reveal animation complete');
												
						// // //////.log(step_2);
						
						if(step_2 != undefined){
							 // //////.log('STOPPING ANIMATION: %s',$(this).attr('id'));
							
							
							// check for class
							if(step_2.remove != undefined){
								// Add an remove classes
								// //////.log('change classes');
								$(this).removeClass(step_2.remove);
								$(this).addClass(step_2.add);
								return false;
							}
							
							// // //////.log($(this).attr('id')+ ' second animation');
							
							var lposition = $(this).position();
					  		// move item to beginning animation state
					  		
					  		if( RevoPaths[step_2.color][step_2.slot][step_2.action].reposition){
								// //////.log('move item for new animation');
					  			$(this).css({
						  			'left': RevoPaths[step_2.color][step_2.slot][step_2.action].reposition.left+'px',
						  			'top': RevoPaths[step_2.color][step_2.slot][step_2.action].reposition.top+'px',
									'width':'230px',
									'height':'470px'
						  			});
					  		}else if( RevoPaths[step_2.color][step_2.slot][step_2.action] ){
					  			// //////.log('move item for new animation %s', step_1.reEntry);
								$(this).removeAttr("style");
								// //////.log(step_1.reEntry);
								if(step_1.reEntry){
									$(this).addClass(step_1.reEntry);	
								}
								
							
						  		
							}
					  
					   		lposition = $(this).position();
					  		//// // //////.log(reveal_animate.path.p1[0]);
					  		// // //////.log(lposition);
	
							
							
							
							
							// // //////.log(arguments);
							
							// //////.log(step_class);
							methods["animate"].call( this, step_2, step_class);
						
					    }else{
					    	
					    	if(step_1.reEntry){
					    		//////.log('remove style, repositon');
					    		$(this).removeAttr("style");
								$(this).addClass(step_1.reEntry);	
							}
							
								// do callback
								//////.log('callback: %s',step_1.callBack);
								if(step_1.callBack != undefined){
										
										window[step_1.callBack].call();	
								}
					    }
					    // End step two
						
						
						
				} // end function done animate
			);		
	    },
	   
	    hide : function( ) { // GOOD 
	    },
	   
	    update : function( content ) { // !!! 
	    }
    
   };
  
  
  
  $.fn.revoMan = function(method) {
    	 // //////.log('INIT REVOMAn');
			 // //////.log(RevoStates);
	    //debug(this);
	    // build main options before element iteration
	//    var opts = $.extend({}, $.fn.revoMan.defaults, options);
	    // iterate and reformat each matched element
	    
	    
	    ///////////////////////////////////////////////////////////////////////
		// Method calling logic
		if ( methods[method] ) {
		// // //////.log('Arguments');
		// // //////.log(Array.prototype.slice.call( arguments, 1 ));
			      return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
			    } else if ( typeof method === 'object' || ! method ) {
			      return methods.init.apply( this, arguments );
			    } else {
			      $.error( 'Method ' +  method + ' does not exist on jQuery.tooltip' );
		}    

	    
	/*
    
	    return this.each(function() {
	     
		      $this = $(this);
		      
		      // // //////.log('REVOMAN: %s',$this);
		      
		      // build element specific options
		      // var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
		      // update element styles
		     /*
	 $this.css({
		        backgroundColor: o.background,
		        color: o.foreground
		      });
	
		      
		      var markup = $this.html();
		      // call our format function
		      //markup = $.fn.revoMan.format(markup);
		      //$this.html(markup);
		      
		      // // //////.log('Arugments %s',arguments);
		      // // //////.dir(arguments);
		   //   // // //////.dir('SIZE: %s', size);

		      
		  		      
	      
	      
	    });
*/

  };
  
  
  //
  // private function for debugging
  //
 /*
 function debug($obj) {
    if (window.// // ////// && window.// // //////.log)
      window.// // //////.log('hilight selection count: ' + $obj.size());
  };
  
*/
  
  // Reveal person. Anitmae from teh back
  function create_path(coords){
  		//return new $.path.bezier(coords);
  		return '';
  }
  
  
   
  //
  // plugin defaults
  //
  $.fn.revoMan.defaults = {
    foreground: 'red',
    background: 'yellow'
  };
//
// end of closure
//
})(jQuery);

