//<![CDATA[
/*#######################################################################*/
/*### Steuerung der Links der Hauptnavigation                         ###*/
/*### hnziel = Name des Bereiches, bzw. des Zielordners               ###*/
/*#######################################################################*/

//window.addEvent('domready', function(){
//    LoadingSpinner = new Spinner('contentcontainer', {
//        id: 'loadingspinner',
//        message: '',
//        style: {
//            opacity: 1
//        },
//        styles:{
//            'background-color': '#fff', 
//            'width': '960px', 
//            'height': '431px', 
//            'left': '15px', 
//            'top': '120px',
//            'display': 'block',
//            'opacity': 0
//        },
//        fxOptions: {
//            transition: 'quint:in:out'
//        }
//        //,
////        onShow: function(){
////            vidPause();
////        },
////        onHide: function(){
////            vidPause();
////        }
//    });
//    
//});

/*var hauptnavigation = function(hnziel, snziel){
    if($defined($('subnavigation')))LoadingSpinner.show();
    XXXhauptnavigation.delay(500,'',[hnziel, snziel]);
}*/

/*var XXXhauptnavigation = function(hnziel, snziel){
    if($defined(Subnaviscroller))Subnaviscroller = null;
    var subnaviziel;
    //UL-Element der Hauptnavigation
    var hauptnavigationLi = $('hauptnavigation');
    //Zuweisung der Bereichstartseiten der einzelnen Bereiche (hnziel)
    //alert(!$defined(snziel));
    if(!$defined(snziel)){
        switch(hnziel){
            case "ueber-die-agentur":
                subnaviziel = "kennzahlen";
            break;
            case "unsere-leistungen":
                subnaviziel = "leistungen-im-ueberblick";
            break;
            case "unsere-referenzen":
                subnaviziel = "projekte";
            break;
            case "kontakt":
                subnaviziel = "";
                //subnaviziel = "kontakt";
            break;
        }
    }else{
        subnaviziel = snziel;
    }
    url = "/"+hnziel;
    //XMLHTTP-Request zum Laden der index.htm des jeweiligen Bereiches
    hauptnavirequest = new Request.HTML({
        url: url,
        method: 'get',
        update: 'contentcontainer',
        evalScripts: true,
        evalResponse: true,
        //useSpinner: Einbindung einer Ladegrafik
        useSpinner: false,
        //spinnerTarget: Ziel-DOM-Element für die Ladegrafik
        spinnerTarget: 'content',
        onComplete: function(){
            //Wenn die URL geladen ist wird der entsprechende Hauptnavipunkt
            //gehighlightet und ggf. vorhergehend aktive Hauptnavipunkte wieder
            //auf "passiv" gesetzt!
            if($defined(hauptnavigationLi)){
                hauptnavigationLi.getElements('a').each(function(item, index){
                    if(item.getParent().id == hnziel && !item.hasClass("active")){
                        item.toggleClass("active");
                    }else{
                        item.removeClass("active");
                    }
                });
                //Einleiten des Ladens der Unterseite.
                if(subnaviziel != ""){
                    subnavigation(hnziel,subnaviziel);
                }else{
                    subnavigation(hnziel);
                }
            }
        }
    }).send();
}*/

/*#######################################################################*/
/*### Blendet den Pfeil bei den aktiven Subnavipunkten ein, bzw. aus! ###*/
/*### snziel = Die angewählte Unterseite                              ###*/
/*#######################################################################*/

