function c_content_app() 
{
    this.slide_show = null;
    this.last_image_selector_div = 0;
    this.slide_show_initialized = false;
    this.initialize_slide_show = function(  )
    {
    }
    this.get_content = function(  )
    {
        if( this.slide_show_initialized )
        {
            this.slide_show.kill();
        }
        content_app.last_image_selector_div = 0;
        var arr = dog( 'top_menu_menu_arr_string' ).value.split( const_delimiter );
        //alert( arr );
        var menu = 'index';
        for( i = 0; i < arr.length; i++ )
        {
            if( dog( 'top_menu_menu_' + arr[i] ).className == "top_menu_item_content_selected" || 
                dog( 'top_menu_menu_' + arr[i] ).className == "top_menu_item_content_selected_hover" )
            {
                menu = arr[i];
            }
        }
        var arr = dog( 'top_menu_language_arr_string' ).value.split( const_delimiter );
        var language = 'nl';
        for( i = 0; i < arr.length; i++ )
        {
            if( dog( 'top_menu_language_' + arr[i] ).className == "top_menu_language_content_selected" || 
                dog( 'top_menu_language_' + arr[i] ).className == "top_menu_language_content_selected_hover" )
            {
                language = arr[i];
            }
        }
        var t_obj = this;
        $.ajax({
            type: "POST",
            url: "content.php",
            data: "language=" + language +
                  "&top_menu=" + menu,
            success: function( msg )
            {
                var arr = msg.split( const_delimiter ); 
                if( arr[ arr.length - 2] == 'initialize_template' )
                {
                    var length = msg.length - ( arr[ arr.length - 2].length + const_delimiter.length + arr[ arr.length - 1].length + const_delimiter.length );
                    dog( 'content_div' ).innerHTML = msg.substring( 0,  length );
                    //alert( dog( 'content_div' ).innerHTML );
                    content_app.initialize_template( arr[ arr.length - 1] );
                }
                else
                {
                    //alert( msg );
                    dog( 'content_div' ).innerHTML = msg;
                }
            }
         });
        
    }
    this.initialize_template = function( template )
    {
        if( template == 'slide_show' )
        {
            this.initialize_slide_show_template();
        }
        if( template == 'slide_show_with_thumbs' )
        {
            this.initialize_slide_show_with_thumbs_template();
        }
        if( template == 'slide_show_with_content' )
        {
            this.initialize_slide_show_with_content_template();
        }
    }
    this.initialize_slide_show_template = function(  )
    {
        var image_arr = dog( "image_arr" ).value.split( const_delimiter );       
        this.slide_show = new c_slide_show( 'slide_show_0_div', // div where to write to
                                       image_arr, 
                                       800, 400,  // width && height
                                       'black', // background color
                                       100,   // zindex
                                       10,    // fade_speed
                                       2000,  // interval period inbetween images
                                       6000,  // pause period after click or got to 
                                       true,  // match image to container size
                                       false,  // stop on mouse_over
                                       null ); // callback
        this.slide_show.start();
        this.slide_show_initialized = true;                                       
    }
    this.initialize_slide_show_with_thumbs_template = function(  )
    {
        var image_arr = dog( "image_arr" ).value.split( const_delimiter );       
        this.slide_show = new c_slide_show( 'slide_show_0_div', // div where to write to
                                       image_arr, 
                                       400, 400,  // width && height
                                       'black', // background color
                                       100,   // zindex
                                       10,    // fade_speed
                                       6000,  // interval period inbetween images
                                       6000,  // pause period after click or got to 
                                       true,  // match image to container size
                                       true,  // stop on mouse_over
                                       this.image_ready_callback ); // callback
        this.slide_show_initialized = true;                                       
        this.slide_show.start();
    }
    this.initialize_slide_show_with_content_template = function(  )
    {
        var image_arr = dog( "image_arr" ).value.split( const_delimiter );       
        this.slide_show = new c_slide_show( 'slide_show_0_div', // div where to write to
                                       image_arr, 
                                       400, 400,  // width && height
                                       'black', // background color
                                       100,   // zindex
                                       10,    // fade_speed
                                       5000,  // interval period inbetween images
                                       6000,  // pause period after click or got to 
                                       true,  // match image to container size
                                       true,  // stop on mouse_over
                                       this.slide_show_with_content_image_ready_callback ); // callback
        var arr = dog( "slide_show_with_content_content" ).value.split( const_delimiter );
        dog( "slide_show_with_content_content_div" ).innerHTML = undo_js_safe_str( arr[ 0 ] ); 
        this.slide_show_initialized = true;                                       
        this.slide_show.start();
    }
    this.image_ready_callback = function( index )
    {
        dog( 'image_selector_' + content_app.last_image_selector_div ).className = 'image_selector_div';   
        content_app.last_image_selector_div = index;
        dog( 'image_selector_' + index ).className = 'image_selector_div_with_border';   
    }
    this.slide_show_with_content_image_ready_callback = function( index )
    {
       var arr = dog( "slide_show_with_content_content" ).value.split( const_delimiter );
       dog( "slide_show_with_content_content_div" ).innerHTML = undo_js_safe_str( arr[ index ] ); 
    }
}
