
(function(){function setStyleDisplay(id,status){document.getElementById(id).style.display=status;}
function goTop(acceleration,time){acceleration=acceleration||0.1;time=time||16;var dx=0;var dy=0;var bx=0;var by=0;var wx=0;var wy=0;if(document.documentElement){dx=document.documentElement.scrollLeft||0;dy=document.documentElement.scrollTop||0;}
if(document.body){bx=document.body.scrollLeft||0;by=document.body.scrollTop||0;}
var wx=window.scrollX||0;var wy=window.scrollY||0;var x=Math.max(wx,Math.max(bx,dx));var y=Math.max(wy,Math.max(by,dy));var speed=1+acceleration;window.scrollTo(Math.floor(x/speed),Math.floor(y/speed));if(x>0||y>0){var invokeFunction="MGJS.goTop("+acceleration+", "+time
+")";window.setTimeout(invokeFunction,time);}}
window['MGJS']={};window['MGJS']['setStyleDisplay']=setStyleDisplay;window['MGJS']['goTop']=goTop;})();(function(){function reply(authorId,commentId,commentBox){var author=document.getElementById(authorId).innerHTML;var insertStr='<a href="#'+commentId+'">@'
+author.replace(/\t|\n|\r\n/g,"")+' </a>\n';appendReply(insertStr,commentBox);}
function quote(authorId,commentId,commentBodyId,commentBox){var author=document.getElementById(authorId).innerHTML;var comment=document.getElementById(commentBodyId).innerHTML;var insertStr='<blockquote cite="#'+commentBodyId+'">';insertStr+='\n<strong><a href="#'+commentId+'">'
+author.replace(/\t|\n|\r\n/g,"")+'</a> :</strong>';insertStr+=comment.replace(/\t/g,"");insertStr+='</blockquote>\n';insertQuote(insertStr,commentBox);}
function appendReply(insertStr,commentBox){if(document.getElementById(commentBox)&&document.getElementById(commentBox).type=='textarea'){field=document.getElementById(commentBox);}else{alert("The comment box does not exist!");return false;}
if(field.value.indexOf(insertStr)>-1){alert("You've already appended this reply!");return false;}
if(field.value.replace(/\s|\t|\n/g,"")==''){field.value=insertStr;}else{field.value=field.value.replace(/[\n]*$/g,"")+'\n\n'
+insertStr;}
field.focus();}
function insertQuote(insertStr,commentBox){if(document.getElementById(commentBox)&&document.getElementById(commentBox).type=='textarea'){field=document.getElementById(commentBox);}else{alert("The comment box does not exist!");return false;}
if(document.selection){field.focus();sel=document.selection.createRange();sel.text=insertStr;field.focus();}else if(field.selectionStart||field.selectionStart=='0'){var startPos=field.selectionStart;var endPos=field.selectionEnd;var cursorPos=startPos;field.value=field.value.substring(0,startPos)+insertStr
+field.value.substring(endPos,field.value.length);cursorPos+=insertStr.length;field.focus();field.selectionStart=cursorPos;field.selectionEnd=cursorPos;}else{field.value+=insertStr;field.focus();}}
function loadCommentShortcut(frm,submitbnt,desc){document.getElementById(frm).onkeydown=function(moz_ev){var ev=null;ev=window.event?window.event:moz_ev;if(ev!=null&&ev.ctrlKey&&ev.keyCode==13){document.getElementById(submitbnt).click();}};document.getElementById(submitbnt).value+=desc;}
window['CMT']={};window['CMT']['reply']=reply;window['CMT']['quote']=quote;window['CMT']['loadCommentShortcut']=loadCommentShortcut;})();(function(){var Class={create:function(){return function(){this.initialize.apply(this,arguments);};}};var GhostlyMenu=Class.create();GhostlyMenu.prototype={initialize:function(target,align,sub){this.obj=cleanWhitespace(target);this.align=align||'left';this.sub=sub||-1;this.menu=this.obj.childNodes;if(this.menu.length<2){return;}
this.title=this.menu[0];this.body=this.menu[1];cleanWhitespace(this.body).firstChild.getElementsByTagName('a')[0].className+='first';setStyle(this.body,'visibility','hidden');setStyle(this.body,'display','block');addListener(this.obj,'mouseover',bind(this,this.activate),false);addListener(this.obj,'mouseout',bind(this,this.deactivate),false);},activate:function(){if(this.sub==1){var pos=currentOffset(this.title);var top=pos[1]+3;var left=getWidth(this.body)-6;}else{var pos=cumulativeOffset(this.title);var top=pos[1]+getHeight(this.title);var left=pos[0]-1;}
if(!/current/.test(this.title.className)){this.title.className+=' current';}
setStyle(this.body,'left',left+'px');setStyle(this.body,'top',top+'px');setStyle(this.body,'visibility','visible');},deactivate:function(){this.title.className=this.title.className.replace('current','');var t=this;var tid=setInterval(function(){clearInterval(tid);if(!/current/.test(t.title.className)){setStyle(t.body,'visibility','hidden');}
return false;},400);}}
$A=function(iterable){if(!iterable){return[];}
if(iterable.toArray){return iterable.toArray();}else{var results=[];for(var i=0;i<iterable.length;i++){results.push(iterable[i]);}
return results;}}
bind=function(){var array=this.$A(arguments);var func=array[array.length-1];var _method=func,args=array,object=args.shift();return function(){return _method.apply(object,args.concat(array));};}
getHeight=function(element){return element.offsetHeight;}
getWidth=function(element){return element.offsetWidth;}
setStyle=function(element,key,value){element.style[key]=value;}
getStyle=function(element,key){return element.style[key];}
cleanWhitespace=function(list){var node=list.firstChild;while(node){var nextNode=node.nextSibling;if(node.nodeType==3&&!/\S/.test(node.nodeValue)){list.removeChild(node);}
node=nextNode;}
return list;}
currentOffset=function(element){var valueT=element.offsetTop||0;var valueL=element.offsetLeft||0;return[valueL,valueT];}
cumulativeOffset=function(element){var valueT=0,valueL=0;do{valueT+=element.offsetTop||0;valueL+=element.offsetLeft||0;element=element.offsetParent;}while(element);return[valueL,valueT];}
addListener=function(element,name,observer,useCapture){if(element.addEventListener){element.addEventListener(name,observer,useCapture);}else if(element.attachEvent){element.attachEvent('on'+name,observer);}}
function loadMenus(){var menubar=document.getElementById('navigation');if(menubar){var list=menubar.getElementsByTagName('ul');for(var i=0;i<list.length;i++){var menu=list[i].parentNode;if(menu.parentNode===menubar){new GhostlyMenu(menu,'left');}else{new GhostlyMenu(menu,'left',1);menu.firstChild.className+=' subtitle';}}}}
if(document.addEventListener){document.addEventListener("DOMContentLoaded",loadMenus,false);}else if(/MSIE/i.test(navigator.userAgent)){document.write('<script id="__ie_onload_for_elegantbox" defer src="javascript:void(0);"></script>');var script=document.getElementById("__ie_onload_for_elegantbox");script.onreadystatechange=function(){if(this.readyState=='complete'){loadMenus();}}}else if(/WebKit/i.test(navigator.userAgent)){var _timer=setInterval(function(){if(/loaded|complete/.test(document.readyState)){clearInterval(_timer);loadMenus();}},10);}else{window.onload=function(e){loadMenus();};}})();