var setSubnaviPfeil = function(snziel){
    //Prüft, ob der Inhalt bereits den richtigen Style für eine Unterseite hat (#content.subseite)!//
    if(!$('content').hasClass('subseite'))$('content').addClass('subseite');
    //ziel = Ziel-Listenelement zur Manipulation
    //var ziel = $('sn_'+snziel);
    var ziel = $(snziel);
    //Wenn die Pfeilgrafik noch nicht eingebunden ist wird sie hier 
    //in den DOM injected
    if(!$defined($('subnavipfeil'))){
        subnavipfeil = new Element('img',{
            'src':'/img/subnavigation/pfeil-up.png',
            'alt': 'Aktiv',
            'id': 'subnavipfeil'
        });
        subnavipfeil.inject(ziel);
    //Wenn die Pfeilgrafik bereits im DOM vorhanden ist, 
    //wird sie hier entfernt und im richtigen Listenpunkt eingefügt
    }else{
        var removedPfeil = $('subnavipfeil').dispose();
        removedPfeil.inject(ziel);
   }
    //Positionierung des Pfeiles in der Mitte des Navibuttons
    $('subnavipfeil').setStyle('left', (ziel.getSize().x/2)-($('subnavipfeil').width/2));
    //Alle aktiven Navipunkte werden inaktiv gesetzt und der gewählte
    //Navipunkt bekommt den active-Style zugeordnet
    $('ul_subnavigation').getChildren('.active').toggleClass('active');
    ziel.addClass('active');
    controlBereichstart(ziel);
    createSubnaviScroller(ziel);
 }

var controlBereichstart = function(ziel){
    //Behandlung des Sonderfalls einer Bereichstartseite!
    //Laut Definition ist der erste Subnavigationspunkt immer die Bereichstartseite
    //Daher: entsprechende Stylezuordnung, wenn ziel.id == erster subnavpunkt.id
    //($('ul_subnavigation').getChildren()[0].id)
    var stage = $('stage');
    var bereichstartseite = $('ul_subnavigation').getChildren()[0].id;
    //alert(ziel.id != bereichstartseite && $('subnavigation').hasClass('bereichstart') && ziel.id != "sn_kontakt");
    if(ziel.id == bereichstartseite && !$('subnavigation').hasClass('bereichstart') && ziel.id != "ctl00_Li_kontakt"){
        //alert("ist bereichstart");
        $('subnavigation').toggleClass("bereichstart");
        stage.toggleClass('darkgrey');
        stage.toggleClass('fullheight');
        stage.toggleClass('grey');
        //$('mainhead').setStyle('display','block');
    }else if(ziel.id != bereichstartseite && $('subnavigation').hasClass('bereichstart') && ziel.id != "ctl00_Li_kontakt"){
        $('subnavigation').toggleClass("bereichstart");
        //stage.toggleClass('darkgrey');
        //stage.toggleClass('fullheight');
        //stage.toggleClass('grey');
        //$('mainhead').setStyle('display','none');
    }    
}

/*var subnavigation = function(hnbereich,snurl){
    if($defined($('subnavigation'))){
        $('subnavigation').setStyle('visibility','hidden');
        if($defined(LoadingSpinner)){
            if(LoadingSpinner.hidden)LoadingSpinner.show();
        }
    }
    XXXsubnavigation.delay(500,'',[hnbereich,snurl])
}*/

//Steuerung der Links der Subnavigation
/*var XXXsubnavigation = function(hnbereich,snurl){
    if(!$defined(snurl)){snurl = hnbereich;}
    //alert(snurl);
    setSubnaviPfeil(snurl);
    var url = "/"+hnbereich+"/"+snurl+".htm";
    subnavirequest = new Request.HTML({
        url: url,
        method: 'get',
        update: 'content',
        useSpinner: false,
        evalScripts: true,
        onComplete: function(){
            $('subnavigation').setStyle('visibility','visible');
            if($defined($('subnavigation')))if($defined(LoadingSpinner))LoadingSpinner.hide.delay(500,LoadingSpinner);
        }
    }).send();
}*/

var createSubnaviScroller = function(ziel){
    //SCROLLBARE SUBNAVIGATION!!!
    //Positionierung der Subnavigation. Wenn ein Listenpunkt außerhalb des sichtbaren
    //Bereiches der Subnavigation aktiviert wurde scrollt die Subnavi an das
    //entsprechende Ende.
    var positionListenpunkt = ziel.getPosition().x;
    var positionBreiteListenpunkt = positionListenpunkt + ziel.getSize().x;
    var positionSubnavigation = $('contentcontainer').getPosition().x + 30;
    var breiteSubnavigation = positionSubnavigation + $('subnavigation').getSize().x;
    if(positionBreiteListenpunkt > breiteSubnavigation){
        if($defined(Subnaviscroller))Subnaviscroller.jumpRight();
    }else if(positionListenpunkt < positionSubnavigation){
        if($defined(Subnaviscroller))Subnaviscroller.jumpLeft();
    }
}

