/*
* scripts page implementation
*/
var Scripts = new function(){

	this.initialized = false;

	/*
	* initialize scripts page; load documents
	*/
	this.initialize = function(){

		this.initialized = true;
		
		var gui = this;

		this.selectionContainer = $("#scriptsSelection");
		$('<h2>'+Util.getString('scriptSelection')+'</h2>').appendTo(this.selectionContainer);

		var form = $('<form/>').appendTo(this.selectionContainer);
		var fieldset = $('<fieldset/>').appendTo(form);
		this.selectionDropdown = $('<select class="selectHandschriften"/>').appendTo(fieldset);

		$('<option>'+Util.getString('selectHandwriting')+'</option>').appendTo(gui.selectionDropdown);
		$(this.selectionDropdown).change(function(){
			$("select option:selected",this.selectionDropdown).each(function(){
				if( $(this).attr('id') != '' ){
					gui.showDocument($(this).attr('id'));
				}
			});
		});

		var loadDocs = function(){
			if( Util.docsLoaded == 1 ){
				for( var i=0; i<Util.documents.length; i++ ){
					$('<option id="'+Util.documents[i].title+'">'+Util.documents[i].name+'</option>').appendTo(gui.selectionDropdown);
				}
			}
			else {
				if( Util.docsLoaded == -1 ){
					Util.loadDocuments();
				}
				setTimeout(function(){
					loadDocs();
				}, 100 );
			}
		}
		loadDocs();
		this.scriptContainer = $("#scriptContainer");
	};

	/*
	* show document with given <title>
	*/
	this.showDocument = function(title){
		if( title == Util.getString('selectHandwriting') ){
			return;
		}
		var doc = Util.getDoc(title);
		var gui = this;
		$(this.scriptContainer).empty();
		$.ajax({
			url: EditionProperties.metadataQuery.replace('DOC_ID',title),
			dataType: 'html',
			success: function(xhtml){
				$('<h2 class="head-handwriting" id='+title+'>'+Util.getString('handwriting')+': '+title+'</h2>').appendTo(gui.scriptContainer);
				var width = ScriptsProps.hwImageWidth;
				var height = ScriptsProps.hwImageHeight;
				var imageDiv = $('<div/>').appendTo(gui.scriptContainer);
				var image = $('<img alt="" height="'+height+'" src="'+doc.preview+'" class="content-img-style2" />').appendTo(imageDiv);
				var contentDiv = $('<div/>').appendTo(gui.scriptContainer);
				$(xhtml).appendTo(contentDiv);
				$('span',contentDiv).each(function(){
					var lang = Util.getAttribute(this,'xml:lang');
					if( Util.language != lang && this.className !== 'tei:date'){
						$(this).css('display','none');
					}
				});
			}
		});
	};
};

ScriptsProps = {
	// default size if manuscripts page image 
	hwImageHeight: 328,
	hwImageWidth: 359
};
@@ -282,17 +282,19 @@
 $('%3Ch2%3E'
-+
+ + 
 Util.get
@@ -318,17 +318,19 @@
 ection')
-+
+ + 
 '%3C/h2%3E')
@@ -372,27 +372,67 @@
 %0A%0A%09%09
-var form = $('%3Cform
+this.selectionDropdown = $('%3Cul class=%22selectHandschriften%22
 /%3E')
@@ -471,280 +471,286 @@
 r);%0A
+%0A
 %09%09var 
-fieldset = $('%3Cfieldset/%3E').appendTo(form);%0A%09%09this.selectionDropdown = $('%3Cselect class=%22selectHandschriften%22/%3E').appendTo(fieldset);%0A%0A%09%09$('%3Coption%3E'+Util.getString('selectHandwriting')+'%3C/option%3E').appendTo(gui.selectionDropdown);%0A%09%09$(this.selectionDropdown).change
+loadDocs = function()%7B%0A%09%09%09if( Util.docsLoaded == 1 )%7B%0A%09%09%09%09for (var i = 0; i %3C Util.documents.length; i++) %7B%0A%09%09%09%09%09$('%3Cli id=%22' + Util.documents%5Bi%5D.title + '%22%3E' + Util.documents%5Bi%5D.name + '%3C/li%3E').appendTo(gui.selectionDropdown);%0A%09%09%09%09%7D%0A%09%09%09%09$(%22.selectHandschriften li%22).each
 (fun
@@ -760,68 +760,57 @@
 on()
+ 
 %7B%0A%09%09%09
-$(%22select option:selected%22,this.selectionDropdown).each
+%09%09%09%09console.log(this);%0A%09%09%09%09%09%09%09$(this).click
 (fun
@@ -818,24 +818,28 @@
 tion()%7B%0A
+%09%09%09%09
 %09%09%09%09if
-(
  
+(
 $(this).
@@ -854,20 +854,24 @@
 ') != ''
- )%7B%0A
+) %7B%0A%09%09%09%09
 %09%09%09%09%09gui
@@ -913,259 +913,34 @@
 %09%09%09%09
-%7D%0A
 %09%09%09
-%7D);%0A%09%09%7D);%0A%0A%09%09var loadDocs = function()%7B%0A%09%09%09if( Util.docsLoaded == 1 )%7B%0A%09%09%09%09for( var i=0; i%3CUtil.documents.length; i++ )%7B%0A%09%09%09%09%09$('%3Coption id=%22'+Util.documents%5Bi%5D.title+'%22%3E'+Util.documents%5Bi%5D.name+'%3C/option%3E').appendTo(gui.selectionDropdown);%0A%09%09%09%09%7D
+%09%7D%0A%09%09%09%09%09%09%09%7D)%0A%09%09%09%09%09%09%7D);%0A
 %0A%09%09%09
@@ -1557,19 +1557,25 @@
 id='
-+
+ + 
 title
-+'%3E'+
+ + '%3E' + 
 Util
@@ -1603,20 +1603,26 @@
 ng')
-+
+ + 
 ': '
-+
+ + 
 title
-+
+ + 
 '%3C/h
@@ -1851,16 +1851,20 @@
 t=%22'
-+
+ + 
 height
-+
+ + 
 '%22 s
@@ -1868,17 +1868,19 @@
 %22 src=%22'
-+
+ + 
 doc.prev
@@ -1882,17 +1882,19 @@
 .preview
-+
+ + 
 '%22 class
@@ -2120,16 +2120,17 @@
 te(this,
+ 
 'xml:lan

Output of manuscripts as list