<!--

function ContentManager()
{
    var obj =
    {
        initLanguage: 'de',
        currentLanguage: 'de',

        currentSection: '',
        currentChapter: '',

        init: function()
        {
            if( window.ie )
            {
                if  ( navigator.userLanguage.indexOf("de") > -1 )
                {
                    this.initLanguage = 'de';
                }
                else
                {
                    this.initLanguage = 'en';
                }
            }
            else
            {
                if ( navigator.language.indexOf("de") > -1 )
                {
                    this.initLanguage = 'de';
                }
                else
                {
                    this.initLanguage = 'en';
                }
            }

            this.currentLanguage = this.initLanguage;

            // register to history manager:
            unFocus.History.addEventListener('historyChange', this.historyListener.bind(this));

            this.changeLanguage(this.currentLanguage);

            if ( this.currentLanguage == this.initLanguage )
            {
                this.loadNavigation();
            }

            var winLocation = window.location.href;

            if ( winLocation.test(/cnt/ig) )
            {
                if ( winLocation.test(/#/ig) )
                {
                     winLocation = '/' + winLocation.substr(winLocation.lastIndexOf('#'));
                }
                else
                {
                    winLocation = winLocation.replace(/cnt/ig, '#')
                }

                winLocation = winLocation.replace(/\.html/ig, '');
                winLocation = winLocation.replace(/\.php/ig, '');
                winLocation = winLocation.replace(/_/ig, '%20');

                window.location = winLocation;
            }

            this.historyListener(unFocus.History.getCurrent());

        },

        historyListener: function(historyhash)
        {
            var lang = this.currentLanguage;
            var section = null;
            var chapter = '';

            if ( historyhash.length > 0 )
            {
                var historyParts = historyhash.split('/');
                tmp     = historyParts[0];
                lang    = historyParts[1];
                section = historyParts[2];
                chapter = historyParts[3];
            }

            if ( lang != this.currentLanguage)
            {
                 this.changeLanguage(lang);
            }

            this.currentSection = section;
            if ( this.currentSection == null )
            {
                this.currentSection = 'Registration';
            }
            this.currentChapter = chapter;

            if ( nav )
            {
                nav.setLocation(this.currentSection, this.currentChapter);
                nav.reRender();
            }


            this.loadContent();
        },

        changeState: function(section, chapter)
        {
        	this.unloadContent();

            var locationString = '/' + this.currentLanguage + '/' + section;
            if ( chapter )
            {
                locationString += '/' + chapter;
            }

            unFocus.History.addHistory(locationString);

            return false;
        },

        replaceContentAndFadeIn: function (elementId, content, onComplete)
        {
//            var myFx = new Fx.Style(elementId, 'opacity').set(0);
        	alert(elementId);
            $(elementId).setHTML(content);

            var configObj = {duration: 1000};
            if (onComplete)
            {
                configObj.onComplete = onComplete;
            }

//            var myFx = new Fx.Style(elementId, 'opacity', configObj).start(0, 1);
        },

        changeLanguage: function(language)
        {
            if (language != 'de' && language != 'en')
            {
                return;
            }

            this.currentLanguage = language;

            if ( this.currentSection )
            {
                this.changeState(this.currentSection, this.currentChapter);
            }

            this.loadNavigation();
            //this.loadContent();
        },

        loadContent: function()
        {
            var contentToLoad = '/content/' + this.currentLanguage + '/' + this.currentSection.replace(' ', '_') + '/';
            
            if ( this.currentChapter)
            {
                contentToLoad += this.currentChapter.replace(/\s/g, '_');
            }
            else
            {
                contentToLoad += 'index.php';
            }

            //contentToLoad += '.html';

            this.loadContentInto(contentToLoad, 'content_main', this.scrollTop.bind(this));
        },

        scrollTop: function()
        {
            window.scrollTo(0, 0);
        },

        loadNavigation: function()
        {
            var navLoader = new Ajax('/content/' + this.currentLanguage + '/' + 'navigation.js',
                    {
                        method: 'get',
                        onComplete: function(content)
                        {
//                            var myFx = new Fx.Style('navigation', 'opacity').set(0);

//                            content += "\nnew Fx.Style('navigation', 'opacity', {duration: 1000}).start(0, 1);";

                            window.setTimeout(content, 10);
                        }
                    }).request();
        },



        executeScripts: function()
        {
            var scripts = $$('#content_main script');
            var totalscripts = '';

            for (var i = 0; i < scripts.length; i++)
            {
                var script = scripts[i].innerHTML;
                totalscripts += "\n"+script;
            }

            eval(totalscripts);
        },



        loadContentInto: function(url, elementId, onComplete)
        {
            var navLoader = new Ajax(url,
            {
                method: 'get',
                evalScripts: true,
                update: elementId,
                onComplete: function(content)
                {

                    //$(elementId).style.visibility = 'hidden';
                    //$(elementId).setHTML(content);

                    //window.setTimeout('contentManager.executeScripts();', 100);


//                                    var configObj = {duration: 1000};
                    var configObj = {};
                    if (onComplete)
                    {
//                        configObj.onComplete = onComplete;
                        onComplete();
                    }

//                    var myFx = new Fx.Style(elementId, 'opacity', configObj).set(1);
//                                    var myFx = new Fx.Style(elementId, 'opacity', configObj).start(0, 1);

                }
            }).request();


            return;
            var myFx = new Fx.Style(elementId, 'opacity',
                {
                    duration: 0,
                    onComplete: function()
                    {
                        $(elementId).setHTML('');
                        var navLoader = new Ajax(url,
                            {
                                method: 'get',
                                evalScripts: false,
                                update: elementId,
                                onComplete: function(content)
                                {

                                    //$(elementId).style.visibility = 'hidden';
                                    //$(elementId).setHTML(content);

                                    window.setTimeout('contentManager.executeScripts();', 100);


//                                    var configObj = {duration: 1000};
                                    var configObj = {};
                                    if (onComplete)
                                    {
                                        configObj.onComplete = onComplete;
                                    }

                                    var myFx = new Fx.Style(elementId, 'opacity', configObj).set(1);
//                                    var myFx = new Fx.Style(elementId, 'opacity', configObj).start(0, 1);

                                }
                            }).request();

                    }
                }
            ).start(1, 0);
        },
        
        unloadContent: function()
        {
        	switch(this.currentSection)
        	{
        		case 'Home':
					homePager.removeSlideshow();
        			break;
        		default:
        			break;
        	}
        }

    };

    obj.init();

    return obj;
}




//-->