var Cta = function() {
	
	//private static vars
	var IS_ANIMATING = new Boolean();
	var ANIMATION_SPEED = 1500;
	var DEFAULT_EASE = 'easeInOutQuint';
	
	// public vars
	this.init = init;
	this.className = "cta"
	
	// public methods
	this.onChange = function(event, num) 
	{
		setCtaBackground(num)
    }
	
	// private vars
	var _bgTexture;

	function init() 
	{
		setCtas();
	}

	function setCtaBackground(num)
	{
		var textureURL = fma.textureArr[num];
		var previous = null;
		
		if(_bgTexture != null)previous = _bgTexture;
		
		_bgTexture = "<div class='bg-texture' id='bg-texture" + num + "'></div>";
		$('#main-cta-bg').append(_bgTexture);
		_bgTexture = $('#bg-texture' + num);
		
		_bgTexture.css({
			'background': 'url(' + textureURL + ') repeat-x bottom',
			'width': '100%',
			'height': 385 +'px',
			'position': 'absolute',
			"opacity": 0
		});
		
		IS_ANIMATING = true;
		
		_bgTexture.animate(
		{
			"opacity": 1
		}, 
			ANIMATION_SPEED, 
			DEFAULT_EASE,
			function(){ 
				clearPrevious(previous); 
			}
		);
	}
	
	function clearPrevious(p){
		
		IS_ANIMATING = false;
		if(p != null)
		{
			p.remove();
		}
	}
	
	function setCtas()
	{
		//cta 1 ///////////////////////////////////////////
		$('.cta1').hover(function(){
			$(".slider .caption", this).stop().animate({top:'142px'},{queue:false,duration:300});
			}, function() {
				$(".slider .caption", this).stop().animate({top:'380px'},{queue:false,duration:300});
		});
		
		//cta 2 ///////////////////////////////////////////
		$('.cta2').hover(function(){
			$(".slider .caption", this).stop().animate({top:'142px'},{queue:false,duration:300});
			}, function() {
				$(".slider .caption", this).stop().animate({top:'380px'},{queue:false,duration:300});
		});
		
		//cta 3 ///////////////////////////////////////////
		$('.cta3').hover(function(){
			$(".slider .caption", this).stop().animate({top:'142px'},{queue:false,duration:300});
			}, function() {
				$(".slider .caption", this).stop().animate({top:'380px'},{queue:false,duration:300});
		});
		
		//cta 4 ///////////////////////////////////////////
		$('.cta4').hover(function(){
			$(".slider .caption", this).stop().animate({top:'142px'},{queue:false,duration:300});
			}, function() {
				$(".slider .caption", this).stop().animate({top:'380px'},{queue:false,duration:300});
		});
	}
}




