var TeaserInfoAnimation = new Class({
	
    initialize: function()
    {
        this.isOpening = false;
        this.teaserInfoOpen = true;
    },

    getTeaserInfo: function()
    {
        return document.getElementsBySelector("div.teaser_info_content")[0];
    },

	getTeaserSwitch: function()
    {
        return document.getElementsBySelector("a.TeaserInfoAnimationButton")[0];
    },

    openTeaserInfo: function()
    {
		if ($chk(this.anim) && this.anim.isMoving) this.anim.stop();
		//if ($chk(this.anim) && this.anim.isMoving) this.anim = '';
		//if ($chk(this.anim) && this.anim.isMoving) return(0);
		//if ($chk(this.anim) && this.anim.isMoving) this.stopEvent(e);

        var ffo = this.getTeaserInfo();
        //var fbu = this.getTeaserSwitch();
                
        /*fbu.setStyle("background-color", "white");*/
       // ffo.setStyle("visibility", "visible");
       // ffo.setStyle("display", "block");

         this.anim = new Fx.Style(ffo, 'margin-top', {duration:1000, onStart: function() { 
        	this.isMoving = 1;
        }, onComplete: function() { 
        	this.isMoving = 0;
//        	this.teaserInfoOpen = true;
        }});
        //animWidth.set(0);
        this.anim.start(0);
        this.teaserInfoOpen = true;
       // fbu.innerHTML = '<img src="fileadmin/templates/img/button_slidebox_close.gif" alt="Button" />';
      //  this.isOpening = false;
        
        //document.getElementsBySelector("div.teaser_info_content")[0].unselectable = "on";
    	//document.getElementsBySelector("div.teaser_info_content")[0].style.MozUserSelect = "none";

    },

    closeTeaserInfo: function()
    {
		if ($chk(this.anim) && this.anim.isMoving) this.anim.stop();
		//if ($chk(this.anim) && this.anim.isMoving) this.anim = '';
		//if ($chk(this.anim) && this.anim.isMoving) return(0);
		//if ($chk(this.anim) && this.anim.isMoving) this.stopEvent(e);
  		
        var ffo = this.getTeaserInfo();
        //var fbu = this.getTeaserSwitch();

         this.anim = new Fx.Style(ffo, 'margin-top', {duration:1000, onStart: function() { 
        	this.isMoving = true;
        }, onComplete: function() {
        	this.isMoving = false;
//        	this.teaserInfoOpen = false;
//        alert('complete closed'+this.teaserInfoOpen);
        }});
        this.teaserInfoOpen = false;
        this.anim.start(30);
        //fbu.setHTML('<img src="fileadmin/templates/img/button_slidebox_open.gif" alt="Button" />');
    },

    stopEvent: function(e)
    {
        if (e.stopPropagation)
        {
            e.stopPropagation();
        }
        else
        {
            e.cancelBubble = true;
        }
    },
    		
	toggleInfo: function(e)
	{
		var teaserInfo = document.getElementById("teaser_info");
		if (this.teaserInfoOpen == true) {
			this.closeTeaserInfo(e);
		} else {
			this.openTeaserInfo(e);
		}
	} 
});


function initTeaserSwitch() {

window.addEvent('domready', function(){
  TeaserInfoAnimation = new TeaserInfoAnimation();
  close();
  var button = $$('.teaser_info_content');
  button.addEvent('mouseover',open);
  button.addEvent('mouseout',close);
  button.addEvent('click',toggle);
});


}


function toggle(e) {
	TeaserInfoAnimation.toggleInfo(e);
}

function open(e) {
	TeaserInfoAnimation.openTeaserInfo(e);
	
}

function close(e) {
	TeaserInfoAnimation.closeTeaserInfo(e);
}