
// ============================================================
// Klasse DialogTemplates
// ============================================================
//
// Objekthierarchie:
// -----------------
//   Object
//     |-- DialogTemplates
//
// Konstruktor:
// ------------
//   - DialogTemplates()
//
// Beschreibung:
// -------------
//   ...
//

// ------------------------------------------------------------
// Private Klasseneigenschaften
// ------------------------------------------------------------

// DialogTemplates._htmlRoot = "file:///C:/rd/entwicklung/eclipse-workspace/Integrale/htmlroot/backend";
// DialogTemplates._htmlRoot = "/integrale/backend";
DialogTemplates._htmlRoot = "/frontend";

// ------------------------------------------------------------
// Konstruktor
// ------------------------------------------------------------

function DialogTemplates() {
}

// ---------------------------------
// DialogTemplates._getDialogHTML
// ---------------------------------
DialogTemplates.prototype._getDialogHTML = function(o) {
  var html = "";
  html += '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\n';
  html += '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n';
  html += '<html xmlns="http://www.w3.org/1999/xhtml">\n';
  html += '<head>\n';
  html += '<title>Editor\'s Office - Dateneingabe</title>\n';
  html += '<link href="' + DialogTemplates._htmlRoot + '/resource/css/xdoc.css" type="text/css" media="all" rel="stylesheet">';
  html += '<script>window.focus();</script>\n';
  html += '</head>\n';
  html += '<body class="dialog">\n';

  
  html += '<div class="dialog-page">\n';
  html += '<div class="dialog-title">\n';
  html += this.title + '<br/>\n';
  html += '</div>\n';
  if (this.subtitle){
    html += '<div class="dialog-subtitle">\n';
    html +=  this.subtitle + '<br/>\n';
    html += '</div>\n';
  }
  html += '<div class="dialog-content">\n';
  html += '<form name="input-dialog" class="dialog-form">\n';
  if (this._inputList.length>0){
    html += '<div class="dialog-form">\n';
    for (var i=0; i<this._inputList.length; i++) {
      if (this._inputList[i]._getHTML() != ''){
      html += this._inputList[i]._getHTML();
      }
    }
    html += '</div>\n';
  }
  html += '</form>\n';
  html += '</div>\n';
  html += '</div>\n';
  html += '</body>\n';
  html += '</html>\n';
  return html;
}

// ------------------------------------
// DialogTemplates._getTextInputHTML
// ------------------------------------
DialogTemplates.prototype._getTextInputHTML = function(o) {
  if (o.hidden) {
    return "";
  }
  var html = "";
  var outputDescription = '';
  if (o.description!=undefined){
    outputDescription =  '(' + o.description + ')';
  }
  
  html += '<div class="dialog-formular-element">\n';
  html += '<div class="dialog-formular-element-label">\n';
  html += '<label for="' + o.name + '">\n';
  html += o.label + '\n';
  html += '</label><br/>\n';
  html += '</div>\n';
  html += '<div class="dialog-formular-element-value">\n';
  html += '<input type="text" class="dialog-formular-einzeilig" name="' + o.name + '" value="' + o.defaultValue + '"/><br/>\n' + outputDescription;
  html += '</div>\n';
  html += '<div class="float-aufheben"><br /></div>\n';
  html += '</div>\n';

  return html;
}

// ---------------------------------------
// DialogTemplates._getBooleanInputHTML
// ---------------------------------------
DialogTemplates.prototype._getBooleanInputHTML = function(o) {
  if (o.hidden) {
    return "";
  }
  var outputDescription = '';
  if (o.description!=undefined){
    outputDescription =  '(' + o.description + ')';
  }
  var html = "";
  
  html += '<div class="dialog-formular-element">\n';
  html += '<div class="dialog-formular-element-label">\n';
  html += '<label for="' + o.name + '">\n';
  html += o.label + '\n';
  html += '</label><br/>\n';
  html += '</div>\n';
  html += '<div class="dialog-formular-element-value">\n';
  html += '<input type="checkbox" name="' + o.name + '" value="' + o.defaultValue + '" '+ (o.defaultValue ? " checked" : "") +'/> '+ outputDescription +'<br />\n';
  html += '</div>\n';
  html += '<div class="float-aufheben"><br /></div>\n';
  html += '</div>\n';

  return html;
}

