/* Contao Open Source CMS :: Copyright (C) 2005-2013 Leo Feyer :: LGPL license */
var Typobox={preInit:function(){var a;tinyMCEPopup.requireLangPack(),(a=tinyMCEPopup.getParam("external_image_list_url"))&&document.write('<script language="javascript" type="text/javascript" src="'+tinyMCEPopup.editor.documentBaseURI.toAbsolute(a)+'"></script>')},init:function(){var a=document.forms[0],b=tinyMCEPopup.editor;document.getElementById("srcbrowsercontainer").innerHTML=getBrowserHTML("srcbrowser","src","image","theme_advanced_image"),isVisible("srcbrowser")&&(document.getElementById("src").style.width="180px"),this.fillFileList("image_list","tinyMCEImageList"),this.fillModeList("mode_list"),this.fillRelList("rel_list"),TinyMCE_EditableSelects.init(),c=b.selection.getContent();if(!c||c.indexOf("image::")==-1)return;c=c.replace(/^.*\{\{image::/gi,""),c=c.replace(/\}\}.*$/i,""),c=c.replace(/\[&amp;\]|\[&\]|&amp;|&/gi,"?");var d=c.split("?");a.src.value=d[0];for(i=1;i<d.length;i++){sub=d[i].split("=");switch(sub[0]){case"width":a.width.value=sub[1];break;case"height":a.height.value=sub[1];break;case"alt":a.alt.value=sub[1];break;case"class":a.cssClass.value=sub[1];break;case"mode":selectByValue(a,"mode_list",sub[1],!0);break;case"rel":selectByValue(a,"rel_list",sub[1],!0)}}},fillFileList:function(a,b){var c=tinyMCEPopup.dom,d=c.get(a),e,f;b=window[b],b&&b.length>0?(d.options[d.options.length]=new Option("",""),tinymce.each(b,function(a){d.options[d.options.length]=new Option(a[0],a[1])})):c.remove(c.getParent(a,"tr"))},fillModeList:function(a){var b=tinyMCEPopup.dom,c=b.get(a),d;c.options[c.options.length]=new Option(tinyMCEPopup.getLang("typolinks_dlg.image_crop"),"crop"),c.options[c.options.length]=new Option(tinyMCEPopup.getLang("typolinks_dlg.image_proportional"),"proportional"),c.options[c.options.length]=new Option(tinyMCEPopup.getLang("typolinks_dlg.image_box"),"box")},fillRelList:function(a){var b=tinyMCEPopup.dom,c=b.get(a),d;c.options[c.options.length]=new Option(tinyMCEPopup.getLang("not_set"),""),c.options[c.options.length]=new Option(tinyMCEPopup.getLang("typolinks_dlg.image_rel_single"),"lightbox"),c.options[c.options.length]=new Option(tinyMCEPopup.getLang("typolinks_dlg.image_rel_multi"),"lightbox[multi]")},update:function(){var a=document.forms[0],b=a.elements,c=tinyMCEPopup.editor,d={},e;tinyMCEPopup.restoreSelection();if(a.src.value==""){tinyMCEPopup.close();return}var f=a.src.value,g="?";a.width.value&&(f+=g+"width="+a.width.value,g="&amp;"),a.height.value&&(f+=g+"height="+a.height.value,g="&amp;"),a.alt.value&&(f+=g+"alt="+a.alt.value,g="&amp;"),a.cssClass.value&&(f+=g+"class="+a.cssClass.value,g="&amp;"),a.mode_list&&(f+=g+"mode="+getSelectValue(a,"mode_list")),a.rel_list&&(f+=g+"rel="+getSelectValue(a,"rel_list")),f="{{image::"+f+"}}",e=c.selection.getNode(),c.execCommand("mceInsertRawHTML",!1,f),c.undoManager.add(),tinyMCEPopup.close()}};Typobox.preInit(),tinyMCEPopup.onInit.add(Typobox.init,Typobox);