
var tplVars={}
var domLoaded=function(callback){if(document.addEventListener){document.addEventListener('DOMContentLoaded',callback,false);return;}if(/KHTML|WebKit|iCab/i.test(navigator.userAgent)){var DOMLoadTimer=setInterval(function(){if(/loaded|complete/i.test(document.readyState)){callback();clearInterval(DOMLoadTimer);}},10);return;}window.onload=callback;};if(typeof(window.$)!="Function")window.$=function $(id){var el=document.getElementById(id);var tags=["div","img","span","form","b","a","i","u","td","table"];if(el&&el.id!=id&&el.name==id){for(i in tags){var els=document.getElementsByTagName(tags[i]);for(j in els)if(els[j].id==id)return els[j];}}return el;}
function $assign(varname,value){tplVars[varname]=value;}
function $fetch(content){for(key in tplVars){reg=new RegExp("\\{\\$"+key+"\\}",'g');content=content.replace(reg,this.tplVars[key]);}reg=new RegExp("\\{\\$[A-Za-z0-9_-]*\\}",'g');content=content.replace(reg,"");return content;}
function $sutra(id){return $(id);}
function $print_r(theObj,outputEl){var html;if(is.Array(theObj)||is.Object(theObj)){html+="<ul style='margin-left:50px'>";for(var p in theObj){if(is.Array(theObj[p])||is.Object(theObj[p])){html+="<li>["+p+"] => "+typeof(theObj)+"</li>";html+="<ul>";$print_r(theObj[p]);html+="</ul>";}else{html+="<li>["+p+"] => "+theObj[p]+"</li>";}}html+="</ul>";}var output=document.getElementById(outputEl);if(output)output.innerHTML+=html;return html;}
function $_GET(name,url){name=name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");var regexS="[\\?&]"+name+"=([^&#]*)";var regex=new RegExp(regexS);var results=regex.exec(url?url:window.location.href);if(results==null)return"";else return results[1];}
function $hyphenate(str){if(!str)return false;str=String(str);str=str.toLowerCase();return str.replace(/[^a-z0-9]/gi,"-");}
function $formToString(formId){var form=$sutra(formId);if(!form)return"form not found";var elements=form.elements;var nElements=elements.length;var string="";for(var i=0;i<nElements;i++){var element=elements[i];if(element==null)continue;if(element.type=="checkbox"||element.type=="radio"){string+=element.name;string+=element.checked?"=true&":"=false&";}else if(element.type=='select-one'){string+=element.name+"="+element.options[element.selectedIndex].value+"&";}else if(element.type=='text'||element.type=='password'||element.type=='hidden'){string+=element.name+"="+element.value+"&";}}return encodeURI(string);}
function $validateForm(formId){var form=$sutra(formId);if(!form)return"form not found";var elements=form.elements;var nElements=elements.length;var error=false;for(var i=0;i<nElements;i++){var element=elements[i];if(element==null||!element.className.match("required"))continue;if(element.type=='select-one'){error&=(element.selectedIndex==0);element.style.background="#FF0000";}else if(element.type=='text'||element.type=='password'||element.type=='hidden'){error&=(element.value.length>0);if(element.value.length==0)element.style.background="#FF0000";}}return!error;}
function $addEvent(obj,type,fn){if(obj.addEventListener){obj.addEventListener(type,fn,false);return true;}else if(obj.attachEvent){obj['e'+type+fn]=fn;obj[type+fn]=function(){obj['e'+type+fn](window.event);};var r=obj.attachEvent('on'+type,obj[type+fn]);return r;}else{alert("event chaining disabled!");obj['on'+type]=fn;obj['on'+type]=(function(old){return function(){if(old)old.call(this,arguments);fn.call(this.arguments);return false;}})(obj['on'+type].onclick);return true;}}
function $checkExtension(file,array_ext){var ok=false;var ext=file.substring(file.length-3,file.length);ext=ext.toLowerCase();for(var i=0;i<array_ext.length;i++)if(ext==array_ext[i])ok=true;return ok;}
function $captcha(formId){var a=prompt("SPAMBOT protection:\n\nHow much is 1 + 2 ?");if(!a||a.length==0)return false;var e=document.createElement("input");e.type="hidden";e.name="magic";e.value=a;$sutra(formId).appendChild(e);setTimeout("$sutra(formId).submit()",10);}
function $in_array(needle,haystack,argStrict){var key='',strict=!!argStrict;if(strict){for(key in haystack){if(haystack[key]===needle){return true;}}}else{for(key in haystack){if(haystack[key]==needle){return true;}}}return false;}
function $hasClass(className,classNames){if(classNames==undefined)return false;var names=classNames.split(' ');return $in_array(className,names);}
function $getPosX(e){var x=0;while(e){x+=e.offsetLeft;e=e.offsetParent;}return x;}
function $getPosY(e){var x=0;while(e){x+=e.offsetTop;e=e.offsetParent;}return x;}
function _assert(expr,description){if(!expr){var err="SUTRA ASSERTION FAIL: "+description;if(window.console)console.log(err);alert(err);return false;}else return true;}
function _trace(mixed){if(window.console){if(!is.String(mixed)&&console.dir!=undefined)console.dir(mixed);else console.log("SUTRA TRACE: "+mixed);}return mixed}
var on={domready:function(){eval("onDomReady();");}}
domLoaded(on.domready);function assert(expr,description){var popup=false;var firebug_assert=true;var email=true;if(!expr){var err="ASSERTION FAIL: "+description;if(popup)
alert(err);if(firebug_assert)
console.assert(expr,description);if(email&&window.error!=undefined)
window.error.handleError(err,"","",true);}}
var is={Null:function(a){return a===null;},Undefined:function(a){return a===undefined;},nt:function(a){return(a===null||a===undefined);},Function:function(a){return(typeof(a)==='function')?a.constructor.toString().match(/Function/)!==null:false;},String:function(a){return(typeof(a)==='string')?true:(typeof(a)==='object')?a.constructor.toString().match(/string/i)!==null:false;},Array:function(a){return(typeof(a)==='object')?a.constructor.toString().match(/array/i)!==null||a.length!==undefined:false;},Boolean:function(a){return(typeof(a)==='boolean')?true:(typeof(a)==='object')?a.constructor.toString().match(/boolean/i)!==null:false;},Date:function(a){return(typeof(a)==='date')?true:(typeof(a)==='object')?a.constructor.toString().match(/date/i)!==null:false;},HTML:function(a){return(typeof(a)==='object')?a.constructor.toString().match(/html/i)!==null:false;},Number:function(a){return(typeof(a)==='number')?true:(typeof(a)==='object')?a.constructor.toString().match(/Number/)!==null:false;},Object:function(a){if(is.Null(a)||is.Undefined(a))return false;return(typeof(a)==='object')?a.constructor.toString().match(/object/i)!==null:false;},RegExp:function(a){return(typeof(a)==='function')?a.constructor.toString().match(/regexp/i)!==null:false;}};var type={of:function(a){for(var i in is){if(is[i](a)){return i.toLowerCase();}}}};if(typeof(window.assert)!="Function")window.assert=function(expr,msg){if(!expr)alert(msg);}
if(typeof(window.$sutra)!="Function")window.$sutra=function $sutra(id){return document.getElementById(id);}
var ajax={baseurl:false,anchors:false,sessionId:false,fadetime:250,scripts:false,isLoading:false,intervals:new Array(),links:new Array(),http:new Array(),urls:new Array(),callbacks:new Array(),init:function(_sessionId,baseurl){ajax.sessionId=_sessionId;if(baseurl)ajax.baseurl=baseurl;if(!ajax.baseurl&&!baseurl)
ajax.baseurl=baseurl="http://"+document.location.hostname+document.location.pathname;ajax.anchors=document.getElementsByTagName("a");for(i=0;i<ajax.anchors.length;i++){var skip=false;if(ajax.anchors[i].className.search("ajax")!=-1){if(ajax.anchors[i].rel==""){assert(false,"ajax.js: anchor with href='"+ajax.anchors[i].href+"' misses REL-tag");continue;}
for(var j=0;j<ajax.links.length;j++)
if(ajax.links[j]==ajax.anchors[i])skip=true;if(skip)continue;$addEvent(ajax.anchors[i],'click',function(){var url=new String(this.href).substring(this.href.search("#")).replace("#",ajax.baseurl);ajax.intervals.push(setTimeout("window.ajax.doRequest( '"+url+"', '', 'GET', '"+this.rel+"' )",ajax.fadetime));return false;});var strippedUrl=(ajax.anchors[i].href.search(ajax.baseurl)!=-1)?ajax.anchors[i].href.substring(ajax.baseurl.length):ajax.anchors[i].href;strippedUrl="#"+strippedUrl;ajax.anchors[i].href=strippedUrl;ajax.links.push(ajax.anchors[i]);}}},createRequestObject:function(){return(navigator.appName=='Microsoft Internet Explorer')?new ActiveXObject('Microsoft.XMLHTTP'):new XMLHttpRequest();},doRequest:function(url,args,method,elname)
{document.body.style.cursor='progress';for(i=0;i<ajax.intervals.length;i++)
clearInterval(ajax.intervals[i]);ajax.loading(true);method=method?method:"GET";elname=elname?elname:"no_element_"+(((1+Math.random())*0x10000)|0).toString(16).substring(1);if(elname.match("no_element_")==null){changeOpacity(100,elname);shiftOpacity(elname,ajax.fadetime);}
url=(url[0]=="/")?url.substring(1):url;url=(url.search("http://")==-1)?ajax.baseurl+url:url;url+=url.match("\\?")?"&SESSION_ID="+ajax.sessionId:"?SESSION_ID="+ajax.sessionId;ajax.urls[elname]=url;ajax.http[elname]=ajax.createRequestObject();ajax.http[elname].open(method,url,true);ajax.http[elname].setRequestHeader("Content-Type","application/x-www-form-urlencoded");ajax.http[elname].onreadystatechange=function(){if(ajax.http[elname].readyState==4)
ajax.intervals.push(setTimeout("ajax.requestComplete( '"+elname+"','"+url+"' )",ajax.fadetime+100));}
ajax.http[elname].send(args);},requestComplete:function(elname,url){if(url!=ajax.urls[elname])return;document.body.style.cursor='default';ajax.isLoading=false;if(!elname.match("no_element_")){var el=$sutra(elname);assert(el,"AJAX: could not find element with id '"+elname+"'");if(!el)return;ajax.executeJS(ajax.http[elname].responseText);if(el.tagName=="INPUT")
el.value=ajax.http[elname].responseText;else
el.innerHTML=ajax.http[elname].responseText;shiftOpacity(elname,ajax.fadetime);}
for(var i in ajax.callbacks)
if(typeof ajax.callbacks[i]=="function")
ajax.callbacks[i]();ajax.intervals.push(setTimeout("ajax.loading()",ajax.fadetime));},addCallback:function(callback){ajax.callbacks.push(callback);},executeJS:function(html){for(var i=0;i<2;i++){var external=(i==0)?String(html.match(/<script[^"]*[^>]*>/i)):String(html.match(/<script[^"]*>/i));while(true){var src=external.match(/src=['"]([^'"]*)['"]/i);if(src==null)break;var begin=external.search(src[1])+String(src[1]).length+1;var e=document.createElement("script");e.src=src[1];e.type="text/javascript";document.getElementsByTagName("head")[0].appendChild(e);external=external.substring(begin,String(external).length-1);}}
scripts="";var tmp=html.replace(/<script[^>]*[^>]*>([\s\S]*?)<\/script>/gi,function(){scripts+=arguments[1]+'\n';return'';});setTimeout(ajax.executeJSInline,100);},executeJSInline:function(){eval(scripts);},loading:function(state){var el=$sutra("ajax");if(el){ajax.isLoading=true;var src=new String(el.src);el.src=src.replace("loading-"+(!state?"on":"off")+".gif","loading-"+(state?"on":"off")+".gif");if(!state)
ajax.init(ajax.sessionId);}}}
function shiftOpacity(id,millisec){var el=document.getElementById(id);if(!el)return;var op=getOpacity(id);if(op<1)
opacity(id,0,100,millisec);else
opacity(id,100,0,millisec);}
function opacity(id,opacStart,opacEnd,millisec){var speed=Math.round(millisec/100);var timer=0;if(opacStart>opacEnd){for(i=opacStart;i>=opacEnd;i--){setTimeout("changeOpacity("+i+",'"+id+"')",(timer*speed));timer++;}}else if(opacStart<opacEnd){for(i=opacStart;i<=opacEnd;i++)
{setTimeout("changeOpacity("+i+",'"+id+"')",(timer*speed));timer++;}}}
function changeOpacity(opacity,id){var object=document.getElementById(id);if(!object)return;object.style.opacity=(opacity/100);object.style.MozOpacity=(opacity/100);object.style.KhtmlOpacity=(opacity/100);object.style.filter="alpha(opacity="+opacity+")";}
function getOpacity(id){var object=document.getElementById(id);if(!object)return;if(object.style.opacity!=undefined)return object.style.opacity*100;if(object.style.MozOpacity!=undefined)return object.style.MozOpacity*100;if(object.style.KhtmlOpacity!=undefined)return object.style.KhtmlOpacity*100;if(object.style.filter!=undefined)return object.style.filter;}
var bkExtend=function(){var args=arguments;if(args.length==1)args=[this,args[0]];for(var prop in args[1])args[0][prop]=args[1][prop];return args[0];};function bkClass(){}
bkClass.prototype.construct=function(){};bkClass.extend=function(def){var classDef=function(){if(arguments[0]!==bkClass){return this.construct.apply(this,arguments);}};var proto=new this(bkClass);bkExtend(proto,def);classDef.prototype=proto;classDef.extend=this.extend;return classDef;};var bkElement=bkClass.extend({construct:function(elm,d){if(typeof(elm)=="string"){elm=(d||document).createElement(elm);}
elm=$BK(elm);return elm;},appendTo:function(elm){elm.appendChild(this);return this;},appendBefore:function(elm){elm.parentNode.insertBefore(this,elm);return this;},addEvent:function(type,fn){bkLib.addEvent(this,type,fn);return this;},setContent:function(c){this.innerHTML=c;return this;},pos:function(){var curleft=curtop=0;var o=obj=this;if(obj.offsetParent){do{curleft+=obj.offsetLeft;curtop+=obj.offsetTop;}while(obj=obj.offsetParent);}
var b=(!window.opera)?parseInt(this.getStyle('border-width')||this.style.border)||0:0;return[curleft+b,curtop+b+this.offsetHeight];},noSelect:function(){bkLib.noSelect(this);return this;},parentTag:function(t){var elm=this;do{if(elm&&elm.nodeName&&elm.nodeName.toUpperCase()==t){return elm;}
elm=elm.parentNode;}while(elm);return false;},hasClass:function(cls){return this.className.match(new RegExp('(\\s|^)nicEdit-'+cls+'(\\s|$)'));},addClass:function(cls){if(!this.hasClass(cls)){this.className+=" nicEdit-"+cls};return this;},removeClass:function(cls){if(this.hasClass(cls)){this.className=this.className.replace(new RegExp('(\\s|^)nicEdit-'+cls+'(\\s|$)'),' ');}
return this;},setStyle:function(st){var elmStyle=this.style;for(var itm in st){switch(itm){case'float':elmStyle['cssFloat']=elmStyle['styleFloat']=st[itm];break;case'opacity':elmStyle.opacity=st[itm];elmStyle.filter="alpha(opacity="+Math.round(st[itm]*100)+")";break;case'className':this.className=st[itm];break;default:elmStyle[itm]=st[itm];}}
return this;},getStyle:function(cssRule,d){var doc=(!d)?document.defaultView:d;if(this.nodeType==1)
return(doc&&doc.getComputedStyle)?doc.getComputedStyle(this,null).getPropertyValue(cssRule):this.currentStyle[bkLib.camelize(cssRule)];},remove:function(){this.parentNode.removeChild(this);return this;},setAttributes:function(at){for(var itm in at){this[itm]=at[itm];}
return this;}});var bkLib={isMSIE:(navigator.appVersion.indexOf("MSIE")!=-1),addEvent:function(obj,type,fn){(obj.addEventListener)?obj.addEventListener(type,fn,false):obj.attachEvent("on"+type,fn);},toArray:function(iterable){var length=iterable.length,results=new Array(length);while(length--){results[length]=iterable[length]};return results;},noSelect:function(element){if(element.setAttribute&&element.nodeName.toLowerCase()!='input'&&element.nodeName.toLowerCase()!='textarea'){element.setAttribute('unselectable','on');}
for(var i=0;i<element.childNodes.length;i++){bkLib.noSelect(element.childNodes[i]);}},camelize:function(s){return s.replace(/\-(.)/g,function(m,l){return l.toUpperCase()});},inArray:function(arr,item){return(bkLib.search(arr,item)!=null);},search:function(arr,itm){for(var i=0;i<arr.length;i++){if(arr[i]==itm)
return i;}
return null;},cancelEvent:function(e){e=e||window.event;if(e.preventDefault&&e.stopPropagation){e.preventDefault();e.stopPropagation();}
return false;},domLoad:[],domLoaded:function(){if(arguments.callee.done)return;arguments.callee.done=true;for(i=0;i<bkLib.domLoad.length;i++)bkLib.domLoad[i]();},onDomLoaded:function(fireThis){this.domLoad.push(fireThis);if(document.addEventListener){document.addEventListener("DOMContentLoaded",bkLib.domLoaded,null);}else if(bkLib.isMSIE){document.write("<style>.nicEdit-main p { margin: 0; }</style><scr"+"ipt id=__ie_onload defer "+((location.protocol=="https:")?"src='javascript:void(0)'":"src=//0")+"><\/scr"+"ipt>");$BK("__ie_onload").onreadystatechange=function(){if(this.readyState=="complete"){bkLib.domLoaded();}};}
window.onload=bkLib.domLoaded;}};function $BK(elm){if(typeof(elm)=="string"){elm=document.getElementById(elm);}
return(elm&&!elm.appendTo)?bkExtend(elm,bkElement.prototype):elm;}
var bkEvent={addEvent:function(evType,evFunc){if(evFunc){this.eventList=this.eventList||{};this.eventList[evType]=this.eventList[evType]||[];this.eventList[evType].push(evFunc);}
return this;},fireEvent:function(){var args=bkLib.toArray(arguments),evType=args.shift();if(this.eventList&&this.eventList[evType]){for(var i=0;i<this.eventList[evType].length;i++){this.eventList[evType][i].apply(this,args);}}}};function __(s){return s;}
Function.prototype.closure=function(){var __method=this,args=bkLib.toArray(arguments),obj=args.shift();return function(){if(typeof(bkLib)!='undefined'){return __method.apply(obj,args.concat(bkLib.toArray(arguments)));}};}
Function.prototype.closureListener=function(){var __method=this,args=bkLib.toArray(arguments),object=args.shift();return function(e){e=e||window.event;if(e.target){var target=e.target;}else{var target=e.srcElement};return __method.apply(object,[e,target].concat(args));};}
var nicEditorConfig=bkClass.extend({buttons:{'bold':{name:__('Click to Bold'),command:'Bold',tags:['B','STRONG'],css:{'font-weight':'bold'},key:'b'},'italic':{name:__('Click to Italic'),command:'Italic',tags:['EM','I'],css:{'font-style':'italic'},key:'i'},'underline':{name:__('Click to Underline'),command:'Underline',tags:['U'],css:{'text-decoration':'underline'},key:'u'},'left':{name:__('Left Align'),command:'justifyleft',noActive:true},'center':{name:__('Center Align'),command:'justifycenter',noActive:true},'right':{name:__('Right Align'),command:'justifyright',noActive:true},'justify':{name:__('Justify Align'),command:'justifyfull',noActive:true},'removeformat':{name:__('Remove Formatting'),command:'removeformat',noActive:true},'hr':{name:__('Horizontal Rule'),command:'insertHorizontalRule',noActive:true}},iconsPath:'lib/core/nicedit/gfx/nicEditorIcons.gif',buttonList:['save','bold','italic','underline','left','center','right','justify','ol','ul','fontSize','fontFamily','fontFormat','indent','outdent','image','upload','link','unlink','forecolor','bgcolor'],iconList:{"xhtml":1,"bgcolor":2,"forecolor":3,"bold":4,"center":5,"hr":6,"indent":7,"italic":8,"justify":9,"left":10,"ol":11,"outdent":12,"removeformat":13,"right":14,"save":25,"strikethrough":16,"subscript":17,"superscript":18,"ul":19,"underline":20,"image":21,"link":22,"unlink":23,"close":24,"arrow":26,"upload":27}});var nicConfig=new nicEditorConfig();var nicEditors={nicPlugins:[],editors:[],registerPlugin:function(plugin,options){this.nicPlugins.push({p:plugin,o:options});},allTextAreas:function(nicOptions){var textareas=document.getElementsByTagName("textarea");for(var i=0;i<textareas.length;i++){nicEditors.editors.push(new nicEditor(nicOptions).panelInstance(textareas[i]));}
return nicEditors.editors;},findEditor:function(e){var editors=nicEditors.editors;for(var i=0;i<editors.length;i++){if(editors[i].instanceById(e)){return editors[i].instanceById(e);}}}};var nicEditor=bkClass.extend({construct:function(o){this.options=nicConfig;bkExtend(this.options,o);this.nicInstances=new Array();this.loadedPlugins=new Array();var plugins=nicEditors.nicPlugins;for(var i=0;i<plugins.length;i++){this.loadedPlugins.push(new plugins[i].p(this,plugins[i].o));}
nicEditors.editors.push(this);bkLib.addEvent(document.body,'mousedown',this.selectCheck.closureListener(this));},panelInstance:function(e,o){e=this.checkReplace($BK(e));var panelElm=new bkElement('DIV').setStyle({width:(parseInt(e.getStyle('width'))||e.clientWidth)+'px'}).appendBefore(e);this.setPanel(panelElm);return this.addInstance(e,o);},checkReplace:function(e){var r=nicEditors.findEditor(e);if(r){r.removeInstance(e);r.removePanel();}
return e;},addInstance:function(e,o){e=this.checkReplace($BK(e));if(e.contentEditable||!!window.opera){var newInstance=new nicEditorInstance(e,o,this);}else{var newInstance=new nicEditorIFrameInstance(e,o,this);}
this.nicInstances.push(newInstance);return this;},removeInstance:function(e){e=$BK(e);var instances=this.nicInstances;for(var i=0;i<instances.length;i++){if(instances[i].e==e){instances[i].remove();this.nicInstances.splice(i,1);}}},removePanel:function(e){if(this.nicPanel){this.nicPanel.remove();this.nicPanel=null;}},instanceById:function(e){e=$BK(e);var instances=this.nicInstances;for(var i=0;i<instances.length;i++){if(instances[i].e==e){return instances[i];}}},setPanel:function(e){this.nicPanel=new nicEditorPanel($BK(e),this.options,this);this.fireEvent('panel',this.nicPanel);return this;},nicCommand:function(cmd,args){if(this.selectedInstance){this.selectedInstance.nicCommand(cmd,args);}},getIcon:function(iconName,options){var icon=this.options.iconList[iconName];var file=(options.iconFiles)?options.iconFiles[iconName]:'';return{backgroundImage:"url('"+((icon)?this.options.iconsPath:file)+"')",backgroundPosition:((icon)?((icon-1)*-18):0)+'px 0px'};},selectCheck:function(e,t){var found=false;do{if(t.className&&t.className.indexOf('nicEdit')!=-1){return false;}}while(t=t.parentNode);this.fireEvent('blur',this.selectedInstance,t);this.lastSelectedInstance=this.selectedInstance;this.selectedInstance=null;return false;}});nicEditor=nicEditor.extend(bkEvent);var nicEditorInstance=bkClass.extend({isSelected:false,construct:function(e,options,nicEditor){this.ne=nicEditor;this.elm=this.e=e;this.options=options||{};newX=parseInt(e.getStyle('width'))||e.clientWidth;newY=parseInt(e.getStyle('height'))||e.clientHeight;this.initialHeight=newY-8;var isTextarea=(e.nodeName.toLowerCase()=="textarea");if(isTextarea||this.options.hasPanel){var ie7s=(bkLib.isMSIE&&!((typeof document.body.style.maxHeight!="undefined")&&document.compatMode=="CSS1Compat"))
var s={width:newX+'px',border:'1px solid #ccc',borderTop:0,overflowY:'auto',overflowX:'hidden'};s[(ie7s)?'height':'maxHeight']=(this.ne.options.maxHeight)?this.ne.options.maxHeight+'px':null;this.editorContain=new bkElement('DIV').setStyle(s).appendBefore(e);var editorElm=new bkElement('DIV').setStyle({width:(newX-8)+'px',margin:'4px',minHeight:newY+'px'}).addClass('main').appendTo(this.editorContain);e.setStyle({display:'none'});editorElm.innerHTML=e.innerHTML;if(isTextarea){editorElm.setContent(e.value);this.copyElm=e;var f=e.parentTag('FORM');if(f){bkLib.addEvent(f,'submit',this.saveContent.closure(this));}}
editorElm.setStyle((ie7s)?{height:newY+'px'}:{overflow:'hidden'});this.elm=editorElm;}
this.ne.addEvent('blur',this.blur.closure(this));this.init();this.blur();},init:function(){this.elm.setAttribute('contentEditable','true');if(this.getContent()==""){this.setContent('<br />');}
this.instanceDoc=document.defaultView;this.elm.addEvent('mousedown',this.selected.closureListener(this)).addEvent('keypress',this.keyDown.closureListener(this)).addEvent('focus',this.selected.closure(this)).addEvent('blur',this.blur.closure(this)).addEvent('keyup',this.selected.closure(this));this.ne.fireEvent('add',this);},remove:function(){this.saveContent();if(this.copyElm||this.options.hasPanel){this.editorContain.remove();this.e.setStyle({'display':'block'});this.ne.removePanel();}
this.disable();this.ne.fireEvent('remove',this);},disable:function(){this.elm.setAttribute('contentEditable','false');},getSel:function(){return(window.getSelection)?window.getSelection():document.selection;},getRng:function(){var s=this.getSel();if(!s){return null;}
return(s.rangeCount>0)?s.getRangeAt(0):s.createRange();},selRng:function(rng,s){if(window.getSelection){s.removeAllRanges();s.addRange(rng);}else{rng.select();}},selElm:function(){var r=this.getRng();if(r.startContainer){var contain=r.startContainer;if(r.cloneContents().childNodes.length==1){for(var i=0;i<contain.childNodes.length;i++){var rng=contain.childNodes[i].ownerDocument.createRange();rng.selectNode(contain.childNodes[i]);if(r.compareBoundaryPoints(Range.START_TO_START,rng)!=1&&r.compareBoundaryPoints(Range.END_TO_END,rng)!=-1){return $BK(contain.childNodes[i]);}}}
return $BK(contain);}else{return $BK((this.getSel().type=="Control")?r.item(0):r.parentElement());}},saveRng:function(){this.savedRange=this.getRng();this.savedSel=this.getSel();},restoreRng:function(){if(this.savedRange){this.selRng(this.savedRange,this.savedSel);}},keyDown:function(e,t){if(e.ctrlKey){this.ne.fireEvent('key',this,e);}},selected:function(e,t){if(!t){t=this.selElm()}
if(!e.ctrlKey){var selInstance=this.ne.selectedInstance;if(selInstance!=this){if(selInstance){this.ne.fireEvent('blur',selInstance,t);}
this.ne.selectedInstance=this;this.ne.fireEvent('focus',selInstance,t);}
this.ne.fireEvent('selected',selInstance,t);this.isFocused=true;this.elm.addClass('selected');}
return false;},blur:function(){this.isFocused=false;this.elm.removeClass('selected');},saveContent:function(){if(this.copyElm||this.options.hasPanel){this.ne.fireEvent('save',this);(this.copyElm)?this.copyElm.value=this.getContent():this.e.innerHTML=this.getContent();}},getElm:function(){return this.elm;},getContent:function(){this.content=this.getElm().innerHTML;this.ne.fireEvent('get',this);return this.content;},setContent:function(e){this.content=e;this.ne.fireEvent('set',this);this.elm.innerHTML=this.content;},cleanupContent:function(){var html=this.getContent();html=html.replace(/<o:p>\s*<\/o:p>/g,"");html=html.replace(/<o:p>.*?<\/o:p>/g,"&nbsp;");html=html.replace(/\s*mso-[^:]+:[^;"]+;?/gi,"");html=html.replace(/\s*MARGIN: 0cm 0cm 0pt\s*;/gi,"");html=html.replace(/\s*MARGIN: 0cm 0cm 0pt\s*"/gi,"\"");html=html.replace(/\s*TEXT-INDENT: 0cm\s*;/gi,"");html=html.replace(/\s*TEXT-INDENT: 0cm\s*"/gi,"\"");html=html.replace(/\s*TEXT-ALIGN: [^\s;]+;?"/gi,"\"");html=html.replace(/\s*PAGE-BREAK-BEFORE: [^\s;]+;?"/gi,"\"");html=html.replace(/\s*FONT-VARIANT: [^\s;]+;?"/gi,"\"");html=html.replace(/\s*tab-stops:[^;"]*;?/gi,"");html=html.replace(/\s*tab-stops:[^"]*/gi,"");html=html.replace(/\s*face="[^"]*"/gi,"");html=html.replace(/\s*face=[^ >]*/gi,"");html=html.replace(/\s*FONT-FAMILY:[^;"]*;?/gi,"");html=html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi,"<$1$3");html=html.replace(/<(\w[^>]*) style="([^\"]*)"([^>]*)/gi,"<$1$3");html=html.replace(/\s*style="\s*"/gi,'');html=html.replace(/<SPAN\s*[^>]*>\s*&nbsp;\s*<\/SPAN>/gi,'&nbsp;');html=html.replace(/<SPAN\s*[^>]*><\/SPAN>/gi,'');html=html.replace(/<SPAN\s*>(.*?)<\/SPAN>/gi,'$1');html=html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi,"<$1$3");html=html.replace(/<FONT\s*>(.*?)<\/FONT>/gi,'$1');html=html.replace(/<\\?\?xml[^>]*>/gi,"");html=html.replace(/<\/?\w+:[^>]*>/gi,"");html=html.replace(/<H\d>\s*<\/H\d>/gi,'');html=html.replace(/<H1([^>]*)>/gi,'');html=html.replace(/<H2([^>]*)>/gi,'');html=html.replace(/<H3([^>]*)>/gi,'');html=html.replace(/<H4([^>]*)>/gi,'');html=html.replace(/<H5([^>]*)>/gi,'');html=html.replace(/<H6([^>]*)>/gi,'');html=html.replace(/<\/H\d>/gi,'<br>');html=html.replace(/<style([^>]*)>/gi,'');html=html.replace(/<xml([^>]*)>/gi,'');html=html.replace(/<(U|I|STRIKE)>&nbsp;<\/\1>/g,'&nbsp;');html=html.replace(/<(B|b)>&nbsp;<\/\b|B>/g,'');html=html.replace(/<([^\s>]+)[^>]*>\s*<\/\1>/g,'');html=html.replace(/<([^\s>]+)[^>]*>\s*<\/\1>/g,'');html=html.replace(/<([^\s>]+)[^>]*>\s*<\/\1>/g,'');this.setContent(html);this.saveContent();},nicCommand:function(cmd,args){document.execCommand(cmd,false,args);switch(cmd){case"removeformat":this.ne.selectedInstance.cleanupContent();break;}}});var nicEditorIFrameInstance=nicEditorInstance.extend({savedStyles:[],init:function(){var c=this.elm.innerHTML.replace(/^\s+|\s+$/g,'');this.elm.innerHTML='';(!c)?c="<br />":c;this.initialContent=c;this.elmFrame=new bkElement('iframe').setAttributes({'src':'javascript:;','frameBorder':0,'allowTransparency':'true','scrolling':'no'}).setStyle({height:'100px',width:'100%'}).addClass('frame').appendTo(this.elm);if(this.copyElm){this.elmFrame.setStyle({width:(this.elm.offsetWidth-4)+'px'});}
var styleList=['font-size','font-family','font-weight','color'];for(itm in styleList){this.savedStyles[bkLib.camelize(itm)]=this.elm.getStyle(itm);}
setTimeout(this.initFrame.closure(this),50);},disable:function(){this.elm.innerHTML=this.getContent();},initFrame:function(){var fd=$BK(this.elmFrame.contentWindow.document);fd.designMode="on";fd.open();var css=this.ne.options.externalCSS;fd.write('<html><head>'+((css)?'<link href="'+css+'" rel="stylesheet" type="text/css" />':'')+'</head><body id="nicEditContent" style="margin: 0 !important; background-color: transparent !important;">'+this.initialContent+'</body></html>');fd.close();this.frameDoc=fd;this.frameWin=$BK(this.elmFrame.contentWindow);this.frameContent=$BK(this.frameWin.document.body).setStyle(this.savedStyles);this.instanceDoc=this.frameWin.document.defaultView;this.heightUpdate();this.frameDoc.addEvent('mousedown',this.selected.closureListener(this)).addEvent('keyup',this.heightUpdate.closureListener(this)).addEvent('keydown',this.keyDown.closureListener(this)).addEvent('keyup',this.selected.closure(this));this.ne.fireEvent('add',this);},getElm:function(){return this.frameContent;},setContent:function(c){this.content=c;this.ne.fireEvent('set',this);this.frameContent.innerHTML=this.content;this.heightUpdate();},getSel:function(){return(this.frameWin)?this.frameWin.getSelection():this.frameDoc.selection;},heightUpdate:function(){this.elmFrame.style.height=Math.max(this.frameContent.offsetHeight,this.initialHeight)+'px';},nicCommand:function(cmd,args){this.frameDoc.execCommand(cmd,false,args);setTimeout(this.heightUpdate.closure(this),100);}});var nicEditorPanel=bkClass.extend({construct:function(e,options,nicEditor){this.elm=e;this.options=options;this.ne=nicEditor;this.panelButtons=new Array();this.buttonList=bkExtend([],this.ne.options.buttonList);this.panelContain=new bkElement('DIV').setStyle({overflow:'hidden',width:'100%',border:'1px solid #cccccc',backgroundColor:'#efefef'}).addClass('panelContain');this.panelElm=new bkElement('DIV').setStyle({margin:'2px',marginTop:'0px',zoom:1,overflow:'hidden'}).addClass('panel').appendTo(this.panelContain);this.panelContain.appendTo(e);var opt=this.ne.options;var buttons=opt.buttons;for(button in buttons){this.addButton(button,opt,true);}
this.reorder();e.noSelect();},addButton:function(buttonName,options,noOrder){var button=options.buttons[buttonName];var type=(button['type'])?eval('(typeof('+button['type']+') == "undefined") ? null : '+button['type']+';'):nicEditorButton;var hasButton=bkLib.inArray(this.buttonList,buttonName);if(type&&(hasButton||this.ne.options.fullPanel)){this.panelButtons.push(new type(this.panelElm,buttonName,options,this.ne));if(!hasButton){this.buttonList.push(buttonName);}}},findButton:function(itm){for(var i=0;i<this.panelButtons.length;i++){if(this.panelButtons[i].name==itm)
return this.panelButtons[i];}},reorder:function(){var bl=this.buttonList;for(var i=0;i<bl.length;i++){var button=this.findButton(bl[i]);if(button){this.panelElm.appendChild(button.margin);}}},remove:function(){this.elm.remove();}});var nicEditorButton=bkClass.extend({construct:function(e,buttonName,options,nicEditor){this.options=options.buttons[buttonName];this.name=buttonName;this.ne=nicEditor;this.elm=e;this.margin=new bkElement('DIV').setStyle({'float':'left',marginTop:'2px'}).appendTo(e);this.contain=new bkElement('DIV').setStyle({width:'20px',height:'20px'}).addClass('buttonContain').appendTo(this.margin);this.border=new bkElement('DIV').setStyle({backgroundColor:'#efefef',border:'1px solid #efefef'}).appendTo(this.contain);this.button=new bkElement('DIV').setStyle({width:'18px',height:'18px',overflow:'hidden',zoom:1,cursor:'pointer'}).addClass('button').setStyle(this.ne.getIcon(buttonName,options)).appendTo(this.border);this.button.addEvent('mouseover',this.hoverOn.closure(this)).addEvent('mouseout',this.hoverOff.closure(this)).addEvent('mousedown',this.mouseClick.closure(this)).noSelect();if(!window.opera){this.button.onmousedown=this.button.onclick=bkLib.cancelEvent;}
nicEditor.addEvent('selected',this.enable.closure(this)).addEvent('blur',this.disable.closure(this)).addEvent('key',this.key.closure(this));this.disable();this.init();},init:function(){},hide:function(){this.contain.setStyle({display:'none'});},updateState:function(){if(this.isDisabled){this.setBg();}
else if(this.isHover){this.setBg('hover');}
else if(this.isActive){this.setBg('active');}
else{this.setBg();}},setBg:function(state){switch(state){case'hover':var stateStyle={border:'1px solid #666',backgroundColor:'#ddd'};break;case'active':var stateStyle={border:'1px solid #666',backgroundColor:'#ccc'};break;default:var stateStyle={border:'1px solid #efefef',backgroundColor:'#efefef'};}
this.border.setStyle(stateStyle).addClass('button-'+state);},checkNodes:function(e){var elm=e;do{if(this.options.tags&&bkLib.inArray(this.options.tags,elm.nodeName)){this.activate();return true;}}while(elm=elm.parentNode&&elm.className!="nicEdit");elm=$BK(e);while(elm.nodeType==3){elm=$BK(elm.parentNode);}
if(this.options.css){for(itm in this.options.css){if(elm.getStyle(itm,this.ne.selectedInstance.instanceDoc)==this.options.css[itm]){this.activate();return true;}}}
this.deactivate();return false;},activate:function(){if(!this.isDisabled){this.isActive=true;this.updateState();this.ne.fireEvent('buttonActivate',this);}},deactivate:function(){this.isActive=false;this.updateState();if(!this.isDisabled){this.ne.fireEvent('buttonDeactivate',this);}},enable:function(ins,t){this.isDisabled=false;this.contain.setStyle({'opacity':1}).addClass('buttonEnabled');this.updateState();this.checkNodes(t);},disable:function(ins,t){this.isDisabled=true;this.contain.setStyle({'opacity':0.6}).removeClass('buttonEnabled');this.updateState();},toggleActive:function(){(this.isActive)?this.deactivate():this.activate();},hoverOn:function(){if(!this.isDisabled){this.isHover=true;this.updateState();this.ne.fireEvent("buttonOver",this);}},hoverOff:function(){this.isHover=false;this.updateState();this.ne.fireEvent("buttonOut",this);},mouseClick:function(){if(this.options.command){this.ne.nicCommand(this.options.command,this.options.commandArgs);if(!this.options.noActive){this.toggleActive();}}
this.ne.fireEvent("buttonClick",this);},key:function(nicInstance,e){if(this.options.key&&e.ctrlKey&&String.fromCharCode(e.keyCode||e.charCode).toLowerCase()==this.options.key){this.mouseClick();if(e.preventDefault)e.preventDefault();}}});var nicPlugin=bkClass.extend({construct:function(nicEditor,options){this.options=options;this.ne=nicEditor;this.ne.addEvent('panel',this.loadPanel.closure(this));this.init();},loadPanel:function(np){var buttons=this.options.buttons;for(var button in buttons){np.addButton(button,this.options);}
np.reorder();},init:function(){}});var nicPaneOptions={};var nicEditorPane=bkClass.extend({construct:function(elm,nicEditor,options,openButton){this.ne=nicEditor;this.elm=elm;this.pos=elm.pos();this.contain=new bkElement('div').setStyle({zIndex:'99999',overflow:'hidden',position:'absolute',left:this.pos[0]+'px',top:this.pos[1]+'px'})
this.pane=new bkElement('div').setStyle({fontSize:'12px',border:'1px solid #ccc','overflow':'hidden',padding:'10px',textAlign:'left',backgroundColor:'#ffffc9'}).addClass('pane').setStyle(options).appendTo(this.contain);if(openButton&&!openButton.options.noClose){this.close=new bkElement('div').setStyle({'float':'right',height:'16px',width:'16px',cursor:'pointer'}).setStyle(this.ne.getIcon('close',nicPaneOptions)).addEvent('mousedown',openButton.removePane.closure(this)).appendTo(this.pane);}
this.contain.noSelect().appendTo(document.body);this.position();this.init();},init:function(){},position:function(){if(this.ne.nicPanel){var panelElm=this.ne.nicPanel.elm;var panelPos=panelElm.pos();var newLeft=panelPos[0]+parseInt(panelElm.getStyle('width'))-(parseInt(this.pane.getStyle('width'))+8);if(newLeft<this.pos[0]){this.contain.setStyle({left:newLeft+'px'});}}},toggle:function(){this.isVisible=!this.isVisible;this.contain.setStyle({display:((this.isVisible)?'block':'none')});},remove:function(){if(this.contain){this.contain.remove();this.contain=null;}},append:function(c){c.appendTo(this.pane);},setContent:function(c){this.pane.setContent(c);}});var nicEditorAdvancedButton=nicEditorButton.extend({init:function(){this.ne.addEvent('selected',this.removePane.closure(this)).addEvent('blur',this.removePane.closure(this));},mouseClick:function(){if(!this.isDisabled){if(this.pane&&this.pane.pane){this.removePane();}else{this.pane=new nicEditorPane(this.contain,this.ne,{width:(this.width||'270px'),backgroundColor:'#fff'},this);this.addPane();this.ne.selectedInstance.saveRng();}}},addForm:function(f,elm){this.form=new bkElement('form').addEvent('submit',this.submit.closureListener(this));this.pane.append(this.form);this.inputs={};for(itm in f){var field=f[itm];var val='';if(elm){val=elm.getAttribute(itm);}
if(!val){val=field['value']||'';}
var type=f[itm].type;if(type=='title'){new bkElement('div').setContent(field.txt).setStyle({fontSize:'14px',fontWeight:'bold',padding:'0px',margin:'2px 0'}).appendTo(this.form);}else{var contain=new bkElement('div').setStyle({overflow:'hidden',clear:'both'}).appendTo(this.form);if(field.txt){new bkElement('label').setAttributes({'for':itm}).setContent(field.txt).setStyle({margin:'2px 4px',fontSize:'13px',width:'50px',lineHeight:'20px',textAlign:'right','float':'left'}).appendTo(contain);}
switch(type){case'text':this.inputs[itm]=new bkElement('input').setAttributes({id:itm,'value':val,'type':'text'}).setStyle({margin:'2px 0',fontSize:'13px','float':'left',height:'20px',border:'1px solid #ccc',overflow:'hidden'}).setStyle(field.style).appendTo(contain);break;case'select':this.inputs[itm]=new bkElement('select').setAttributes({id:itm}).setStyle({border:'1px solid #ccc','float':'left',margin:'2px 0'}).appendTo(contain);for(opt in field.options){var o=new bkElement('option').setAttributes({value:opt,selected:(opt==val)?'selected':''}).setContent(field.options[opt]).appendTo(this.inputs[itm]);}
break;case'content':this.inputs[itm]=new bkElement('textarea').setAttributes({id:itm}).setStyle({border:'1px solid #ccc','float':'left'}).setStyle(field.style).appendTo(contain);this.inputs[itm].value=val;}}}
new bkElement('input').setAttributes({'type':'submit','value':'Opslaan'}).setStyle({backgroundColor:'#efefef',border:'1px solid #ccc',margin:'3px 0','float':'left','clear':'both'}).appendTo(this.form);this.form.onsubmit=bkLib.cancelEvent;},submit:function(){},findElm:function(tag,attr,val){var list=this.ne.selectedInstance.getElm().getElementsByTagName(tag);for(var i=0;i<list.length;i++){if(list[i].getAttribute(attr)==val){return $BK(list[i]);}}},removePane:function(){if(this.pane){this.pane.remove();this.pane=null;this.ne.selectedInstance.restoreRng();}}});var nicButtonTips=bkClass.extend({construct:function(nicEditor){this.ne=nicEditor;nicEditor.addEvent('buttonOver',this.show.closure(this)).addEvent('buttonOut',this.hide.closure(this));},show:function(button){this.timer=setTimeout(this.create.closure(this,button),400);},create:function(button){this.timer=null;if(!this.pane){this.pane=new nicEditorPane(button.button,this.ne,{fontSize:'12px',marginTop:'5px'});this.pane.setContent(button.options.name);}},hide:function(button){if(this.timer){clearTimeout(this.timer);}
if(this.pane){this.pane=this.pane.remove();}}});var nicSelectOptions={buttons:{'fontFormat':{name:__('Select Font Format'),type:'nicEditorFontFormatSelect',command:'formatBlock'}}};var nicEditorSelect=bkClass.extend({construct:function(e,buttonName,options,nicEditor){this.options=options.buttons[buttonName];this.elm=e;this.ne=nicEditor;this.name=buttonName;this.selOptions=new Array();this.margin=new bkElement('div').setStyle({'float':'left',margin:'2px 1px 0 1px'}).appendTo(this.elm);this.contain=new bkElement('div').setStyle({width:'90px',height:'20px',cursor:'pointer',overflow:'hidden'}).addClass('selectContain').addEvent('click',this.toggle.closure(this)).appendTo(this.margin);this.items=new bkElement('div').setStyle({overflow:'hidden',zoom:1,border:'1px solid #ccc',paddingLeft:'3px',backgroundColor:'#fff'}).appendTo(this.contain);this.control=new bkElement('div').setStyle({overflow:'hidden','float':'right',height:'18px',width:'16px'}).addClass('selectControl').setStyle(this.ne.getIcon('arrow',options)).appendTo(this.items);this.txt=new bkElement('div').setStyle({overflow:'hidden','float':'left',width:'66px',height:'14px',marginTop:'1px',fontFamily:'sans-serif',textAlign:'center',fontSize:'12px'}).addClass('selectTxt').appendTo(this.items);if(!window.opera){this.contain.onmousedown=this.control.onmousedown=this.txt.onmousedown=bkLib.cancelEvent;}
this.margin.noSelect();this.ne.addEvent('selected',this.enable.closure(this)).addEvent('blur',this.disable.closure(this));this.disable();this.init();},disable:function(){this.isDisabled=true;this.close();this.contain.setStyle({opacity:0.6});},enable:function(t){this.isDisabled=false;this.close();this.contain.setStyle({opacity:1});},setDisplay:function(txt){this.txt.setContent(txt);},toggle:function(){if(!this.isDisabled){(this.pane)?this.close():this.open();}},open:function(){this.pane=new nicEditorPane(this.items,this.ne,{width:'88px',padding:'0px',borderTop:0,borderLeft:'1px solid #ccc',borderRight:'1px solid #ccc',borderBottom:'0px',backgroundColor:'#fff'});for(var i=0;i<this.selOptions.length;i++){var opt=this.selOptions[i];var itmContain=new bkElement('div').setStyle({overflow:'hidden',borderBottom:'1px solid #ccc',width:'88px',textAlign:'left',overflow:'hidden',cursor:'pointer'});var itm=new bkElement('div').setStyle({padding:'0px 4px'}).setContent(opt[1]).appendTo(itmContain).noSelect();itm.addEvent('click',this.update.closure(this,opt[0])).addEvent('mouseover',this.over.closure(this,itm)).addEvent('mouseout',this.out.closure(this,itm)).setAttributes('id',opt[0]);this.pane.append(itmContain);if(!window.opera){itm.onmousedown=bkLib.cancelEvent;}}},close:function(){if(this.pane){this.pane=this.pane.remove();}},over:function(opt){opt.setStyle({backgroundColor:'#ccc'});},out:function(opt){opt.setStyle({backgroundColor:'#fff'});},add:function(k,v){this.selOptions.push(new Array(k,v));},update:function(elm){this.ne.nicCommand(this.options.command,elm);this.close();}});var nicEditorFontSizeSelect=nicEditorSelect.extend({sel:{1:'1&nbsp;(8pt)',2:'2&nbsp;(10pt)',3:'3&nbsp;(12pt)',4:'4&nbsp;(14pt)',5:'5&nbsp;(18pt)',6:'6&nbsp;(24pt)'},init:function(){this.setDisplay('Font&nbsp;Size...');for(itm in this.sel){this.add(itm,'<font size="'+itm+'">'+this.sel[itm]+'</font>');}}});var nicEditorFontFamilySelect=nicEditorSelect.extend({sel:{'arial':'Arial','comic sans ms':'Comic Sans','courier new':'Courier New','georgia':'Georgia','helvetica':'Helvetica','impact':'Impact','times new roman':'Times','trebuchet ms':'Trebuchet','verdana':'Verdana'},init:function(){this.setDisplay('Font&nbsp;Family...');for(itm in this.sel){this.add(itm,'<font face="'+itm+'">'+this.sel[itm]+'</font>');}}});var nicEditorFontFormatSelect=nicEditorSelect.extend({sel:{'p':'Paragraph','pre':'Pre','h6':'Heading&nbsp;6','h5':'Heading&nbsp;5','h4':'Heading&nbsp;4','h3':'Heading&nbsp;3','h2':'Heading&nbsp;2','h1':'Heading&nbsp;1'},init:function(){this.setDisplay('Font&nbsp;Format...');for(itm in this.sel){var tag=itm.toUpperCase();this.add('<'+tag+'>','<'+itm+' style="padding: 0px; margin: 0px;">'+this.sel[itm]+'</'+tag+'>');}}});var nicLinkOptions={buttons:{'link':{name:'Add Link',type:'nicLinkButton',tags:['A']},'unlink':{name:'Remove Link',command:'unlink',noActive:true}}};var nicLinkButton=nicEditorAdvancedButton.extend({addPane:function(){this.ln=this.ne.selectedInstance.selElm().parentTag('A');this.addForm({'':{type:'title',txt:'Add/Edit Link'},'href':{type:'text',txt:'URL',value:'http://',style:{width:'150px'}},'title':{type:'text',txt:'Title'},'target':{type:'select',txt:'Open In',options:{'':'Current Window','_blank':'New Window'},style:{width:'100px'}}},this.ln);},submit:function(e){var url=this.inputs['href'].value;if(url=="http://"||url==""){alert("You must enter a URL to Create a Link");return false;}
this.removePane();if(!this.ln){var tmp='javascript:nicTemp();';this.ne.nicCommand("createlink",tmp);this.ln=this.findElm('A','href',tmp);}
if(this.ln){this.ln.setAttributes({href:this.inputs['href'].value,title:this.inputs['title'].value,target:this.inputs['target'].options[this.inputs['target'].selectedIndex].value});}}});var nicColorOptions={buttons:{}};var nicEditorColorButton=nicEditorAdvancedButton.extend({addPane:function(){var colorList={0:'00',1:'33',2:'66',3:'99',4:'CC',5:'FF'};var colorItems=new bkElement('DIV').setStyle({width:'270px'});for(var r in colorList){for(var b in colorList){for(var g in colorList){var colorCode='#'+colorList[r]+colorList[g]+colorList[b];var colorSquare=new bkElement('DIV').setStyle({'cursor':'pointer','height':'15px','float':'left'}).appendTo(colorItems);var colorBorder=new bkElement('DIV').setStyle({border:'2px solid '+colorCode}).appendTo(colorSquare);var colorInner=new bkElement('DIV').setStyle({backgroundColor:colorCode,overflow:'hidden',width:'11px',height:'11px'}).addEvent('click',this.colorSelect.closure(this,colorCode)).addEvent('mouseover',this.on.closure(this,colorBorder)).addEvent('mouseout',this.off.closure(this,colorBorder,colorCode)).appendTo(colorBorder);if(!window.opera){colorSquare.onmousedown=colorInner.onmousedown=bkLib.cancelEvent;}}}}
this.pane.append(colorItems.noSelect());},colorSelect:function(c){this.ne.nicCommand('foreColor',c);this.removePane();},on:function(colorBorder){colorBorder.setStyle({border:'2px solid #000'});},off:function(colorBorder,colorCode){colorBorder.setStyle({border:'2px solid '+colorCode});}});var nicEditorBgColorButton=nicEditorColorButton.extend({colorSelect:function(c){this.ne.nicCommand('hiliteColor',c);this.removePane();}});var nicImageOptions={buttons:{'image':{name:'Add Image',type:'nicImageButton',tags:['IMG']}}};var nicImageButton=nicEditorAdvancedButton.extend({addPane:function(){this.im=this.ne.selectedInstance.selElm().parentTag('IMG');this.addForm({'':{type:'title',txt:'Add/Edit Image'},'src':{type:'text',txt:'URL','value':'http://',style:{width:'150px'}},'alt':{type:'text',txt:'Alt Text',style:{width:'100px'}},'align':{type:'select',txt:'Align',options:{none:'Default','left':'Left','right':'Right'}}},this.im);},submit:function(e){var src=this.inputs['src'].value;if(src==""||src=="http://"){alert("You must enter a Image URL to insert");return false;}
this.removePane();if(!this.im){var tmp='javascript:nicImTemp();';this.ne.nicCommand("insertImage",tmp);this.im=this.findElm('IMG','src',tmp);}
if(this.im){this.im.setAttributes({src:this.inputs['src'].value,alt:this.inputs['alt'].value,align:this.inputs['align'].value});}}});var nicSaveOptions={buttons:{'save':{name:__('Save this content'),type:'nicEditorSaveButton'}}};var nicEditorSaveButton=nicEditorButton.extend({init:function(){if(!this.ne.options.onSave){this.margin.setStyle({'display':'none'});}},mouseClick:function(){var onSave=this.ne.options.onSave;var selectedInstance=this.ne.selectedInstance;onSave(selectedInstance.getContent(),selectedInstance.elm.id,selectedInstance);}});var nicUploadOptions={buttons:{'upload':{name:'Upload Image',type:'nicUploadButton'}}};var nicUploadButton=nicEditorAdvancedButton.extend({nicURI:'http://files.nicedit.com/',addPane:function(){this.im=this.ne.selectedInstance.selElm().parentTag('IMG');this.myID=Math.round(Math.random()*Math.pow(10,15));this.requestInterval=1000;this.uri=this.ne.options.uploadURI||this.nicURI;nicUploadButton.lastPlugin=this;this.myFrame=new bkElement('iframe').setAttributes({width:'100%',height:'100px',frameBorder:0,scrolling:'no'}).setStyle({border:0}).appendTo(this.pane.pane);this.progressWrapper=new bkElement('div').setStyle({display:'none',width:'100%',height:'20px',border:'1px solid #ccc'}).appendTo(this.pane.pane);this.progress=new bkElement('div').setStyle({width:'0%',height:'20px',backgroundColor:'#ccc'}).setContent('&nbsp').appendTo(this.progressWrapper);setTimeout(this.addForm.closure(this),50);},addForm:function(){var myDoc=this.myDoc=this.myFrame.contentWindow.document;myDoc.open();myDoc.write("<html><body>");myDoc.write('<form method="post" action="'+this.uri+'?id='+this.myID+'" enctype="multipart/form-data">');myDoc.write('<input type="hidden" name="APC_UPLOAD_PROGRESS" value="'+this.myID+'" />');if(this.uri==this.nicURI){myDoc.write('<div style="position: absolute; margin-left: 160px;"><img src="http://imageshack.us/img/imageshack.png" width="30" style="float: left;" /><div style="float: left; margin-left: 5px; font-size: 10px;">Hosted by<br /><a href="http://www.imageshack.us/" target="_blank">ImageShack</a></div></div>');}
myDoc.write('<div style="font-size: 14px; font-weight: bold; padding-top: 5px;">Insert an Image</div>');myDoc.write('<input name="nicImage" type="file" style="margin-top: 10px;" />');myDoc.write('</form>');myDoc.write("</body></html>");myDoc.close();this.myBody=myDoc.body;this.myForm=$BK(this.myBody.getElementsByTagName('form')[0]);this.myInput=$BK(this.myBody.getElementsByTagName('input')[1]).addEvent('change',this.startUpload.closure(this));this.myStatus=new bkElement('div',this.myDoc).setStyle({textAlign:'center',fontSize:'14px'}).appendTo(this.myBody);},startUpload:function(){this.myForm.setStyle({display:'none'});this.myStatus.setContent('<img src="http://files.nicedit.com/ajax-loader.gif" style="float: right; margin-right: 40px;" /><strong>Uploading...</strong><br />Please wait');this.myForm.submit();setTimeout(this.makeRequest.closure(this),this.requestInterval);},makeRequest:function(){if(this.pane&&this.pane.pane){nicUploadButton.lastPlugin=this;var s=new bkElement('script').setAttributes({type:'text/javascript',src:this.uri+'?check='+this.myID+'&rand='+Math.round(Math.random()*Math.pow(10,15))}).addEvent('load',function(){s.parentNode.removeChild(s);}).appendTo(document.getElementsByTagName('head')[0]);if(this.requestInterval){setTimeout(this.makeRequest.closure(this),this.requestInterval);}}},setProgress:function(percent){this.progressWrapper.setStyle({display:'block'});this.progress.setStyle({width:percent+'%'});},update:function(o){if(o==false){this.progressWrapper.setStyle({display:'none'});}else if(o.url){this.setProgress(100);this.requestInterval=false;if(!this.im){this.ne.selectedInstance.restoreRng();var tmp='javascript:nicImTemp();';this.ne.nicCommand("insertImage",tmp);this.im=this.findElm('IMG','src',tmp);}
var w=parseInt(this.ne.selectedInstance.elm.getStyle('width'));if(this.im){this.im.setAttributes({src:o.url,width:(w&&o.width)?Math.min(w,o.width):''});}
this.removePane();}else if(o.error){this.requestInterval=false;this.setProgress(100);alert("There was an error uploading your image ("+o.error+").");this.removePane();}else if(o.noprogress){this.progressWrapper.setStyle({display:'none'});if(this.uri.indexOf('http:')==-1||this.uri.indexOf(window.location.host)!=-1){this.requestInterval=false;}}else{this.setProgress(Math.round((o.current/o.total)*75));if(o.interval){this.requestInterval=o.interval;}}}});nicUploadButton.statusCb=function(o){nicUploadButton.lastPlugin.update(o);}
var nicXHTML=bkClass.extend({stripAttributes:['_moz_dirty','_moz_resizing','_extended'],noShort:['style','title','script','textarea','a'],cssReplace:{'font-weight:bold;':'strong','font-style:italic;':'em'},sizes:{1:'xx-small',2:'x-small',3:'small',4:'medium',5:'large',6:'x-large'},construct:function(nicEditor){this.ne=nicEditor;if(this.ne.options.xhtml){nicEditor.addEvent('get',this.cleanup.closure(this));}},cleanup:function(ni){var node=ni.getElm();var xhtml=this.toXHTML(node);ni.content=xhtml;},toXHTML:function(n,r,d){var txt='';var attrTxt='';var cssTxt='';var nType=n.nodeType;var nName=n.nodeName.toLowerCase();var nChild=n.hasChildNodes&&n.hasChildNodes();var extraNodes=new Array();switch(nType){case 1:var nAttributes=n.attributes;switch(nName){case'b':nName='strong';break;case'i':nName='em';break;case'font':nName='span';break;}
if(r){for(var i=0;i<nAttributes.length;i++){var attr=nAttributes[i];var attributeName=attr.nodeName.toLowerCase();var attributeValue=attr.nodeValue;if(!attr.specified||!attributeValue||bkLib.inArray(this.stripAttributes,attributeName)||typeof(attributeValue)=="function"){continue;}
switch(attributeName){case'style':var css=attributeValue.replace(/ /g,"");for(itm in this.cssReplace){if(css.indexOf(itm)!=-1){extraNodes.push(this.cssReplace[itm]);css=css.replace(itm,'');}}
cssTxt+=css;attributeValue="";break;case'class':attributeValue=attributeValue.replace("Apple-style-span","");break;case'size':cssTxt+="font-size:"+this.sizes[attributeValue]+';';attributeValue="";break;}
if(attributeValue){attrTxt+=' '+attributeName+'="'+attributeValue+'"';}}
if(cssTxt){attrTxt+=' style="'+cssTxt+'"';}
for(var i=0;i<extraNodes.length;i++){txt+='<'+extraNodes[i]+'>';}
if(attrTxt==""&&nName=="span"){r=false;}
if(r){txt+='<'+nName;if(nName!='br'){txt+=attrTxt;}}}
if(!nChild&&!bkLib.inArray(this.noShort,attributeName)){if(r){txt+=' />';}}else{if(r){txt+='>';}
for(var i=0;i<n.childNodes.length;i++){var results=this.toXHTML(n.childNodes[i],true,true);if(results){txt+=results;}}}
if(r&&nChild){txt+='</'+nName+'>';}
for(var i=0;i<extraNodes.length;i++){txt+='</'+extraNodes[i]+'>';}
break;case 3:txt+=n.nodeValue;break;}
return txt;}});var nicBBCode=bkClass.extend({construct:function(nicEditor){this.ne=nicEditor;if(this.ne.options.bbCode){nicEditor.addEvent('get',this.bbGet.closure(this));nicEditor.addEvent('set',this.bbSet.closure(this));var loadedPlugins=this.ne.loadedPlugins;for(itm in loadedPlugins){if(loadedPlugins[itm].toXHTML){this.xhtml=loadedPlugins[itm];}}}},bbGet:function(ni){var xhtml=this.xhtml.toXHTML(ni.getElm());ni.content=this.toBBCode(xhtml);},bbSet:function(ni){ni.content=this.fromBBCode(ni.content);},toBBCode:function(xhtml){function rp(r,m){xhtml=xhtml.replace(r,m);}
rp(/\n/gi,"");rp(/<strong>(.*?)<\/strong>/gi,"[b]$1[/b]");rp(/<em>(.*?)<\/em>/gi,"[i]$1[/i]");rp(/<span.*?style="text-decoration:underline;">(.*?)<\/span>/gi,"[u]$1[/u]");rp(/<ul>(.*?)<\/ul>/gi,"[list]$1[/list]");rp(/<li>(.*?)<\/li>/gi,"[*]$1[/*]");rp(/<ol>(.*?)<\/ol>/gi,"[list=1]$1[/list]");rp(/<img.*?src="(.*?)".*?>/gi,"[img]$1[/img]");rp(/<a.*?href="(.*?)".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");rp(/<br.*?>/gi,"\n");rp(/<.*?>.*?<\/.*?>/gi,"");return xhtml;},fromBBCode:function(bbCode){function rp(r,m){bbCode=bbCode.replace(r,m);}
rp(/\[b\](.*?)\[\/b\]/gi,"<strong>$1</strong>");rp(/\[i\](.*?)\[\/i\]/gi,"<em>$1</em>");rp(/\[u\](.*?)\[\/u\]/gi,"<span style=\"text-decoration:underline;\">$1</span>");rp(/\[list\](.*?)\[\/list\]/gi,"<ul>$1</ul>");rp(/\[list=1\](.*?)\[\/list\]/gi,"<ol>$1</ol>");rp(/\[\*\](.*?)\[\/\*\]/gi,"<li>$1</li>");rp(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />");rp(/\[url=(.*?)\](.*?)\[\/url\]/gi,"<a href=\"$1\">$2</a>");rp(/\n/gi,"<br />");return bbCode;}});nicEditor=nicEditor.extend({floatingPanel:function(){this.floating=new bkElement('DIV').setStyle({position:'absolute',top:'-1000px'}).appendTo(document.body);this.addEvent('focus',this.reposition.closure(this)).addEvent('blur',this.hide.closure(this));this.setPanel(this.floating);},reposition:function(){var e=this.selectedInstance.e;this.floating.setStyle({width:(parseInt(e.getStyle('width'))||e.clientWidth)+'px'});var top=e.offsetTop-this.floating.offsetHeight;if(top<0){top=e.offsetTop+e.offsetHeight;}
this.floating.setStyle({top:top+'px',left:e.offsetLeft+'px',display:'block'});},hide:function(){this.floating.setStyle({top:'-1000px'});}});var nicCodeOptions={buttons:{'xhtml':{name:'Edit HTML',type:'nicCodeButton'}}};var nicCodeButton=nicEditorAdvancedButton.extend({width:'350px',addPane:function(){this.addForm({'':{type:'title',txt:'Edit HTML'},'code':{type:'content','value':this.ne.selectedInstance.getContent(),style:{width:'340px',height:'200px'}}});},submit:function(e){var code=this.inputs['code'].value;this.ne.selectedInstance.setContent(code);this.removePane();}});var agt=navigator.userAgent.toLowerCase();var is_major=parseInt(navigator.appVersion);var is_minor=parseFloat(navigator.appVersion);var is_nav=((agt.indexOf('mozilla')!=-1)&&(agt.indexOf('spoofer')==-1)&&(agt.indexOf('compatible')==-1)&&(agt.indexOf('opera')==-1)&&(agt.indexOf('webtv')==-1)&&(agt.indexOf('hotjava')==-1));var is_nav4=(is_nav&&(is_major==4));var is_nav6=(is_nav&&(is_major==5));var is_nav6up=(is_nav&&(is_major>=5));var is_ie=((agt.indexOf("msie")!=-1)&&(agt.indexOf("opera")==-1));var tooltip={toolTipDiv:null,ajaxLoader:"lib/core/tooltip/gfx/ajaxloader.gif",init:function(onlyAnchors){if(!document.getElementById)return;if(!onlyAnchors){this.toolTipDiv=document.getElementById("toolTip")?document.getElementById("toolTip"):document.createElement('div');this.toolTipDiv.style.left="0";this.toolTipDiv.style.right="0";this.toolTipDiv.style.position="absolute";this.toolTipDiv.id="toolTip";if(!document.getElementById("toolTip"))
document.body.appendChild(this.toolTipDiv);this.toolTipDiv=this.toolTipDiv.style;if(is_ie||is_nav6up)
{this.toolTipDiv.visibility="visible";this.toolTipDiv.display="none";document.onmousemove=tooltip.moveToMousePos;}}
var anchors=document.getElementsByTagName("a");for(var i=0;i<anchors.length;i++){if(anchors[i].title.length>0){anchors[i].onmouseover=(anchors[i].rel.length>0&&anchors[i].className.search("tooltip")!=-1)?new Function("tooltip.toolTip( '"+document.location.href+anchors[i].rel+"', true )"):new Function("tooltip.toolTip( '"+anchors[i].title+"' )");anchors[i].onmouseout=new Function("tooltip.toolTip()");anchors[i].title="";}}
if(!ajax)
alert("(tooltip.js) need ajax function : doRequest(url, args, method, elname ) <- modify this call according to your js framework!");},moveToMousePos:function(e)
{if(!is_ie){x=e.pageX;y=e.pageY;}else{x=event.x+document.body.scrollLeft;y=event.y+document.body.scrollTop;}
this.toolTipDiv=document.getElementById("toolTip").style;this.toolTipDiv.left=(x+25)+'px';this.toolTipDiv.top=(y+25)+'px';return true;},toolTip:function(data,isUrl)
{if(this.toolTip.arguments.length==0)
{if(is_nav4)
this.toolTipDiv.visibility="hidden";else
this.toolTipDiv.display="none";}
else
{var content='<table border="0" cellspacing="0" cellpadding="0" class="toolTip"><tr><td>'+'<table border="0" cellspacing="1" cellpadding="0"><tr><td id="toolTipText">';if(isUrl){setTimeout('ajax.doRequest( "'+data+'", false, "GET", "toolTipText" )',250);content+='<img id="ajaxloader" src="'+this.ajaxLoader+'"/>';}else content+=data;content+='</td></tr></table>';content+='</td></tr></table>';if(is_nav4){this.toolTipDiv.document.write(content);this.toolTipDiv.document.close();this.toolTipDiv.visibility="visible";}else if(is_ie||is_nav6up){document.getElementById("toolTip").innerHTML=content;this.toolTipDiv.display='block'}}}}
var admin={strings:Array(),cache:Array(),dev:false,edit:false,editor:false,resetStatus:false,ro:(navigator.appName=='Microsoft Internet Explorer')?new ActiveXObject('Microsoft.XMLHTTP'):ro=new XMLHttpRequest(),toggleMouseListeners:function(state){document.onmouseover=state?admin.inspectMouseOver:null;document.onmouseout=state?admin.inspectMouseOut:null;document.onmousedown=state?admin.inspectMouseDown:null;window.onscroll=admin.autoScroll;},init:function(){admin.cache['border']=Array();},autoScroll:function(){if($sutra('popup')==undefined||$sutra('popupPage').style.display=="none")
tween($sutra('panel'),'top','current',(admin.cross_scrollTop()+15)+"px",150);},getWidgetFromEvent:function(e){if(e==null)e=window.event;var target=e.target!=null?e.target:e.srcElement;var id=String(target.id);return id.match(/widget_/)?target:false;},toggleEditableContent:function(state){if(!admin.editor)return;var divs=document.getElementsByTagName("div");for(var i=0;i<divs.length;i++){var className=String(divs[i].className);if(className.match(/editable/)){if(state)
admin.editor.addInstance(divs[i]);else
admin.editor.removeInstance(divs[i]);}}},inspectMouseOver:function(e){var target=admin.getWidgetFromEvent(e);if(target){admin.cache['border'][String(target.id)]=target.style.border;target.style.border="1px dotted blue";}},inspectMouseOut:function(e){var target=admin.getWidgetFromEvent(e);if(target){target.style.border=admin.cache['border'][String(target.id)];}},inspectMouseDown:function(e){var target=admin.getWidgetFromEvent(e);if(target){if(admin.edit)admin.toggleEdit();admin.setStatus(admin.strings['STATUS_WIDGET_IS_LOADING']);admin.show("popupPage",true,true);}},show:function(elname,show,erase){var el=$sutra(elname);if(!el)return;el.style.display=show?"block":"none";if(erase)el.innerHTML="";},saveContent:function(content,id,instance){var el=$sutra(id);var page_id=false;var params=el.className.split(" ");for(i in params)
if((params[i]==parseInt(params[i]))&&(page_id=params[i]))
break;content=admin.cleanMSWord(content,true);page_id=page_id?"&page_id="+page_id:"";ajax.doRequest('admin','event=SUTRA_ADMIN_SAVE_CONTENT&'+id+'='+escape(content)+page_id,"POST");alert(admin.strings["CONTENT_SAVED"]);admin.toggleEdit();},cleanMSWord:function(specialchartext,toHtml){specialchartext=escape(specialchartext);if(toHtml){specialchartext=specialchartext.replace(/%u201C/g,"&ldquo;");specialchartext=specialchartext.replace(/%u201D/g,"&rdquo;");specialchartext=specialchartext.replace(/%u2018/g,"&lsquo;");specialchartext=specialchartext.replace(/%u2019/g,"&rsquo;");specialchartext=specialchartext.replace(/%u2026/g,"&hellip;");}else{specialchartext=specialchartext.replace(/%u201C/g,"\"");specialchartext=specialchartext.replace(/%u201D/g,"\"");specialchartext=specialchartext.replace(/%u2018/g,"'");specialchartext=specialchartext.replace(/%u2019/g,"'");specialchartext=specialchartext.replace(/%u2026/g,"...");}
specialchartext=specialchartext.replace(/%u2013/g,"&ndash;");specialchartext=specialchartext.replace(/%u2013/g,"&ndash;");specialchartext=specialchartext.replace(/%u2014/g,"&mdash;");specialchartext=specialchartext.replace(/%A9/g,"&copy;");specialchartext=specialchartext.replace(/%AE/g,"&reg;");specialchartext=specialchartext.replace(/%u2122/g,"&trade;");specialchartext=specialchartext.replace(/%uF04A/g,":)");specialchartext=unescape(specialchartext);return specialchartext;},closePopup:function(){admin.show('popupContent',true,true);admin.show('popupPage',false,false);},setStatus:function(message){if(admin.resetStatus)clearTimeout(admin.resetStatus);var el=$sutra("panelStatus");if(el){el.innerHTML="<p id='statusMessage'>"+message+"</p>";admin.resetStatus=setTimeout("admin.setStatus('')",2600);}},clickModule:function(name){if(admin.edit)
admin.toggleEdit();$('popup').style.top=40+$getPosY($('panel'))+"px";admin.show('popupPage',true,false);admin.show('popupClose',false,false);admin.setStatus(name);},toggleDev:function(){admin.dev=!admin.dev;admin.toggleImage('iconDev','icon.dev');if(admin.dev)
alert(admin.strings['ALERT_DEV']);window.ajax.doRequest("/togglecache");},toggleEdit:function(){admin.edit=!admin.edit;admin.toggleMouseListeners(admin.edit);admin.toggleImage('iconEdit','icon.edit');admin.show('popupPage',false,false);admin.show('popupClose',false,false);admin.show('panelStatus',!admin.edit,true);if(admin.edit&&!admin.editor){admin.editor=new nicEditor({fullPanel:true,onSave:admin.saveContent});admin.editor.setPanel('nicedit');}
admin.show('nicedit',admin.edit,false);admin.toggleEditableContent(admin.edit);},toggleImage:function(elname,prefix){var el=$sutra(elname);if(el){var src=new String(el.src);var state=!src.match(/-on/);el.src=src.replace(prefix+"-"+(!state?"on":"off")+".gif",prefix+"-"+(state?"on":"off")+".gif");}},toggleNames:function(name,state,fade){var els=document.getElementsByName(name);for(var i=0;i<els.length;i++){if(!els[i].id)
els[i].id=((new Date()).getTime()+""+Math.floor(Math.random()*1000000)).substr(0,18);if(fade)
opacity(els[i].id,state?0:100,state?100:0,400);else els[i].style.display=state?(els[i].tagName=="DIV"?"block":"inline"):"none";}},close:function(){ajax.doRequest(window.baseurl+"?logout");$sutra("panel").innerHTML="";$sutra("popup").innerHTML="";},cross_clientHeight:function(){return admin.cross_filterResults(window.innerHeight?window.innerHeight:0,document.documentElement?document.documentElement.clientHeight:0,document.body?document.body.clientHeight:0);},cross_scrollTop:function(){return admin.cross_filterResults(window.pageYOffset?window.pageYOffset:0,document.documentElement?document.documentElement.scrollTop:0,document.body?document.body.scrollTop:0);},cross_filterResults:function(n_win,n_docel,n_body){var n_result=n_win?n_win:0;if(n_docel&&(!n_result||(n_result>n_docel)))
n_result=n_docel;return n_body&&(!n_result||(n_result>n_body))?n_body:n_result;}}
admin.init();var fps=40;var debugging=0;var tw=[];var rand_str=generatePassword();var float_pcre=new RegExp("(\\+|-)?(\\d*\\.)?\\d+",'g');var color_at_end=new RegExp("[Cc]olor$");function tween(a,b,c,d,e){if(arguments.length<5)return false;if(Math.random()>=0.75){for(var i=0;i<tw.length;++i){if(tw[i]["status"]==="playing")break;if(i==tw.length-1){tw=[]}}}var f=tw.length;tw[f]=[];tw[f]["f"]=(Boolean(arguments[5]))?arguments[5]:"linear";tw[f]["ez"]=0;tw[f]["status"]="playing";tw[f]["element"]=resolve_element(a);tw[f]["property"]=resolve_property(b);if(Boolean(tw[f]["property"].match(color_at_end)))tw[f]["is_color_tween"]=true;tw[f]["duration"]=e;tw[f]["step"]=0;tw[f]["interval"]=1000/fps;tw[f]["steps"]=Math.ceil(e/tw[f]["interval"]);tw[f]["from_orig"]=c;tw[f]["to_orig"]=d;tw[f]["timer"]=false;for(var g=0;g<f;++g){if(tw[g]["status"]!=="playing")continue;if(tw[g]["element"]!==tw[f]["element"])continue;if(tw[g]["property"]!==tw[f]["property"])continue;tw[g]["status"]="aborted";clearInterval(tw[g]["timer"])}if(tw[f]["from_orig"]==='current'){tw[f]["from"]=getStyle(tw[f]["element"],tw[f]["property"]);if(tw[f]["from"]===''||tw[f]["from"]==='NaN'||typeof(tw[f]["from"])==="undefined")tw[f]["from"]=tw[f]["element"].style[tw[f]["property"]];if(tw[f]["from"]===''||tw[f]["from"]==='NaN'||typeof(tw[f]["from"])==="undefined"){if(tw[f]["is_color_tween"])tw[f]["from"]="#7F7F7F";else tw[f]["from"]='0'}if(tw[f]["is_color_tween"])tw[f]["from"]=resolve_color(tw[f]["from"])}if(tw[f]["is_color_tween"]){if(tw[f]["from_orig"]==='current');else tw[f]["from"]=resolve_color(tw[f]["from_orig"]);tw[f]["to"]=resolve_color(tw[f]["to_orig"]);tw[f]["change"]=[];tw[f]["change"]["red"]=tw[f]["to"]["red"]-tw[f]["from"]["red"];tw[f]["change"]["green"]=tw[f]["to"]["green"]-tw[f]["from"]["green"];tw[f]["change"]["blue"]=tw[f]["to"]["blue"]-tw[f]["from"]["blue"]}else{if(tw[f]["from_orig"]!==''){if(tw[f]["from_orig"]==='current')tw[f]["from"]=tw[f]["from"].match(float_pcre);else tw[f]["from"]=tw[f]["from_orig"].match(float_pcre);tw[f]["from"]=parseFloat(tw[f]["from"]);tw[f]["to"]=parseFloat(tw[f]["to_orig"].match(float_pcre));tw[f]["change"]=tw[f]["to"]-tw[f]["from"];var h;if(tw[f]["from_orig"]==='current')h=tw[f]["to_orig"];else h=tw[f]["from_orig"];h=h.replace(float_pcre,rand_str);tw[f]["prefix"]=h.slice(0,h.indexOf(rand_str));tw[f]["suffix"]=str_replace(tw[f]["prefix"]+rand_str,'',h)}}if(debugging){var k=new String();var l=['id','tagName','className'];for(var i in tw[f]){k+=i+": ";if(i!=="element"&&typeof(tw[f][i])===typeof(Object())){for(var j in tw[f][i])k+="\n\t"+j+": "+tw[f][i][j]}else if(i==="element"){for(var j=0;j<l.length;j++)k+="\n\t"+l[j]+": "+tw[f][i][l[j]]}else k+=tw[f][i];k+="\n\n"}alert(k)}if(tw[f]["from_orig"]===""){tw[f]["status"]="playing";tw[f]["timer"]=setTimeout("tw["+f+"][\"element\"].style[tw["+f+"][\"property\"]] = tw["+f+"][\"to_orig\"];tw["+f+"][\"status\"] = \"complete\"",tw[f]["duration"])}else ease(f);return f}function ease(a){if(tw[a]["step"]===0){tw[a]["status"]="playing";if(tw[a]["is_color_tween"])tw[a]["element"].style[tw[a]["property"]]="rgb("+tw[a]["from"]["red"]+","+tw[a]["from"]["green"]+","+tw[a]["from"]["blue"]+")";else tw[a]["element"].style[tw[a]["property"]]=tw[a]["prefix"]+tw[a]["from"]+tw[a]["suffix"]}tw[a]["step"]++;if(tw[a]["step"]<=tw[a]["steps"]&&tw[a]["step"]!==0&&tw[a]["status"]==='playing'){if(tw[a]["is_color_tween"]){var b=parseInt(eval(tw[a]["f"])(tw[a]["step"],parseInt(tw[a]["from"]["red"]),parseInt(tw[a]["change"]["red"]),tw[a]["steps"]));var c=parseInt(eval(tw[a]["f"])(tw[a]["step"],parseInt(tw[a]["from"]["green"]),parseInt(tw[a]["change"]["green"]),tw[a]["steps"]));var d=parseInt(eval(tw[a]["f"])(tw[a]["step"],parseInt(tw[a]["from"]["blue"]),parseInt(tw[a]["change"]["blue"]),tw[a]["steps"]));tw[a]["ez"]="rgb("+b+","+c+","+d+")"}else{tw[a]["ez"]=parseInt(eval(tw[a]["f"])(tw[a]["step"],tw[a]["from"],tw[a]["change"],tw[a]["steps"])*100)/100;tw[a]["ez"]=tw[a]["prefix"]+tw[a]["ez"]+tw[a]["suffix"]}tw[a]["timer"]=setTimeout("ease_repeat("+a+")",tw[a]["interval"])}if(tw[a]["step"]>=tw[a]["steps"]){tw[a]["status"]="complete"}}function ease_repeat(a){try{tw[a]["element"].style[tw[a]["property"]]=tw[a]["ez"];ease(a)}catch(e){}}function h2d(h){return parseInt(h,16)}function str_replace(a,b,c,d){var i=0,j=0,temp='',repl='',sl=0,fl=0,f=[].concat(a),r=[].concat(b),s=c,ra=r instanceof Array,sa=s instanceof Array;s=[].concat(s);if(d)this.window[d]=0;for(i=0,sl=s.length;i<sl;i++){if(s[i]==='')continue;for(j=0,fl=f.length;j<fl;j++){temp=s[i]+'';repl=ra?(r[j]!==undefined?r[j]:''):r[0];s[i]=(temp).split(f[j]).join(repl);if(d&&s[i]!==temp){this.window[d]+=(temp.length-s[i].length)/f[j].length}}}return sa?s:s[0]}function resolve_element(a){if(typeof(a)=="object");else if(typeof(a)=="string")a=document.getElementById(a);if(a.tagName!="undefined")return a;return false}function resolve_property(a){var b;var c=new RegExp("-[a-z]");while(1){if(b=a.match(c)){b=b.toString();a=str_replace(b,b.charAt(1).toUpperCase(),a)}else break}return a}function resolve_color(a){if(a==='transparent')a='#FFF';var r,g,b;var c=new RegExp("^#[0-9a-f]{3}([0-9a-f]{3})?$",'gi');var d=new RegExp("rgb\\(\\s*((?:[0-2]?[0-9])?[0-9])\\s*,\\s*((?:[0-2]?[0-9])?[0-9])\\s*,\\s*((?:[0-2]?[0-9])?[0-9])\\s*\\)$",'gi');if(a.match(c)){if(a.length==4){r=a.charAt(1)+""+a.charAt(1);g=a.charAt(2)+""+a.charAt(2);b=a.charAt(3)+""+a.charAt(3)}else{r=a.charAt(1)+""+a.charAt(2);g=a.charAt(3)+""+a.charAt(4);b=a.charAt(5)+""+a.charAt(6)}r=h2d(r);g=h2d(g);b=h2d(b)}else if(a.match(d)){r=RegExp.$1;g=RegExp.$2;b=RegExp.$3}else return false;var e=[];e['red']=r;e['green']=g;e['blue']=b;return e}function getStyle(c,d){var e="";if(document.defaultView&&document.defaultView.getComputedStyle){e=document.defaultView.getComputedStyle(c,"").getPropertyValue(d)}else if(c.currentStyle){d=d.replace(/\-(\w)/g,function(a,b){return b.toUpperCase()});e=c.currentStyle[d]}return e}function generatePassword(a){a=parseInt(a);if(!a)a=6;var b="";var c="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";var d=c.length;var e;for(i=0;i<a;i++){e=c.charAt(Math.floor(Math.random()*d));b+=e}return b}function substr(a,b,c){a+='';if(b<0){b+=a.length}if(c==undefined){c=a.length}else if(c<0){c+=a.length}else{c+=b}if(c<b){c=b}return a.substring(b,c)}function microtime(a){var b=new Date().getTime()/1000;var s=parseInt(b,10);return(a)?b:(Math.round((b-s)*1000)/1000)+' '+s}function $(){var a=new Array();for(var i=0,len=arguments.length;i<len;i++){var b=arguments[i];if(typeof b=='string'){var c=document.getElementById(b);if(c){a.push(c)}else{var d=(document.all)?document.all:document.getElementsByTagName('*');var e=new RegExp('(^| )'+b+'( |$)');for(var i=0,len=d.length;i<len;i++)if(e.test(d[i].className))a.push(d[i])}if(!a.length)a=document.getElementsByTagName(b);if(!a.length){a=new Array();var d=(document.all)?document.all:document.getElementsByTagName('*');for(var i=0,len=d.length;i<len;i++)if(d[i].getAttribute(b))a.push(d[i])}if(!a.length){var d=(document.all)?document.all:document.getElementsByTagName('*');for(var i=0,len=d.length;i<len;i++)if(d[i].attributes)for(var j=0,lenn=d[i].attributes.length;j<lenn;j++)if(d[i].attributes[j].specified)if(d[i].attributes[j].nodeValue==b)a.push(d[i])}}else{a.push(b)}}if(a.length==1){return a[0]}else{return a}}linear=function(t,b,c,d){return c*t/d+b};easeInBack=function(t,b,c,d,s){if(s==undefined)s=1.70158;return c*(t/=d)*t*((s+1)*t-s)+b};easeOutBack=function(t,b,c,d,s){if(s==undefined)s=1.70158;return c*((t=t/d-1)*t*((s+1)*t+s)+1)+b};easeInOutBack=function(t,b,c,d,s){if(s==undefined)s=1.70158;if((t/=d/2)<1)return c/2*(t*t*(((s*=(1.525))+1)*t-s))+b;return c/2*((t-=2)*t*(((s*=(1.525))+1)*t+s)+2)+b};easeInCirc=function(t,b,c,d){return-c*(Math.sqrt(1-(t/=d)*t)-1)+b};easeOutCirc=function(t,b,c,d){return c*Math.sqrt(1-(t=t/d-1)*t)+b};easeInOutCirc=function(t,b,c,d){if((t/=d/2)<1)return-c/2*(Math.sqrt(1-t*t)-1)+b;return c/2*(Math.sqrt(1-(t-=2)*t)+1)+b};easeInBounce=function(t,b,c,d){return c-easeOutBounce(d-t,0,c,d)+b};easeOutBounce=function(t,b,c,d){if((t/=d)<(1/2.75)){return c*(7.5625*t*t)+b}else if(t<(2/2.75)){return c*(7.5625*(t-=(1.5/2.75))*t+.75)+b}else if(t<(2.5/2.75)){return c*(7.5625*(t-=(2.25/2.75))*t+.9375)+b}else{return c*(7.5625*(t-=(2.625/2.75))*t+.984375)+b}};easeInOutBounce=function(t,b,c,d){if(t<d/2)return easeInBounce(t*2,0,c,d)*.5+b;return easeOutBounce(t*2-d,0,c,d)*.5+c*.5+b};var nicSutraImageOptions={buttons:{'sutraImage':{name:'Add Image',type:'nicSutraImageButton',tags:['IMG']}}};var nicSutraImageButton=nicEditorAdvancedButton.extend({addPane:function(){this.im=this.ne.selectedInstance.selElm().parentTag('IMG');this.addForm({'':{type:'title',txt:'Add/Edit Image'},'src':{type:'text',txt:'URL','value':'http://',style:{width:'150px'}},'alt':{type:'text',txt:'Alt Text',style:{width:'100px'}},'align':{type:'select',txt:'Align',options:{'left':'Left','right':'Right'}}},this.im);var el=document.createElement("br");el.style.clear="both";var tree=document.createElement("div");tree.className="block border curved fill padding";tree.id="tree";this.form.appendChild(el);this.form.appendChild(tree);window.ajax.doRequest('/widget/filemanager/tree?setOnClick=treeOnClick','','GET','tree');},submit:function(e){var src=this.inputs['src'].value;if(src==""||src=="http://"){alert("You must enter a valid Image URL to insert");return false;}
this.removePane();if(!this.im){var tmp='javascript:nicImTemp();';this.ne.nicCommand("insertImage",tmp);this.im=this.findElm('IMG','src',tmp);}
if(this.im){this.im.setAttributes({src:this.inputs['src'].value,alt:this.inputs['alt'].value,align:this.inputs['align'].value});this.im.className="img-align-"+this.inputs['align'].value;}}});window.treeOnClick=function(id){var url=baseurl.substr(0,baseurl.length-1);url+="/data/upload";url+=id;$sutra("src").value=url;return false;}
nicConfig.buttonList=['save','bold','italic','underline','left','center','right','justify','ol','ul','fontSize','fontFamily','fontFormat','indent','outdent','sutraImage','link','unlink','forecolor','bgcolor'];nicConfig.iconList={"xhtml":1,"bgcolor":2,"forecolor":3,"bold":4,"center":5,"hr":6,"indent":7,"italic":8,"justify":9,"left":10,"ol":11,"outdent":12,"removeformat":13,"right":14,"save":25,"strikethrough":16,"subscript":17,"superscript":18,"ul":19,"underline":20,"image":21,"sutraImage":21,"link":22,"unlink":23,"close":24,"arrow":26,"upload":27};nicConfig.colorList=["#4eb048","#898b8c","#000000"];nicConfig.formatList={'h2':'Heading&nbsp;2','h3':'Heading&nbsp;3'};nicEditors.registerPlugin(nicButtonTips);nicEditors.registerPlugin(nicPlugin,nicSelectOptions);nicEditors.registerPlugin(nicPlugin,nicLinkOptions);nicEditors.registerPlugin(nicPlugin,nicColorOptions);nicEditors.registerPlugin(nicPlugin,nicSaveOptions);nicEditors.registerPlugin(nicXHTML);nicEditors.registerPlugin(nicPlugin,nicCodeOptions);nicEditors.registerPlugin(nicPlugin,nicSutraImageOptions);
