
LITHIUM.DropDownMenu=Class.create({initialize:function(element,activationEventType,options){this.element=$(element);this.menuLoaded=false;this.menuElement=this.element.down(".lia-menu-dropdown-items");this.options={useAnimation:false,effectsOpenOptions:{duration:.1,from:0,to:1.0},effectsCloseOptions:{duration:.1,from:1.0,to:0}};this.observers=[];this.bound={documentObserver:null};Object.extend(this.options,options||{});this.addEventListeners(activationEventType);this.element.reference=this;},addHoverStyle:function(){this.element.addClassName("dropdownHover");},removeHoverStyle:function(){$$('.dropdownHover').invoke("removeClassName","dropdownHover");},openMenu:function(){if(this.iframeElement==null){this.iframeElement=new Element("iframe",{"id":"dropDownShim","src":"javascript:void(0);","style":"display:none;"});this.element.up().appendChild(this.iframeElement);this.iframeElement.setStyle({"zIndex":"500","position":"absolute","frameborder":"0","border":"0"});}else{this.iframeElement.show();}
this.addHoverStyle();this.iframeElement.clonePosition(this.menuElement);},closeMenu:function(){Event.stopObserving(document,'click',this.bound.documentObserver);this.removeHoverStyle();this.iframeElement.hide();},clickEvent:function(event){var clickElement=Event.findElement(event,'a');if(typeof clickElement!='undefined'&&clickElement.name=="title"){$(clickElement).up().select("a.dialog-link").each(function(item){Event.observe(item,'click',this.closeMenu.bindAsEventListener(this));}.bind(this));$(clickElement).up().select("a.ajax-link").each(function(item){Event.observe(item,'click',this.closeMenu.bindAsEventListener(this));}.bind(this));this.bound.documentObserver=this.closeMenu.bindAsEventListener(this);Event.observe(document,'click',this.bound.documentObserver);this.openMenu();Event.stop(event);}},addEventListeners:function(activationEventType){if(activationEventType=="mouseover"){Event.observe(this.element,'mouseover',this.openMenu.bindAsEventListener(this));Event.observe(this.element,'mouseout',this.closeMenu.bindAsEventListener(this));}
else if(activationEventType=="click"){Event.observe(this.element,'click',this.clickEvent.bindAsEventListener(this));}
this.menuLoaded=true;},removeEventListeners:function(activationEventType){if(activationEventType=="mouseover"){Event.stopObserving(this.element,'mouseover',this.openMenu.bindAsEventListener(this));Event.stopObserving(this.element,'mouseout',this.closeMenu.bindAsEventListener(this));}
else if(activationEventType=="click"){Event.stopObserving(this.element,'click',this.clickEvent.bindAsEventListener(this));}}});LITHIUM.DropDownMenu.forceCloseMenu=function(element){element.up(".dropdownHover").reference.closeMenu();};

LITHIUM.ResizeImages=Class.create({initialize:function(element,maxWidth,elementCssSelector,maxWidthCssClass){this.element=element;var selected=$(this.element).select(elementCssSelector);selected.each(function(item){this.resizeImagesInElement(item,maxWidth,maxWidthCssClass)}.bind(this));},resizeImagesInElement:function(item,maxWidth,maxWidthClass){item.select('img').each(function(subItem){var siWidth=subItem.getWidth();if(siWidth>maxWidth){var siHeight=subItem.getHeight();var multiplier=maxWidth/siWidth;subItem.width=maxWidth;subItem.height=siHeight*multiplier;subItem.addClassName(maxWidthClass);}});}});

LITHIUM.TagList=Class.create({initialize:function(element,confirmationElementSelector,toggleSelector){this.element=$(element);this.confirmationElementSelector=confirmationElementSelector;this.element.select(toggleSelector).each(function(item){var selector=this.confirmationElementSelector;Event.observe(item,"click",function(event){Event.stop(event);item.up("li").down(selector).toggleClassName("hidden");});}.bind(this));}});

