
gSiteLife.mi={};var urlTS=new Date();gSiteLife.mi.commenting={submitReturnAddress:'http://'+location.host+location.pathname+"?mi_pluck_action=comment_submitted&qwxq="+Math.floor(Math.random()*10000)+urlTS.getMilliseconds()+"#Comments_Container"};gSiteLife.mi.userLoggedIn=function(){if(this.loggedIn===undefined){var cookies=document.cookie.split(';');var insiteCrumb=false;var pluckCrumb=false;for(var i=cookies.length-1;i>=0;i--){if(cookies[i].match(/^\s*AT=/)||cookies[i].match(/^\s*HD=/)){pluckCrumb=true;}
else if(cookies[i].match(/_user_auth=/)){insiteCrumb=true;}}
this.loggedIn=(insiteCrumb&&pluckCrumb);}
return this.loggedIn;};
var NYX={version:"0.6"};NYX.fixConsole=function(){if(typeof window.console!="object"){window.console={};}
if(window.console.isNyxxed){}
else{var firebugMethods=["log","debug","info","warn","error","assert","dir","dirxml","trace","group","groupEnd","time","timeEnd","profile","profileEnd","count"];for(var methodIdx=0;methodIdx<firebugMethods.length;methodIdx++){var methodName=firebugMethods[methodIdx];if(typeof window.console[methodName]!="function"){window.console[methodName]=function(){};}}}
window.console.isNyxxed=true;};NYX.fixConsole();console.info("Nyx library loaded, version "+NYX.version);NYX.cache={};NYX.ieSafeExecution=function(){var This=this;this.timeoutLength=200;if(typeof arguments[0]!="function"){throw("First parameter to NYX.ieSafeExecution is required and must be a function");}else{this.functionToCall=arguments[0];}
this.execute=function(){if(typeof This.arguments=="undefined"){This.arguments=arguments;}
if(typeof document.body.attachEvent=="object"&&(document.readyState!="loaded"&&document.readyState!="complete")){if(typeof console=="object"){console.log("in the IE block");}
try{document.documentElement.doScroll("left");This.functionToCall.apply(This.functionToCall,This.arguments);}catch(error){setTimeout(This.execute,This.timeoutLength);}}else{if(typeof console=="object"){console.log("executing immediately");}
This.functionToCall.apply(This.functionToCall,This.arguments);}};};NYX.util={};NYX.util.makePuid=function(optExtraDigits,optBase){var timeSeed,rnd,puid;if(typeof optExtraDigits!="number"){optExtraDigits=5;}
if(typeof optBase!="number"){optBase=32;}
timeSeed=(new Date().valueOf())-Date.parse("1/1/2008");rnd=Math.random().toString().substr(2,optExtraDigits);puid=parseInt(timeSeed+""+rnd).toString(optBase);return puid;};NYX.util.querystring={get:function(name){var key=name+"=";var nameValuePairs=document.location.search.substring(1).split("&");for(var pairIdx=0;pairIdx<nameValuePairs.length;pairIdx++){if(nameValuePairs[pairIdx].indexOf(key)===0){return nameValuePairs[pairIdx].substring(key.length);}}
return null;},set:function(name,value,optExistingQS){var qs;if(typeof optExistingQS!="string"){qs=location.search;}else{qs=optExistingQS;}
var theReturn=qs;if(typeof value=="undefined"){value="";}
var nvp=encodeURI(name+"="+value);if(qs===""){theReturn=nvp;}else if(!NYX.util.string.contains(qs,name)){theReturn=qs+"&"+nvp;}else{var regex=new RegExp("("+name+"=[^&^]*)","gi");var qsm=qs.match(regex);if(qsm!==null){theReturn=qs.replace(qsm,nvp);}}
if(!NYX.util.string.startsWith(theReturn,"?")){theReturn="?"+theReturn;}
return theReturn;}};NYX.util.obj={extend:function(targetClass,parentClass){for(var member in parentClass){targetClass[member]=parentClass[member];}
return targetClass;}};NYX.util.array={contains:function(theArray,match){if(theArray.length){for(var idx=0;idx<theArray.length;idx++){if(theArray[idx]==match){return true;}}}
return false;}};NYX.util.string={contains:function(source,match,optIgnoreCase){if(optIgnoreCase){source=source.toLowerCase();match=match.toLowerCase();}
return(source.indexOf(match)>-1);},replaceAll:function(source,match,replacement){replacement=replacement.replace(/\$/g,'tom MI.dollar sawyer');while(this.contains(source,match)){source=source.replace(match,replacement);}
source=source.replace(/tom MI\.dollar sawyer/g,'$');return source;},ensure:function(arg){if(typeof arg=="string"){return arg;}
if(arg===null||typeof arg=="undefined"){return"";}
return arg.toString();},trim:function(stringToTrim){stringToTrim=this.ensure(stringToTrim);return stringToTrim.replace(/(^\s+|\s+$)/g,"");},isBlank:function(source){return(this.trim(source)==="");},startsWith:function(source,match,optIgnoreCase){return(source.substring(0,match.length)==match);},endsWith:function(source,match,optIgnoreCase){if(optIgnoreCase){source=source.toLowerCase();match=match.toLowerCase();}
return(source.substring(source.length-match.length)==match);}};NYX.util.dom={getElementsByClass:function(className,optElem){var theReturn=[];if(typeof optElem=="undefined"){var elem=document.body;}
var children=elem.getElementsByTagName("*");for(var childIdx=0;childIdx<children.length;childIdx++){var child=children[childIdx];if(typeof child.className=="string"&&this.elemHasClass(child,className)){theReturn.push(child);}}
return theReturn;},elemHasClass:function(elem,className){var currentClasses=elem.className.toLowerCase().split(/\s+/g);return NYX.util.array.contains(currentClasses,className.toLowerCase());}};NYX.TemplateTool={DOM_TARGET_SUFFIX:"dynamicContent",DOM_WAITMSG_SUFFIX:"waitMsg",ALT_CLASS_2:"nyx2",ALT_CLASS_3:"nyx3",getElem:function(idSuffix){return document.getElementById(this.idRoot+"_"+idSuffix);},getIndexedElem:function(idSuffix,index){return document.getElementById(this.idRoot+"_"+idSuffix+"_"+index);},showElem:function(idSuffix){var elem=this.getElem(idSuffix);if(elem!==null){elem.style.display="";}},flattenDaapiItem:function(daapiItem){var flatData={};for(var child in daapiItem){if(daapiItem[child]===null){flatData[child]=null;}else if(typeof daapiItem[child]!="object"){flatData[child]=daapiItem[child];}else{if(typeof daapiItem[child].join=="function"&&typeof daapiItem[child].length=="number"){flatData[child]=daapiItem[child];}else{for(var grandchild in daapiItem[child]){if(typeof flatData[grandchild]=="undefined"){flatData[grandchild]=daapiItem[child][grandchild];}}}}}
return flatData;},processTemplate:function(dataObj,template){var regex,template,matches,matchIdx,theMatch,varName;regex=/\@Nyx\.[^\@]+\@/g;matches=template.match(regex);if(matches!==null){for(matchIdx=0;matchIdx<matches.length;matchIdx++){theMatch=matches[matchIdx];varName=theMatch.substring(5,theMatch.length-1);if(typeof dataObj[varName]!="undefined"){template=NYX.util.string.replaceAll(template,theMatch,dataObj[varName]);}}}
return template;},applyAltClasses:function(itemIndex,template){var className,templateVariable;templateVariable="@Nyx.AlternateClass@";if(template.indexOf(templateVariable)>-1){className=" ";if((itemIndex+1)%2===0){className+=this.ALT_CLASS_2+" ";}
if((itemIndex+1)%3===0){className+=this.ALT_CLASS_3+" ";}
template=NYX.util.string.replaceAll(template,templateVariable,className);}
return template;},showTarget:function(domTarget){var waitingMsgElem=this.getElem(this.DOM_WAITMSG_SUFFIX);if(waitingMsgElem!==null){waitingMsgElem.style.display="none";}
if(domTarget!==null){domTarget.style.display="";}}};function requestPluckUserAvatar(){var requestBatch=new RequestBatch();var currentUser=retrieveSSOCookieUserId();if(currentUser!==''&&currentUser!='undefined'){currentUser=hex_md5(currentUser);}
var userKey=new UserKey(currentUser);requestBatch.AddToRequest(userKey);requestBatch.BeginRequest(serverUrl,renderUserAvatar);}
function renderUserAvatar(responseBatch){var user=retrieveSSOCookieUserId();console.log('user = '+retrieveSSOCookieUserId());if(user===null){}else{var user=responseBatch.Responses[0].User;var avatar=document.createElement('a');avatar.href='/personas?plckUserId='+user.UserKey.Key+'&insiteUserId='+user.UserKey.Key;var genericAvatar=document.getElementById("avatar");var newImg=genericAvatar.cloneNode();newImg.src=user.AvatarPhotoUrl;avatar.appendChild(newImg);genericAvatar.replaceChild(avatar,genericAvatar);}}

NYX.CurrentUser=function(idRoot){NYX.util.obj.extend(this,NYX.TemplateTool);this.idRoot=idRoot;this.userTemplate="";this.guestTemplate="";this.prepareData=function(user){var dataObj=this.flattenDaapiItem(user);return dataObj;};this.writeGui=function(user){var flatUser,targetElem;flatUser=this.prepareData(user);targetElem=this.getElem(this.DOM_TARGET_SUFFIX);if(targetElem!==null){this.initGui(targetElem);if(user.UserTier.toLowerCase()=="anonymous"||gSiteLife.mi.userLoggedIn()===false){targetElem.innerHTML=this.processTemplate(flatUser,this.guestTemplate);}else{targetElem.innerHTML=this.processTemplate(flatUser,this.userTemplate);}
this.finishGui(targetElem);this.showTarget(targetElem);}};this.initGui=function(domTarget){return true;};this.finishGui=function(domTarget){return true;};};