// requires jquery, syntaxHighlighter (colorEverything), lineNumberer

$(document).ready(
	function(){
		$('.richCodeEditor').each(
			function(){
				var fileName = this.id.replace(/_studentCodeColor$/,'');
				// if that pre is empty, there is no default code.
				// thus this is not a book example (not from course_notes or lecture_notes)
				// this is either from home or from exam part
				if( $('#'+fileName).text() ==''){ //$('#'+fileName).hasClass('noDefaultCode')
					$('#'+fileName+'_loadDefaultCodeButton').hide();
				}
				else{
					$('#'+fileName+'_backToFilesButton').hide();
					this.loadDefaultCodeButton = get(fileName+'_loadDefaultCodeButton');
					this.loadDefaultCodeButton.field = this;
					this.defaultCodeContainerDiv = get(fileName+'_defaultCodeContainer');
					this.defaultCodeContainerDiv.innerHTML=colorEverything(this.defaultCodeContainerDiv.innerHTML);
					
				}
			}
		);
		
		
		$('.loadDefaultCodeButton').click(
			function(){				
				this.field.innerHTML = this.field.defaultCodeContainerDiv.innerHTML;
				$(this.field).keyup();
			}
		);
	}
);


