ccms.namespace('csocial');ccms.event.onAvailable('page',function(){setupZoom();});ccms.event.onAvailable('search-results',function(){new quickSearch('quick-search','quick-query','search-results','api/search');});ccms.event.onAvailable('quick-login',function(){new quickLogin('quick-login');});function editList(name,action){var availableList=document.getElementById('fieldlist_'+name+'_fields');var selectedList=document.getElementById('fieldlist_'+name+'_selected');switch(action){case'add':var addIndex=availableList.selectedIndex;if(addIndex<0)
return;selectedList.appendChild(availableList.options.item(addIndex));availableList.selectedIndex=addIndex>0?addIndex-1:addIndex;selectedList.selectedIndex=-1;break;case'remove':var selIndex=selectedList.selectedIndex;if(selIndex<0)
return;if(selectedList[selectedList.selectedIndex].value=='divide')
return;availableList.appendChild(selectedList.options.item(selIndex))
availableList.selectedIndex=-1;selectedList.selectedIndex=selIndex>0?selIndex-1:selIndex;break;case'up':var selIndex=selectedList.selectedIndex;if(selIndex<1)
return;var opt=selectedList.options[selIndex];selectedList.removeChild(opt);selectedList.insertBefore(opt,selectedList.options[selIndex-1]);availableList.selectedIndex=-1;break;case'down':var selIndex=selectedList.selectedIndex;if(selIndex>=(selectedList.options.length-1))
return;var opt=selectedList.options[selIndex];selectedList.removeChild(opt);if(selIndex>selectedList.options.length-2)
selectedList.appendChild(opt);else
selectedList.insertBefore(opt,selectedList.options[selIndex+1]);availableList.selectedIndex=-1;break;}
var listValue='';var isDivide=false;for(i=0;i<selectedList.options.length;i++){var newValue=selectedList.options[i].value;if(newValue=='divide'){listValue+='|';isDivide=true;}
else{listValue+=((listValue!=''&&!isDivide)?',':'')+newValue;isDivide=false;}}
document.getElementById('fieldlist_'+name).value=listValue;}
csocial.isInternalLink=function(url){var domain=/[^.]+\.(com|net|info|org|uk|co\.uk|org\.uk|gov\.uk|me\.uk)$/.exec(window.location.host)[0];return!(/^http:/.test(url))||(url.indexOf(domain)!=-1);var host=new RegExp("^http://"+domain+"/");return!(url.match(/^http/)&&!host.test(url));}
ccms.dom.updateExternalLinks=function(root){if(typeof root=='undefined')root=document;ccms.arrayOf(root.getElementsByTagName('a')).foreach(function(node){if(ccms.dom.hasRel(node,'player')){ccms.event.attach(node,'click',function(){var player=window.open(node.href,node.target?node.target:'csoPlayer','height=300,width=300,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');if(window.focus){player.focus()}
return false;});}
else if(ccms.dom.hasRel(node,'external')){node.setAttribute('target','_blank');}
else if(window.location.pathname.startswith('/forums')&&!csocial.isInternalLink(node.getAttribute('href'))){node.setAttribute('target','_blank');}});}
ccms.widgets.addInstaller('updateExternalLinks',ccms.dom.updateExternalLinks);if(window.location.search.match(/\bquote=/)){ccms.async.when(function(){return tinymce&&tinymce.EditorManager.activeEditor},function(){var end,root,ed=tinymce.EditorManager.activeEditor;root=ed.dom.getRoot();end=root.childNodes.length?root.childNodes[root.childNodes.length-1]:root;if(tinymce.isGecko){while(end.childNodes.length&&window.getComputedStyle(end,null).display=='block'){end=end.childNodes[end.childNodes.length-1];}}
ed.selection.select(end);ed.selection.collapse(false);ed.focus();});}