//Reservierte Instanz für eine scrollbare Subnavigation
var Subnaviscroller;

var ScrollSubnavi = new Class({
	initialize: function(options) {
		var liGesamtbreite = 0;
		this.ul = $('ul_subnavigation');
		var ulInitbreite = this.ul.getSize().x;
		this.ul.getChildren().each(function(item, index) {
			liGesamtbreite += item.getSize().x;
		});
		this.ul.setStyle('width', liGesamtbreite);
		this.snScrolling = new Fx.Scroll($('subnavigation'), {
			duration: 'normal',
			transition: 'circ:in:out',
			offset: { 'x': 0, 'y': 0 },
			link: 'cancel'
		});
		this.snJump = new Fx.Scroll($('subnavigation'), {
			duration: 0,
			offset: {'x':0, 'y':0},
			link: 'cancel'
		});
	},
	jumpLeft: function(){
		this.snJump.toLeft().chain(function() {
			if (!$('snScrollLeft').hasClass('end')) {
				$('snScrollRight').toggleClass('end');
				$('snScrollLeft').toggleClass('end');
			}
		});
	},
	jumpRight: function(){
		this.snJump.toRight().chain(function() {
			if (!$('snScrollRight').hasClass('end')) {
				$('snScrollRight').toggleClass('end');
				$('snScrollLeft').toggleClass('end');
			}
		});
	},
	scrollLeft: function() {
		this.snScrolling.toLeft().chain(function() {
			if (!$('snScrollLeft').hasClass('end')) {
				$('snScrollRight').toggleClass('end');
				$('snScrollLeft').toggleClass('end');
			}
		});
	},
	scrollRight: function() {
		this.snScrolling.toRight().chain(function() {
			if (!$('snScrollRight').hasClass('end')) {
				$('snScrollRight').toggleClass('end');
				$('snScrollLeft').toggleClass('end');
			}
		});
	}
});

