function windowScroll(ID){
  IDnumber = ID . split ( "fi" );
  newID = "c"+IDnumber[1];
  
    var windowScrollFX = new Fx.Scroll(window, {
        wait: false,
        duration: 500,
        offset: {'x': 0, 'y': 0},
        transition: Fx.Transitions.Quad.easeInOut
    });


    window.addEvent('domready',function(){

        //we use the toElement() method of Fx.Scroll to make the
        //window move to that specific element
        var myFx = new Fx.Scroll(window).toElement( newID, 'y' );
    });

}


var oldProduct = new Array();
oldProduct['name'] = "";
oldProduct['status'] = "close";

function toggleProduct(wert, old){
    if(document.getElementById(wert)){
        window.addEvent('domready', function() {
            var status = {
                    'true': 'open',
                    'false': 'close'
            };
          
            //alert(oldProduct['status']);
            //WENN EIN DIV BEREITS OFFEN IST
            if(oldProduct['name'] != wert && oldProduct['name'] != ""){
                //toggleProduct(oldProduct['name'], "true");
                var myVerticalSlide = new Fx.Slide(oldProduct['name']);
                myVerticalSlide.slideOut();
            }

            //NEUE KLASSENINSTANZ
            var myVerticalSlide = new Fx.Slide(wert);

            //NUR BEI ERSTAUFRUF
            if(document.getElementById(wert).style.display == 'none'){
                myVerticalSlide.hide();
                document.getElementById(wert).style.display = 'block';
            }

            //DIV AUF/ZU
            myVerticalSlide.toggle();
          
            //BEI ENDE DER AKTION WERTE SPEICHERN
            oldProduct['name'] = wert;
            oldProduct['status'] = status[myVerticalSlide.open];

            //BEI ENDE DER AKTION ZUM OBJEKT START SCROLLEN
            myVerticalSlide.addEvent('complete', function() {
              if(old == "false"){
                //Scrolls the "myElement" to the top corner of the window.
                windowScroll(wert);
                //
              }
            });

        });
    }
}