if(typeof addthis_widget15=="undefined"){var addthis_widget15='addthis';var baseUrl=(document.location.protocol=="https:")?'https://secure.addthis.com/':'http://s7.addthis.com/';var at15O=baseUrl;var at15o=baseUrl+'services/';var at15Y=baseUrl+'select/';var at15y=new Array();at15y['ask']=['Ask','ask.png'];at15y['delicious']=['Del.icio.us','delicious.png'];at15y['digg']=['Digg','digg.png'];at15y['email']=['Email','email.png'];at15y['favorites']=['Favorites','favorites.png'];at15y['facebook']=['Facebook','facebook.gif'];at15y['fark']=['Fark','fark.png'];at15y['furl']=['Furl','furl.gif'];at15y['google']=['Google','goog.png'];at15y['live']=['Live','live.gif'];at15y['myspace']=['MySpace','myspace.png'];at15y['myweb']=['Yahoo MyWeb','yahoo-myweb.png'];at15y['newsvine']=['Newsvine','newsvine.png'];at15y['reddit']=['Reddit','reddit.gif'];at15y['sk*rt']=['Sk*rt','skrt.gif'];at15y['slashdot']=['Slashdot','slashdot.png'];at15y['stumbleupon']=['StumbleUpon','su.png'];at15y['stylehive']=['Stylehive','stylehive.gif'];at15y['tailrank']=['Tailrank','tailrank2.png'];at15y['technorati']=['Technorati','technorati.png'];at15y['thisnext']=['ThisNext','thisnext.gif'];at15y['twitter']=['Twitter','twitter.gif'];at15y['ballhype']=['BallHype','ballhype.png'];at15y['yardbarker']=['Yardbarker','yardbarker.png'];at15y['more']=['More ...','more.gif'];function at15I(at15i){return document.getElementById(at15i);}
function addthis_clearclosewin15(){if(typeof at15A!="undefined")
clearTimeout(at15A);}
function addthis_open(at15a,at15E,at15e,at15U){addthis_clearclosewin15();addthis_url=at15e;addthis_title=at15U;if(addthis_url==''||addthis_url=='[URL]')
addthis_url=location.href;if(addthis_title==''||addthis_title=='[TITLE]')
addthis_title=document.title;var at15u=020;var at15Z=at15a.getElementsByTagName('img');if(at15Z&&at15Z[0]){at15a=at15Z[0];at15u=0;}
atshow(at15E);var at15z=at15X(at15a);var at15x=at15z[0]+addthis_offset_left;var at15W=at15z[1]+at15u+1+addthis_offset_top;var at15w=at15V();var at15v=at15T();var at15t=at15I('addthis_dropdown15');at15t.style.display='block';if(at15x-at15v[0]+at15t.clientWidth+024>at15w[0])
at15x=at15x-at15t.clientWidth;if(at15W-at15v[1]+at15t.clientHeight+at15a.clientHeight+024>at15w[1])
at15W=at15W-at15t.clientHeight-024;at15t.style.left=at15x+'px';at15t.style.top=(at15W+at15a.clientHeight)+'px';if(addthis_hide_embed){var at15S=at15x+at15t.clientWidth;var at15s=at15W+at15t.clientHeight;var at15R=document.getElementsByTagName('embed');var at15r=0,at15Q=0,at15q=0;for(at15P=0;at15P<at15R.length;at15P++){at15r=at15X(at15R[at15P]);at15Q=at15r[0];at15q=at15r[1];if(at15x<at15Q+at15R[at15P].clientWidth&&at15W<at15q+at15R[at15P].clientHeight){if(at15S>at15Q&&at15s>at15q){if(at15R[at15P].style.visibility!='hidden'){at15R[at15P].at15p=true;at15R[at15P].style.visibility='hidden';}}}}}
at15N();return false;}
function at15N(){if(at15n)
return;var at15M=addthis_options.replace(/\s/g,'');var at15m=at15M.split(',');for(var at15P=0;at15P<at15m.length;at15P++){var at15L=at15m[at15P];if(at15L in at15y){var at15l=at15I('addthis_'+at15L+'15');if(at15l)
at15l.src=at15o+at15y[at15L][1];}}
at15n=true;}
function addthis_close(){at15A=setTimeout("addthis_closewin15()",0764);}
function addthis_closewin15(){var at15t=at15I('addthis_dropdown15');at15t.style.display='none';var at15R=document.getElementsByTagName('embed');if(addthis_hide_embed){for(at15P=0;at15P<at15R.length;at15P++){if(at15R[at15P].at15p)
at15R[at15P].style.visibility='visible';}}
return false;}
function addthis_sendto(at15K){if(at15K=='email'){atshow(at15K);return false;}
addthis_closewin15();if(at15K=='favorites'){if(document.all)
window.external.AddFavorite(addthis_url,addthis_title);else
window.sidebar.addPanel(addthis_title,addthis_url,'');return false;}
if(at15K=='stumbleupon')
at15K='su';if(at15K=='sk*rt')
at15K='skrt';window.open(at15k(at15K),'addthis','scrollbars=yes,menubar=no,width=620,height=500,resizable=yes,toolbar=no,location=no,status=no');return false;}
function at15k(at15K){var at15J=encodeURIComponent(addthis_url);var at15j=encodeURIComponent(addthis_title);var at15H=encodeURIComponent(addthis_logo);return'http://www.addthis.com/bookmark.php?v=15&winname=addthis&pub='+addthis_pub+'&s='+at15K+'&url='+at15J+'&title='+at15j+'&logo='+at15H+'&logobg='+addthis_logo_background+'&logocolor='+addthis_logo_color;}
function at15X(at15h){var at15G=0,at15g=0;do{at15G+=at15h.offsetTop||0;at15g+=at15h.offsetLeft||0;at15h=at15h.offsetParent;}while(at15h);return[at15g,at15G];}
function at15V(){var at15F=0;var at15f=0;if(typeof(window.innerWidth)=='number'){at15F=window.innerWidth;at15f=window.innerHeight;}else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){at15F=document.documentElement.clientWidth;at15f=document.documentElement.clientHeight;}else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){at15F=document.body.clientWidth;at15f=document.body.clientHeight;}
return[at15F,at15f];}
function at15T(){var at15D=0;var at15d=0;if(typeof(window.pageYOffset)=='number'){at15d=window.pageYOffset;at15D=window.pageXOffset;}else if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){at15d=document.body.scrollTop;at15D=document.body.scrollLeft;}else if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){at15d=document.documentElement.scrollTop;at15D=document.documentElement.scrollLeft;}
return[at15D,at15d];}
function at15C(){var at15c=document.createElement('link');at15c.rel='stylesheet';at15c.type='text/css';at15c.href=addthis_css;at15c.media='all';document.lastChild.firstChild.appendChild(at15c);}
function at15B(){at15b();at15C();var at15o0='<div id="addthis_dropdown15" onmouseover="addthis_clearclosewin15()" onmouseout="addthis_close()" style="z-index: 1000000; position: absolute; display: none">';at15o0+='<table width="100%" cellpadding="2" cellspacing="0" style="background-color: #EEEEEE; height: 18px">';at15o0+='<tr><td style="font-size: 12px; color: #666666; padding-left:3px"><span id="at_caption">Bookmark&nbsp;&amp;&nbsp;Share</span></td><td align="right" style="font-size: 9px; color: #666666; padding-right: 3px">'+addthis_brand+'</td></tr>';at15o0+='</table>';var at15O0=false;at15o0+='<div id="at_share">';at15o0+='<table id="addthis_services" width="100%" cellpadding="0" style="font-family: Verdana, Arial; font-size: 11px">';at15o0+='<tr><td colspan="2" style="height: 0px"></td></tr>';var at15m=addthis_options.split(',');for(var at15P=0;at15P<at15m.length;at15P++){var at15L=at15m[at15P];if(at15L in at15y){if(!at15O0)
at15o0+='<tr>';at15o0+='\x3ctd width=\"50%\" style=\"height: 19px\">\x3ca href=\"/\" onclick=\"return addthis_sendto(\''+at15L+'\');\">\x3cimg id=\"addthis_'+at15L+'15" alt="" width="16" height="16" />&nbsp; '+at15y[at15L][0]+'</a></td>';if(at15O0)
at15o0+='</tr>';at15O0=!at15O0;}}
if(at15O0)
at15o0+='<td></td></tr>';at15o0+='<tr><td colspan="2" style="height: 2px"></td></tr>';at15o0+='</table>';at15o0+='\x3c/div>\n';at15o0+='<div id="at_email" style="display: none; font-size: 11px; padding-left: 20px; padding-top: 6px">';at15o0+='<table border="0">';at15o0+='<tr><td style="font-size: 12px">To:</td><td><input id="at_to" type="text" style="width: 130px; height: 18px; font-size: 11px; font-family: Arial; color: #999999" value=" email address" onfocus="checkto(this)" /></td</tr>';at15o0+='<tr><td style="font-size: 12px">From:</td><td><input id="at_from" type="text" style="width: 130px; height: 18px; font-size: 11px; font-family: Arial; color: #999999" value=" email address" onfocus="checkto(this)"/></td</tr>';at15o0+='<tr><td style="font-size: 12px" valign="top">Note:</td><td><textarea id="at_msg" style="width: 130px; height: 36px; font-size: 11px; font-family: Arial;"/></textarea></td</tr>';at15o0+='<tr><td colspan="2" align="right"><span id="at_success" style="font-size: 10px; color: #777777;"></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="Send" onclick="return addthis_send()" style="font-size: 9px"/></td</tr>';at15o0+='</table>';at15o0+='\x3c/div>\n';at15o0+='<table width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color: #EEEEEE">';at15o0+='<tr><td colspan="2" align="right" style="padding: 0px; padding-right: 10px; height: 11px"><img id="at_img" src="'+at15Y+'select_load.png" style="width: 1px; height: 1px" /><a href="http://www.addthis.com" target="_blank" style="height: 6px; padding: 0px"><img src="'+at15o+'addthis-mini.gif" border="0" style="padding: 0px; width: 50px; height: 9px" alt="" /></a></td></tr>';at15o0+='\x3c/table>\n';at15o0+='\x3c/div>\n';at15l0=document.createElement('div');at15l0.innerHTML=at15o0;document.body.insertBefore(at15l0,document.body.firstChild);at15l0.style.zIndex=03641100;}
function at15b(){at15n=false;if(typeof addthis_pub=='undefined')
addthis_pub='';if(typeof at15i0=='undefined')
at15i0='Bookmark &amp Share';if(typeof addthis_brand=='undefined')
addthis_brand='';if(typeof addthis_logo=='undefined')
addthis_logo='';if(typeof addthis_logo_background=='undefined')
addthis_logo_background='';if(typeof addthis_logo_color=='undefined')
addthis_logo_color='';if(typeof addthis_options=='undefined')
addthis_options='favorites, digg, delicious, google, myspace, facebook, reddit, newsvine, live, more';if(typeof addthis_offset_top!='number')
addthis_offset_top=0;if(typeof addthis_offset_left!='number')
addthis_offset_left=0;if(typeof addthis_caption_share=='undefined')
addthis_caption_share='Bookmark &amp; Share';if(typeof addthis_caption_email=='undefined')
addthis_caption_email='Email a Friend';if(typeof addthis_css=='undefined')
addthis_css=at15O+'css/152/addthis_widget.css';if(typeof addthis_hide_embed=='undefined')
addthis_hide_embed=true;addthis_options=addthis_options.replace(/\s/g,'');}
function atshow(at15I0){var at15o1=at15I('at_share');var at15O1=at15I('at_email');var at15l1=at15I('at_caption');var at15i1=at15I('at_success');at15o1.style.display='none';at15O1.style.display='none';at15i1.innerHTML='';if(at15I0=='share'||at15I0==''){at15o1.style.display='block';at15l1.innerHTML=addthis_caption_share;}else{at15O1.style.display='block';at15l1.innerHTML=addthis_caption_email;}}
function addthis_send(){var at15I1=at15I('at_from');var at15o2=at15I('at_to');var at15O2=at15I('at_img');var at15i1=at15I('at_success');var at15l2=at15I('at_msg');if(at15I1.value.indexOf('@')<0||at15o2.value.indexOf('@')<0||at15I1.value.indexOf('.')<0||at15o2.value.indexOf('.')<0){alert('Please enter a valid email address!');return;}
at15i2=Math.random();at15I2='http://www.addthis.com/tellfriend.php?pub='+encodeURIComponent(addthis_pub)+'&url='+encodeURIComponent(addthis_url)+'&fromname=aaa&fromemail='+encodeURIComponent(at15I1.value)+'&tofriend='+encodeURIComponent(at15o2.value)+'&note='+encodeURIComponent(at15l2.value)+'&r='+at15i2;at15O2.src=at15I2;at15i1.innerHTML='Message Sent!';at15A=setTimeout("addthis_closewin15()",02260);return false;}
function checkto(at15o3){at15o3.style.color='#000000';if(at15o3.value==' email address')
at15o3.value='';}
at15B();}