//###### ScrollerModul Klasse#######
var ScrollerModule = new Class({
    Implements: Events,
    //ClassId = Objektname der Klasseninstanz
    //Scroller = id des Scroller Divs (äußerste Umrahmung der zu scrollenden Inhalte)
    //StageCounter = [bool] Soll eine Ziffernnavigation eingeblendet werden?
    //pagesArr = wird benötigt wenn die Subnavigation auch über die Ziffernnavigation bedient werden soll, 
    //um den entsprechenden Subnavipunkt aktiv zu setzen. Array mit den Subnavigations IDs.
    options:{
        ClassId: null,
        ScrollerId: null,
        StageCounter: null,
        pagesArr: null,
        ScrollObjectPrefix: null
    },
    initialize: function(options){
        if($defined(options.pagesArr))this.pagesArr = options.pagesArr;
        if($defined($(options.ScrollerId))){
            this.ScrollerDiv = $(options.ScrollerId);
        }else{
            alert("Der Scroller wurde nicht im DOM gefunden!"); 
            return false;
        }
        //alert(StageCounter);
        this.ClassId = options.ClassId;
        this.naviImages = this.ClassId+"PreloadImages";
        this.ScrollObjectPrefix = options.ScrollObjectPrefix;
        this.Scrollcontainer = this.ScrollerDiv.getElement('.Scrollcontainer');
        this.activeItem = 1;
        this.Items = this.ScrollerDiv.getElements('.scrollobject');
        this.countItems = this.Items.length;
        this.itemWidth = this.ScrollerDiv.getElement('.scrollobject').getStyle('width').toInt();
        this.itemMarginRight = this.ScrollerDiv.getElement('.scrollobject').getStyle('margin-right').toInt();
        this.Scrollbody = this.ScrollerDiv.getElement('.Scrollbody');
        this.ScrollerCenter = this.findCenter();
        //this.scrollButtons = this.ScrollerDiv.getChildren('.scrollbutton');
        //alert(this.ScrollerCenter);
        //this.Scrollbody.setStyles({'padding-left':this.ScrollerCenter,'width':this.Scrollbody.getSize().x - this.ScrollerCenter});
        //alert(this.Scrollbody.getSize().x);
        this.Scrollcontainer.setStyles({'width':($$('.scrollobject').length*(this.itemMarginRight+this.itemWidth))});
        //$('mittechecker').setStyles({'left':this.ScrollerCenter});
        
        //Fx.Scroll.implement(Events);

        this.Scrolling = new Fx.Scroll(this.Scrollbody,{
            duration: 'long',
            transition: 'circ:out',
            offset: {'x': this.Scrollcontainer.getStyle('margin-left').toInt()*(-1), 'y': 0},
            link: 'cancel'
        });

        if(this.countItems>1)this.setScrollButtonPositions();
        if(options.StageCounter)this.setStageCounter();

    },
    findCenter: function(){
        findCenter = this.ScrollerDiv.getStyle('width').toInt()/2-this.itemWidth/2;
        return findCenter;
    },
    setScrollButtonPositions: function(){
        //<div id="scr" class="scrollbutton ScrollLeft" style="display: none;">
        //<a href="javascript:MeinScroller.scrollLeft($('Scroller'));" onmouseover="MeinScroller.scrollButtonOver('scleft');" onmouseout="MeinScroller.scrollButtonOut('scleft');">
        //<img id="scleft" src="/img/scrollfenster/scroll-pfeil-links.png" alt="nach links navigieren" /></a></div>
        //<div id="scl" class="scrollbutton ScrollRight" style="display: none;"><a href="javascript:MeinScroller.scrollRight($('Scroller'));" onmouseover="MeinScroller.scrollButtonOver('scright');" onmouseout="MeinScroller.scrollButtonOut('scright');"><img id="scright" src="/img/scrollfenster/scroll-pfeil-rechts.png" alt="nach rechts navigieren" /></a></div>
        var ScrDiv = this.ScrollerDiv.id;
        var objName = this.ClassId;

        var ButtonLeft = new Element('div',{
            'class': 'scrollbutton ScrollLeft'
        });
        
        var ButtonLeftA = new Element('a', {
            'href': 'javascript:void(0);',
            'events':{
                'click': function(){
                    window[objName].scrollLeft(ScrDiv);
                },
                'mouseover': function(){
                    window[objName].scrollButtonOver(ButtonLeftImg.id);
                },
                'mouseout': function(){
                    window[objName].scrollButtonOut(ButtonLeftImg.id);
                }
            }
        }).inject(ButtonLeft);
        var ButtonLeftImg = new Element('img',{
            'src': window[this.naviImages][0].src,
            'alt': 'nach links navigieren',
            'id': this.ScrollerDiv.id + 'BtnLeft'
        }).inject(ButtonLeftA);
        
        ButtonLeft.inject(this.ScrollerDiv, 'top');
        
        var ButtonRight = new Element('div',{
            'class': 'scrollbutton ScrollRight'
        });
        
        var ButtonRightA = new Element('a',{
            'href': 'javascript:void(0);',
            'events':{
                'click': function(){
                    window[objName].scrollRight(ScrDiv);
                },
                'mouseover': function(){
                    window[objName].scrollButtonOver(ButtonRightImg.id);
                },
                'mouseout': function(){
                    window[objName].scrollButtonOut(ButtonRightImg.id);
                }
            }
        }).inject(ButtonRight);
        
        var ButtonRightImg = new Element('img',{
            'src': window[this.naviImages][1].src,
            'alt': 'nach rechts navigieren',
            'id': this.ScrollerDiv.id + 'BtnRight'
        }).inject(ButtonRightA);
        
        ButtonRight.inject(ButtonLeft, 'after');
        
        var ButtonLeftHeight = ButtonLeft.getSize().y;
        var ButtonRightHeight = ButtonRight.getSize().y;
        var ScrollerDivHeight = this.ScrollerDiv.getSize().y;
        ButtonLeft.setStyle('top',(ScrollerDivHeight/2)-(ButtonLeftHeight/2));
        ButtonRight.setStyle('top',(ScrollerDivHeight/2)-(ButtonRightHeight/2));
    },
    setStageCounter: function(){
        var objName = this.ClassId;
        var prefix = this.ScrollObjectPrefix ;
        var secondClickEvent = "";
        var counterUl = new Element('ul',{
            id:'stagecounter'
            });
        $each(this.Items, function(item, index){
            if(index==0){
                var counterLi = new Element('li',{
                    id: 'ziffer'+(index+1),
                    'class': 'active'
                });
                var counterLiAImage = new Element('img',{
                    'src': '/img/scrollfenster/c'+(index+1)+'_on.png',
                    'alt': (index+1)
                });
            }else{
                var counterLi = new Element('li',{
                    id: 'ziffer'+(index+1)
                });
                var counterLiAImage = new Element('img',{
                    'src': '/img/scrollfenster/c'+(index+1)+'.png',
                    'alt': (index+1)
                });
            }
            /*if($defined(this.pagesArr)){
                secondClickEvent = 'setSubnaviPfeil("'+this.pagesArr[index]+'");';
            }*/
            var counterLiA = new Element('a', {
                'href': 'javascript:void(0);', 
                'events':{
                    'click': function(){
                       window[objName].scrollToElement(prefix +(index+1).toString());
                    }  
                }
            });
            counterLiAImage.inject(counterLiA);
            counterLiA.inject(counterLi);
            counterLi.inject(counterUl);
        });
        counterUl.inject(this.ScrollerDiv,'after');
    },
    scrollRight: function(){
        //this.Scrolling.start((ScrollerDiv.getPosition().x-this.Scrollbody.getPosition().x)+(this.itemWidth+this.itemMarginRight) + (ScrollerDiv.getStyle('border-width').toInt()*2), this.Scrollbody.getPosition().y);
        if(this.activeItem<this.countItems){
            this.activeItem ++;
        }else{
            this.activeItem = 1;
        }
        var targetElement = this.ScrollObjectPrefix + this.activeItem;
        this.scrollToElement(targetElement);
    },
    scrollLeft: function(){
        //this.Scrolling.start((ScrollerDiv.getPosition().x-this.Scrollbody.getPosition().x)-(this.itemWidth+this.itemMarginRight), this.Scrollbody.getPosition().y);
        if(this.activeItem > 1){
            this.activeItem --;
        }else{
            this.activeItem = this.countItems;
        }
        var targetElement = this.ScrollObjectPrefix + this.activeItem;
        this.scrollToElement(targetElement);
    },
    scrollFunctionExtension: function(activeItem){
        if($defined($('ul_subnavigation'))){
           var zielString = $('ul_subnavigation').getChildren()[activeItem-1].id; 
           setSubnaviPfeil(zielString.substr(3,zielString.length - 3));
        }else{
            //alert('$("ul_subnavigation") ist nicht definiert!');
        }        
    },
    scrollToNumber: function(number){
        this.scrollToElement(this.ScrollObjectPrefix+number);
    },
    scrollToElement: function(elementString){
        //vidPause();
        var element = $(elementString);
        var elementNumber = elementString.substr(this.ScrollObjectPrefix.length,elementString.length);
        if(this.activeItem != elementNumber)this.activeItem = elementNumber;
        this.setScrollCounterHighlight(this.activeItem);
        this.Scrolling.toElement(element).chain(function(){
            //vidPause();
            //alert(this.duration);
        });
    },
    finishScroll: function(){
        //alert('Funktion');
    },
    scrollButtonOver: function(sbTarget){
        switch(sbTarget){
            case this.ScrollerDiv.id+"BtnRight":
                $(sbTarget).setProperty('src',window[this.naviImages][3].src);
                break;
            case this.ScrollerDiv.id+"BtnLeft":
                $(sbTarget).setProperty('src',window[this.naviImages][2].src);
        }
    },
    scrollButtonOut: function(sbTarget){
        switch(sbTarget){
            case this.ScrollerDiv.id+"BtnRight":
                $(sbTarget).setProperty('src',window[this.naviImages][1].src);
                break;
            case this.ScrollerDiv.id+"BtnLeft":
                $(sbTarget).setProperty('src',window[this.naviImages][0].src);
        }        
    },
    setScrollCounterHighlight: function(nr){
        if($defined($('stagecounter'))){
            var counterImgAktuell = $('ziffer'+this.activeItem);
            $('stagecounter').getElements('li').each(function(item, index){
                if(item.hasClass('active')){
                    item.toggleClass('active');
                    item.getElement('img').setProperty('src','/img/scrollfenster/c'+(index+1)+'.png');
                }
            });
            counterImgAktuell.toggleClass('active');
            counterImgAktuell.getElement('img').setProperty('src','/img/scrollfenster/c'+this.activeItem+'_on.png');
        }
    }
   });
