(function(){var iModalButtons=''+'<button id="tinymce-module-form-imodal-close" type="button" style="float: left;">'+'Cancel'+'</button>'+'<button id="tinymce-module-form-imodal-insert" type="button" style="float: right; font-weight: bold;" disabled="disabled">'+'Insert Survey Link'+'</button>';tinymce.create('tinymce.plugins.interspireSurvey',{init:function(ed,url){ed.addCommand('mceInsertFeedbackForm',function(){var win=$.fn.window.create({title:'Link to a Survey',width:400,height:250,uri:'index.php?Page=Addons&Addon=surveys&Action=tinymceSurveylist&ajax=1',autoOpen:true}).buttons(iModalButtons);win.jQuery().bind('windowAfterOpen',function(){$('#tinymce-module-form-imodal-close').bind('click',function(){$.fn.window.closeAll()});$('#tinymce-module-form-imodal-insert').bind('click',function(){_insertAndClose.apply($('#tinymce-module-form-list').find(':radio:checked'))});$('#tinymce-module-form-list tr').bind('click',function(){$('#tinymce-module-form-imodal-insert').removeAttr('disabled')}).bind('dblclick',function(){_insertAndClose.apply($(this).closest('tr').find(':radio'))});function _insertAndClose(){var radio=$(this);var id=radio.val();var surveyname=$('input[name=surveyId]:checked + label').text();var selectedtext=tinyMCE.activeEditor.selection.getContent();if(selectedtext){ed.execCommand('mceInsertContent',false,'<a href=\"%%SURVEY_'+id+'_LINK%%\">'+selectedtext+'</a>')}else{ed.execCommand('mceInsertContent',false,'<a href=\"%%SURVEY_'+id+'_LINK%%\">Click here to take our survey</a>')}$.fn.window.closeAll()}})});ed.addButton('interspiresurvey',{title:'Insert a link to the Survey Page',image:'addons/surveys/images/tinymce_icon.png',cmd:'mceInsertFeedbackForm'})}});tinymce.PluginManager.add('interspiresurvey',tinymce.plugins.interspireSurvey)})();