LITHIUM.AddThis=Class.create({initialize:function(element,url,title){this.element=element;this.addThisElement=$(this.element).down(".add-this-widget");this.url=url;this.title=title.unescapeHTML();this.addThisIsOpen=false;if(this.addThisElement!=null){this.addEventListeners();}},addEventListeners:function(){Event.observe(this.addThisElement,'click',this.clickAddThis.bindAsEventListener(this));Event.observe(this.addThisElement,'mouseout',this.mouseOutAddThis.bindAsEventListener(this));Event.observe(this.addThisElement,'mouseover',this.mouseOverAddThis.bindAsEventListener(this));},clickAddThis:function(event){Event.stop(event);return addthis_sendto();},mouseOutAddThis:function(event){Event.stop(event);clearTimeout(this.timeout);this.addThisIsOpen=false;addthis_close();},mouseOverAddThis:function(event){Event.stop(event);clearTimeout(this.timeout);if(this.addThisIsOpen==false){this.timeout=setTimeout(function(){this.addThisIsOpen=true;addthis_open(this.addThisElement,'',this.url,this.title)}.bind(this),600);}}});

LITHIUM.TabGroup=Class.create({initialize:function(elementId,tabChangeEvent){var element=$(elementId);var tabLiElements=element.down("ul").childElements();Event.observe(element,tabChangeEvent,function(event){tabLiElements.invoke("removeClassName",LITHIUM.Css.BASE_TABS_ACTIVE).invoke("addClassName",LITHIUM.Css.BASE_TABS_INACTIVE);Event.findElement(event).up("li").removeClassName(LITHIUM.Css.BASE_TABS_INACTIVE).addClassName(LITHIUM.Css.BASE_TABS_ACTIVE);});}});

