if(document.all&&!document.getElementById){document.getElementById=function(A){return document.all[A]}}function BlockSubmit(B,C){var A=B.keyCode||B.which;if(A==13){C();return false}else{return true}}function CheckAll(B){var A=Explode(B,",");for(j=0;j<A.length;j++){CheckSwitch(A[j],true)}}function CheckNone(B){var A=Explode(B,",");for(j=0;j<A.length;j++){CheckSwitch(A[j],false)}}function CheckSwitch(C,A){var B=document.getElementsByTagName("input");for(i=0;i<B.length;i++){if(B[i].type=="checkbox"&&B[i].id.indexOf(C)==0){B[i].checked=A}}}function ClearContents(A){if(A){A.innerHTML=""}}function CompletePreferenceSet(B){var A=document.getElementById(B);if(A){A.className="PreferenceComplete"}}function Explode(B,A){return B.split(A)}function Focus(A){var B=document.getElementById(A);if(B){B.focus()}}function GetElements(A,B){var D=document.getElementsByTagName(A);var C=new Array();for(i=0;i<D.length;i++){if(D[i].id.indexOf(B)==0){C[C.length]=D[i]}}return C}function HideElement(A,C){var B=document.getElementById(A);if(B){B.style.display="none";if(C==1){ClearContents(B)}}}function PathFinder(){this.params=new function(){this.url=document.URL;this.domain=document.domain;this.httpMethod=this.url.replace(/^(http|https)(:\/\/).*$/,"$1$2");return this};this.getRootPath=function(C,B,F){var A=document.getElementsByTagName(C);var G="";var D="";for(var E=0;E<A.length;E++){G="";if(A[E].getAttribute&&A[E].getAttribute(B)){G=A[E].getAttribute(B)}else{if(A[E][B]){G=A[E][B]}}if(G.match(F)){D=G.replace(F,"");D=D.replace(/^http(s)?:\/\/[^\/]+/,"");break}}return D||false};return this}function PopTermsOfService(A){window.open(A,"TermsOfService","toolbar=no,status=yes,location=no,menubar=no,resizable=yes,height=600,width=400,scrollbars=yes")}function PreferenceSet(A){setTimeout("CompletePreferenceSet('"+this.Param+"');",400)}function RefreshPage(A){if(!A){A=400}setTimeout("document.location.reload();",A)}function RefreshPageWhenAjaxComplete(A){RefreshPage()}function SubmitForm(C,A,B){Wait(A,B);document[C].submit()}function SwitchElementClass(C,F,A,G,E,D){var B=document.getElementById(C);Sender=document.getElementById(F);if(B&&Sender){if(B.className==G){B.className=A;Sender.innerHTML=E}else{B.className=G;Sender.innerHTML=D}}}function SwitchExtension(E,F,D){var C=document.getElementById(F);if(C){C.className="Processing"}var B="ExtensionKey="+F+"&PostBackKey="+D;var A=new DataManager();A.Param=F;A.RequestFailedEvent=SwitchExtensionResult;A.RequestCompleteEvent=SwitchExtensionResult;A.LoadData(E+"?"+B)}function SwitchExtensionResult(B){var A=document.getElementById(Trim(B.responseText));if(A){setTimeout("SwitchExtensionItemClass('"+Trim(B.responseText)+"')",400)}else{alert(Trim(B.responseText))}}function SwitchExtensionItemClass(C){var B=document.getElementById(C);var A=document.getElementById("chk"+C+"ID");if(B&&A){B.className=A.checked?"Enabled":"Disabled"}}function SwitchPreference(G,F,C,E){var A=document.getElementById(F);var D=document.getElementById(F+"ID");if(D&&A){A.className="PreferenceProgress";var B=new DataManager();B.Param=F;B.RequestFailedEvent=HandleFailure;if(C==1){B.RequestCompleteEvent=RefreshPageWhenAjaxComplete}else{B.RequestCompleteEvent=PreferenceSet}B.LoadData(G+"?Type="+F+"&PostBackKey="+E+"&Switch="+D.checked)}}function Trim(A){return A.replace(/^\s*|\s*$/g,"")}function UpdateCheck(D,B,C){var A=new DataManager();A.RequestCompleteEvent=UpdateCheckStatus;A.RequestFailedEvent=UpdateCheckStatus;A.Param=D;A.LoadData(D+"?RequestName="+B+"&PostBackKey="+C)}function UpdateCheckStatus(E){if(E.responseText=="COMPLETE"){return }var F=E.responseText.substring(0,E.responseText.indexOf("|"));if(F=="First"){var B=document.getElementById("Core");var G=document.getElementById("CoreDetails")}else{var B=document.getElementById(F);var G=document.getElementById(F+"Details")}var D=E.responseText.slice(E.responseText.indexOf("|")+1);var A=document.getElementById("FormPostBackKey");var C=(A)?A.value:"";if(B&&G){if(D.indexOf("ERROR]")==1){B.className="UpdateError";G.innerHTML=D.replace(/\[ERROR\]/g,"")}else{if(D.indexOf("OLD]")==1){B.className="UpdateOld"}else{if(D.indexOf("UNKNOWN]")==1){B.className="UpdateUnknown"}else{B.className="UpdateGood"}}G.innerHTML=D.replace(/\[OLD\]/g,"").replace(/\[UNKNOWN\]/g,"").replace(/\[GOOD\]/g,"");setTimeout("UpdateCheck('"+this.Param+"', '"+F+"', '"+C+"');",300)}}else{alert("Error: "+E.responseText)}}function Wait(A,C){A.disabled=true;A.value=C;var B=A.parentNode;while(B!=null){if(B.tagName=="FORM"){B.submit();break}B=B.parentNode}}function WriteEmail(D,B,G,A){if(document.createElement&&document.getElementById){var E,C,F;E=document.createElement("a");E.href="mailto:"+B+"@"+D;G=G||B+"@"+D;F=document.createTextNode(G);E.appendChild(F);C=document.getElementById(A);if(C){C.parentNode.appendChild(E)}}}function showById(A){document.getElementById(A).style.display="block"};
function show(id){document.getElementById(id).style.display='block';}
function hide(id){document.getElementById(id).style.display='none';}
function SetNotifi(Type,ElementID,Value,Elem,Class,NewText){var pathFinder,root,ajax;pathFinder=new PathFinder();root=pathFinder.getRootPath('script','src','js/global.js')||pathFinder.getRootPath('script','src',/extensions\/LowCalVanilla\/packer\.php.*$/)||'';ajax=new Ajax.Request(root+'extensions/Notifi/ajax.php',{parameters:'PostBackAction=ChangeNotifi&Type='+Type+'&ElementID='+ElementID+'&Value='+Value,onSuccess:function(r){if(Type==="ALL"&&Elem==="NotifiAllCont"){if(Value===1){hide('NotifiOwnCont');hide('NotifiCommentCont');hide('categoriesContainer');hide('discussionsContainer');}else if(!Value){show('NotifiOwnCont');show('NotifiCommentCont');show('categoriesContainer');show('discussionsContainer');}}
if(Type==="COMMENT"&&Elem==="NotifiCommentCont"){if(Value===1){hide('NotifiOwnCont');}else if(!Value){show('NotifiOwnCont');}}
if(Elem==="SetNotifiAll"||Elem==="SetNotifiDiscussion_"+ElementID||Elem==="SetNotifiCategory_"+ElementID){Element.removeClassName(Elem,Class);if(NewText){Elem.innerHTML=NewText;}
$(Elem).innerHTML=NewText;}else{Element.removeClassName(Elem,Class);if(NewText){Elem.innerHTML=NewText;}}}});return true;}
function NotifiCat(CategoryID){Element.addClassName('NotifiCatCont_'+CategoryID,'PreferenceProgress');if($('NotifiCat_'+CategoryID).checked==true)Value=1;else Value=0;SetNotifi('CATEGORY',CategoryID,Value,'NotifiCatCont_'+CategoryID,'PreferenceProgress','');}
function NotifiDiscussion(DiscussionID){Element.addClassName('NotifiDiscussionCont_'+DiscussionID,'PreferenceProgress');if($('NotifiDiscussion_'+DiscussionID).checked==true)Value=1;else Value=0;SetNotifi('DISCUSSION',DiscussionID,Value,'NotifiDiscussionCont_'+DiscussionID,'PreferenceProgress','');}
function PNotifiAll(SetText,UnSetText){Element.addClassName('SetNotifiAll','Progress');if($('SetNotifiAll').innerHTML==SetText){Value=1;NewText=UnSetText;}else{Value=0;NewText=SetText;}
SetNotifi('ALL',0,Value,'SetNotifiAll','Progress',NewText);}
function PNotifiCategory(CategoryID,SetText,UnSetText){Element.addClassName('SetNotifiCategory_'+CategoryID,'Progress');if($('SetNotifiCategory_'+CategoryID).innerHTML==SetText){Value=1;NewText=UnSetText;}else{Value=0;NewText=SetText;}
SetNotifi('CATEGORY',CategoryID,Value,'SetNotifiCategory_'+CategoryID,'Progress',NewText);}
function PNotifiDiscussion(DiscussionID,SetText,UnSetText){Element.addClassName('SetNotifiDiscussion_'+DiscussionID,'Progress');if($('SetNotifiDiscussion_'+DiscussionID).innerHTML==SetText){Value=1;NewText=UnSetText;}else{Value=0;NewText=SetText;}
SetNotifi('DISCUSSION',DiscussionID,Value,'SetNotifiDiscussion_'+DiscussionID,'Progress',NewText);}
function NotifiAll(){Element.addClassName('NotifiAllCont','PreferenceProgress');if($('NotifiAllField').checked==true)Value=1;else Value=0;SetNotifi('ALL',0,Value,'NotifiAllCont','PreferenceProgress','');}
function NotifiOwn(){Element.addClassName('NotifiOwnCont','PreferenceProgress');if($('NotifiOwnField').checked==true)Value=1;else Value=0;SetNotifi('OWN',0,Value,'NotifiOwnCont','PreferenceProgress','');}
function NotifiComment(){Element.addClassName('NotifiCommentCont','PreferenceProgress');if($('NotifiCommentField').checked==true)Value=1;else Value=0;SetNotifi('COMMENT',0,Value,'NotifiCommentCont','PreferenceProgress','');}
function KeepEmailing(){Element.addClassName('KeepEmailingCont','PreferenceProgress');if($('KeepEmailingField').checked==true)Value=1;else Value=0;SetNotifi('KEEPEMAILING',0,Value,'KeepEmailingCont','PreferenceProgress','');}
