
jQuery.fn.cmsModuleEditor_Navigation=function(opts){return this.each(function(){$(this).find('ul').each(function(){var thisRef=$(this);thisRef.sortable({containment:'parent',cursor:'crosshair',start:function(event,ui){$(ui.item).parent().find('a').each(function(){$(this).data('url',$(this).attr('href'));this.href='javascript:void(0);';});},update:function(event,ui){$(ui.item).animate({width:$(ui.item).width()},50,function(){var pageOrdering=[];$(ui.item).parent().find(' > li').each(function(){pageOrdering.push($(this).attr('rel'));});var parentId='HOME';var parentLI=$(ui.item).parents('li:first');if(parentLI&&parentLI.attr('rel')){parentId=parentLI.attr('rel');}
$.postJSON('/cms/pages/SetOrder',{parent:parentId,ordering:$.compactJSON(pageOrdering)},function(json){if(json.success){}});$(ui.item).parent().parent().find('a').each(function(){$(this).animate({width:$(this).width()},50,function(){this.href=$(this).data('url');});});});}});});});};var cmsNicPanel=null;var myNicEditor=null;function nicEdit_InsertImage(src,alt,width,height){if(!cmsNicPanel.im){var tmp='javascript:nicImTemp();';cmsNicPanel.ne.nicCommand("insertImage",tmp);cmsNicPanel.im=cmsNicPanel.findElm('IMG','src',tmp);}
if(cmsNicPanel.im){cmsNicPanel.im.setAttributes({src:src,alt:alt});if(width.indexOf('px')==-1)
width=width+'px';if(height.indexOf('px')==-1)
height=height+'px';cmsNicPanel.im.setStyle({width:width,height:height});}
cmsNicPanel.removePane();}
function nicEdit_InsertFile(src,target){if(!cmsNicPanel.ln){var tmp='javascript:nicTemp();';cmsNicPanel.ne.nicCommand("createlink",tmp);cmsNicPanel.ln=cmsNicPanel.findElm('A','href',tmp);}
if(cmsNicPanel.ln){cmsNicPanel.ln.setAttributes({href:src,title:src,target:target});}
cmsNicPanel.removePane();}
var cmsCtrlPressed=false;$(window).keydown(function(event){if(event.ctrlKey){cmsCtrlPressed=true;}
return true;});$(window).keyup(function(event){cmsCtrlPressed=false;return true;});function cmsContentModuleEditor_DefaultSave(moduleElement,nicEditor){try{if($(moduleElement).data('config').Content!=nicEditor.getContent()){$(moduleElement).data('config').Content=nicEditor.getContent();cmsSaveDraft();}}catch(e){}}
function cmsContentModuleEditor_DefaultSetup(moduleElement,nicEditor){$(moduleElement).data('config').Content=nicEditor.getContent();}
var cmsContentModuleEditor_CheckTargetCallback=null;$().ready(function(){$(window).click(function(evt){if(!evt&&window.event){evt=window.event;}
if(evt){var lastClickInNicEditPanel=$(evt.target).parents('.nicEdit-pane').length>0||$(evt.target).parents('.nicEdit-panel').length>0;if(cmsContentModuleEditor_CheckTargetCallback!=null){cmsContentModuleEditor_CheckTargetCallback(lastClickInNicEditPanel);cmsContentModuleEditor_CheckTargetCallback=null;}}
return true;});});jQuery.fn.cmsContentModuleEditor=function(opts){return this.each(function(){if(!$(this).hasClass('cmsInherited')){$('#cmsNicPanelContainer').remove();cmsNicPanel=$('<div id="cmsNicPanelContainer"><div id="cmsNicPanel"></div></div>').appendTo($('body'));myNicEditor=new nicEditor({fullPanel:true}).panelInstance('cmsNicPanel');$('#cmsNicPanelContainer').hide(0);if(opts.onSetup==null||opts.onSetup==undefined){opts=$.extend(opts,{onSetup:cmsContentModuleEditor_DefaultSetup});}
if(opts.onSave==null||opts.onSave==undefined){opts=$.extend(opts,{onSave:cmsContentModuleEditor_DefaultSave});}
$(this).click(function(){$('#cmsNicPanelContainer').show(0).css('top',parseInt((parseInt($(window).scrollTop())+47))+'px');$('#cmsNicPanelContainer > div').width($('body').width());$('.nicEdit-panelContain').css('border-right','0px').css('border-left','0px');if(!nicEditors.findEditor(this.id)){$('#cmsNicPanelContainer').show(0).css('top','47px').scrollFollow({speed:250,offset:47});try{var contentModuleNicEditor=myNicEditor.addInstance(this.id);opts.onSetup(this,nicEditors.findEditor(this.id));this.focus();}
catch(e){}}}).blur(function(){var cmsContentModuleEditor_CheckTargetCallbackElement=this;var cmsContentModuleEditor_CheckTargetCallbackOnSave=opts.onSave;cmsContentModuleEditor_CheckTargetCallback=function(r){if(!r){$('#cmsNicPanelContainer').hide(0);cmsContentModuleEditor_CheckTargetCallbackOnSave(cmsContentModuleEditor_CheckTargetCallbackElement,nicEditors.findEditor(cmsContentModuleEditor_CheckTargetCallbackElement.id));myNicEditor.removeInstance(cmsContentModuleEditor_CheckTargetCallbackElement.id);}};if(!jQuery.support.noCloneEvent)
cmsContentModuleEditor_CheckTargetCallback(false);});}});};