LITHIUM.CustomEvent={register:function(element,triggerEvent,fireEvent,eventContext){var element=$(element);Event.observe(element,triggerEvent,function(event){var customEvent=element.fire(fireEvent,eventContext);if(customEvent.stopped){event.stop();}});}}

LITHIUM.Jspell=Class.create({initialize:function(element,options){this.options={jspellDisableLearn:false,jspellIgnoreDouble:true,jspellIgnoreNumbers:false,jspellIgnoreUpper:false}
Object.extend(this.options,options||{});LITHIUM.Jspell.elements.set(element);jspellShowOptionsMenu=false;jspellRealtime=false;jspellAutoAttach=false;jspellDialogShowNoErrors=true;jspellAttachToHiddenElements=true;jspellDisableLearn=this.options.jspellDisableLearn;jspellIgnoreDouble=this.options.jspellIgnoreDouble;jspellIgnoreNumbers=this.options.jspellIgnoreNumbers;jspellIgnoreUpper=this.options.jspellIgnoreUpper;jspellPersonalDictionaryType="SERVER";jspellPersonalDictionary='0';jspellCustomRegExp=/^\<.*?\>$/;jspellDialogHalign="center";jspellDialogValign="center";jspellTextLanguage=this.options.jspellTextLanguage;jspellGUILanguage=this.options.jspellTextLanguage;jspellDialogShowNoErrorsMessage=this.options.jspellDialogShowNoErrorsMessage;window.getSpellCheckArray=function(){return LITHIUM.Jspell.elements.values();}}});LITHIUM.Jspell.elements=function(){var elements=new Hash();return{get:function(element){elements.get(element);},set:function(element){elements.set(element,[document,element]);},update:function(element,value){elements.unset(element);elements.set(element,[document,value]);},values:function(){return elements.values();}}}();LITHIUM.Jspell.activate=function(event){LITHIUM.Jspell.initJspell.init();}
LITHIUM.Jspell.initJspell=function(){var initStarted=false;var initialized=false;return{init:function(){if(initStarted==false){initStarted=true;jspellInit();initialized=true;}
jspellCheck();}}}();