// ------------------------------------
// DialogTemplates._getListInputHTML
// ------------------------------------
DialogTemplates.prototype._getListInputHTML = function(o) {
  if (o.hidden) {
    return "";
  }
  var html = "";
  
  html += '<div class="dialog-formular-element">\n';
  html += '<div class="dialog-formular-element-label">\n';
  html += '<label for="' + o.name + '">\n';
  html += o.label + '\n';
  html += '</label><br/>\n';
  html += '</div>\n';
  html += '<div class="dialog-formular-element-value">\n';
  html += '<select '+ o.name +' class="dialog-formular-select">\n';
  html += "<option value='" + o.defaultValue + "'>Bitte wählen...</option>\n";
  for (var i=0; i<o.options.length; i++) {
    html += "<option value='" + o.options[i] + "'" + (o.options[i] == o.defaultValue ? " selected" : "") + ">" + o.options[i] + "</option>\n";
  }
  html += '</select><br />\n';
  var outputDescription = '';
  if (o.description!=undefined){
    outputDescription =  '(' + o.description + ')<br/>\n';
  }
  html += outputDescription;
  html += '</div>\n';
  html += '<div class="float-aufheben"><br /></div>\n';
  html += '</div>\n';

  return html;
}


// ------------------------------------------------------------
// Öffentliche Klassenmethoden
// ------------------------------------------------------------

