var ajaxCounter=0;
function enhance(){f();
$$("input[alt]").each(function(g){new OverText(g)
});
a();
new Tips($$(".tip"),{fixed:true,className:"helpTip",offset:{x:20,y:-10}});
$$("#FlashMessage.messageBox").each(function(g){displayMessage(g.dispose().get("html"))
});
if(!Browser.Engine.trident){c()
}try{var d=_gat._getTracker("UA-15053055-1");
d._trackPageview()
}catch(e){}function a(){var i=null;
var h=null;
$$("form *[name][type!=hidden]").some(function(j){if(j.get("value")&&j.get("value")!=""){return false
}if(j.get("tag")=="input"&&(j.get("type")=="text"||j.get("type")=="password"||j.get("type")=="file")||j.get("tag")=="textarea"||j.get("tag")=="select"){if(j.get("alt")){i=j
}else{h=j;
return true
}}return false
});
if(h){g(h)
}else{if(i){g(i)
}}function g(k){Log.logger("positioning... cursor, "+k.get("name"));
var j=$(document.body).getScroll();
k.focus();
Log.logger("positioned cursor");
$(document.body).scrollTo(j.x,j.y)
}}function f(){var g=new Hash();
$$("input[name=md5]").each(function(h){var i=h.getParent("form");
g[i.get("name")]=h.get("value");
i.addEvent("submit",function(j){i.set("submitting","Y");
$type(i.update)=="function"&&i.update()
});
window.onbeforeunload=function(){if(i.get("submitting")=="Y"){return
}$type(i.update)=="function"&&i.update();
var k=makeQueryString(i);
var j=MD5(k);
if(g[i.get("name")]!=j){Log.logger("queryString="+k);
Log.logger("MD5="+j);
return"If you leave this page now your changes will be lost."
}else{return
}}
})
}function c(){if(window.parent!=window){$$("form[enctype!=multipart/form-data]").each(function(g){Log.logger("found a form");
g.getElements("input[type=submit]").each(function(h){Log.logger("found a button");
h.addEvent("click",function(){new Element("input",{type:"hidden",name:h.get("name"),value:h.get("value")}).inject(g)
})
});
g.addEvent("submit",function(h){h.stop();
Log.logger("submitting form via ajax");
this.set("send",{onSuccess:function(){Log.logger("submitted form via ajax");
window.document.open();
window.document.write(this.response.text);
window.document.close()
}});
this.send()
})
})
}}function b(i,h){var k=i.indexOf("<"+h);
if(k!=-1){k=i.indexOf(">",k)+1;
var g=i.indexOf("</"+h+">");
var j=i.substring(k,g);
Log.logger("tagHtml="+j);
return j
}return""
}}function updateCounter(b,a){$(b);
if(b.get("value").length>a){b.get("value")=b.get("value").substr(0,a)
}b.getNext("p").getFirst("span").set("text",""+(a-b.get("value").length))
}function readAndIncrement(b){var a=parseInt(b.get("value"));
b.set("value",a+1);
return a
}function injectCssAndScriptTags(a){a.getElements("link[rel=STYLESHEET]").each(function(b){b.inject(window.document.head)
});
a.getElements("script").each(function(b){b.get("src")&&window.document.body.getElement("script[src="+b.get("src")+"]")||b.inject(window.document.body)
})
}var BetterSortables=new Class({Extends:Sortables,start:function(b,a){if(!this.idle){return
}this.idle=false;
this.element=a;
this.opacity=a.get("opacity");
this.list=a.getParent();
this.clone=this.getClone(b,a);
this.drag=new Drag.Move(this.clone,{snap:this.options.snap,container:this.options.constrain&&this.element.getParent(),droppables:this.getDroppables(),onSnap:function(){b.stop();
this.clone.setStyle("visibility","visible");
this.element.set("opacity",this.options.opacity||0);
this.fireEvent("start",[this.element,this.clone])
}.bind(this),onEnter:this.insert.bind(this),onCancel:this.reset.bind(this),onComplete:this.end.bind(this)});
if(!this.clone.getParent()){this.clone.inject(this.element,"before")
}this.drag.start(b)
}});
function ajaxButtonClick(a,b){new Request.JSON({url:a,onSuccess:function(d,c){if(d.success!=null){b.apply(window,d,c)
}}}).post()
}var messageBox=new Roar({position:"lowerRight"});
function displayMessage(a){messageBox.alert(a,null,{className:"roar info"})
}function displayError(a){messageBox.alert(a,null,{className:"roar error"})
}function makeQueryString(a){var b=[];
a.getElements("[name]").each(function(c){if(c.tagName!="INPUT"&&c.tagName!="SELECT"&&c.tagName!="TEXTAREA"||c.disabled||c.type=="submit"||c.type=="reset"||c.type=="file"||c.hasClass("md5x")||c.get("id")=="recaptcha_challenge_field"){return
}var d=(c.tagName.toLowerCase()=="select")?Element.getSelected(c).map(function(e){return e.value
}):((c.type=="radio"||c.type=="checkbox")&&!c.checked)?null:c.value;
if(typeof d!="undefined"&&d!=null&&d!=""){b.push(c.name+"="+encodeURIComponent(d))
}});
return b.sort().join("&")
}var RecaptchaOptions={theme:"custom"};
function initializeInstantHelp(c,b){var a=new Fx.Slide(c);
$(c.parentNode).addClass("moo");
a.hide();
document.getInstantHelp=function(d){if(d==""){a.slideOut()
}else{new Request({url:b+"/"+d,method:"get",onSuccess:function(e){c.getFirst().set("html",e);
if(a.open&&e.trim()==""){a.slideOut()
}else{if(!a.open&&e.trim()!=""){a.slideIn()
}}}}).send()
}}
}function enableProfileModuleSorting(n){var c=n.getParent("form");
var k=null;
var g=$("NewModule");
var m=$("Top");
var h=$("Left");
var r=$("Right");
var l=$("Unused");
var d=$("Trash");
var i=null;
var p=new Scroller(window.document.body);
k=new (new Class({Extends:BetterSortables,getDroppables:function(){var s=this.element.getElement(".module");
a(s);
return this.parent()
},adjustCloneClass:function(t,s){t.removeClass("W").removeClass("N").removeClass("I").addClass(f(s))
}}))([g,m,h,r,l,d],{opacity:0,clone:true,handle:"h3",onStart:function(s,u){k.lists.each(function(v){v.addClass("dropZone")
});
var t=f(s);
s.store("size",t);
if(t=="W"){s.getElement(".module").addClass("wide")
}i=null;
p.start();
p.attach()
},onSort:function(s,w){this.adjustCloneClass(w,s);
this.drag.mouse.pos.x=Math.floor(w.getSize().x/2);
var v=s.getElement(".module");
if(v.hasClass("redrawWhenMoved")||$type(v.resizeListener)=="function"){var u=f(s);
var t=s.retrieve("size");
s.store("size",u);
if(v.hasClass("redrawWhenMoved")){if(v.hasClass("wide")&&u=="N"||!v.hasClass("wide")&&u=="W"){reconfigureModule(v,w);
v.toggleClass("wide")
}}else{v.resizeListener()
}}},clone:function(u,t){var s=t.getElement(".module");
var v=new Element("div",{"class":"cloneModule",styles:{position:"absolute","z-index":"2"}}).adopt(s.clone(true)).inject(window.document.body).setPosition(s.getPosition());
this.adjustCloneClass(v,t);
return v
},onComplete:function(s){p.stop();
p.detach();
s.getElement(".module").removeClass("wide");
k.lists.each(function(t){t.removeClass("dropZone")
});
if($("NewModule").getElements(".module").length==0){$("NewModuleContainer").addClass("empty")
}q();
e()
}});
function f(s){if(s.getParent("#Top")||s.getParent("#TopFixed")){return"W"
}if(s.getParent("#Left")||s.getParent("#Right")){return"N"
}return"I"
}function a(s){!s.hasClass("allowNarrow")&&k.removeLists(h,r);
!s.hasClass("allowWide")&&k.removeLists(m);
!s.getParent("#NewModule")&&k.removeLists(g)
}function q(){k.removeLists(k.lists);
k.addLists(g,m,h,r,l,d)
}function e(){$(n).set("value",k.serialize(0)+"|"+k.serialize(1)+"|"+k.serialize(2)+"|"+k.serialize(3)+"|"+k.serialize(4)+"|"+k.serialize(5))
}window.reconfigureModule=function(v,x){var t=$(v).hasClass("module")?$(v):$(v).getParent(".module");
var w=t.getElement(".parameters")==null?"":t.getElement(".parameters").toQueryString();
var u=f(t);
c.getElement("[name="+t.getParent("li").get("id").toLowerCase()+"Parameters]").set("value",w);
var s=t.getElement(".moduleContent");
s.set("load",{onComplete:function(){new Element("div",{"class":"cover"}).inject(s);
if($type(t.resizeListener)=="function"){t.resizeListener()
}x.empty().adopt(t.clone(true))
}});
s.load("/Profile/ReconfigureModule/"+o()+"/"+u+"/"+t.getElement("[name=moduleId]").get("value")+"/"+w)
};
function o(){return c.getElement("[name=profilePageId]").get("value")
}window.addModule=function(s){new (new Class({Extends:Request,processScripts:function(t){return t
}}))({url:"/Profile/LoadModule/"+o()+"/I/"+s,method:"get",onSuccess:function(t){b(t,s)
}}).send()
};
function b(u,v){Log.logger("injectModule called");
var t=new Element("div",{html:u});
var w="N"+(j(v)-1);
var s=new Element("li",{id:w}).adopt(t.getElement(".module")).inject($("NewModule"),"top");
$("NewModuleContainer").removeClass("empty");
k.addItems(s);
e();
c.adopt(new Element("input",{type:"hidden",name:w.toLowerCase()+"TitleOverride"}),new Element("input",{type:"hidden",name:w.toLowerCase()+"Parameters"}));
injectCssAndScriptTags(t)
}function j(s){var u=c.getElement("[name=addModules]");
var t=u.get("value")==""?new Array():u.get("value").split(",");
t.push(s);
u.set("value",t.join(","));
return t.length
}window.toggleConfig=function(t){var s=$(t).getParent(".module").getElement(".config");
if(s.hasClass("hide")){s.removeClass("hide");
$(t).addClass("selected")
}else{s.addClass("hide");
$(t).removeClass("selected")
}};
window.deleteModule=function(t){var s=$(t).getParent(".module").getParent("li");
k.removeItems(s);
$("Trash").grab(s,"top");
k.addItems(s);
e()
}
}function configurePages(e,d,b){var f;
d.getChildren("li").each(function(h,g){if(g==0){f=h
}else{a(h)
}});
var c=new Sortables(d,{opacity:0,clone:true,handle:".drag",onComplete:function(g){e.set("value",c.serialize(0))
}});
c.removeItems(f);
document.addPage=function(i,j){var k="N"+readAndIncrement(j);
var h=new Element("input",{type:"text",name:k.toLowerCase()+"name"});
var g=new Element("li",{id:k}).adopt(h).inject(i);
a(g);
c.addItems(g);
c.fireEvent("complete",g);
h.focus()
};
function a(g){new Element("div",{"class":"drag"}).inject(g,"top");
var h=g.get("id").charAt(0)=="C";
if(h){var i=g.getElement("input[name$=delete]");
if(i.get("value")=="true"){g.addClass("delete")
}new Element("a",{"class":"delete",html:b,href:"javascript:void(0)",events:{click:function(){var j=i.get("value")=="false";
i.set("value",j);
if(j){g.addClass("delete")
}else{g.removeClass("delete")
}return false
}}}).inject(g)
}else{new Element("a",{"class":"delete",html:b,href:"javascript:void(0)",events:{click:function(){c.removeItems(g);
g.dispose();
c.fireEvent("complete",null);
return false
}}}).inject(g)
}}}function addSubscribe(b,a,e,d){var c;
a.getChildren("li").each(function(g,f){if(f==0){c=g
}else{}});
document.addFolder=function(){var h="N"+readAndIncrement(e);
var g=new Element("input",{type:"text","class":"name",maxlength:100,name:h.toLowerCase()+"name"});
var f=new Element("tr",{id:h}).adopt(new Element("td").adopt(new Element("div").adopt(g)),new Element("td").adopt(new Element("input",{type:"checkbox",value:"Y",name:"folderName"+h.toLowerCase()})),new Element("td").adopt(new Element("input",{type:"checkbox",value:"Y",name:"active"+h.toLowerCase()})),new Element("td",{html:d.replace(/\%id\%/g,h.toLowerCase())})).inject(a);
b.set("value",b.get("value")+","+h);
g.focus()
}
}var favoriteSortables;
function favorites(c,d,b){d.getChildren("li").each(a);
favoriteSortables=new Sortables(d,{clone:true,opacity:0,handle:".drag",onComplete:function(e){c.set("value",favoriteSortables.serialize(0))
}});
window.addFavorite=function(f,i){var h;
var g="N"+readAndIncrement(i);
var e=new Element("div",{html:b.replace(/NX/g,g).replace(/nx/g,g.toLowerCase())}).getFirst();
a(e);
e.inject(f);
favoriteSortables.addItems(e);
favoriteSortables.fireEvent("complete",e)
};
function a(e){new Element("div",{"class":"drag"}).inject(e,"top");
var f=e.get("id").charAt(0)=="C";
if(f){var g=e.getElement("input[name$=delete]");
if(g){if(g.get("value")=="true"){e.addClass("delete")
}new Element("a",{"class":"delete",html:"delete",href:"javascript:void(0)",events:{click:function(){var h=g.get("value")=="false";
g.set("value",h);
if(h){e.addClass("delete")
}else{e.removeClass("delete")
}return false
}}}).inject(e)
}}else{new Element("a",{"class":"delete",html:"delete",href:"javascript:void(0)",events:{click:function(){favoriteSortables.removeItems(e);
e.dispose();
favoriteSortables.fireEvent("complete",null);
return false
}}}).inject(e)
}}}var phoneNumberSortables;
function numbers(c,d,b){d.getChildren("li").each(a);
phoneNumberSortables=new Sortables(d,{clone:true,opacity:0,handle:".drag",onComplete:function(e){c.set("value",phoneNumberSortables.serialize(0))
}});
window.addNumber=function(g,f){var i;
var h="N"+readAndIncrement(f);
var e=new Element("div",{html:b.replace(/NX/g,h).replace(/nx/g,h.toLowerCase())}).getFirst();
a(e);
e.inject(g);
phoneNumberSortables.addItems(e);
phoneNumberSortables.fireEvent("complete",e)
};
function a(e){new Element("div",{"class":"drag"}).inject(e,"top");
var f=e.get("id").charAt(0)=="C";
if(f){var g=e.getElement("input[name$=delete]");
if(g){if(g.get("value")=="true"){e.addClass("delete")
}new Element("a",{"class":"delete",html:"delete",href:"javascript:void(0)",events:{click:function(){var h=g.get("value")=="false";
g.set("value",h);
if(h){e.addClass("delete")
}else{e.removeClass("delete")
}return false
}}}).inject(e)
}}else{new Element("a",{"class":"delete",html:"delete",href:"javascript:void(0)",events:{click:function(){phoneNumberSortables.removeItems(e);
e.dispose();
phoneNumberSortables.fireEvent("complete",null);
return false
}}}).inject(e)
}}}function enableAccessGridEvents(a){var b=null;
$(document.body).getElements(".checkbox").addEvents({mouseenter:function(c){if(b!=null){highlight(b)
}highlight(c.target,"#ffff00","#ffffcc","#ffeecc");
b=c.target
},mouseleave:function(c){if(b==c.target){highlight(c.target);
b=null
}}});
$(document.body).getElements("input[type=checkbox]").addEvents({change:function(d){var e=$(d.target).getParent(".checkbox");
var c=d.target.checked;
changeState(e,c)
}})
}function highlight(d,b,e,a){var c=$(d).hasClass("checkbox")?$(d):$(d).getParent(".checkbox");
$(c).setStyle("background-color",b);
$(document.body).getElements("."+$(c).get("id").charAt(0).toLowerCase()+$(c).get("id").substr(1)).each(function(f){$(f).setStyle("background-color",e)
});
d.className.split(" ").each(function(f){if(f.charAt(0)=="p"){$(f.toUpperCase()).setStyle("background-color",a)
}})
}function changeState(d,c){var a="."+d.get("id").charAt(0).toLowerCase()+d.get("id").substr(1);
var b=d.className.split(" ");
$(document.body).getElements(a).each(function(g){if(c){$(g).getElement("input[type=checkbox]").checked=true
}else{var h=$(g).getElement("input[type=checkbox]");
if(h.checked){var f=g.className.split(" ").filter(function(i){return b.indexOf(i)==-1
});
for(var e=0;
e<f.length;
e++){if($(f[e].toUpperCase()).getElement("input[type=checkbox]").checked){return
}}h.checked=false
}}})
}function enableActionDrawerSlideFx(b,c,a){var d=new Fx.Slide(b);
$(b.parentNode).addClass("moo");
if(c.checked){d.hide();
b.removeClass("hide")
}c.addEvent("change",function(e){if(e.target.checked){d.cancel();
d.slideOut()
}});
a.addEvent("change",function(e){if(e.target.checked){d.cancel();
d.slideIn()
}})
}function enableAddressDrawerSlideFx(b,c,a){var d=new Fx.Slide(b);
$(b.parentNode).addClass("moo");
if(c.some(function(e){return e.checked
})){d.hide();
b.removeClass("hide")
}c.addEvent("change",function(e){if(e.target.checked){d.cancel();
d.slideOut()
}});
a.addEvent("change",function(e){if(e.target.checked){d.cancel();
d.slideIn()
}})
}function activateCountrySelector(b,a){b.addEvent("change",function(c){a.each(function(e){e.getParent("div").addClass("hide")
});
var d=$(document.body).getElement("[name=state"+b.getSelected().get("value")+"]");
if(d){d.getParent("div").removeClass("hide")
}else{$(document.body).getElement("[name=state]").getParent("div").removeClass("hide")
}})
}function initializeBuildFamilyTree(d,g,l,j,m,b,i,c,f){d.sortable=new Sortables(d,{opacity:0,clone:true,handle:"p",onComplete:function(n){g.set("value",d.sortable.serialize(0))
}});
l.sortable=new Sortables(l,{opacity:0,clone:true,handle:"p",onComplete:function(n){j.set("value",l.sortable.serialize(0))
}});
m.sortable=new Sortables(m,{opacity:0,clone:true,handle:"p",onComplete:function(n){b.set("value",m.sortable.serialize(0))
}});
$$("li[id^=P]").each(function(n){new Element("p",{text:n.getElement("input[name$=name]").get("value")}).inject(n)
});
$$("li[id^=C]","li[id^=E]","li[id^=P]").each(a);
k();
function h(o,p){Log.logger("add family member");
var n,q;
if(p.get("value")==""){q="P"+readAndIncrement($(window.document).getElement("input[name=highestPlaceholder]"));
n=new Element("li",{id:q,html:"<p>"+o.get("value")+'</p><input type="hidden" name="'+q.toLowerCase()+'name" value="'+o.get("value")+'" />'})
}else{q=p.get("value");
n=new Element("li",{id:q,html:"<p>"+o.get("value")+"</p>"})
}if(SqueezeBox.ul==l){new Element("span",{html:c.replace(/\%id\%/g,q.toLowerCase())}).getChildren().inject(n)
}if(SqueezeBox.ul==m){new Element("input",{type:"checkbox",name:q.toLowerCase()+"show",value:"Y",checked:"checked"}).inject(n)
}a(n);
n.inject(SqueezeBox.ul);
k();
SqueezeBox.ul.sortable.addItems(n);
SqueezeBox.ul.sortable.fireEvent("complete",n);
SqueezeBox.close()
}function k(){$$(d,l,m).setStyle("height");
var n=Math.max(d.getSize().y,l.getSize().y,m.getSize().y)+10;
$$(d,l,m).setStyle("height",n)
}function a(n){var o=n.get("id").charAt(0)=="C";
if(o){var p=n.getElement("input[name$=delete]");
if(p.get("value")=="true"){n.addClass("delete")
}new Element("a",{"class":"delete",html:"X",href:"javascript:void(0)",events:{click:function(){var q=p.get("value")=="false";
p.set("value",q);
if(q){n.addClass("delete")
}else{n.removeClass("delete")
}}}}).inject(n)
}else{new Element("a",{"class":"delete",html:"X",href:"javascript:void(0)",events:{click:function(){var q=n.getParent().sortable;
q.removeItems(n);
n.dispose();
k();
q.fireEvent("complete",null)
}}}).inject(n)
}}function e(n,o,q){var p=new Class({Extends:Autocompleter.Local,initialize:function(s,t,u,r){this.parent(s,u,r);
this.hiddenInput=t
},prefetch:function(){this.hiddenInput.set("value");
return this.parent()
},setSelection:function(t){var s=this.selected.inputValue,u=this.tokens.get(s);
this.selectedValue=u;
var v=this.queryValue.length,r=u.length;
if(u.substr(0,v).toLowerCase()!=this.queryValue.toLowerCase()){v=0
}this.observer.setValue(u);
this.opted=u;
if(t||this.selectMode=="pick"){v=r
}this.element.selectRange(v,r);
this.hiddenInput.set("value",s);
this.fireEvent("onSelection",[this.element,this.selected,u,s])
}});
new p(n,o,q,{minLength:0,zIndex:65560,overflow:true,selectMode:"type-ahead",injectChoice:function(t,s,u){var r=new Element("li",{html:this.markQueryValue(t)});
r.inputValue=s;
this.addChoiceEvents(r).inject(this.choices)
},autoSubmit:true})
}window.showAddFamilyMember=function(n,o){SqueezeBox.legend=n;
SqueezeBox.ul=o;
SqueezeBox.open(i,{closable:false,handler:"string",size:{x:300,y:150},contentFx:{onComplete:function(){$(this.win).getElement("input[name=displayName]").focus()
}.bind(SqueezeBox)},onOpen:function(r){Log.logger("SqueezeBox onOpen called");
$(r).getElement("h3").set("text",SqueezeBox.legend);
var p=$(r).getElement("input[name=displayName]");
var s=$(r).getElement("input[name=selectedPersonId]");
$(r).getElement("form").addEvent("submit",function(){if(p.get("value")!=null&&p.get("value").trim()!=""){h(p,s)
}return false
});
var q=(g.get("value")+","+j.get("value")+","+b.get("value")).split(/,+/);
e(p,s,f.filter(function(u,t){return !q.contains(t)&&!q.contains("C"+t.substr(1))
}))
}})
}
}var membersBox;
function initializeHouseholdMembers(d,j,i,f,b,g){window.withdrawInvitationText=i;
var e=new Sortables(d,{clone:true,opacity:0,onComplete:function(k){j.set("value",e.serialize(0))
}});
e.removeItems(d.getLast());
$$("li[id^=C]","li[id^=N]","li[id^=E]").each(a);
function h(l,m){Log.logger("add household member");
var k,n;
if(m.get("value")==""){n="N"+readAndIncrement($(window.document).getElement("input[name=highestPlaceholder]"));
k=new Element("li",{id:n,html:'<img src="/img/site/profile-neutral-90S.jpg?fp=a97512" /><span>'+l.get("value")+'</span><input type="hidden" name="'+n.toLowerCase()+'name" value="'+l.get("value")+'" />'})
}else{n=m.get("value");
k=new Element("li",{id:n,html:'<img src="'+g[n]+'" /><span>'+l.get("value")+"</span>"})
}a(k);
k.inject(d.getLast(),"before");
e.addItems(k);
e.fireEvent("complete",k);
SqueezeBox.close()
}window.filterConnections=function(){return"&filter="+j.get("value").split(",").filter(function(k){return k.charAt(0)!="N"
}).map(function(k){return k.substring(1)
}).join(",")
};
window.showAddHouseholdMember=function(){SqueezeBox.open(f,{closable:false,handler:"string",size:{x:300,y:150},contentFx:{onComplete:function(){$(this.win).getElement("input[name=displayName]").focus()
}.bind(SqueezeBox)},onOpen:function(m){Log.logger("SqueezeBox onOpen called");
var k=$(m).getElement("input[name=displayName]");
var n=$(m).getElement("input[name=selectedPersonId]");
$(m).getElement("form").addEvent("submit",function(){if(k.get("value")!=null&&k.get("value").trim()!=""){h(k,n)
}return false
});
var l=j.get("value").split(/,+/);
c(k,n,b.filter(function(p,o){return !l.contains(o)&&!l.contains("C"+o.substr(1))
}))
}})
};
function c(k,l,n){var m=new Class({Extends:Autocompleter.Local,initialize:function(p,q,r,o){this.parent(p,r,o);
this.hiddenInput=q
},prefetch:function(){this.hiddenInput.set("value");
return this.parent()
},setSelection:function(q){var p=this.selected.inputValue,r=this.tokens.get(p);
this.selectedValue=r;
var s=this.queryValue.length,o=r.length;
if(r.substr(0,s).toLowerCase()!=this.queryValue.toLowerCase()){s=0
}this.observer.setValue(r);
this.opted=r;
if(q||this.selectMode=="pick"){s=o
}this.element.selectRange(s,o);
this.hiddenInput.set("value",p);
this.fireEvent("onSelection",[this.element,this.selected,r,p])
}});
new m(k,l,n,{minLength:0,zIndex:65560,overflow:true,selectMode:"type-ahead",injectChoice:function(q,p,r){var o=new Element("li",{html:this.markQueryValue(q)});
o.inputValue=p;
this.addChoiceEvents(o).inject(this.choices)
},autoSubmit:true})
}function a(k){var m=k.get("id").charAt(0)=="C";
var l;
if(m){var n=k.getElement("input[name$=delete]");
l=new Element("a",{"class":"trash",html:"X",href:"javascript:void(0)",events:{click:function(){var o=n.get("value")=="false";
n.set("value",o);
if(o){k.addClass("delete")
}else{k.removeClass("delete")
}}}}).inject(k)
}else{l=new Element("a",{"class":"trash",html:"X",href:"javascript:void(0)",events:{click:function(){e.removeItems(k);
k.dispose();
e.fireEvent("complete",null)
}}}).inject(k)
}if(k.getElement(".pending")){Log.logger(window.withdrawInvitationText);
l.set("title",window.withdrawInvitationText)
}}}function resizeFontAndVerticallyCenter(a,b){var c=(760/a.getSize().x*100)+"%";
a.getElements("p").setStyle("font-size",c);
a.setStyle("margin-top",Math.max(10,(b.getSize().y-a.getCoordinates(b).top-a.getSize().y)/2.5))
}function drawTree(){$$(".tree").each(function(a){drawOneTree(a);
var b=a.getParent(".module");
if(b){b.resizeListener=function(){drawOneTree(b.getElement(".tree"))
}
}})
}function drawOneTree(a){a.getElements("div[rel=tree]").dispose();
a.getElements("div[rel=treeWrapper]").each(function(b){b.getParent().adopt(b.getChildren());
b.dispose()
});
a.getElements(".d td").each(function(h){if(!(h.hasClass("f")||h.hasClass("m")||h.hasClass("l")||h.hasClass("o"))){return
}var g=new Element("div",{rel:"treeWrapper",styles:{position:"relative"}}).adopt(h.getChildren()).inject(h);
var e=h.getElement("p");
var d=-g.getCoordinates(h).top;
var b=Math.floor(h.getSize().y/2)+d;
if(h.hasClass("o")||h.hasClass("m")){new Element("div",{"class":"line",rel:"tree",styles:{position:"absolute",top:b+"px",right:"0px",width:(g.getSize().x-e.getCoordinates(g).right)+"px",height:"1px"}}).inject(g);
if(h.hasClass("m")){new Element("div",{"class":"line",rel:"tree",styles:{position:"absolute",top:d+"px",right:"0px",width:"1px",height:h.getSize().y+"px"}}).inject(g)
}}else{var c=h.hasClass("f");
new Element("div",{"class":c?"tr":"br",rel:"tree",styles:{position:"absolute",top:c?b:d+"px",right:"0px",width:(g.getSize().x-e.getCoordinates(g).right-1)+"px",height:(Math.floor(h.getSize().y/2))+"px"}}).inject(g)
}if(!h.hasClass("nd")){new Element("div",{"class":"line",rel:"tree",styles:{position:"absolute",top:b+"px",left:"0px",width:(e.getCoordinates(g).left)+"px",height:"1px"}}).inject(g)
}});
a.getElements(".a td").each(function(h){if(!(h.hasClass("f")||h.hasClass("m")||h.hasClass("l")||h.hasClass("o"))){return
}var g=new Element("div",{rel:"treeWrapper",styles:{position:"relative"}}).adopt(h.getChildren()).inject(h);
var e=h.getElement("p");
var d=-g.getCoordinates(h).top;
var b=Math.floor(h.getSize().y/2)+d;
if(h.hasClass("o")||h.hasClass("m")){new Element("div",{"class":"line",rel:"tree",styles:{position:"absolute",top:b+"px",left:"0px",width:e.getCoordinates(g).left+"px",height:"1px"}}).inject(g);
if(h.hasClass("m")){new Element("div",{"class":"line",rel:"tree",styles:{position:"absolute",top:d+"px",left:"0px",width:"1px",height:h.getSize().y+"px"}}).inject(g)
}}else{var c=h.hasClass("f");
new Element("div",{"class":c?"tl":"bl",rel:"tree",styles:{position:"absolute",top:c?b:d+"px",left:"0px",width:e.getCoordinates(g).left+"px",height:(Math.floor(h.getSize().y/2))+"px"}}).inject(g)
}if(!h.hasClass("na")){new Element("div",{"class":"line",rel:"tree",styles:{position:"absolute",top:b+"px",right:"0px",width:(g.getSize().x-e.getCoordinates(g).right-1)+"px",height:"1px"}}).inject(g)
}});
a.getElements(".c").each(function(g){var f=new Element("div",{rel:"treeWrapper",styles:{position:"relative"}}).adopt(g.getChildren()).inject(g);
var e=g.getElement("div div p");
var d=-f.getCoordinates(g).top;
var b=Math.floor(g.getSize().y/2)+d;
if(!g.hasClass("nd")){new Element("div",{"class":"line",rel:"tree",styles:{position:"absolute",top:b+"px",left:"0px",width:e.getCoordinates(f).left+"px",height:"1px"}}).inject(f)
}if(!g.hasClass("na")){new Element("div",{"class":"line",rel:"tree",styles:{position:"absolute",top:b+"px",right:"0px",width:(f.getSize().x-e.getCoordinates(f).right-1)+"px",height:"1px"}}).inject(f)
}var c=g.getElement(".p");
if(c==null){return
}new Element("div",{"class":"bl",rel:"tree",styles:{position:"absolute",top:e.getCoordinates(f).bottom+"px",left:e.getCoordinates(f).left+"px",width:(c.getCoordinates(f).left-e.getCoordinates(f).left-2)+"px",height:(c.getCoordinates().top-e.getCoordinates().bottom+Math.floor(c.getSize().y/2))+"px"}}).inject(f)
})
}function cropper(b,a,d,f,e){var c=$(b);
new uvumiCropper(b,{keepRatio:true,mini:{x:30,y:30},preview:a,previewSize:{x:240,y:240},handles:[["top","left"],["top","right"],["bottom","left"],["bottom","right"]],cropperSize:{top:parseInt(d.get("value")),left:parseInt(f.get("value")),x:parseInt(e.get("value")),y:parseInt(e.get("value"))},onComplete:function(i,h,g){Log.logger("top="+i+", left="+h+", size="+g);
d.set("value",i);
f.set("value",h);
e.set("value",g)
}});
c.setStyles({height:c.height,width:c.width})
}function initializeOrganizePhotos(j,o,x,B,p,e,b,z,w,f,A,i,y){var t=JSON.decode(p.get("value"));
var m=JSON.decode(e.get("value"));
var c=JSON.decode(b.get("value"));
var u=new Scroller(window.document.body);
$$(".albums").each(function(D){var C=new Element("ul",{"class":"dashboard"}).inject(D,"after");
new Element("a",{text:i,href:"javascript:void(0);",events:{click:function(){r(D)
}}}).inject(new Element("li").inject(C));
D.getChildren().each(d)
});
$("Trash").getFirst().getChildren().filter(function(C){return C.getElement("h3")
}).each(function(C){new Element("div",{"class":"drag"}).inject(C.getFirst().getFirst("h3"),"top")
});
$$(".photos li").each(g);
var h=new (new Class({Extends:BetterSortables,getDroppables:function(){if(!this.adjustedDroppables){if(this.photo){var E=this.element.get("id").match(/P\d+/)[0];
var D=this.list;
this.removeLists(this.lists.filter(function(F){return !(F.hasClass("photos")||F.hasClass("trash"))||F!=D&&F.getElement("li[id$="+E+"]")
}))
}else{this.removeLists(this.lists.filter(function(F){return F.hasClass("photos")
}))
}this.adjustedDroppables=true
}var C=this.parent();
return C
},start:function(D,C){this.allLists=this.lists.flatten();
this.parent(D,C)
},adjustCloneClass:function(D,C){if(this.photo){if(C.getPrevious()==null&&!C.getParent("#PhotoClipboard")&&!C.getParent("#Trash")){D.addClass("cloneOfFirst");
D.set("src",D.get("src").replace(/60S/,"125S"))
}else{D.removeClass("cloneOfFirst");
D.set("src",D.get("src").replace(/125S/,"60S"))
}}else{C.getParent("#Trash")?D.addClass("inTrash").removeClass("inAlbums"):D.addClass("inAlbums").removeClass("inTrash")
}},adjustPhotos:function(){$$(".albums .photos li:first-child img[src$=60S]").each(function(C){C.set("src",C.get("src").replace(/60S/,"125S"))
});
$$("li img[src$=125S]").filter(function(C){return C.getParent("li").getPrevious()||!C.getParent(".albums")
}).each(function(C){C.set("src",C.get("src").replace(/125S/,"60S"))
})
}}))($$(".photos",".albums",".trash"),{handle:".drag",opacity:0,onStart:function(C,D){window.prevY=null;
u.start();
u.attach()
},onSort:function(D,E){this.adjustCloneClass(E,D);
if(this.photo){this.drag.mouse.pos={x:Math.floor(E.getSize().x/2),y:Math.floor(E.getSize().y/2)};
this.adjustPhotos()
}if(D.getParent().hasClass("trash")){var C=D.getParent();
D.dispose();
if(this.photo||!C.getChildren().some(function(F){if(F.getFirst().get("tag")=="img"){D.inject(F,"before");
return true
}return false
})){D.inject(C)
}}},clone:function(E,D){this.photo=D.getFirst("img")!=null;
if(this.photo){var C=D.getFirst("img");
var G=C.clone(false).addClass("clonePhoto").setStyles({position:"absolute","z-index":"2"});
G.inject($(window.document).getElement("body")).setPosition(C.getPosition());
this.adjustCloneClass(G,D);
return G
}else{var G=D.getFirst("div").clone(true).addClass("cloneAlbum").setStyles({position:"absolute","z-index":"2"});
var F=D.getElement("div");
G.inject($(window.document).getElement("body")).setPosition(F.getPosition());
this.adjustCloneClass(G,D);
return G
}},onComplete:function(F){u.stop();
u.detach();
if(this.photo){var E=F.getParent("li")?F.getParent("li").get("id"):"";
var D=E+F.get("id").match(/P\d+/)[0];
F.set("id",D);
F.getParent().getChildren("#"+D).erase(F).dispose();
var C=F.getElement("img");
if(F.getPrevious()==null&&!F.getParent("#PhotoClipboard")&&!F.getParent("#Trash")){C.set("src",C.get("src").replace(/60S/,"125S"))
}else{C.set("src",C.get("src").replace(/125S/,"60S"))
}}else{if(F.getParent().hasClass("trash")){F.getElement(".photos").getChildren().each(function(G){var H=G.get("id").match(/P\d+$/)[0];
if(!$(H)){G.clone(true).set("id",H).inject(F.getParent())
}})
}else{F.getElement(".photos").getChildren().each(function(G){var H=G.get("id").match(/P\d+$/)[0];
if($(H)){$(H).dispose()
}})
}}this.removeLists(this.lists);
this.addLists(this.allLists);
this.adjustedDroppables=false
}});
$("AlbumContainer").getChildren("h3").each(function(C){C.drawer=C.getNext();
C.addClass("open");
C.store("slide:open",C.hasClass("open"));
C.addEvent("click",function(E){var D=C.hasClass("open");
if(D){s(C)
}else{v(C)
}})
});
function v(C){if(C.drawer.hasClass("hide")){q(C).hide();
C.drawer.removeClass("hide")
}q(C).slideIn();
C.store("slide:open",true)
}function s(C){q(C).slideOut();
C.store("slide:open",false)
}function q(C){if(C.drawer.fxSlide){return C.drawer.fxSlide
}C.drawer.fxSlide=new Fx.Slide(C.drawer,{onComplete:function(){if(C.retrieve("slide:open")){n(C.drawer);
C.removeClass("shut").addClass("open")
}else{C.removeClass("open").addClass("shut")
}}});
C.drawer.retrieve("wrapper").addClass("moo");
return C.drawer.fxSlide
}function n(C){C.replaces(C.getParent());
C.eliminate("wrapper");
C.fxSlide=null
}x.getParent("form").update=function(){var D=C();
x.set("value",JSON.encode(D.albumOrderMap));
B.set("value",JSON.encode(D.photoOrderMap));
z.set("value",JSON.encode(D.clipboard));
w.set("value",JSON.encode(D.trash));
p.set("value",JSON.encode(t));
e.set("value",JSON.encode(m));
b.set("value",JSON.encode(c));
function C(){var E=new Object();
E.albumOrderMap=new Object();
E.photoOrderMap=new Object();
E.clipboard=$("PhotoClipboard").getElements("li").map(function(F){return F.get("id").substring(1)
});
E.trash=$("Trash").getFirst().getChildren("li").map(function(F){return F.get("id").substring(1)
});
$("Trash").getFirst().getChildren("li").each(function(F){if(F.getElement(".photos")){var G=F.getElement(".photos").getChildren("li").map(function(H){return H.get("id").match(/P\d+/)[0].substring(1)
});
E.photoOrderMap[F.get("id")]=G
}});
$$(".albums").each(function(G){var F=new Array();
E.albumOrderMap[G.get("id").substring(1)]=F;
G.getChildren("li").each(function(H){var J=H.get("id");
F.push(J);
var I=H.getElement(".photos").getChildren("li").map(function(K){return K.get("id").match(/P\d+/)[0].substring(1)
});
E.photoOrderMap[J]=I
})
});
return E
}};
function l(C){var D=C.get("id");
var E=new Hash({formSubmitted:"PhotoAlbumEditForm",runSubmitHandler:"N",photoAlbumName:t[D],photoAlbumDescription:m[D],photoIds:C.getElement(".photos").getChildren("li").map(function(F){return F.get("id").match(/P\d+/)[0].substring(1)
}).join(",")});
C.getElement(".photos").getChildren("li").each(function(F){var G=F.get("id").match(/P\d+/)[0].substring(1);
E.set("caption"+G,c[F.get("id")])
});
SqueezeBox.open(null,{closable:false,handler:"iframe",url:null,iframeOptions:{events:{load:function(){var G=this;
if(G.getProperty("loadStatus")=="LOADED"){G.setStyle("display","")
}else{var F=new IFrame(this);
new (new Class({Extends:Request,processScripts:function(H){return H
}}))({url:"/Photo/EditAlbum?iframe=Y",evalScripts:false,evalResponse:false,onSuccess:function(H){G.setStyle("display","none");
G.setProperty("loadStatus","LOADED");
G.contentWindow.document.write(H);
G.contentWindow.document.close()
}}).send(E.toQueryString());
this.formSubmittedOk=function(I,K,J){t[D]=I;
m[D]=K;
var H=C.getFirst().getFirst("h3");
H.getFirst("span").set("text",I);
H.getLast("span").set("text",K);
$each(JSON.decode(J),function(M,L){c[D+"P"+L]=M
});
SqueezeBox.close()
}
}}}}})
}function r(C){SqueezeBox.open(null,{closable:false,handler:"iframe",url:"/Photo/AddAlbum?iframe=Y",iframeOptions:{events:{load:function(){this.formSubmittedOk=function(F,G){var E="N"+readAndIncrement(o);
t[E]=F;
m[E]=G;
var H=new Element("ul",{"class":"clearfix photos"});
var D=new Element("li",{id:E}).adopt(new Element("div",{"class":"fieldset"}).adopt(new Element("h3").adopt(new Element("span",{"class":"name",text:F}),new Element("span",{text:G})),H)).inject(C);
d(D);
h.addItems(D).addLists(H);
SqueezeBox.close()
}
}}}})
}function k(C){var D=$("Trash").getElement(".trash");
if(this.photo||!D.getChildren().some(function(E){if(E.getFirst().get("tag")=="img"){C.inject(E,"before");
return true
}return false
})){C.inject(D)
}C.getElement(".photos").getChildren().each(function(E){var F=E.get("id").match(/P\d+$/)[0];
if(!$(F)){E.clone(true).set("id",F).inject(D)
}})
}function d(C){var F=C.get("id");
var E=C.getFirst().getFirst("h3");
new Element("div",{"class":"drag"}).inject(E,"top");
var D=new Element("ul",{"class":"dashboard"}).inject(E.getParent());
new Element("a",{text:f,href:"javascript:void(0);",events:{click:function(){l(C)
}}}).inject(new Element("li").inject(D));
new Element("a",{text:A,href:"javascript:void(0);",events:{click:function(){k(C)
}}}).inject(new Element("li").inject(D));
E.drawer=E.getNext();
E.addClass("open");
E.store("slide:open",E.hasClass("open"));
E.addEvent("click",function(H){var G=E.hasClass("open");
if(G){s(E)
}else{v(E)
}})
}function g(C){C.setStyle("position","relative");
return new Element("div",{"class":"photoCover",styles:{position:"absolute",top:0,left:0,right:0,bottom:0,background:"#FFF"},opacity:0.00001}).inject(C)
}if(y){window.addNewPhotosToClipboard=function(D){if(D.newPhotos){var C=$("PhotoClipboard").getFirst("ul");
D.newPhotos.each(function(F){if(!$(F.photoId)){var E=new Element("li",{id:"P"+F.photoId});
new Element("img",{border:0,width:60,height:60,src:F.photoUrl}).inject(E.inject(C));
g(E);
h.addItems(E)
}})
}};
function a(){new Request.JSON({url:j,onSuccess:window.addNewPhotosToClipboard}).get()
}a.periodical(2500)
}}function initializeModuleResize(expandModuleUrl,collapseModuleUrl,moduleToken){$$(".module.open",".module.shut").each(function(module){module.getFirst("h3").addEvent("click",clickEvent);
module.store("slide:open",module.hasClass("open"))
});
function clickEvent(event){var module=event.target.getParent(".module");
var dashboard=module.getFirst(".dashboard");
var drawer=module.getElement(".moduleContent");
drawer.fxSlide&&drawer.fxSlide.cancel();
if(module.retrieve("slide:open")){slideOut(module);
new Request({url:collapseModuleUrl.replace(eval("/"+moduleToken+"/"),module.get("rel"))}).send()
}else{if(drawer.get("rel")){module.removeClass("shut").addClass("loading");
new (new Class({Extends:Request,processScripts:function(text){return text
}}))({url:drawer.get("rel"),evalScripts:false,evalResponse:false,onSuccess:function(responseText){var root=new Element("div",{html:responseText});
var newDrawer=root.getElement(".moduleContent");
newDrawer.addClass("hide");
newDrawer.replaces(drawer);
drawer=newDrawer;
dashboard=root.getElement(".dashboard");
dashboard&&dashboard.inject(module.getFirst("h3"),"after");
injectCssAndScriptTags(root);
slideIn(module)
}}).send("ajax=Y&ajaxCounter="+ ++ajaxCounter)
}else{slideIn(module);
new Request({url:expandModuleUrl.replace(eval("/"+moduleToken+"/"),module.get("rel"))}).send()
}}function slideIn(module){if(module.getElement(".moduleContent").hasClass("hide")){getSlider(module).hide();
module.getElement(".moduleContent").removeClass("hide");
module.getFirst(".dashboard")&&module.getFirst(".dashboard").removeClass("hide")
}getSlider(module).slideIn();
module.store("slide:open",true)
}function slideOut(module){getSlider(module).slideOut();
module.store("slide:open",false)
}function getSlider(module){var drawer=module.getElement(".moduleContent");
if(drawer.fxSlide){return drawer.fxSlide
}drawer.fxSlide=new Fx.Slide(drawer,{onComplete:function(){if(module.retrieve("slide:open")){removeSlider(drawer);
module.removeClass("shut").removeClass("loading").addClass("open");
module.getFirst(".dashboard").removeClass("hide")
}else{var dashboard=module.getFirst(".dashboard");
module.getFirst(".dashboard")&&module.getFirst(".dashboard").addClass("hide");
module.removeClass("open").addClass("shut")
}}});
drawer.retrieve("wrapper").addClass("moo");
return drawer.fxSlide;
function removeSlider(drawer){drawer.replaces(drawer.getParent());
drawer.eliminate("wrapper");
drawer.fxSlide=null
}}}}function configureBlogs(b,a){a.getChildren("li").each(function(c){addDeleteLink(c)
});
window.updateIdList=function(){b.set("value",a.getElements("li").map(function(c){return c.get("id")
}).join(","))
}
}function addBlog(b,c){var d="N"+readAndIncrement(c);
var a=new Element("li",{id:d});
new Element("input",{type:"text",name:d.toLowerCase()+"name"}).inject(a);
addDeleteLink(a);
a.inject(b);
updateIdList()
}function addDeleteLink(a){var b=a.get("id").charAt(0)=="C";
if(b){var c=a.getElement("input[name$=delete]");
if(c.get("value")=="true"){a.addClass("delete")
}new Element("a",{"class":"delete",text:"X",href:"javascript:void(0)",events:{click:function(){var d=c.get("value")=="false";
c.set("value",d);
if(d){a.addClass("delete")
}else{a.removeClass("delete")
}return false
}}}).inject(a)
}else{new Element("a",{"class":"delete",text:"X",href:"javascript:void(0)",events:{click:function(){a.dispose();
updateIdList();
return false
}}}).inject(a)
}}function generalSettings(l,b,a,h,k){l.getElements("td.delete").each(d);
var e=a.getParent("form");
e.update=function(){a.set("value",l.getElements("tr[id^=N]").map(function(m){return m.get("id")
}).join(","))
};
var c=e.getElement("input[name=default]:checked").get("value");
e.getElements("input[name=default]").addEvent("click",i);
$("C"+c).getElement("td[class=delete] a").hide();
var j=e.getElement("input[name=invite]:checked").get("value");
e.getElements("input[name=invite]").addEvent("click",f);
$("C"+j).getElement("td[class=delete] a").hide();
document.addEmailAddress=function(){var o="N"+readAndIncrement(b);
var m=new Element("input",{type:"text",name:"newEmailAddress"+o});
var n=new Element("td",{"class":"delete"});
l.adopt(new Element("tr",{id:o}).adopt(new Element("td").adopt(m),new Element("td"),new Element("td"),n,new Element("td",{text:k}),new Element("td").adopt(new Element("input",{type:"checkbox",checked:"checked",disabled:"disabled"}))));
d(n);
m.focus()
};
function d(n){var m=n.getParent("tr");
n.adopt(new Element("a",{"class":"delete",html:h,href:"javascript:void(0)",events:{click:g}}))
}function g(m){var n=$(m.target).getParent("tr");
if(n.get("id").substr(0,1)=="C"){n.toggleClass("delete");
n.getElement("input[name=default]")&&n.getElement("input[name=default]").set("disabled",n.hasClass("delete"));
n.getElement("input[name=invite]")&&n.getElement("input[name=invite]").set("disabled",n.hasClass("delete"))
}else{n.dispose()
}}function i(m){if(c!=j){$("C"+c).getElement("td[class=delete] a").setStyle("display","inline-block")
}c=$(m.target).get("value");
$("C"+c).getElement("td[class=delete] a").hide()
}function f(m){if(j!=c){$("C"+j).getElement("td[class=delete] a").setStyle("display","inline-block")
}j=$(m.target).get("value");
$("C"+j).getElement("td[class=delete] a").hide()
}}function configureBlog(d,b,g,c){var e=g.getElement("ul");
var f=e.getLast();
var h=f.getElement("input[type=text]");
var a=f.getElement("input[type=radio]");
h.addEvents({click:function(){a.set("checked","checked")
},focus:function(){a.set("checked","checked")
}});
if(e.getChildren().length>1){j();
g.getElements("input[type=radio]").each(function(k){if(k.getParent("li")!=f){k.addEvent("click",function(l){j()
})
}})
}var i=new Sortables(b,{handle:".drag",clone:true,opacity:0,onComplete:function(){d.set("value",i.serialize(0))
}});
if(b.getChildren().length==1){i.removeItems(b.getFirst())
}function j(){if(h.get("value")==""&&a.get("checked")==""&&f==e.getLast()){f.setStyle("display","none");
var k=new Element("li").adopt(new Element("a",{html:c,href:"javascript:void(0)",events:{click:function(l){f.setStyle("display","block");
h.focus();
k.dispose()
}}})).inject(e)
}}window.addPage=function(q,n,s){var m="N"+readAndIncrement(n);
if(q.getChildren().length==1){var l=q.getFirst();
var p=l.get("id");
var o=l.getElement("#"+p+"body").getParent("div");
var k=new Element("div",{html:s.replace(/%ID%/g,p).replace(/%id%/g,p.toLowerCase())}).getFirst();
i.removeItems(k);
k.replaces(l);
i.addItems(k);
o.replaces(q.getFirst().getElement("#"+p+"body").getParent("div"))
}var r=new Element("div",{html:s.replace(/%ID%/g,m).replace(/%id%/g,m.toLowerCase())}).getFirst();
r.inject(q);
i.addItems(r);
i.fireEvent("complete",r)
};
window.deletePage=function(k){var l=k.get("id").charAt(0)=="C";
if(l){var o=k.getElement("input[name$=delete]");
var p=o.get("value")=="false";
o.set("value",p);
if(p){k.addClass("delete")
}else{k.removeClass("delete")
}}else{var m=k.getParent();
i.removeItems(k);
k.dispose();
i.fireEvent("complete");
if(m.getChildren().length==1){var r=m.getFirst();
var q=r.get("id");
var n=r.getElement("#"+q+"body").getParent("div");
new Element("li",{id:q}).adopt(n).replaces(r)
}}}
}function enhanceInviteForm(contactMapField,ignoreListField,editContactFormHtml,firstNameId,lastNameId){Log.logger("editContactFormHtml="+editContactFormHtml);
var contactMap=JSON.decode(contactMapField.get("value"));
var ignoreList=ignoreListField.get("value")==""?[]:ignoreListField.get("value").split(/\s*,\s*/);
Log.logger("ignoreList="+ignoreList.length);
function enhanceContact(el){new Element("a",{"class":"delete",text:"ignore",href:"javascript:void(0)",events:{click:ignore.bindWithEvent(el)}}).inject(el.getParent("ul.p")?el.getParent("ul"):el.getParent("div"),el.getParent("ul.p")?"before":"bottom");
new Element("a",{"class":"edit",text:"edit",href:"javascript:void(0)",events:{click:edit.bindWithEvent(el)}}).inject(el.getParent("div"))
}$$("ul input[name^=c]").each(enhanceContact);
function redoLabel(el){var contactItems=contactMap[el.get("name").substr(1)];
if(!contactItems){Log.logger("not found: "+el.get("name"))
}var name=makeName(contactItems[0],contactItems[1]);
var span=new Element("span");
if(el.getParent("ul.p")){span.set("text",name)
}else{span.set("text",(name?", ":"")+contactItems[2]);
if(name){new Element("strong",{text:name}).inject(span,"top")
}}with(el.getPrevious()){getElements("span[class!=pic]").dispose();
adopt(span)
}}function makeName(firstName,lastName){return[firstName,lastName].clean().join(" ")
}var last=null;
$$(".delete",".edit").addEvents({mouseenter:function(event){if(last!=null){highlight(last)
}highlight(event.target,'url("/img/site/1px50pc.png?fp=1ed256")');
last=event.target
},mouseleave:function(event){if(last==event.target){highlight(event.target);
last=null
}}});
function edit(event){var checkbox=this;
Log.logger("edit "+checkbox.get("name")+", html="+editContactFormHtml);
var contactItems=contactMap[checkbox.get("name").substr(1)];
Log.logger("contactItem="+contactItems);
SqueezeBox.open(editContactFormHtml,{closable:false,handler:"string",size:{x:400,y:180},contentFx:{onComplete:function(){$(this.win).getElement("input").focus()
}.bind(SqueezeBox)},onOpen:function(el){var firstNameField=el.getElement("#"+firstNameId);
var lastNameField=el.getElement("#"+lastNameId);
Log.logger("SqueezeBox onOpen called");
el.getElement("form").addEvent("submit",function(){contactItems[0]=firstNameField.get("value");
contactItems[1]=lastNameField.get("value");
redoLabel(checkbox);
SqueezeBox.close();
return false
});
firstNameField.set("value",contactItems[0]);
lastNameField.set("value",contactItems[1]);
el.getElement("h3").set("text",contactItems[2])
}})
}function ignore(event){var id=this.get("name").substr(1);
Log.logger("ignore "+id);
var li=this.getParent("ul.p")?this.getParent("li").getParent("li"):this.getParent("li");
if(ignoreList.contains(id)){li.removeClass("delete");
ignoreList.erase(id)
}else{li.addClass("delete");
ignoreList.push(id)
}}function highlight(el,background){$(el).getParent("li").setStyle("background",background)
}contactMapField.getParent("form").update=function(){contactMapField.set("value",JSON.encode(contactMap));
ignoreListField.set("value",ignoreList.join(","))
}
}function myConnections(b,c){var a=new Fx.Accordion(b,c,{opacity:false,onActive:function(e,d){e.addClass("myAccordion")
},onBackground:function(e,d){e.removeClass("myAccordion")
}})
}function allAlbums(b,c){var a=new Fx.Accordion(b,c,{opacity:false,onActive:function(e,d){e.addClass("myAccordion")
},onBackground:function(e,d){e.removeClass("myAccordion")
}})
};