LITHIUM.TinyMceEditor=Class.create({initialize:function(element,options,buttons,customPluginSourceTemplate){this.element=element;this.options={useGraphicalEditor:true,useSpellChecker:false,styleSheetUrl:"",useImageUploader:true,useVideo:true,bodyCssClass:""}
Object.extend(this.options,options||{});var customPlugins=["emoticons","customlinkplus","insertcode","customsafari"];var plugins=["inlinepopups","media","paste"];if(this.options.useImageUploader){customPlugins.push("imageuploader");}
if(this.options.useVideo){customPlugins.push("video")}
var urlTemplate=new Template(customPluginSourceTemplate);var customContributedPlugins=!Object.isUndefined(buttons.customPlugins)?String.split(buttons.customPlugins,","):[];$A(customPlugins.concat(customContributedPlugins)).each(function(customPlugin){tinymce.PluginManager.load(customPlugin,urlTemplate.evaluate({customPlugin:customPlugin}));plugins.push("-"+customPlugin);});var tinyMceOptions={mode:"exact",theme:"advanced",auto_focus:LITHIUM.TinyMceEditor.focusBody==true?this.element:false,content_css:this.options.styleSheetUrl,button_tile_map:true,plugins:plugins.join(","),strict_loading_mode:true,theme_advanced_buttons1:"",theme_advanced_buttons2:"",theme_advanced_buttons3:"",theme_advanced_toolbar_location:"top",theme_advanced_toolbar_align:"left",theme_advanced_statusbar_location:"bottom",theme_advanced_resizing:true,theme_advanced_path:false,theme_advanced_resize_horizontal:false,convert_fonts_to_spans:false,inline_styles:false,width:"100%",height:"250px",accessibility_focus:false,convert_urls:false,extended_valid_elements:"span[class],"+"font[face|size|style|id|class|dir|color],"+"object[classid|width|height|codebase|*],"+"embed[wmode|type|width|height|src|*],"+"embed[src|type|wmode|width|height],"+"param[name|value|_value],"+"img[style|class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|obj|param|embed|livideoattrs],"+"li-video[vid|align|size|width|height|originalwidth|originalheight|thumbnail|uploading|external]",execcommand_callback:(function(){if(Prototype.Browser.IE&&parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5))==6){var addedOnunload=false;var selectIframeShims=[];var isInlinePopup=function(command){switch(command){case"mcePasteWord":case"mceEmoticons":case"mceCustomLinkPlus":case"mceImageUploader":return true;default:return false;}}
return function(editor_id,elm,command,user_interface,value){var isInline=isInlinePopup(command);if(isInline){$$('select').each(function(select){var iframeElement=new Element("iframe",{"id":"dropDownShim","src":"javascript:void(0);","style":"display:none;"});document.body.appendChild(iframeElement);iframeElement.setStyle({"zIndex":"500","position":"absolute","frameborder":"0","border":"0"});iframeElement.clonePosition(select);iframeElement.show();selectIframeShims.push(iframeElement);});if(!addedOnunload){addedOnunload=true;tinymce.EditorManager.activeEditor.windowManager.onClose.add(function(){if(isInline){for(var i=0;i<selectIframeShims.length;i++){var iframe=selectIframeShims[i];iframe.hide();}
selectIframeShims=[];}});}}}}else{return function(){};}})(),oninit:this.loaded.bindAsEventListener(this),init_instance_callback:this.loaded.bindAsEventListener(this)};Object.extend(tinyMceOptions,buttons||{});tinyMCE.init(tinyMceOptions);if(this.options.useGraphicalEditor==true){tinyMCE.execCommand("mceAddControl",false,this.element);}
LITHIUM.observeWindowBeforeUnload(function(){if(tinyMCE&&tinyMCE.triggerSave){tinyMCE.triggerSave();}});Event.observe($(this.element).up("form"),"submit",function(){tinyMCE.execCommand("mceCleanup")});},loaded:function(inst){if(this.options.useSpellChecker){LITHIUM.Jspell.elements.update(inst.editorId,inst.editorId+"_ifr");}}});LITHIUM.TinyMceEditor.isActive=function(element){return!Object.isUndefined(tinyMCE.get(element));}
LITHIUM.TinyMceEditor.focusBody=false;LITHIUM.TinyMceEditor.insertTextAtCursor=function(fieldElement,text,tinyMceOverrideText){if(typeof text!="undefined"&&text!=""){if(LITHIUM.TinyMceEditor.isActive(fieldElement.id)){if(typeof tinyMceOverrideText!="undefined"){text=tinyMceOverrideText;}
tinyMCE.execInstanceCommand(fieldElement.id,'mceInsertContent',false,text);}else{if(document.selection){fieldElement.focus();sel=document.selection.createRange();sel.text=text;}
else if(fieldElement.selectionStart||fieldElement.selectionStart=='0'){var startPos=fieldElement.selectionStart;var endPos=fieldElement.selectionEnd;var restoreTop=fieldElement.scrollTop;fieldElement.value=fieldElement.value.substring(0,startPos)
+text
+fieldElement.value.substring(endPos,fieldElement.value.length);if(restoreTop>0){fieldElement.scrollTop=restoreTop;}}else{fieldElement.value+=text;}}}}