//###### ENDE ScrollerModul Klasse ENDE #######

//Klasse für das Verhalten der Expandables    
var Expandable = new Class({
    Implements: Events,
    options: {
        wrapperHeight: null,
        expCount: null,
        expHeadHeight: null,
        expContentHeight: null,
        expAccordion: null
    },
    initialize: function(){
        this.wrapperHeights = $('expandableWrapper').getStyles('height', 'padding-bottom');
        this.expCount = $$('#expandableWrapper .expandable').length;
        this.expHeadHeight = this.getHeadHeight();
        this.expContentHeight = this.wrapperHeights.height.toInt() - (this.wrapperHeights['padding-bottom'].toInt()/2) - ((this.expHeadHeight+this.getContentMargins()/2)*this.expCount);
        this.expAccordion = new Fx.Accordion(
            $$('.expandablehead'),
            $$('.expandablecontent'),
            {display:0,
            height:true,
            fixedHeight:this.expContentHeight, 
            returnHeightToAuto: false, 
            onActive: function(toggler, element){
                //alert('Active -> '+element.getParent().id);
                //element.setStyle('overflow-y','hidden');
                toggler.addClass('on');
            },
            onBackground: function(toggler, element){
                //alert('Background -> '+element.id);
                //element.setStyle('overflow-y','hidden');
                toggler.removeClass('on');
            }
        });
        
    },

    
    getHeadHeight: function(){
        var headstyles = $('exp1').getElement('.expandablehead').getStyles('height','margin-bottom', 'margin-top');
        getHeadHeight = headstyles.height.toInt() + headstyles['margin-bottom'].toInt();
        return getHeadHeight;
    },
    getContentMargins: function(){
        var contentstyles = $('exp1').getElement('.expandablecontent').getStyles('margin-bottom', 'margin-top');
        getContentMargins = contentstyles['margin-bottom'].toInt() + contentstyles['margin-top'].toInt();
        return getContentMargins;
    },
    meinefunktion: function(){
       //irgendwelche_sachen
       this.fireEvent('meinefunktionwurdeausgefuehrt');
    }
});

