/**
 * This is a customization on the link dialog which adds a new tab named
 * "Pages" to the dialog, containing a list of all the pages in the website.
 */

CKEDITOR.on('dialogDefinition', function(ev) {

//for (var i in ev)
//    alert(i + "=" + ev[i]);

    // Take the dialog name and its definition from the event
    // data.
    var dialogName = ev.data.name;
    var dialogDefinition = ev.data.definition;

    // Check if the definition is from the dialog we're
    // interested on (the "Link" dialog).
    if (dialogName == 'link') {
		dialogDefinition.removeContents( 'upload' );
		dialogDefinition.contents[0].elements[0].items.push(["Website Page", "page"]);
		dialogDefinition.contents[0].elements.push(
					{
						type : 'vbox',
						id : 'pageOptions',
						children :
						[
							{
								type : 'hbox',
								children :
								[
									{
										id : 'pageName',
										type : 'select',
										label : 'Website Page',
										'default' : '',
										style : 'width : 100%;',
										items :
										[
																																],
										setup : function( data )
										{
											if ( data.page )
												this.setValue( data.page.pageName || '' );
										},
										commit : function( data )
										{
											if ( !data.page )
												data.page = {};

											data.page.pageName = this.getValue();
										}
									}
								],
								setup : function( data )
								{
									if ( !this.getDialog().getContentElement( 'info', 'linkType' ) )
										this.getElement().show();
								}
							}
						]
					});
		/*dialogDefinition.contents[0].elements.unshift(
                {
                    id: 'pageNames',
                    type: 'select',
                    label: 'Website Page',
                    items: [
						['--', '']
                                            ]
                });
		dialogDefinition.addContents({
            id: 'pagesTab',
            label: 'Pages',
            accessKey: 'P',
            elements: [
                {
                    id: 'pageNames',
                    type: 'select',
                    label: 'Website Page',
                    items: [
						['', '']
                                            ]
                }
            ]
        }, 'info');*/

    }
    
});