LITHIUM.BlockEvents=Class.create({initialize:function(elementId){Event.observe(elementId,"click",function(event){event.stop();});}});

LITHIUM.KeepSessionAlive=Class.create({initialize:function(blankPageUrl,timeOut){if(timeOut>0){window.setInterval(function(){new Ajax.Request(blankPageUrl)},timeOut);}}});

LITHIUM.MessageEditor=Class.create({initialize:function(elementId,tinyMceElementId,previewSubmitElementId,messageEditorTabHiddenCssSelector,convertCrToBrCheckboxElementCssClass,useGraphicalEditor,defaultTabName,tabChangeEvent,macroChangeEvent){this.element=$(elementId);this.tinyMceElement=$(tinyMceElementId);this.previewSubmitElement=$(previewSubmitElementId);this.messageEditorTabHiddenElement=this.element.up("form").down("."+messageEditorTabHiddenCssSelector);this.convertCrToBrCheckbox=this.element.up("form").down("."+convertCrToBrCheckboxElementCssClass);this.useGraphicalEditor=useGraphicalEditor;this.messageEditor=this.element.down(".message-body-editor");this.messagePreview=this.element.down(".message-preview");this.messageEditorControls=this.element.down(".message-editor-controls");this.convertCrToBrCheckbox.setValue(false);tinyMCE.settings.convert_newlines_to_brs=false;this.messageEditorTabHiddenElement.setValue(defaultTabName);if(defaultTabName=="preview"){LITHIUM.FormWatch.FORCE_UNSAVED_DATA_WARNING=true;}
Event.observe(this.element,tabChangeEvent,this.toggleEditorMode.bindAsEventListener(this));Event.observe(this.element,macroChangeEvent,function(event){var selectElement=Event.findElement(event);LITHIUM.TinyMceEditor.insertTextAtCursor(this.tinyMceElement,$H(event.memo.macros).get($F(selectElement)));selectElement.selectedIndex=0;}.bindAsEventListener(this));},toggleEditorMode:function(event){Event.stop(event);var currentTab=$F(this.messageEditorTabHiddenElement);var tabName=event.memo.tab;this.messageEditorTabHiddenElement.setValue(tabName);if(currentTab!=tabName){if(tabName!="preview"){this.messagePreview.hide();this.messageEditor.show();this.messageEditorControls.show()}
if(tabName=="html"){LITHIUM.Jspell.elements.update(this.tinyMceElement.id,this.tinyMceElement.id);tinyMCE.execCommand("mceRemoveControl",false,this.tinyMceElement.id);}else if(tabName=="rich"&&!LITHIUM.TinyMceEditor.isActive(this.tinyMceElement.id)){tinyMCE.execCommand("mceAddControl",false,this.tinyMceElement.id);}else if(tabName=="preview"){LITHIUM.FormWatch.IGNORE_UNSAVED_DATA_WARNING=true;this.previewSubmitElement.click();}}}});LITHIUM.MessageEditor.MessageQuote=function(quoteButtonElementId,tinyMceElementId,text){var tinyMceElementId=tinyMceElementId;var text=text;Event.observe(quoteButtonElementId,'click',function(event){Event.stop(event);LITHIUM.TinyMceEditor.insertTextAtCursor($(tinyMceElementId),text,text+"<p> </p>");});}
LITHIUM.MessageEditor.SpellCheck=function(spellCheckButtonId){Event.observe(spellCheckButtonId,'click',function(event){Event.stop(event);LITHIUM.Jspell.activate();});}

LITHIUM.Captcha=Class.create({initialize:function(reloadLinkId,switchAudioLinkId,switchImageLinkId,showHelpLinkId){$(reloadLinkId).observe('click',function(event){Event.stop(event);Recaptcha.reload();});$(switchAudioLinkId).observe('click',function(event){Event.stop(event);return Recaptcha.switch_type('audio');});$(switchImageLinkId).observe('click',function(event){Event.stop(event);return Recaptcha.switch_type('image');});$(showHelpLinkId).observe('click',function(event){Event.stop(event);return Recaptcha.showhelp();});}});