/*DropDown für die Referenzdirektauswahl*/
var SelectBox = new Class({
    Implements: Chain,
    options:{
        //DataSource ist Hash mit Key-Value Paaren
        DataSource: null,
        sbContainer: null,
        ScrollerName: null
    },
    initialize: function(options){
        this.DataSource = options.DataSource;
        this.sbContainer = options.sbContainer;
        this.ScrollerName = options.ScrollerName;
        this.selectBox = this.createSelectBox();
        if(!$defined(this.sbContainer))this.selectBox.inject($('content'),'bottom')
        else this.selectBox.inject($(this.sbContainer),'bottom');
        this.selectBox.addEvent('click', function(){
            this.morphBox();
        }.bind(this));
        this.selectBoxMorphIn = new Fx.Morph(this.selectBox,{duration:500, transition:'quart:out', link:'chain'});
        this.selectBoxMorphOut = new Fx.Morph(this.selectBox,{duration:500, transition:'quart:in', link:'chain'})
   },
   morphBox:function(){
        if(this.selectBox.getStyle('display') == 'none'){
            this.selectBox.setStyle('display','block');
            this.selectBoxMorphIn.start('.selectBox').chain(
                function(){
                    this.sbContentDiv.setStyle('display','block');
                }.bind(this)
            );
        }else{
            this.sbContentDiv.setStyle('display','none');
            this.selectBoxMorphOut.start('.selectBoxSmall').chain(
                function(){
                    this.selectBox.setStyle('display','none');
                }.bind(this)
            );
            }
   },
   createSelectBox : function(){
        this.sbContentDiv = this.buildContentDiv();
        this.sbLinkList = this.buildLinkListe().inject(this.sbContentDiv);
        this.selectBox = this.buildSelectBoxFrame(this.sbContentDiv);
        return this.selectBox;
   },
   buildLinkListe:function(){
        var sbContentUl = new Element('ul');
        var count = 1;
        this.DataSource.each(function(value,key){
            var li = new Element('li');
            var a = new Element('a',{
               'href':'javascript:'+this.ScrollerName+'.scrollToNumber('+count+');'
            });
            a.set('html','<b>'+key +'</b> &ndash; '+ value);
            a.inject(li);
            li.inject(sbContentUl,'bottom');
            count++;
        },this);
        return sbContentUl;
   },
   buildContentDiv:function(){
        var sbContentDiv = new Element('div',{
            'class':'sbContent',
        styles:{
            'display':'none'
        }
        });
        return sbContentDiv;
   },
   buildSelectBoxFrame : function(contentdiv){
    var selectBoxDiv = new Element('div',{
        'class':'selectBoxSmall',
        id:'selectBox',
        styles: {
            'display':'none'
        }/*,
        events:{
            'click': function(){
                alert('mouseleave');
            }
        }*/
    });
    var sbTopDiv = new Element('div',{
        'class':'sbTop'
    }).inject(selectBoxDiv);
    
    var sbBottomDiv = new Element('div',{
        'class':'sbBottom'
    }).inject(sbTopDiv,'after');
    
    var sbTopPfeil = new Element('img',{
        'src':'/img/basis/pfeil_up.gif',
        'alt':'nach oben scrollen',
        styles:{
            'display':'none'
        }
    }).inject(sbTopDiv);
    
    var sbBottomPfeil = new Element('img',{
        'src':'/img/basis/pfeil_down.gif',
        'alt':'nach unten scrollen',
        styles:{
            'display':'none'
        }
    }).inject(sbBottomDiv);
     contentdiv.inject(sbTopDiv,'after');
     return selectBoxDiv;
   }
});
/*ENDE - DropDown für die Referenzdirektauswahl - ENDE*/