// ---------------------------------
// DialogTemplates.GetDialogHTMLMediaReferenz
// ---------------------------------
DialogTemplates.GetDialogHTMLMediaReferenz = function(applicationURL) {

  var referenzUrlMedia = applicationURL + '&MODULE=MediaDB&ACTION=ViewMediaSearchForm&MODE=ReferenceDialog&Search.Media.MediaType=image';
  //var referenzUrlUpload = applicationURL + '&ACTION=ViewUploadFileForm&MODULE=MediaDB&MODE=Image';
  var referenzUrlUpload = applicationURL + '&MODULE=MediaDB&ACTION=ViewMediaCreateForm&MODE=ReferenceDialog&Media.MediaType=image';

  var html = "";

  html += '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\n';
  html += '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n';
  html += '<html xmlns="http://www.w3.org/1999/xhtml">\n';
  html += '<head>\n';
  html += '<title>Editor\'s Office - Dateneingabe</title>\n';
  html += '<link href="' + DialogTemplates._htmlRoot + '/resource/richtext-editor/css/standard.css" type="text/css" media="all" rel="stylesheet">';
  html += '<link href="' + DialogTemplates._htmlRoot + '/resource/richtext-editor/css/custom.css" type="text/css" media="all" rel="stylesheet">';
  html += '<link href="' + DialogTemplates._htmlRoot + '/resource/xui/css/xui-standard.css" type="text/css" media="all" rel="stylesheet">';
  html += '<link href="' + DialogTemplates._htmlRoot + '/resource/xui/css/xui-system.css" type="text/css" media="all" rel="stylesheet">';
  html += '<link href="' + DialogTemplates._htmlRoot + '/resource/xui/css/xui-content.css" type="text/css" media="all" rel="stylesheet">';
  html += '<link href="' + DialogTemplates._htmlRoot + '/resource/xui/css/xui-component.css" type="text/css" media="all" rel="stylesheet">';
  html += '<link href="' + DialogTemplates._htmlRoot + '/resource/xui/css/xml-editor-standard.css" type="text/css" media="all" rel="stylesheet">';
  html += '<script>window.focus();';

  html += 'function _giveOpenerDialogContext() {\n';
  html += 'var pk = document[\'input-dialog\'][\'bildPK\'].value;\n';
  html += 'document[\'input-dialog\'][\'bildSrc\'].value = document[\'input-dialog\'][\'_imageUrl\'].value;\n';
  html += 'var url = document[\'input-dialog\'][\'bildSrc\'].value;\n';
  html += 'var mediatype = document[\'input-dialog\'][\'bildMediaType\'].value;\n';
  html += 'var titel = document[\'input-dialog\'][\'ImageAlt\'].value;\n';
  html += 'var layout = \'\';\n';
  html += 'for (var i=0; i<document[\'input-dialog\'][\'Layout\'].length; i++){\n';
  html += 'if (document[\'input-dialog\'][\'Layout\'][i].checked == true){\n';
  html += 'layout = document[\'input-dialog\'][\'Layout\'][i].value;\n';
  html += '}\n';
  html += '}\n';
  html += 'var picAlign = document[\'input-dialog\'][\'ImageAlign\'].options[document[\'input-dialog\'][\'ImageAlign\'].options.selectedIndex].value;\n';
  html += 'opener.dialogContext.callback(pk, url, mediatype, picAlign, titel, layout);\n';
  html += 'close();\n';
  html += '}\n';

  html += 'function _openReferenceDialogXMLEditorRichtextMedia() {\n';
  html += 'var callback = new Function("pk", "url", "mediaType", "titel", "_setReferenceXMLEditorRichtextMedia(pk, url, mediaType, titel)");\n';
  html += 'dialogContext = {callback : callback, multiple : false};\n';
  html += 'dialogWindow = window.open(\'' + referenzUrlMedia + '\', "ReferenceDialogNEW", \'width=800,heigth=600,resizable=yes,scrollbars=yes\');\n';
  html += 'dialogWindow.focus();\n';
  html += '}\n';

  html += 'function _setReferenceXMLEditorRichtextMedia(pk, url, mediaType, titel) {\n';
  html += 'document[\'input-dialog\'][\'bildPK\'].value = pk;\n';
  html += 'document[\'input-dialog\'][\'bildSrc\'].value = url;\n';
  html += 'document[\'input-dialog\'][\'bildMediaType\'].value = mediaType;\n';
  html += 'document[\'input-dialog\'][\'ImageAlt\'].value = titel;\n';
  html += 'document.getElementById(\'_imageUrl\').value = url;\n';
  html += '}\n';

  html += 'function _openReferenceDialogXMLEditorRichtextUpload() {\n';
  html += 'var callback = new Function("pk", "url", "mediaType", "titel", "_setReferenceXMLEditorRichtextUpload(pk, url, mediaType, titel)");\n';
  html += 'dialogContext = {callback : callback, multiple : false};\n';
  html += 'dialogWindow = window.open(\'' + referenzUrlUpload + '\', "ReferenceDialogNEW", \'width=800,heigth=600,resizable=yes,scrollbars=yes\');\n';
  html += 'dialogWindow.focus();\n';
  html += '}\n';

  html += 'function _setReferenceXMLEditorRichtextUpload(pk, url, mediaType, titel) {\n';
  html += 'document[\'input-dialog\'][\'bildPK\'].value = pk;\n';
  html += 'document[\'input-dialog\'][\'bildSrc\'].value = url;\n';
  html += 'document[\'input-dialog\'][\'bildMediaType\'].value = mediaType;\n';
  html += 'document[\'input-dialog\'][\'ImageAlt\'].value = titel;\n';
  html += 'document.getElementById(\'_imageUrl\').value = url;\n';
  html += '}\n';

  html += '</script>\n';
  html += '</head>\n';
  html += '<body class="Cont">\n';

  html += '<form name="input-dialog">\n';

  html += '<input type="hidden" name="bildSrc" />';
  html += '<input type="hidden" name="bildPK" />';
  html += '<input type="hidden" name="bildMediaType" />';

  html += '<div id="Content">\n';
  html += '<div id="Compo-Site-Component">\n';

  html += '<div class="XUI-Page-Head">\n';
  html += '<div class="XUI-Title">\n';
  html += '<table class="XUI-Title-Inline" cellspacing="0" cellpadding="0" border="0">\n';
  html += '<tr>\n';
  html += '<td class="XUI-Title-Item">\n';
  html += '<span class="XUI">';
  html += 'Bild<br/>\n';
  html += '</span>\n';
  html += '</td>\n';
  html += '</tr>\n';
  html += '</table>\n';
  html += '</div>\n';
  html += '</div>\n';

  html += '<div class="XUI-Page-Body">\n';

  html += '<div class="XUI-Block-Space-First">\n';

  html += '<div class="XUI-Object-Field">\n';
  html += '<table class="XUI-Object-Field-Inline" cellspacing="0" cellpadding="0" border="0">\n';
  html += '<tr>\n';
  html += '<td class="XUI-Object-Field-Switch">\n';
  html += '<img border="0" height="1" width="9" src="' + DialogTemplates._htmlRoot + '/resource/xui/graphic/trans.gif"><br>\n';
  html += '</td>\n';
  html += '<td>\n';
  html += '<table style="width: 100%;" cellspacing="0" cellpadding="0" border="0">\n';
  html += '<tr>\n';
  html += '<td class="XUI-Object-Field-Lable">\n';
  html += '<div class="XUI-Object-Field-Lable-Inline">\n';
  html += '<span class="XUI">\n';
  html += 'Bild-URL\n';
  html += '</span>\n';
  html += '</div>\n';
  html += '</td>\n';
  html += '<td class="XUI-Object-Field-Body">\n';

  html += '<div style="margin-bottom: 5px;">\n';
  html += '<input id="_imageUrl" type="text" name="_imageUrl" value="" class="XMLEdit-Input-String"/><br/>\n';
  html += '</div>\n';

  html += '<table border="0" cellpadding="0" cellspacing="0" style="margin-top: 10px;">';
  html += '<tr>';
  html += '<td style="padding-right: 10px">';

  html += '<table border="0" cellpadding="0" cellspacing="0">\n';
  html += '<tr>\n';
  html += '<td class="XUI-Obj-Navigation-Button-Left">\n';
  html += '<img src="' + DialogTemplates._htmlRoot + '/resource/xui/graphic/trans.gif" width="9" height="1" border="0" /><br />\n';
  html += '</td>\n';
  html += '<td class="XUI-Obj-Navigation-Button-Middle">\n';
  html += '<a href="javascript:_openReferenceDialogXMLEditorRichtextMedia();" class="SectionButton">\n';
  html += 'Media...\n';
  html += '</a><br />\n';
  html += '</td>\n';
  html += '<td class="XUI-Obj-Navigation-Button-Right">\n';
  html += '<img src="' + DialogTemplates._htmlRoot + '/resource/xui/graphic/trans.gif" width="9" height="1" border="0" /><br />\n';
  html += '</td>\n';
  html += '</tr>\n';
  html += '</table>\n';

  html += '</td>';
  html += '<td>';

  html += '<table border="0" cellpadding="0" cellspacing="0">\n';
  html += '<tr>\n';
  html += '<td class="XUI-Obj-Navigation-Button-Left">\n';
  html += '<img src="' + DialogTemplates._htmlRoot + '/resource/xui/graphic/trans.gif" width="9" height="1" border="0" /><br />\n';
  html += '</td>\n';
  html += '<td class="XUI-Obj-Navigation-Button-Middle">\n';
  html += '<a href="javascript:void(0);" onclick="_openReferenceDialogXMLEditorRichtextUpload()" class="SectionButton">\n';
  html += 'Upload...';
  html += '</a><br />\n';
  html += '</td>\n';
  html += '<td class="XUI-Obj-Navigation-Button-Right">\n';
  html += '<img src="' + DialogTemplates._htmlRoot + '/resource/xui/graphic/trans.gif" width="9" height="1" border="0" /><br />\n';
  html += '</td>\n';
  html += '</tr>\n';
  html += '</table>\n';

  html += '</td>';
  html += '</tr>\n';
  html += '</table>\n';

  html += '</td>\n';
  html += '<td class="XUI-Object-Field-Button">\n';
  html += '&nbsp;<br>\n';
  html += '</td>\n';
  html += '</tr>\n';
  html += '</table>\n';
  html += '</td>\n';
  html += '</tr>\n';
  html += '</table>\n';
  html += '</div>\n';

  html += '</div>\n';
  html += '<div class="XUI-Block-Space">\n';

  html += '<div class="XUI-Object-Field">\n';
  html += '<table class="XUI-Object-Field-Inline" cellspacing="0" cellpadding="0" border="0">\n';
  html += '<tr>\n';
  html += '<td class="XUI-Object-Field-Switch">\n';
  html += '<img border="0" height="1" width="9" src="' + DialogTemplates._htmlRoot + '/resource/xui/graphic/trans.gif"><br>\n';
  html += '</td>\n';
  html += '<td>\n';
  html += '<table style="width: 100%;" cellspacing="0" cellpadding="0" border="0">\n';
  html += '<tr>\n';
  html += '<td class="XUI-Object-Field-Lable">\n';
  html += '<div class="XUI-Object-Field-Lable-Inline">\n';
  html += '<span class="XUI">\n';
  html += 'Bild-Ausrichtung\n';
  html += '</span>\n';
  html += '</div>\n';
  html += '</td>\n';
  html += '<td class="XUI-Object-Field-Body">\n';

  html += '<select name="ImageAlign">\n';
  html += '<option selected="true" value="right">Rechts (Standard)</option>\n';
  html += '<option value="left">Links</option>\n';
  html += '<option value="">keine Ausrichtung</option>\n';
  html += '</select>\n';

  html += '</td>\n';
  html += '<td class="XUI-Object-Field-Button">\n';
  html += '&nbsp;<br>\n';
  html += '</td>\n';
  html += '</tr>\n';
  html += '</table>\n';
  html += '</td>\n';
  html += '</tr>\n';
  html += '</table>\n';
  html += '</div>\n';

  html += '</div>\n';
  html += '<div class="XUI-Block-Space">\n';

  html += '<div class="XUI-Object-Field">\n';
  html += '<table class="XUI-Object-Field-Inline" cellspacing="0" cellpadding="0" border="0">\n';
  html += '<tr>\n';
  html += '<td class="XUI-Object-Field-Switch">\n';
  html += '<img border="0" height="1" width="9" src="' + DialogTemplates._htmlRoot + '/resource/xui/graphic/trans.gif"><br>\n';
  html += '</td>\n';
  html += '<td>\n';
  html += '<table style="width: 100%;" cellspacing="0" cellpadding="0" border="0">\n';
  html += '<tr>\n';
  html += '<td class="XUI-Object-Field-Lable">\n';
  html += '<div class="XUI-Object-Field-Lable-Inline">\n';
  html += '<span class="XUI">\n';
  html += 'Bild-Titel\n';
  html += '</span>\n';
  html += '</div>\n';
  html += '</td>\n';
  html += '<td class="XUI-Object-Field-Body">\n';

  html += '<input class="XUI-Page-Input-Form-Element-Text" type="text" style="width: 99%;" name="ImageAlt" value="" />';

  html += '</td>\n';
  html += '<td class="XUI-Object-Field-Button">\n';
  html += '&nbsp;<br>\n';
  html += '</td>\n';
  html += '</tr>\n';
  html += '</table>\n';
  html += '</td>\n';
  html += '</tr>\n';
  html += '</table>\n';
  html += '</div>\n';

  html += '</div>\n';
  html += '<div class="XUI-Block-Space">\n';

  html += '<div class="XUI-Object-Field">\n';
  html += '<table class="XUI-Object-Field-Inline" cellspacing="0" cellpadding="0" border="0">\n';
  html += '<tr>\n';
  html += '<td class="XUI-Object-Field-Switch">\n';
  html += '<img border="0" height="1" width="9" src="' + DialogTemplates._htmlRoot + '/resource/xui/graphic/trans.gif"><br>\n';
  html += '</td>\n';
  html += '<td>\n';
  html += '<table style="width: 100%;" cellspacing="0" cellpadding="0" border="0">\n';
  html += '<tr>\n';
  html += '<td class="XUI-Object-Field-Lable">\n';
  html += '<div class="XUI-Object-Field-Lable-Inline">\n';
  html += '<span class="XUI">\n';
  html += 'Layout\n';
  html += '</span>\n';
  html += '</div>\n';
  html += '</td>\n';
  html += '<td class="XUI-Object-Field-Body">\n';

  html += '<table cellspacing="0" cellpadding="0" border="0">\n';
  html += '<tr>\n';
  html += '<td class="XUI">\n';
  html += '<div class="XUI-Page-Input-Element">\n';
  html += '<input class="XUI-Page-Input-Form-Element-Box" type="radio" name="Layout" title="Bild ohne Titel (Standard)" value="layout1" checked="1" />\n';
  html += '</div>\n';
  html += '</td>\n';
  html += '<td class="XUI">\n';
  html += '<div class="XUI-Page-Input-Element">\n';
  html += 'Bild ohne Titel (Standard)\n';
  html += '</div>\n';
  html += '</td>\n';
  html += '</tr>\n';
  html += '<tr>\n';
  html += '<td class="XUI" style="vertical-align: middle;">\n';
  html += '<div class="XUI-Page-Input-Element">\n';
  html += '<input class="XUI-Page-Input-Form-Element-Box" type="radio" name="Layout" title="Bild mit Titel" value="layout2" />\n';
  html += '</div>\n';
  html += '</td>\n';
  html += '<td class="XUI" style="vertical-align: middle;">\n';
  html += '<div class="XUI-Page-Input-Element">\n';
  html += 'Bild mit Titel\n';
  html += '</div>\n';
  html += '</td>\n';
  html += '</tr>\n';
  html += '</table>\n';

  html += '</td>\n';
  html += '<td class="XUI-Object-Field-Button">\n';
  html += '&nbsp;<br>\n';
  html += '</td>\n';
  html += '</tr>\n';
  html += '</table>\n';
  html += '</td>\n';
  html += '</tr>\n';
  html += '</table>\n';
  html += '</div>\n';

  html += '</div>\n';

  // !!! ACHTUNG:
  // "opener" ist nur notwendig, wenn mit echten windows
  // gearbeitet wird - bei Layer-Lösung entfernen.
  html += '<div class="dateneingabeNavigation">\n<table border="0" cellpadding="0" cellspacing="0">\n<tr>\n';
  html += '<td class="dateneingabeNavigation-Button">\n<table border="0" cellpadding="0" cellspacing="0">\n<tr>\n<td class="dateneingabeNavigation-Button-Left">\n<img src="' + DialogTemplates._htmlRoot + '/resource/graphic/trans.gif" width="9" height="1" border="0"><br/>\n</td>\n<td class="dateneingabeNavigation-Button-Middle">\n<a href="javascript: _giveOpenerDialogContext(); close();" class="SectionButton">OK</a><br/>\n</td>\n<td class="dateneingabeNavigation-Button-Right">\n<img src="' + DialogTemplates._htmlRoot + '/resource/graphic/trans.gif" width="9" height="1" border="0"><br/>\n</td>\n</tr>\n</table>\n</td>\n';
  html += '<td class="dateneingabeNavigation-Button">\n<table border="0" cellpadding="0" cellspacing="0">\n<tr>\n<td class="dateneingabeNavigation-Button-Left">\n<img src="' + DialogTemplates._htmlRoot + '/resource/graphic/trans.gif" width="9" height="1" border="0"><br/>\n</td>\n<td class="dateneingabeNavigation-Button-Middle">\n<a href="javascript: close();" class="SectionButton">Cancel</a><br/>\n</td>\n<td class="dateneingabeNavigation-Button-Right">\n<img src="' + DialogTemplates._htmlRoot + '/resource/graphic/trans.gif" width="9" height="1" border="0"><br/>\n</td>\n</tr>\n</table>\n</td>\n';
  html += '</tr>\n</table>\n</div>';
  html += '</div>\n';
  html += '</div>\n';
  html += '</div>\n';
  html += '</form>\n';
  html += '</body>\n';
  html += '</html>\n';
  return html;
}