LITHIUM.Entry=Class.create({initialize:function(inputElementContainer,validationHelpElement){var container=$(inputElementContainer);var inputElements=$(container).select('input');var helpElement=container.down(validationHelpElement);var errorText=container.down("."+LITHIUM.Css.BASE_FORM_ERROR_TEXT);$A(inputElements).each(function(inputElement){Event.observe(inputElement,"focus",function(event){if(LITHIUM.FormFocus.FOCUS_FROM_RULE==true){LITHIUM.FormFocus.FOCUS_FROM_RULE=false;}else{helpElement.show();if(errorText){errorText.hide();}}});Event.observe(inputElement,"click",function(){helpElement.show();if(errorText)errorText.hide()});Event.observe(inputElement,"blur",function(){helpElement.hide();if(errorText)errorText.show()});});}});

LITHIUM.InputEditForm=Class.create({initialize:function(form,options){if(options.swallowEnterEvent){$(form).getInputs().each(function(item){if(!(item.type=='hidden'||item.type=='submit'||item.type=='textarea')){Event.observe(item,'keypress',function(event){if(Event.KEY_RETURN==event.keyCode){Event.stop(event);}});}});}
Object.extend(this.options={useUnsavedDataWarning:false,unloadMessage:"",warnUnsavedDataActionCssClasses:[],ignoreDisableFormDuringSubmitCssClasses:[]},options||{});this.disableFormDuringSubmit=true;var baseButtonCssSelector="."+LITHIUM.Css.BASE_BUTTON;var baseTabLiCssSelector="."+LITHIUM.Css.BASE_TABS_STANDARD+" li";var formActionButtons=Element.select(form,baseButtonCssSelector,baseTabLiCssSelector);Event.observe(form,"submit",function(event){if(this.disableFormDuringSubmit==true){$(form).addClassName(LITHIUM.Css.BASE_FORM_SUBMITTING);formActionButtons.each(function(item){var element=new Element("div").addClassName(LITHIUM.Css.BASE_BUTTON_OVERLAY);item.up().appendChild(element);element.clonePosition(item);item.addClassName(LITHIUM.Css.BASE_DISABLED);});}}.bindAsEventListener(this));formActionButtons.invoke("observe","click",function(event){var clickElement=Event.element(event);$A(this.options.ignoreDisableFormDuringSubmitCssClasses).each(function(item){if(clickElement.hasClassName(item)){this.disableFormDuringSubmit=false;}}.bind(this));}.bindAsEventListener(this));if(this.options.useUnsavedDataWarning===true){new LITHIUM.FormWatch(form,this.options.unloadMessage,formActionButtons,this.options.warnUnsavedDataActionCssClasses);}}});LITHIUM.FormWatch=Class.create({initialize:function(form,message,formActionButtons,warnUnsavedDataActionCssClasses){this.form=$(form);this.submitted=false;this.message=message;this.formActionButtons=formActionButtons;this.warnUnsavedDataActionCssClasses=warnUnsavedDataActionCssClasses;this.clickElement;formActionButtons.invoke("observe","click",function(event){this.clickElement=Event.element(event);}.bindAsEventListener(this));this.originalFormContents=this.form.serialize(true);Event.observe(this.form,"submit",function(event){this.submitted=true;$A(warnUnsavedDataActionCssClasses).each(function(item){if(this.clickElement.hasClassName(item)){this.submitted=false;}}.bind(this));}.bind(this));LITHIUM.observeWindowBeforeUnload(this.confirmExit.bindAsEventListener(this));},confirmExit:function(event){var newFormContents=this.form.serialize(true);if(!this.submitted&&!LITHIUM.FormWatch.IGNORE_UNSAVED_DATA_WARNING){var showUnsavedDataWarning=false;$H(newFormContents).each(function(pair){originalValue=$H(this.originalFormContents).get(pair.key);if(typeof originalValue!="undefined"){var formElement=this.form[pair.key];if(pair.value!=""&&pair.value!=originalValue&&formElement.type!="hidden"){showUnsavedDataWarning=true;}}else if(pair.value!=""&&pair.value!=0&&pair.value!=false){showUnsavedDataWarning=true;}}.bind(this))
if(showUnsavedDataWarning==true||LITHIUM.FormWatch.FORCE_UNSAVED_DATA_WARNING==true){this.form.removeClassName(LITHIUM.Css.BASE_FORM_SUBMITTING);this.formActionButtons.invoke("removeClassName",LITHIUM.Css.BASE_DISABLED);Element.select(this.form,"."+LITHIUM.Css.BASE_BUTTON_OVERLAY).invoke("remove");return this.message;}}}});LITHIUM.FormWatch.IGNORE_UNSAVED_DATA_WARNING=false;LITHIUM.FormWatch.FORCE_UNSAVED_DATA_WARNING=false;LITHIUM.InputEditForm.fieldsetToggle=function(formElementId,triggerElementCssClass,fieldGroupElementCssClass,triggerValue,triggerEvent){var form=$(formElementId);var triggerElements=Element.select(form,"."+triggerElementCssClass);var fieldGroupElementCssClass=fieldGroupElementCssClass;var triggerValue=triggerValue;var fieldsetElement=form.down("."+fieldGroupElementCssClass);$A(triggerElements).each(function(item){Event.observe(item,triggerEvent,function(event){if($F(item)==triggerValue){Form.getElements(fieldsetElement).invoke("enable");fieldsetElement.show();}else{fieldsetElement.hide();Form.getElements(fieldsetElement).invoke("disable");}});});$A(triggerElements).each(function(item){if(item.type!="radio"||(item.type=="radio"&&$F(item)!=null)){if($F(item)==triggerValue){Form.getElements(fieldsetElement).invoke("enable");fieldsetElement.safeShow();}else{Form.getElements(fieldsetElement).invoke("disable");}}});}