// Vorbelegung und Check von Textfeldern
   var FeldPreset = new Class({
   	options: {
   		ID: null,
   		preset: null,
   		validate: null
   	},
   	initialize: function(options) {
   		this.ID = $(options.feld);
   		this.preset = options.preset;
   		this.validationfunction = options.validate;
   		this.setPresetText();
   		this.ID.addEvent('focus', function() {
   			if (this.ID.get('value') == this.preset)
   				this.ID.set('value', '');
   		}.bind(this));
   		this.ID.addEvent('blur', function() {
   			if (this.ID.get('value') == "")
   				this.setPresetText();
   			this.setValidationMarker();
   		}.bind(this));
   	},
   	setPresetText: function() {
   		this.ID.set("value", this.preset);
   	},
   	hasUserData: function() {
   		return (this.ID.get('value') == this.preset) ? false : true;
   	},
   	validate: function() {
   		if (!this.hasUserData())
   			return false;
   		else
   			return (this.validationfunction == null) ? true : eval(this.validationfunction);
   	},
   	setValidationMarker: function() {
   		var vicon = $(this.ID.get('id') + 'Hak');
   		if (this.validate()) {
   			if (vicon.hasClass('err')) vicon.removeClass('err');
   			vicon.addClass('ok');
   		} else {
   			if (vicon.hasClass('ok')) vicon.removeClass('ok');
   			vicon.addClass('err');
   		}
   	}
   });

// send mail
var sendMail = function() {
   	new Request.HTML({
   		url: '/handler/mail.ashx',
   		method: 'post',
   		data: $('mailform'),
   		update: 'jmmail',
   		evalScripts: true,
   		evalResponse: true,
   		//useSpinner: Einbindung einer Ladegrafik
   		useSpinner: true,
   		//spinnerTarget: Ziel-DOM-Element für die Ladegrafik
   		spinnerTarget: 'jmmail',
   		onComplete: function() {
   		}
   	}).send();
}
//]]>
