var ContentSlideModule = new Object();

ContentSlideModule.editorLoaded = function( cof_index, the_index )
{
	var the_layout = document.getElementById( 'cof_image_layout_' + cof_index + '_' + the_index );

	if( the_layout.value != ''  )
		LayoutControl.setLayout( cof_index, the_index, the_layout.value );
	else
		LayoutControl.setLayout( cof_index, the_index, 'IT' );
}

ContentSlideModule.viewerLoaded = function( cof_index, the_index )
{
	var the_image = document.getElementById( 'cof_view_image_' + cof_index + '_' + the_index );
	
	if( the_image )
	{
		this.setNotes( the_image);
		Behaviour.apply();	
	}
}

ContentSlideModule.setNotes = function( the_image )
{
	var theParent = the_image.parentNode;
	var id = theParent.id.slice( theParent.id.lastIndexOf('_') + 1 );
	
	var dimensions = Element.getDimensions( the_image );
	Element.setStyle( theParent, { width: dimensions.width + 'px', height: dimensions.height + 'px' } );
	
	var theNotesJSON = document.getElementById( 'cof_image_notes_' + id );
	if( theNotesJSON.value != '[]' )
	{
		var theNotes = theNotesJSON.value.parseJSON();
		var index = 0;
		
		while( theNotes[index] )
		{
			Annotation.addNote( 'cof_view_image_wrapper_' + id, theNotes[index].text, theNotes[index].top, theNotes[index].left, theNotes[index].height, theNotes[index].width );
			index++;
		}
	}
}

ContentSlideModule.getInputList = function ( cof_index, the_index )
{
	return new Array( 
		'cof_files_' + cof_index + '_' + the_index + '_0',
		'cof_imagedescr_' + cof_index + '_' + the_index
	);
}

ContentSlideModule.getRules = function()
{
	var self = this;

	var my_rules = {
		'.cof-slideimage-remove' : function(el)
		{
			el.onclick = function()
			{
				BasicControlDisable.removeControlsClick( el, self );
			},
			
			el.onkeypress = function(e)
			{
				return ContentObjectFactory.doKeyPress( el, e );
			};	
		}
	};

	return my_rules;
}