LITHIUM.SearchForm=Class.create({'initialize':function(element,nodes){this.element=$(element);this.nodes=nodes;this.searchSelectElement=this.element.down(".search-granularity");this.searchButtonElement=this.element.down("input[type=submit]");Event.observe(this.searchSelectElement,'change',this.updateSearchButtonTitle.bindAsEventListener(this));this.updateSearchButtonTitle();},'updateSearchButtonTitle':function(){var currentOptionValue=$(this.searchSelectElement).value;$A(this.nodes.nodes).each(function(node){if(node.nodeName==currentOptionValue){this.searchButtonElement.title=node.nodeTitle;}}.bind(this));}});LITHIUM.SearchFormAuthorFilterUpdater=Class.create({'initialize':function(initCapsule){LITHIUM.ArgumentChecks.checkObjectFields(initCapsule,{'formElementId':'string','filterParamName':'string','authorFilterParamName':'string','delimiter':'string','equals':'string','toggleRequestParameters':'string','toggleFilter':'string','enterEvent':'string','localizedErrorText':'string','doesUserExistRemoteMethod':'string'});var formRef=$(initCapsule.formElementId);var fieldRef=formRef.down('.search-input');var ajaxFeedback=formRef.down('.AjaxFeedback');LITHIUM.ArgumentChecks.checkNotNull('formRef',formRef,'fieldRef',fieldRef,'ajaxFeedback',ajaxFeedback);function setAuthorValue(values){var newVal="";for(var i=1;i<values.length;i++){newVal+=values[i];if((i+1)<values.length){newVal+=initCapsule.equals;}}
fieldRef.value=newVal;}
function fireRerender(){var valueToFire=initCapsule.authorFilterParamName+initCapsule.equals+fieldRef.value
formRef.fire(initCapsule.toggleFilter,{'paramName':initCapsule.filterParamName,'paramValue':valueToFire,'state':true,'eventRaiser':formRef});}
function errorFeedbackEvent(userName){ajaxFeedback.addClassName(LITHIUM.Css.BASE_FEEDBACK_INLINE_ALERT);ajaxFeedback.down(".ajax-title").update("");ajaxFeedback.down(".ajax-message").update(userName+" "+initCapsule.localizedErrorText);ajaxFeedback.addClassName("ajax-error").removeClassName("hidden");}
function hideFeedbackEvent(){if(!ajaxFeedback.hasClassName("hidden")){ajaxFeedback.addClassName("ajax-error").addClassName("hidden");}}
document.observe(initCapsule.enterEvent,function(event){var searchField=event.memo.searchField;if(searchField&&searchField==fieldRef){Event.stop(event.memo.enterEvent);new Ajax.Request(initCapsule.doesUserExistRemoteMethod,{'method':'post','onSuccess':function(transport){if(transport.responseJSON.response.parameters[0].userExists){hideFeedbackEvent();fireRerender();}
else{errorFeedbackEvent(fieldRef.value);event.memo.onCompleteCallback();}},'parameters':{'userName':fieldRef.value}});}})
document.observe(initCapsule.toggleFilter,function(event){var filterValue=event.memo.paramValue;if(filterValue&&(event.memo.eventRaiser!=formRef)){hideFeedbackEvent();var values=filterValue.split(initCapsule.equals);if(values&&values[0]&&values[0]==initCapsule.authorFilterParamName){if(values.length>1){setAuthorValue(values);}}}});document.observe(initCapsule.toggleRequestParameters,function(event){var filterValues=event.memo.state[initCapsule.filterParamName];var authorInParams=false;if(filterValues){var items=filterValues.split(initCapsule.delimiter);for(var i=0;i<items.length;i++){var temp=items[i].split(initCapsule.equals,2);if(temp[0]&&temp[0]==initCapsule.authorFilterParamName){authorInParams=true;setAuthorValue(temp);hideFeedbackEvent();}}}
if(authorInParams==false){hideFeedbackEvent();fieldRef.value="";}});}});LITHIUM.AdvancedSearchSemaphore=Class.create({'initialize':function(elementId,eventToFireForVisibilityToggle,eventToHandleForVisibilityToggle){LITHIUM.ArgumentChecks.checkNotNull('elementId',elementId,'eventToFireForVisibilityToggle',eventToFireForVisibilityToggle,'eventToHandleForVisibilityToggle',eventToHandleForVisibilityToggle);var elemRef=$(elementId);LITHIUM.ArgumentChecks.checkNotNull('elemRef',elemRef);elemRef.observe('click',function(event){Event.stop(event);elemRef.toggle();elemRef.fire(eventToFireForVisibilityToggle);});document.observe(eventToHandleForVisibilityToggle,function(event){if(!event.memo.toggleFromPriorEvent){elemRef.toggle();}});}});
