// Copyright (c) Microsoft Corporation. All rights reserved. registerNamespace("Spaces.Customize");
Spaces.Customize.HaltNavigation=function(b){b.returnValue=false;
return false;
};
Spaces.Customize.CalculateTextSize=function(c,e,g){var parent=document.body;
var d=document.createElement("div");
d.style.cssText="position:absolute;
top:-500;
left:-500;
z-index:-1;
visibility:hidden;
";
if(e)d.className="customizePopup bold xSmallFont";
else d.className="customizePopup xSmallFont";
if(g)d.style.pixelWidth=g;
d.innerText=c;
parent.appendChild(d);
var i_width=d.offsetWidth;
var i_height=d.offsetHeight;
parent.removeChild(d);
return {"width":i_width,"height":i_height};
};
registerNamespace("Spaces.Customize");
Spaces.Customize.Paging=function(h,j){Spaces.Customize.Paging.initializeBase(this,arguments);
j=this.getParameters();
var objPaging=this;
var pagingTextContainer=null;
var firstImg=null;
var prevImg=null;
var nextImg=null;
var lastImg=null;
var firstLink=null;
var prevLink=null;
var nextLink=null;
var lastLink=null;
this.initialize=function(k){Spaces.Customize.Paging.getBaseMethod(this,"initialize","Web.Bindings.Base").call(this,k);
this.CurrentPage=j.current_page;
pagingTextContainer=document.createElement("div");
pagingTextContainer.style.styleFloat="left";
pagingTextContainer.style.cssFloat="left";
n();
var rightContainer=document.createElement("div");
rightContainer.style.styleFloat="right";
rightContainer.style.cssFloat="right";
rightContainer.style.textAlign="right";
firstImg=document.createElement("img");
prevImg=document.createElement("img");
nextImg=document.createElement("img");
lastImg=document.createElement("img");
firstImg.className="pagingImg";
prevImg.className="pagingImg";
nextImg.className="pagingImg";
lastImg.className="pagingImg";
firstImg.title=Spaces.Customize.Strings.paging_tooltip_first;
prevImg.title=Spaces.Customize.Strings.paging_tooltip_prev;
nextImg.title=Spaces.Customize.Strings.paging_tooltip_next;
lastImg.title=Spaces.Customize.Strings.paging_tooltip_last;
firstImg.alt=firstImg.title;
prevImg.alt=prevImg.title;
nextImg.alt=nextImg.title;
lastImg.alt=lastImg.title;
o();
firstLink=document.createElement("a");
prevLink=document.createElement("a");
nextLink=document.createElement("a");
lastLink=document.createElement("a");
firstLink.attachEvent("onclick",p);
prevLink.attachEvent("onclick",r);
nextLink.attachEvent("onclick",t);
lastLink.attachEvent("onclick",v);
firstLink.appendChild(firstImg);
prevLink.appendChild(prevImg);
nextLink.appendChild(nextImg);
lastLink.appendChild(lastImg);
rightContainer.appendChild(firstLink);
rightContainer.appendChild(prevLink);
rightContainer.appendChild(nextLink);
rightContainer.appendChild(lastLink);
h.appendChild(pagingTextContainer);
h.appendChild(rightContainer);
};
this.dispose=function(l){Spaces.Customize.Paging.getBaseMethod(this,"dispose","Web.Bindings.Base").call(this,l);
h=null;
objPaging=null;
pagingTextContainer=null;
firstImg=null;
prevImg=null;
nextImg=null;
lastImg=null;
if(firstLink)firstLink.detachEvent("onclick",p);
if(prevLink)prevLink.detachEvent("onclick",r);
if(nextLink)nextLink.detachEvent("onclick",t);
if(lastLink)lastLink.detachEvent("onclick",v);
firstLink=null;
prevLink=null;
nextLink=null;
lastLink=null;
};
this.ChangePage=function(m){objPaging.CurrentPage=m;
n();
o();
};
function n(){var firstItem=objPaging.CurrentPage*j.items_per_page+1;
var lastItem=firstItem+j.items_per_page-1;
lastItem=Math.min(lastItem,j.total_items);
pagingTextContainer.innerText=Spaces.Customize.Strings.themesettings_pagingtext.format(firstItem,lastItem,j.total_items);
}function o(){if(objPaging.CurrentPage<=0){firstImg.src="/images/arrow_first_d.gif";
prevImg.src="/images/arrow_prev_d.gif";
}else{firstImg.src="/images/arrow_first.gif";
prevImg.src="/images/arrow_prev.gif";
}if(objPaging.CurrentPage>=j.total_pages-1){nextImg.src="/images/arrow_next_d.gif";
lastImg.src="/images/arrow_last_d.gif";
}else{nextImg.src="/images/arrow_next.gif";
lastImg.src="/images/arrow_last.gif";
}}function p(q){if(objPaging.CurrentPage>0){objPaging.ChangePage(0);
objPaging.fire("onpagechange");
}q.returnValue=false;
return false;
}function r(s){if(objPaging.CurrentPage>0){objPaging.ChangePage(objPaging.CurrentPage-1);
objPaging.fire("onpagechange");
}s.returnValue=false;
return false;
}function t(u){if(objPaging.CurrentPageobjPaging.fire("onpagechange");
}u.returnValue=false;
return false;
}function v(w){if(objPaging.CurrentPageobjPaging.fire("onpagechange");
}w.returnValue=false;
return false;
}};
Spaces.Customize.Paging.registerClass("Spaces.Customize.Paging","Web.Bindings.Base");
Spaces.Customize.Paging.Events=Web.Enum.create("onpagechange");
Spaces.Customize.Paging.Params=Web.Enum.create("total_items","total_pages","current_page","items_per_page");
registerNamespace("Spaces.Customize");
Spaces.Customize.Thumbnail=function(x,y){Spaces.Customize.Thumbnail.initializeBase(this,arguments);
y=this.getParameters();
var elLink=null;
var elSelectedDiv=null;
var elThumbnailDiv=null;
var objThumbnail=this;
this.initialize=function(z){elThumbnailDiv=document.createElement("div");
var thumbnail=document.createElement("img");
elSelectedDiv=document.createElement("div");
elSelectedDiv.attachEvent("onclick",objThumbnail.ProcessItemSelect);
this.pixelHeight=thumbnail.pixelHeight=thumbnail.style.pixelHeight=parseInt(y.height);
this.pixelWidth=thumbnail.pixelWidth=thumbnail.style.pixelWidth=parseInt(y.width);
thumbnail.src=y.url;
thumbnail.className="thumbnailImg";
thumbnail.title=y.tooltip;
thumbnail.alt=y.tooltip;
elSelectedDiv.title=elSelectedDiv.alt=thumbnail.title;
elLink=document.createElement("a");
elLink.href="#";
elLink.appendChild(thumbnail);
elThumbnailDiv.appendChild(elLink);
x.appendChild(elSelectedDiv);
x.appendChild(elThumbnailDiv);
elLink.attachEvent("onclick",objThumbnail.ProcessItemSelect);
Spaces.Customize.Thumbnail.getBaseMethod(this,"initialize","Web.Bindings.Base").call(this,z);
};
Spaces.Customize.Thumbnail.registerBaseMethod(this,"initialize");
this.dispose=function(A){x=null;
if(elLink)elLink.detachEvent("onclick",objThumbnail.ProcessItemSelect);
if(elSelectedDiv)elSelectedDiv.detachEvent("onclick",objThumbnail.ProcessItemSelect);
elLink=null;
elSelectedDiv=null;
elThumbnailDiv=null;
objThumbnail=null;
Spaces.Customize.Thumbnail.getBaseMethod(this,"dispose","Web.Bindings.Base").call(this,A);
};
Spaces.Customize.Thumbnail.registerBaseMethod(this,"dispose");
this.Select=function(){elSelectedDiv.className="selectedImg";
};
this.Deselect=function(){elSelectedDiv.className="";
};
this.SetVisible=function(B){if(B)elSelectedDiv.style.display="";
else elSelectedDiv.style.display="none";
};
this.SetPosition=function(C,D){E(C,D);
};
function E(F,G){var text="position:absolute;
width:"+objThumbnail.pixelWidth+"px;
height:"+objThumbnail.pixelHeight+"px;
top:"+F+"px;
left:"+G+"px";
elSelectedDiv.style.cssText=text;
elThumbnailDiv.style.cssText=text;
}this.ProcessItemSelect=function(H){Web.Debug.Trace("Spaces.Customize.Thumbnail.ProcessItemSelect");
H.returnValue=false;
objLayoutThumbnail.fire("onitemselected");
};
Spaces.Customize.Thumbnail.registerBaseMethod(this,"ProcessItemSelect");
};
Spaces.Customize.Thumbnail.registerClass("Spaces.Customize.Thumbnail","Web.Bindings.Base");
Spaces.Customize.Thumbnail.Params=Web.Enum.create("height","width","url","tooltip");
Spaces.Customize.Thumbnail.Events=Web.Enum.create("onitemselected");
registerNamespace("Spaces.Customize");
Spaces.Customize.CustomizeManager=function(){Spaces.Customize.CustomizeManager.initializeBase(this,arguments);
var objCustomizeManager=this;
var htThemeThumbnails=new Object();
var currentTheme;
var currentThemeUrl;
var currentLayout;
var currentBackgroundString="";
var arrLayouts=new Array();
var arrParts=new Array();
var backgroundMenu=null;
var htPlaceholders=new Object();
var cListsOnPage=0;
var cListCountLimit=20;
var arrListTypes=new Array("Friendslist","Links","Booklist");
var elBackgroundHidden=null;
this.initialize=function(I){Spaces.Customize.CustomizeManager.getBaseMethod(this,"initialize","Web.Bindings.Base").call(this,I);
X();
Y();
elBackgroundHidden=document.createElement("input");
elBackgroundHidden.type="hidden";
elBackgroundHidden.id="backgrounduserdata";
elBackgroundHidden.value=currentBackgroundString;
document.body.appendChild(elBackgroundHidden);
objCustomizeManager.registerFor("Spaces.Customize.ThemeThumbnail",K);
objCustomizeManager.registerFor("Spaces.Customize.LayoutThumbnail",N);
objCustomizeManager.registerFor("Spaces.Customize.PartMenuItem",Q);
objCustomizeManager.registerFor("Spaces.Customize.BackgroundPopup",U);
var bShowToolbar=false;
var querystrings=location.search.substring(1).split("&");
for(var index=0;
indexindex++){if(querystrings[index].split("=")[0].search(/^editmode$/i)!=-1){bShowToolbar=true;
break;
}}InitPage(bShowToolbar);
};
this.dispose=function(J){Spaces.Customize.CustomizeManager.getBaseMethod(this,"dispose","Web.Bindings.Base").call(this,J);
objCustomizeManager=null;
for(theme_id in htThemeThumbnails){var themeArray=htThemeThumbnails[theme_id];
for(var i=0;
ii++){themeArray[i].detachEvent("onitemselected",bb);
}}htThemeThumbnails=null;
for(var i=0;
ii++){arrLayouts[i].detachEvent("onitemselected",Z);
}arrLayouts=null;
for(var i=0;
ii++){arrParts[i].detachEvent("onitemselected",hb);
}arrParts=null;
for(var partType in htPlaceholders){var arrPlaceholders=htPlaceholders[partType];
for(var i=0;
ii++){Web.Bindings.removeBindings(arrPlaceholders[i].BoundElement);
}}htPlaceholders=null;
if(backgroundMenu)backgroundMenu.detachEvent("onitemselected",eb);
backgroundMenu=null;
elBackgroundHidden=null;
};
function K(L,M){Web.Debug.trace("CustomizeManager.RegisterForTheme");
var themeArray=htThemeThumbnails[L.Id];
if(M){L.attachEvent("onitemselected",bb);
if(!themeArray){themeArray=new Array();
htThemeThumbnails[L.Id]=themeArray;
}themeArray.push(L);
if(currentTheme==L.Id)L.Select();
}else{L.detachEvent("onitemselected",bb);
if(themeArray)themeArray.remove(L);
}}function N(O,P){Web.Debug.trace("CustomizeManager.RegisterForLayout");
if(P){O.attachEvent("onitemselected",Z);
arrLayouts.push(O);
if(O.Id==currentLayout)O.Select();
}else{O.detachEvent("onitemselected",Z);
if(arrLayouts)arrLayouts.remove(O);
}}function Q(R,S){Web.Debug.trace("CustomizeManager.RegisterForPart");
if(S){R.attachEvent("onitemselected",hb);
if(R.bIsPlaceholder){var arrPlaceholders=htPlaceholders[R.PartId];
if(!arrPlaceholders){arrPlaceholders=new Array();
htPlaceholders[R.PartId]=arrPlaceholders;
}arrPlaceholders.push(R);
}if(R.IsList()){if(!R.bIsPlaceholder||R.bIsUsed)cListsOnPage++;
if(cListsOnPage>=cListCountLimit){var recursiveCount=0;
T();
}}function T(){if(R.Parent)rb();
else{if(recursiveCount<10){recursiveCount++;
setTimeout(T,1000);
}else Web.Debug.ASSERT(false,"Parent is not defined for part binding")();
}}}else{R.detachEvent("onitemselected",hb);
if(arrParts)arrParts.remove(R);
if(R.IsPlaceholder&&arrPlaceholders)arrPlaceholders.remove(R);
}}function U(V,W){Web.Debug.trace("CustomizeManager.RegisterForBackground");
if(W){backgroundMenu=V;
currentBackgroundString=backgroundMenu.GetBackgroundString();
elBackgroundHidden.value=currentBackgroundString;
backgroundMenu.attachEvent("onitemselected",eb);
}else backgroundMenu.detachEvent("onitemselected",eb);
}function X(){var objLayoutManager=document.getElementById("layoutManager");
if(objLayoutManager&&objLayoutManager.layoutType)currentLayout=objLayoutManager.layoutType;
else currentLayout="";
}function Y(){var themeStyleSheet=document.getElementById("theme");
currentTheme=themeStyleSheet.getAttribute("title");
currentThemeUrl=Spaces.Customize.Arguments.Theme.CurrentThemeUrl;
}function Z(ab){Web.Debug.trace("CustomizeManager.ProcessLayoutSelect, layout id is "+ab.Package.layout_id);
var layout_id=ab.Package.layout_id;
if(layout_id!=currentLayout){var objLayoutManager=document.getElementById("layoutManager");
if(objLayoutManager.layoutType){objLayoutManager.setLayout(layout_id);
dirtyPage();
}var layout;
for(var i=0;
ii++){layout=arrLayouts[i];
if(layout.Id!=layout_id)layout.Deselect();
else layout.Select();
}currentLayout=layout_id;
}}function bb(cb){var theme_id=cb.Package.theme_id;
if(theme_id!=currentTheme){var oldTheme=currentTheme;
currentTheme=theme_id;
currentThemeUrl=cb.Package.theme_url;
gb();
var themeArray=htThemeThumbnails[oldTheme];
if(themeArray)for(var i=0;
ii++){themeArray[i].Deselect();
}themeArray=htThemeThumbnails[currentTheme];
if(themeArray)for(var i=0;
ii++){themeArray[i].Select();
}}}function eb(){Web.Debug.trace("CustomizeManager.ProcessBackgroundSelect");
currentBackgroundString=backgroundMenu.GetBackgroundString();
elBackgroundHidden.value=currentBackgroundString;
gb();
}function gb(){var themeStyleSheet=document.getElementById("theme");
var themeUrl=currentThemeUrl;
if(currentBackgroundString.length>0){var sep;
if(currentThemeUrl.indexOf("?")==-1)sep="?";
else sep="&";
themeUrl=currentThemeUrl+sep+"bi="+currentBackgroundString;
}themeStyleSheet.setAttribute("href",themeUrl);
themeStyleSheet.setAttribute("title",currentTheme);
dirtyPage();
}function hb(jb){dirtyPage();
if(jb.srcBinding.bMultiInstance)kb(jb.srcBinding,jb.Package.IsRemove);
else nb(jb.srcBinding,jb.Package.IsRemove);
}function kb(lb,mb){Web.Debug.trace("CustomizeManager.ProcessMultiPartSelect");
var id=lb.Id;
var targetPart=document.getElementById(id);
if(mb){Web.Debug.ASSERT(targetPart,"could not find instance of part on page")();
targetPart.style.display="none";
if(lb.bIsPlaceholder)lb.Parent.Remove(lb,true);
if(lb.IsList()&&lb.bIsPlaceholder){cListsOnPage--;
if(cListsOnPage==cListCountLimit-1)qb();
}}else{if(targetPart)targetPart.style.display="";
else{if(!lb.bIsPlaceholder)layoutManager.generatePartTemplate(lb.Id,lb.Title,Spaces.Customize.Strings.spacesettings_placeholder,lb.Expansion);
else{Web.Debug.ASSERT(lb.bIsPlaceholder&&lb.Id==lb.PartId,"Binding is not a placeholder without an associated part, as assumed")();
var newBinding=null;
for(var i=0;
ii++){var testBinding=htPlaceholders[lb.PartId][i];
if(!testBinding.GetVisible()&&testBinding.Id!=testBinding.PartId){newBinding=testBinding;
break;
}}if(newBinding){targetPart=document.getElementById(newBinding.Id);
Web.Debug.ASSERT(targetPart,"No part found associated with binding "+newBinding.Id)();
targetPart.style.display="";
}else{newBinding=lb.Clone();
id+=layoutManager.generateHash();
newBinding.Id=id;
layoutManager.generatePartTemplate(id,newBinding.Title,Spaces.Customize.Strings.spacesettings_placeholder,newBinding.Expansion);
}lb.Deselect();
newBinding.Select();
lb.Parent.AddExistingItem(newBinding,lb,true);
}}if(lb.IsList()){cListsOnPage++;
if(cListsOnPage==cListCountLimit)rb();
}}}function nb(ob,pb){Web.Debug.trace("CustomizeManager.ProcessMultiPartSelect");
var id=ob.Id;
var targetPart=document.getElementById(id);
if(targetPart){if(targetPart.style.display=="")targetPart.style.display="none";
else targetPart.style.display="";
}else layoutManager.generatePartTemplate(id,ob.Title,Spaces.Customize.Strings.spacesettings_placeholder,ob.Expansion);
}function qb(){var arrPlaceholders;
var arrItemLists=new Array();
for(var j=0;
jj++){arrPlaceholders=htPlaceholders[arrListTypes[j]];
Web.Debug.ASSERT(arrPlaceholders,"No array of placeholders for list type "+arrListTypes[j])();
if(arrPlaceholders)for(var i=0;
ii++){var placeholder=arrPlaceholders[i];
if(placeholder.Id==placeholder.PartId){if(!arrItemLists.exists(placeholder.Parent))arrItemLists.push(placeholder.Parent);
placeholder.Parent.AddExistingItem(placeholder);
}}}for(var i=0;
ii++){arrItemLists[i].Redraw();
}}function rb(){Web.Debug.trace("CustomizeManager.HideAddLists");
var arrPlaceholders;
var arrItemLists=new Array();
for(var j=0;
jj++){arrPlaceholders=htPlaceholders[arrListTypes[j]];
if(arrPlaceholders)for(var i=0;
ii++){var placeholder=arrPlaceholders[i];
if(placeholder.Id==placeholder.PartId){itemList=placeholder.Parent;
if(!arrItemLists.exists(itemList))arrItemLists.push(itemList);
placeholder.Parent.Remove(placeholder);
placeholder.Parent=itemList;
}}}for(var i=0;
ii++){arrItemLists[i].Redraw();
}}};
Spaces.Customize.CustomizeManager.registerClass("Spaces.Customize.CustomizeManager","Web.Bindings.Base");
registerNamespace("Spaces.Customize");
Spaces.Customize.ItemListPopup=function(sb,tb){Spaces.Customize.ItemListPopup.initializeBase(this,arguments);
tb=this.getParameters();
var objItemListPopup=this;
var PopupBinding=null;
var popupContents=null;
var itemList=null;
var contentContainer=null;
this.initialize=function(ub){Spaces.Customize.ItemListPopup.getBaseMethod(this,"initialize","Web.Bindings.Base").call(this,ub);
sb.attachEvent("onclick",wb);
};
this.dispose=function(vb){Spaces.Customize.ItemListPopup.getBaseMethod(this,"dispose","Web.Bindings.Base").call(this,vb);
sb.detachEvent("onclick",wb);
sb=null;
objItemListPopup=null;
if(PopupBinding)PopupBinding.dispose();
PopupBinding=null;
if(itemList)itemList.detachEvent("onitemselected",yb);
popupContents=null;
};
function wb(){Web.Debug.trace("Spaces.Customize.ItemListPopup.MenuClick");
if(!popupContents)popupContents=xb();
if(PopupBinding)PopupBinding.dispose();
PopupBinding=new Web.UI.Dialog();
PopupBinding.setContents(popupContents);
if(tb.popup_position=="side"){PopupBinding.setDock(Web.UI.Popup.VDock.Top,Web.UI.Popup.HDock.Right);
PopupBinding.setAnchor(Web.UI.Popup.VAnchor.Top,Web.UI.Popup.HAnchor.Left);
}else{PopupBinding.setDock(Web.UI.Popup.VDock.Bottom,Web.UI.Popup.HDock.Left);
PopupBinding.setAnchor(Web.UI.Popup.VAnchor.Top,Web.UI.Popup.HAnchor.Left);
}PopupBinding.setPadding(0,tb.popup_padding);
objItemListPopup.fire("onshow");
PopupBinding.display(sb,true);
}function xb(){var contents=document.createElement("div");
contents.className="customizePopup xSmallFont";
contents.style.position="absolute";
itemList=Web.Bindings.attachElementBindingSync(contents,"Spaces.Customize.ItemList",null,tb.item_list_args);
itemList.attachEvent("onitemselected",yb);
return contents;
}function yb(){Web.Debug.trace("ItemListPopup.ProcessItemSelect");
PopupBinding.dispose();
PopupBinding=null;
objItemListPopup.fire("onitemselected");
}this.hide=function(){if(PopupBinding){PopupBinding.dispose();
PopupBinding=null;
}};
};
Spaces.Customize.ItemListPopup.registerClass("Spaces.Customize.ItemListPopup","Web.Bindings.Base");
Spaces.Customize.ItemListPopup.Params=Web.Enum.create("item_list_args","popup_position","popup_padding");
Spaces.Customize.ItemListPopup.Events=Web.Enum.create("onitemselected","onshow");
registerNamespace("Spaces.Customize");
Spaces.Customize.ItemList=function(zb,Ab){Spaces.Customize.ItemList.initializeBase(this,arguments);
Ab=this.getParameters();
var arrItems=new Array();
var objItemList=this;
var contents;
var heightInItems=Ab.items_height;
var widthInItems=Ab.items_width;
var totalItems=0;
var pageContents=new Array();
var currentPageIndex=0;
var totalPages=0;
var itemsPerPage=0;
var pagingBinding=null;
this.initialize=function(Bb){Spaces.Customize.ItemList.getBaseMethod(this,"initialize","Web.Bindings.Base").call(this,Bb);
contents=document.createElement("div");
contents.className="subMenu";
zb.appendChild(contents);
totalItems=Ab.inner_binding_args.length;
var elHeader;
if(Ab.overflow=="paging")elHeader=Kb();
else elHeader=Mb();
var listContents=Ib(null);
pageContents[currentPageIndex]=listContents;
if(Ab.overflow=="scroll")listContents.style.overflow="auto";
var pxWidth=listContents.style.pixelWidth;
if(elHeader){if(Web.Browser.isIE())elHeader.style.width=listContents.style.width;
else{var pxPadding=4;
elHeader.style.pixelWidth=pxWidth-pxPadding*2;
}contents.appendChild(elHeader);
}contents.appendChild(listContents);
this.pixelWidth=pxWidth;
};
this.dispose=function(Cb){Spaces.Customize.ItemList.getBaseMethod(this,"dispose","Web.Bindings.Base").call(this,Cb);
zb=null;
for(var index=0;
indexindex++){arrItems[index].detachEvent("onitemselected",Nb);
arrItems[index].Parent=null;
}arrItems=null;
objItemList=null;
contents=null;
if(pagingBinding)pagingBinding.detachEvent("onpagechange",Ob);
pagingBinding=null;
pageContents=null;
};
this.AddExistingItem=function(Db,Eb,Fb){Web.Debug.trace("ItemList.AddExistingItem");
if(!Eb)arrItems.push(Db);
else{var beforeIndex=arrItems.indexOf(Eb);
var newArray=new Array();
var oldIndex=0;
var newIndex=0;
while(oldIndexnewArray[beforeIndex+1]=arrItems[oldIndex];
newIndex+=2;
oldIndex++;
}else{newArray[newIndex]=arrItems[oldIndex];
oldIndex++;
newIndex++;
}}arrItems=newArray;
}Db.Parent=objItemList;
Db.attachEvent("onitemselected",Nb);
totalItems+=1;
if(Fb)objItemList.Redraw();
};
this.Remove=function(Gb,Hb){if(arrItems.remove(Gb)){Gb.Parent=null;
Gb.detachEvent("onitemselected",Nb);
Gb.SetPosition(0,0);
Gb.SetVisible(false);
totalItems-=1;
if(Hb)objItemList.Redraw();
}};
this.Redraw=function(){Web.Debug.trace("ItemList.Redraw");
var i;
var oldPage=currentPageIndex;
for(i=0;
ii++){arrItems[i].SetVisible(false);
}for(i=0;
ii++){if(pageContents[i]){currentPageIndex=i;
Ib(pageContents[i]);
}}currentPageIndex=oldPage;
};
function Ib(Jb){var bNewList=false;
if(!Jb){bNewList=true;
Jb=document.createElement("div");
Jb.style.position="relative";
}var startIndex;
var maxIndex;
if(Ab.overflow=="paging"){startIndex=currentPageIndex*itemsPerPage;
maxIndex=Math.min(startIndex+itemsPerPage,totalItems);
}else{if(Ab.overflow=="none"){startIndex=0;
maxIndex=Math.min(heightInItems*widthInItems,totalItems);
}else{if(Ab.overflow=="scroll"){startIndex=0;
maxIndex=totalItems;
}else Web.Debug.ASSERT(false,"unexpected overflow param: "+Ab.overflow)();
}}Web.Debug.ASSERT(maxIndex>=startIndex,"infinite loop: startIndex is greater than max")();
var pxPadding=Ab.padding*1;
var pxOffsetTop=0;
var pxOffsetLeft=0;
var pxRowHeight=0;
var pxRowWidth=0;
var pxLastItemWidth=0;
var cRows=0;
var pxScrollHeight=0;
for(var index=startIndex;
indexindex++){if((index-startIndex)%widthInItems==0){pxRowWidth=Math.max(pxOffsetLeft,pxRowWidth);
pxOffsetTop=pxOffsetTop+pxRowHeight+pxPadding;
pxOffsetLeft=pxPadding;
pxRowHeight=0;
cRows++;
}var bindingItem;
if(bNewList){var elToBind=document.createElement("div");
var bindingItem=Web.Bindings.attachElementBindingSync(elToBind,Ab.inner_binding_type[index],null,Ab.inner_binding_args[index]);
arrItems.push(bindingItem);
bindingItem.Parent=objItemList;
bindingItem.attachEvent("onitemselected",Nb);
Jb.appendChild(elToBind);
}else bindingItem=arrItems[index];
bindingItem.SetPosition(pxOffsetTop,pxOffsetLeft);
bindingItem.SetVisible(true);
pxRowHeight=Math.max(pxRowHeight,bindingItem.pixelHeight);
pxOffsetLeft=pxOffsetLeft+pxPadding+bindingItem.pixelWidth;
pxLastItemWidth=bindingItem.pixelWidth;
if(cRows<=heightInItems)pxScrollHeight=pxOffsetTop+pxRowHeight+pxPadding;
}pxRowWidth=Math.max(pxRowWidth,pxOffsetLeft);
var emptyCols=Math.max(widthInItems-totalItems,0);
var pxWidth=pxRowWidth+emptyCols*(pxPadding+pxLastItemWidth);
var pxHeight=pxOffsetTop+pxRowHeight+pxPadding;
if(Ab.fill_height&&Ab.fill_height!="false"){var emptyRows=heightInItems-cRows;
pxHeight=pxHeight+emptyRows*(pxRowHeight+pxPadding);
}if(Ab.overflow=="scroll"){if(cRows>heightInItems)pxHeight=pxScrollHeight;
pxWidth+=25;
}Jb.style.pixelHeight=pxHeight;
Jb.style.pixelWidth=pxWidth;
return Jb;
}function Kb(Lb){var elHeader=document.createElement("div");
elHeader.className="headerBar";
itemsPerPage=heightInItems*widthInItems;
totalPages=Math.ceil(totalItems/itemsPerPage);
if(totalPages<=1)elHeader=Mb();
else{var pagingArgs=new Object();
pagingArgs.current_page=currentPageIndex;
pagingArgs.items_per_page=itemsPerPage;
pagingArgs.total_items=totalItems;
pagingArgs.total_pages=totalPages;
pagingBinding=Web.Bindings.attachElementBindingSync(elHeader,"Spaces.Customize.Paging",null,pagingArgs);
pagingBinding.attachEvent("onpagechange",Ob);
}return elHeader;
}function Mb(){var elHeader=null;
if(!Ab.remove_header){elHeader=document.createElement("div");
elHeader.className="headerBar";
}return elHeader;
}function Nb(){Web.Debug.trace("ItemList.ProcessItemSelect");
objItemList.fire("onitemselected");
}function Ob(){if(pagingBinding.CurrentPage==currentPageIndex)return;
var oldIndex=currentPageIndex;
currentPageIndex=pagingBinding.CurrentPage;
if(!pageContents[currentPageIndex])pageContents[currentPageIndex]=Ib(null);
contents.replaceChild(pageContents[currentPageIndex],pageContents[oldIndex]);
}};
Spaces.Customize.ItemList.registerClass("Spaces.Customize.ItemList","Web.Bindings.Base");
Spaces.Customize.ItemList.Params=Web.Enum.create("overflow","inner_binding_type","inner_binding_args","items_height","items_width","fill_height","remove_header");
Spaces.Customize.ItemList.Events=Web.Enum.create("onitemselected");
registerNamespace("Spaces.Customize");
Spaces.Customize.CategoryPopup=function(Pb,Qb){Spaces.Customize.CategoryPopup.initializeBase(this,arguments);
Qb=this.getParameters();
var PopupBinding=null;
var popupContents=null;
var objCategoryPopup=this;
var arrCategoryBindings=new Array();
var arrCategoryLinks=new Array();
var featuredAreaBinding=null;
this.initialize=function(Rb){Spaces.Customize.CategoryPopup.getBaseMethod(this,"initialize","Web.Bindings.Base").call(this,Rb);
Pb.attachEvent("onclick",Tb);
};
this.dispose=function(Sb){Spaces.Customize.CategoryPopup.getBaseMethod(this,"dispose","Web.Bindings.Base").call(this,Sb);
Pb.detachEvent("onclick",Tb);
Pb=null;
if(PopupBinding)PopupBinding.dispose();
PopupBinding=null;
objCategoryPopup=null;
var index=0;
for(index=0;
indexindex++){arrCategoryBindings[index].detachEvent("onitemselected",ec);
arrCategoryBindings[index].detachEvent("onshow",gc);
}arrCategoryBindings=null;
for(index=0;
indexindex++){arrCategoryLinks[index].detachEvent("onclick",Spaces.Customize.HaltNavigation);
}arrCategoryLinks=null;
if(featuredAreaBinding){featuredAreaBinding.detachEvent("onitemselected",ec);
featuredAreaBinding.detachEvent("onshow",gc);
}featuredAreaBinding=null;
popupContents=null;
};
function Tb(Ub){Web.Debug.trace("Spaces.Customize.CategoryPopup.MenuClick");
if(PopupBinding)PopupBinding.dispose();
PopupBinding=new Web.UI.Dialog();
if(!popupContents){if(Qb.role=="theme")popupContents=Vb(Spaces.Customize.Arguments.Theme);
else{Web.Debug.ASSERT(false,"Unexpected role for categoryPopup")();
popupContents=Vb(Qb);
}}PopupBinding.setContents(popupContents);
PopupBinding.setDock(Web.UI.Popup.VDock.Bottom,Web.UI.Popup.HDock.Left);
PopupBinding.setAnchor(Web.UI.Popup.VAnchor.Top,Web.UI.Popup.HAnchor.Left);
PopupBinding.display(Pb,true);
Ub.returnValue=false;
}function Vb(Wb){var menuContents=document.createElement("div");
menuContents.className="customizePopup xSmallFont";
menuContents.style.position="absolute";
var pxWidth=200;
if(Wb.display_featured_area&&Wb.display_featured_area!="false"){var elFeaturedArea=document.createElement("div");
menuContents.appendChild(elFeaturedArea);
featuredAreaBinding=Web.Bindings.attachElementBindingSync(elFeaturedArea,Wb.featured_binding_type,null,Wb.featured_binding_args);
featuredAreaBinding.attachEvent("onitemselected",ec);
featuredAreaBinding.attachEvent("onshow",gc);
var pxFeaturedWidth=featuredAreaBinding.pixelWidth;
pxWidth=Math.max(pxWidth,pxFeaturedWidth+2);
}menuContents.style.pixelWidth=pxWidth;
for(var index=0;
indexindex++){var categoryLink=Xb(menuContents,Wb.categories[index],pxWidth,Wb.inner_binding_type,Wb.inner_binding_args[index]);
}return menuContents;
}function Xb(Yb,Zb,ac,bc,cc){var categoryLink=document.createElement("a");
var containerDiv=document.createElement("div");
containerDiv.className="catMenuEntry";
var pxCategoryTextWidth=ac-27;
var size=Spaces.Customize.CalculateTextSize(Zb,false,pxCategoryTextWidth);
var pxCategoryTextHeight=Math.round(size.height);
var pxCategoryItemHeight=Math.round(pxCategoryTextHeight*1.5);
var pxCategoryTextMargin=Math.round(pxCategoryTextHeight*0.25);
var pxImageMargin=Math.round((pxCategoryItemHeight-8)*0.5);
containerDiv.style.pixelHeight=pxCategoryItemHeight;
var leftDiv=document.createElement("div");
leftDiv.style.cssFloat="left";
leftDiv.style.styleFloat="left";
leftDiv.className="catMenuText";
leftDiv.innerText=Zb;
leftDiv.style.pixelWidth=pxCategoryTextWidth;
leftDiv.style.marginTop=pxCategoryTextMargin;
containerDiv.appendChild(leftDiv);
var rightDiv=document.createElement("div");
rightDiv.style.cssFloat="right";
rightDiv.style.styleFloat="right";
rightDiv.className="catMenuImg";
rightDiv.innerHTML="\"\"";
rightDiv.style.marginTop=pxImageMargin;
containerDiv.appendChild(rightDiv);
categoryLink.appendChild(containerDiv);
categoryLink.style.display="block";
categoryLink.href="#";
categoryLink.attachEvent("onclick",Spaces.Customize.HaltNavigation);
arrCategoryLinks.push(categoryLink);
Yb.appendChild(categoryLink);
var categoryBinding=Web.Bindings.attachElementBindingSync(categoryLink,bc,null,cc);
arrCategoryBindings.push(categoryBinding);
categoryBinding.attachEvent("onitemselected",ec);
categoryBinding.attachEvent("onshow",gc);
return categoryLink;
}function ec(){Web.Debug.trace("CategoryPopup.ProcessItemSelect");
PopupBinding.dispose();
PopupBinding=null;
}function gc(hc){for(index=0;
indexindex++){if(arrCategoryBindings[index]!=hc.srcBinding)arrCategoryBindings[index].hide();
}if(featuredAreaBinding&&featuredAreaBinding!=hc.srcBinding)featuredAreaBinding.hide();
}};
Spaces.Customize.CategoryPopup.registerClass("Spaces.Customize.CategoryPopup","Web.Bindings.Base");
Spaces.Customize.CategoryPopup.Params=Web.Enum.create("inner_binding_type","inner_binding_args","categories","display_featured_area","featured_binding_type","featured_binding_args","role");
registerNamespace("Spaces.Customize");
Spaces.Customize.FeaturedArea=function(jc,kc){Spaces.Customize.FeaturedArea.initializeBase(this,arguments);
kc=this.getParameters();
var objFeaturedArea=this;
var elMoreLink;
var itemListBinding;
var itemListPopupBinding;
this.initialize=function(lc){Spaces.Customize.FeaturedArea.getBaseMethod(this,"initialize","Web.Bindings.Base").call(this,lc);
var elHeader=document.createElement("div");
elHeader.className="headerBar bold";
elHeader.innerText=kc.title;
jc.appendChild(elHeader);
var itemListContainer=document.createElement("div");
jc.appendChild(itemListContainer);
itemListBinding=Web.Bindings.attachElementBindingSync(itemListContainer,"Spaces.Customize.ItemList",null,kc.item_list_args);
itemListBinding.attachEvent("onitemselected",nc);
if(kc.display_popup&&kc.display_popup!="false"){var elMoreLink=document.createElement("a");
elMoreLink.className="moreLink";
elMoreLink.innerHTML="
\">{0} 
\"\"
".format(Spaces.Customize.Strings.themes_viewmorethemes);
elMoreLink.href="#";
elMoreLink.attachEvent("onclick",Spaces.Customize.HaltNavigation);
jc.appendChild(elMoreLink);
var elMorePadding=document.createElement("div");
elMorePadding.style.width="100%";
elMorePadding.style.height="15px";
elMorePadding.style.marginBottom="5px";
jc.appendChild(elMorePadding);
itemListPopupBinding=Web.Bindings.attachElementBindingSync(elMoreLink,"Spaces.Customize.ItemListPopup",null,kc.item_list_popup_args);
itemListPopupBinding.attachEvent("onitemselected",nc);
itemListPopupBinding.attachEvent("onshow",pc);
}elLowerHeader=document.createElement("div");
elLowerHeader.className="headerBar bold";
elLowerHeader.style.borderTop="1px solid #000000";
elLowerHeader.innerText=Spaces.Customize.Strings.themes_morethemes;
jc.appendChild(elLowerHeader);
this.pixelWidth=itemListBinding.pixelWidth;
};
this.dispose=function(mc){Spaces.Customize.FeaturedArea.getBaseMethod(this,"dispose","Web.Bindings.Base").call(this,mc);
jc=null;
if(elMoreLink)elMoreLink.detachEvent("onclick",Spaces.Customize.HaltNavigation);
elMoreLink=null;
if(itemListBinding)itemListBinding.detachEvent("onitemselected",nc);
itemListBinding=null;
if(itemListPopupBinding){itemListPopupBinding.detachEvent("onitemselected",nc);
itemListPopupBinding.detachEvent("onshow",pc);
}itemListPopupBinding=null;
};
function nc(oc){Web.Debug.trace("FeaturedArea.ProcessItemSelect");
objFeaturedArea.fire("onitemselected");
}function pc(){objFeaturedArea.fire("onshow");
}this.hide=function(){if(itemListPopupBinding)itemListPopupBinding.hide();
};
};
Spaces.Customize.FeaturedArea.registerClass("Spaces.Customize.FeaturedArea","Web.Bindings.Base");
Spaces.Customize.FeaturedArea.Params=Web.Enum.create("title","item_list_args","display_popup","item_list_popup_args");
Spaces.Customize.FeaturedArea.Events=Web.Enum.create("onitemselected","onshow");
registerNamespace("Spaces.Customize");
Spaces.Customize.ThemeThumbnail=function(qc,rc){Spaces.Customize.ThemeThumbnail.initializeBase(this,arguments);
rc=this.getParameters();
var objThemeThumbnail=this;
this.initialize=function(sc){this.Id=rc.theme_id;
Spaces.Customize.ThemeThumbnail.getBaseMethod(this,"initialize","Spaces.Customize.Thumbnail").call(this,sc);
};
this.dispose=function(tc){Spaces.Customize.ThemeThumbnail.getBaseMethod(this,"dispose","Spaces.Customize.Thumbnail").call(this,tc);
qc=null;
objThemeThumbnail=null;
};
this.ProcessItemSelect=function(uc){Web.Debug.trace("Spaces.Customize.ThemeThumbnail.ProcessItemSelect");
uc.returnValue=false;
objThemeThumbnail.fire("onitemselected",rc);
};
};
Spaces.Customize.ThemeThumbnail.registerClass("Spaces.Customize.ThemeThumbnail","Spaces.Customize.Thumbnail");
Spaces.Customize.ThemeThumbnail.Params=Web.Enum.create("theme_id","theme_url");
registerNamespace("Spaces.Customize");
Spaces.Customize.PartPopup=function(vc,wc){Spaces.Customize.PartPopup.initializeBase(this,arguments);
wc=this.getParameters();
this.initialize=function(xc){Spaces.Customize.PartPopup.getBaseMethod(this,"initialize","Web.Bindings.Base").call(this,xc);
Web.Bindings.attachElementBinding(vc,"Spaces.Customize.ItemListPopup",null,Spaces.Customize.Arguments.Part);
};
this.dispose=function(yc){Spaces.Customize.PartPopup.getBaseMethod(this,"dispose","Web.Bindings.Base").call(this,yc);
vc=null;
};
};
Spaces.Customize.PartPopup.registerClass("Spaces.Customize.PartPopup","Web.Bindings.Base");
registerNamespace("Spaces.Customize");
Spaces.Customize.PartMenuItem=function(zc,Ac){Spaces.Customize.PartMenuItem.initializeBase(this,arguments);
Ac=this.getParameters();
var elLink=null;
var objMenuItem=this;
var elAddRemoveText=null;
this.initialize=function(Bc){this.Expansion=Ac.expansion;
this.Title=Ac.title;
this.PartId=Ac.part_type_id;
this.BoundElement=zc;
if(Ac.is_used&&Ac.is_used!="false")this.bIsUsed=true;
else this.bIsUsed=false;
if(Ac.multi_instance&&Ac.multi_instance!="false")this.bMultiInstance=true;
else this.bMultiInstance=false;
if(Ac.item_id){this.Id=Ac.item_id;
this.bIsPlaceholder=false;
}else{this.Id=Ac.part_type_id;
this.bIsPlaceholder=this.bMultiInstance;
}elLink=document.createElement("a");
elLink.href="#";
elLink.style.color="#000000";
elLink.title=Ac.tooltip;
elLink.className="moduleItem";
var elPartName=document.createElement("div");
elPartName.innerText=Ac.title;
elPartName.className="bold";
elPartName.style.height="20px";
elAddRemoveText=document.createElement("div");
elAddRemoveText.style.styleFloat="right";
elAddRemoveText.style.cssFloat="right";
Gc();
elLink.appendChild(elAddRemoveText);
elLink.appendChild(elPartName);
zc.appendChild(elLink);
var size=Kc(Ac.title);
this.pixelHeight=size.height;
this.pixelWidth=size.width;
elLink.attachEvent("onclick",Mc);
Spaces.Customize.PartMenuItem.getBaseMethod(this,"initialize","Web.Bindings.Base").call(this,Bc);
};
this.dispose=function(Cc){Spaces.Customize.PartMenuItem.getBaseMethod(this,"dispose","Web.Bindings.Base").call(this,Cc);
zc=null;
if(elLink)elLink.detachEvent("onclick",Mc);
elLink=null;
elAddRemoveText=null;
objMenuItem=null;
};
this.Clone=function(){var otherArgs=new Object();
otherArgs.title=objMenuItem.Title;
otherArgs.tooltip=Ac.tooltip;
otherArgs.is_used=false;
otherArgs.part_type_id=objMenuItem.PartId;
otherArgs.expansion=objMenuItem.Expansion;
otherArgs.multi_instance=objMenuItem.bMultiInstance;
var otherEl=document.createElement("div");
var otherBinding=Web.Bindings.attachElementBinding(otherEl,"Spaces.Customize.PartMenuItem",null,otherArgs);
otherBinding.SetVisible(false);
zc.parentElement.appendChild(otherEl);
return otherBinding;
};
this.GetVisible=function(){return elLink.style.display=="";
};
this.SetVisible=function(Dc){if(Dc)elLink.style.display="";
else elLink.style.display="none";
};
this.SetPosition=function(Ec,Fc){Hc(Ec,Fc);
};
this.Select=function(){objMenuItem.bIsUsed=true;
Gc();
};
this.Deselect=function(){objMenuItem.bIsUsed=false;
Gc();
};
this.IsList=function(){return objMenuItem.PartId=="Friendslist"||objMenuItem.PartId=="Links"||objMenuItem.PartId=="Booklist";
};
function Gc(){var text;
if(objMenuItem.bMultiInstance){if(objMenuItem.bIsPlaceholder){if(!objMenuItem.bIsUsed)text=Spaces.Customize.Strings.spacesettings_addnew;
else text=Spaces.Customize.Strings.spacesettings_delete;
}else{if(!objMenuItem.bIsUsed)text=Spaces.Customize.Strings.spacesettings_show;
else text=Spaces.Customize.Strings.spacesettings_hide;
}}else{if(!objMenuItem.bIsUsed)text=Spaces.Customize.Strings.spacesettings_add;
else text=Spaces.Customize.Strings.spacesettings_remove;
}elAddRemoveText.innerText=text;
}function Hc(Ic,Jc){var text="position:absolute;
height:"+objMenuItem.pixelHeight+"px;
top:"+Ic+"px;
left:"+Jc+"px";
zc.style.cssText=text;
}function Kc(Lc){var padding=5;
var partTextSize=Spaces.Customize.CalculateTextSize(Lc,true);
var addTextSize=Spaces.Customize.CalculateTextSize(Spaces.Customize.Strings.spacesettings_add,false);
var createTextSize=Spaces.Customize.CalculateTextSize(Spaces.Customize.Strings.spacesettings_addnew,false);
var deleteTextSize=Spaces.Customize.CalculateTextSize(Spaces.Customize.Strings.spacesettings_delete,false);
var removeTextSize=Spaces.Customize.CalculateTextSize(Spaces.Customize.Strings.spacesettings_remove,false);
var rightTextWidth=Math.max(Math.max(Math.max(addTextSize.width,createTextSize.width),deleteTextSize.width),removeTextSize.width);
var finalSize=new Object();
finalSize.width=rightTextWidth+padding+partTextSize.width;
finalSize.height=addTextSize.height;
return finalSize;
}function Mc(Nc){Web.Debug.trace("PartMenuItem.ProcessItemSelect for item "+objMenuItem.Id);
Nc.returnValue=false;
if(objMenuItem.GetVisible()){var eventPackage=new Object();
eventPackage.IsRemove=objMenuItem.bIsUsed;
objMenuItem.bIsUsed=!objMenuItem.bIsUsed;
Gc();
objMenuItem.fire("onitemselected",eventPackage);
}}};
Spaces.Customize.PartMenuItem.registerClass("Spaces.Customize.PartMenuItem","Web.Bindings.Base");
Spaces.Customize.PartMenuItem.Events=Web.Enum.create("onitemselected");
Spaces.Customize.PartMenuItem.Params=Web.Enum.create("title","tooltip","is_used","part_type_id","expansion","multi_instance","item_id");
registerNamespace("Spaces.Customize");
Spaces.Customize.LayoutPopup=function(Oc,Pc){Spaces.Customize.LayoutPopup.initializeBase(this,arguments);
Pc=this.getParameters();
this.initialize=function(Qc){Spaces.Customize.LayoutPopup.getBaseMethod(this,"initialize","Web.Bindings.Base").call(this,Qc);
Web.Bindings.attachElementBinding(Oc,"Spaces.Customize.ItemListPopup",null,Spaces.Customize.Arguments.Layout);
};
this.dispose=function(Rc){Spaces.Customize.ItemListPopup.getBaseMethod(this,"dispose","Web.Bindings.Base").call(this,Rc);
Oc=null;
};
};
Spaces.Customize.LayoutPopup.registerClass("Spaces.Customize.LayoutPopup","Web.Bindings.Base");
registerNamespace("Spaces.Customize");
Spaces.Customize.LayoutThumbnail=function(Sc,Tc){Spaces.Customize.LayoutThumbnail.initializeBase(this,arguments);
Tc=this.getParameters();
var objLayoutThumbnail=this;
this.initialize=function(Uc){this.Id=Tc.layout_id;
Spaces.Customize.LayoutThumbnail.getBaseMethod(this,"initialize","Spaces.Customize.Thumbnail").call(this,Uc);
};
this.dispose=function(Vc){Spaces.Customize.LayoutThumbnail.getBaseMethod(this,"dispose","Spaces.Customize.Thumbnail").call(this,Vc);
Sc=null;
objLayoutThumbnail=null;
};
this.ProcessItemSelect=function(Wc){Web.Debug.trace("Spaces.Customize.LayoutThumbnail.ProcessItemSelect");
Wc.returnValue=false;
objLayoutThumbnail.fire("onitemselected",Tc);
};
};
Spaces.Customize.LayoutThumbnail.registerClass("Spaces.Customize.LayoutThumbnail","Spaces.Customize.Thumbnail");
Spaces.Customize.LayoutThumbnail.Params=Web.Enum.create("layout_id");
registerNamespace("Spaces.Customize");
Spaces.Customize.BackgroundPopup=function(Xc,Yc){Spaces.Customize.BackgroundPopup.initializeBase(this,arguments);
Yc=this.getParameters();
var objBackgroundPopup=this;
var PopupBinding=null;
var popupContents=null;
var DefaultOptBinding=null;
var CustomTileOptBinding=null;
var CustomCenterOptBinding=null;
var elCustomOptionSection=null;
var bHaveBackground=false;
var bUseBackground=false;
var backgroundPageUrl;
var saveReturnUrl;
var strBackgroundQS1="";
var strBackgroundQS2="";
var strBackgroundQS3="";
var strCenterSelected="4|0";
var strTileSelected="0|3";
var pxSelectedImgSize=16;
var pxIndentAmt=pxSelectedImgSize+6;
this.initialize=function(Zc){Web.Debug.trace("BackgroundPopup.initialize");
Xc.attachEvent("onclick",be);
if(Spaces.Customize.Arguments.Background.have_background=="true")bHaveBackground=true;
bUseBackground=bHaveBackground;
backgroundPageUrl=Spaces.Customize.Arguments.Background.background_page;
if(bHaveBackground){var pieces=Spaces.Customize.Arguments.Background.background_qs.split("|");
if(pieces.length==6){strBackgroundQS1=pieces[0]+"|"+pieces[1]+"|";
strBackgroundQS2=pieces[2]+"|"+pieces[3];
strBackgroundQS3="|"+pieces[4]+"|"+pieces[5];
}}saveReturnUrl=Spaces.Customize.Arguments.Background.save_return_url;
Spaces.Customize.BackgroundPopup.getBaseMethod(this,"initialize","Web.Bindings.Base").call(this,Zc);
};
this.dispose=function(ae){Spaces.Customize.BackgroundPopup.getBaseMethod(this,"dispose","Web.Bindings.Base").call(this,ae);
Xc.detachEvent("onclick",be);
Xc=null;
if(DefaultOptBinding)DefaultOptBinding.detachEvent("onitemselected",Be);
if(CustomTileOptBinding)CustomTileOptBinding.detachEvent("onitemselected",De);
if(CustomCenterOptBinding)CustomCenterOptBinding.detachEvent("onitemselected",Fe);
objBackgroundPopup=null;
if(PopupBinding)PopupBinding.dispose();
PopupBinding=null;
DefaultOptBinding=null;
CustomTileOptBinding=null;
CustomCenterOptBinding=null;
elCustomOptionSection=null;
popupContents=null;
};
this.GetBackgroundString=function(){if(bHaveBackground&&bUseBackground)return strBackgroundQS1+strBackgroundQS2+strBackgroundQS3;
else return "";
};
function be(ce){Web.Debug.trace("Spaces.Customize.BackgroundPopup.MenuClick");
if(PopupBinding)PopupBinding.dispose();
PopupBinding=new Web.UI.Dialog();
if(!popupContents)popupContents=ee();
PopupBinding.setContents(popupContents);
PopupBinding.setDock(Web.UI.Popup.VDock.Bottom,Web.UI.Popup.HDock.Left);
PopupBinding.setAnchor(Web.UI.Popup.VAnchor.Top,Web.UI.Popup.HAnchor.Left);
PopupBinding.display(Xc,true);
ce.returnValue=false;
}function ee(){var contents=document.createElement("div");
contents.className="customizePopup xSmallFont";
contents.style.position="absolute";
var size=He();
ge(contents,size.height,size.textmargin,size.imagemargin);
me(contents,size.height,size.textmargin,size.imagemargin);
re(contents,size.textmargin);
if(!bHaveBackground)elCustomOptionSection.style.display="none";
contents.style.pixelWidth=size.width;
return contents;
}function ge(he,je,ke,le){elDefaultOptionSection=document.createElement("div");
elDefaultOptionSection.style.pixelHeight=je;
DefaultOptBinding=ue(elDefaultOptionSection,Be,Spaces.Customize.Strings.backgroundmenu_defaultopt,ke,le,!bHaveBackground);
he.appendChild(elDefaultOptionSection);
}function me(ne,oe,pe,qe){var bCenterSelected=strBackgroundQS2==strCenterSelected;
var elDiv;
elCustomOptionSection=document.createElement("div");
elDiv=document.createElement("div");
elDiv.className="customAreaTop";
elDiv.style.pixelHeight=oe;
elDiv.style.marginTop=pe;
CustomTileOptBinding=ue(elDiv,De,Spaces.Customize.Strings.backgroundmenu_tileopt,pe,qe,!bCenterSelected);
elCustomOptionSection.appendChild(elDiv);
elDiv=document.createElement("div");
elDiv.className="customAreaBottom";
elDiv.style.pixelHeight=oe;
CustomCenterOptBinding=ue(elDiv,Fe,Spaces.Customize.Strings.backgroundmenu_centeropt,pe,qe,bCenterSelected);
elCustomOptionSection.appendChild(elDiv);
ne.appendChild(elCustomOptionSection);
}function re(se,te){Web.Debug.trace("CreateCustomLink");
var elCustomLink=document.createElement("a");
elCustomLink.href=backgroundPageUrl;
elCustomLink.attachEvent("onclick",Ie);
elCustomLink.className="backgroundMenuLink";
elCustomLink.style.marginLeft=pxIndentAmt+"px";
elCustomLink.style.marginTop=te+"px";
elCustomLink.style.marginBottom=te+"px";
elCustomLink.innerText=Spaces.Customize.Strings.backgroundmenu_choosecustom;
se.appendChild(elCustomLink);
}function ue(ve,we,xe,ye,ze,Ae){var selectedText;
if(Ae)selectedText="true";
else selectedText="false";
var args={"text":xe,"selected":selectedText,"textmargin":ye,"imagemargin":ze};
var binding=Web.Bindings.attachElementBindingSync(ve,"Spaces.Customize.SelectableText",null,args);
binding.attachEvent("onitemselected",we);
return binding;
}function Be(Ce){Web.Debug.trace("BackgroundPopup.DefaultSelected");
bUseBackground=false;
CustomTileOptBinding.Deselect();
CustomCenterOptBinding.Deselect();
DefaultOptBinding.Select();
PopupBinding.dispose();
PopupBinding=null;
objBackgroundPopup.fire("onitemselected");
Ce.returnValue=false;
}function De(Ee){Web.Debug.trace("BackgroundPopup.TileSelected");
DefaultOptBinding.Deselect();
CustomCenterOptBinding.Deselect();
CustomTileOptBinding.Select();
bUseBackground=true;
strBackgroundQS2=strTileSelected;
PopupBinding.dispose();
PopupBinding=null;
objBackgroundPopup.fire("onitemselected");
Ee.returnValue=false;
}function Fe(Ge){Web.Debug.trace("BackgroundPopup.CenterSelected");
DefaultOptBinding.Deselect();
CustomTileOptBinding.Deselect();
CustomCenterOptBinding.Select();
bUseBackground=true;
strBackgroundQS2=strCenterSelected;
PopupBinding.dispose();
PopupBinding=null;
objBackgroundPopup.fire("onitemselected");
Ge.returnValue=false;
}function He(){Web.Debug.trace("BackgroundPopup.CalculateWidth");
var defaultSize=Spaces.Customize.CalculateTextSize(Spaces.Customize.Strings.backgroundmenu_defaultopt,false);
var tileSize=Spaces.Customize.CalculateTextSize(Spaces.Customize.Strings.backgroundmenu_tileopt,false);
var centerSize=Spaces.Customize.CalculateTextSize(Spaces.Customize.Strings.backgroundmenu_centeropt,false);
var linkSize=Spaces.Customize.CalculateTextSize(Spaces.Customize.Strings.backgroundmenu_choosecustom,false);
var maxWidth=Math.max(defaultSize.width,tileSize.width,centerSize.width,linkSize.width)+pxIndentAmt;
var maxTextHeight=Math.max(defaultSize.height,tileSize.height,centerSize.height,linkSize.height);
var maxHeight=Math.max(maxTextHeight*1.5,pxSelectedImgSize);
return {"width":Math.round(maxWidth+10),"height":Math.round(maxHeight),"textmargin":Math.round((maxHeight-maxTextHeight)*0.5),"imagemargin":Math.round((maxHeight-pxSelectedImgSize)*0.5)};
}function Ie(Je){if(isDirty()){if(confirm(Spaces.Customize.Strings.backgroundmenu_linkprompt)){verifySave(saveReturnUrl);
return true;
}else{Je.returnValue=false;
return false;
}}else return true;
}};
Spaces.Customize.BackgroundPopup.registerClass("Spaces.Customize.BackgroundPopup","Web.Bindings.Base");
Spaces.Customize.BackgroundPopup.Params=Web.Enum.create("have_background","background_qs","background_page","save_return_url");
Spaces.Customize.BackgroundPopup.Events=Web.Enum.create("onitemselected");
registerNamespace("Spaces.Customize");
Spaces.Customize.SelectableText=function(Ke,Le){Spaces.Customize.SelectableText.initializeBase(this,arguments);
Le=this.getParameters();
var objSelText=this;
var elLink=null;
var elImgContainer=null;
var iSelectedImgSize="16px";
this.initialize=function(Me){Spaces.Customize.SelectableText.getBaseMethod(this,"initialize","Web.Bindings.Base").call(this,Me);
elLink=document.createElement("a");
elLink.href="#";
elLink.attachEvent("onclick",Oe);
elLink.innerText=Le.text;
elLink.style.marginTop=Le.textmargin;
var elDiv=document.createElement("div");
elDiv.className="backgroundMenuText";
elDiv.appendChild(elLink);
Ke.appendChild(elDiv);
elDiv.style.position="relative";
elLink.style.position="absolute";
elLink.style.left="22px";
elImgContainer=document.createElement("div");
elImgContainer.style.height=iSelectedImgSize;
elImgContainer.style.width=iSelectedImgSize;
elImgContainer.style.marginTop=Le.imagemargin;
if(Le.selected=="true")objSelText.Select();
else objSelText.Deselect();
Ke.appendChild(elImgContainer);
};
this.dispose=function(Ne){Spaces.Customize.SelectableText.getBaseMethod(this,"dispose","Web.Bindings.Base").call(this,Ne);
Ke=null;
objSelText=null;
elLink.detachEvent("onclick",Oe);
elLink=null;
elImgContainer=null;
};
this.Select=function(){elImgContainer.className="backgroundSelected";
};
this.Deselect=function(){elImgContainer.className="backgroundUnselected";
};
function Oe(Pe){objSelText.fire("onitemselected");
Pe.returnValue=false;
}};
Spaces.Customize.SelectableText.registerClass("Spaces.Customize.SelectableText","Web.Bindings.Base");
Spaces.Customize.SelectableText.Params=Web.Enum.create("text","selected","textmargin","imagemargin");
Spaces.Customize.SelectableText.Events=Web.Enum.create("onitemselected");