if(window['console'] === undefined){
  var emptyFunction = function(){};
  window.console = {log:emptyFunction,error:emptyFunction,info:emptyFunction};
}


function BenefitAnimations(animations,  active_animation){ 

    this.animations = animations.split(',');
    this.current_animation = animations.indexOf(active_animation);
    
    this.play = function( ) {
      this.loadAnimation();
    };
    this.stop = function(){
      window[this.animations[this.current_animation]+'_animation'].stop();
    };
    
    this.animatePrevious = function(){
      this.stop();
      this.current_animation--;
      if(this.current_animation < 0) this.current_animation = this.animations.length-1;
      this.play();
    };
    this.animateNext = function(){
      this.stop();
      this.current_animation++;
      if(this.current_animation >= this.animations.length) this.current_animation = 0;
      this.play();
    };
    this.loadAnimation = function() {
      var animation = this.animations[this.current_animation];
      var a = this;
      $('#benefit-animation').load('/animations/'+animation+'/animation.php', function(){
        $('#animation').show();
      });
    };
}


(function(functionName, container) {

  container[functionName] = function(){};

  container[functionName].bouncePast = function(pos) {
    if (pos < (1/2.75)) {
        return (7.5625*pos*pos);
    } else if (pos < (2/2.75)) {
        return 2 - (7.5625*(pos-=(1.5/2.75))*pos + .75);
    } else if (pos < (2.5/2.75)) {
        return 2 - (7.5625*(pos-=(2.25/2.75))*pos + .9375);
    } else {
        return 2 - (7.5625*(pos-=(2.625/2.75))*pos + .984375);
    }
  }

  container[functionName].easeInQuad = function(pos){
     return Math.pow(pos, 2);
  }

  container[functionName].easeOutCubic = function(pos){
    return (Math.pow((pos-1), 3) +1);
  }

  container[functionName].easeOutCirc = function(pos){
    return Math.sqrt(1 - Math.pow((pos-1), 2));
  }

  container[functionName].easeInCirc = function(pos) {
    return -(Math.sqrt(1 - (pos*pos)) - 1);
  }
  
  container[functionName].swingTo = function(pos) {
    var s = 1.70158;
    return (pos-=1)*pos*((s+1)*pos + s) + 1;
  }

  container[functionName].linear = function(pos) {
    return pos;
  }
  

})('easing', this);


(function(functionName, container) {

  container[functionName] = function(){};

  container[functionName].getElement = function(elem) {
    return typeof elem == 'string' ? document.getElementById(elem) : elem;
  }
  
  container[functionName].addEvent = function(elem, type, eventHandle) {
      elem = container[functionName].getElement(elem);
      if ( elem.addEventListener ) {
          elem.addEventListener( type, eventHandle, false );
      } else if ( elem.attachEvent ) {
          elem.attachEvent( "on" + type, eventHandle );
      }
  }
  
  container[functionName].removeClassName = function(elem, name) {
    elem = container[functionName].getElement(elem);
    if(!elem) return;
    elem.className = (' '+(container[functionName].getElement(elem).className)+' ').replace(' '+name+' ', '');
  }
  container[functionName].addClassName = function(elem, name) {
    elem = container[functionName].getElement(elem);
    if(!elem) return;
    elem.className = (' '+(container[functionName].getElement(elem).className)+' ').replace(' '+name+' ', '')+name;
  }
  
  container[functionName].insertCSS = function(path, load_callback) {
    var headID = document.getElementsByTagName("head")[0];
    var cssNode = document.createElement('link');
    cssNode.type = 'text/css';
    cssNode.rel = 'stylesheet';
    cssNode.href = path;
    cssNode.media = 'screen';
		cssNode.id = 'dynacss';
		if($('#dynacss').length) {
			$('#dynacss').attr('href',path);
		}
		else {
			headID.appendChild(cssNode);
		}
    setTimeout(function(){ $('#benefit-animation').show(); load_callback.apply(); }, 1000);
  }

})('fluid', this);



