AJS.Confluence.SharePage={};
AJS.Confluence.SharePage.autocompleteUser=function(C){C=C||document.body;
var D=AJS.$,A=/^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
var B=function(F){if(!F||!F.result){throw new Error("Invalid JSON format")
}var E=[];
E.push(F.result);
return E
};
D("input.autocomplete-sharepage[data-autocomplete-user-bound!=true]",C).each(function(){var G=D(this).attr("data-autocomplete-sharepage-bound","true").attr("autocomplete","off");
var F=G.attr("data-max")||10,I=G.attr("data-alignment")||"left",H=G.attr("data-dropdown-target"),E=null;
if(H){E=D(H)
}else{E=D("<div></div>");
G.after(E)
}E.addClass("aui-dd-parent autocomplete");
G.quicksearch(AJS.REST.getBaseUrl()+"search/user.json",function(){G.trigger("open.autocomplete-sharepage")
},{makeParams:function(J){return{"max-results":F,query:J}
},dropdownPlacement:function(J){E.append(J)
},makeRestMatrixFromData:B,addDropdownData:function(K){var J=D.trim(G.val());
if(A.test(J)){K.push([{name:J,email:J,href:"#",icon:AJS.Confluence.getContextPath()+"/images/icons/profilepics/anonymous.png"}])
}if(!K.length){var L=G.attr("data-none-message");
if(L){K.push([{name:L,className:"no-results",href:"#"}])
}}return K
},ajsDropDownOptions:{alignment:I,displayHandler:function(J){if(J.restObj&&J.restObj.username){return J.name+" ("+J.restObj.username+")"
}return J.name
},selectionHandler:function(L,K){if(K.find(".search-for").length){G.trigger("selected.autocomplete-sharepage",{searchFor:G.val()});
return 
}if(K.find(".no-results").length){this.hide();
L.preventDefault();
return 
}var J=D("span:eq(0)",K).data("properties");
if(!J.email){J=J.restObj
}G.trigger("selected.autocomplete-sharepage",{content:J});
this.hide();
L.preventDefault()
}}})
})
};
(function(E){var D,B={hideCallback:A,width:280,offsetY:17,offsetX:-40,hideDelay:3600000};
var A=function(){E(".dashboard-actions .explanation").hide()
};
var C=function(I,G,H){I.empty();
I.append(AJS.template.load("share-content-popup").fill());
AJS.Confluence.SharePage.autocompleteUser();
var J=function(){D.hide();
return false
};
E(document).keyup(function(L){if(L.keyCode==27){J();
E(document).unbind("keyup",arguments.callee);
return false
}return true
});
I.find(".close-dialog").click(J);
I.find("form").submit(function(){var O=[];
I.find(".recipients li").each(function(P,Q){O.push(E(Q).attr("data-username"))
});
if(O.length<=0){return false
}E("button,input,textarea",this).attr("disabled","disabled");
I.find(".progress-messages").text("Sending");
var L=Raphael.spinner(I.find(".progress-messages-icon")[0],7,"#666");
I.find(".progress-messages-icon").css("left","10px").css("position","absolute");
I.find(".progress-messages").css("padding-left",I.find(".progress-messages-icon").innerWidth()+5);
var O=[];
I.find(".recipients li[data-username]").each(function(P,Q){O.push(E(Q).attr("data-username"))
});
var N=[];
I.find(".recipients li[data-email]").each(function(P,Q){N.push(E(Q).attr("data-email"))
});
var M={users:O,emails:N,note:I.find("#note").val(),entityId:AJS.params.pageId};
E.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:AJS.Confluence.getContextPath()+"/rest/share-page/latest/share",data:JSON.stringify(M),dataType:"text",success:function(){setTimeout(function(){L();
I.find(".progress-messages-icon").css("width","17px");
I.find(".progress-messages-icon").css("height","17px");
I.find(".progress-messages-icon").addClass("done");
I.find(".progress-messages").text("Sent");
setTimeout(function(){J()
},1000)
},500)
},error:function(Q,P){L();
I.find(".progress-messages-icon").css("width","17px");
I.find(".progress-messages-icon").css("height","17px");
I.find(".progress-messages-icon").addClass("error");
I.find(".progress-messages").text("Error while sending")
}});
return false
});
var K=I.find("#users");
var F=I.find(".button-panel input");
K.bind("selected.autocomplete-sharepage",function(M,L){var N=function(P,Q){var S=I.find(".recipients"),R,O;
R="li[data-"+P+'="'+Q.content[P]+'"]';
if(S.find(R).length>0){S.find(R).hide()
}else{S.append(AJS.template.load("share-content-popup-recipient-"+P).fill(Q.content))
}O=S.find(R);
O.find(".remove-recipient").click(function(){O.remove();
if(S.find("li").length==0){F.attr("disabled","true")
}D.refresh();
K.focus();
return false
});
O.fadeIn(200)
};
if(L.content.email){N("email",L)
}else{N("username",L)
}D.refresh();
F.removeAttr("disabled");
K.val("");
return false
});
K.bind("open.autocomplete-sharepage",function(M,L){if(E("a:not(.no-results)",AJS.dropDown.current.links).length>0){AJS.dropDown.current.moveDown()
}});
K.keypress(function(L){if(L.keyCode==13){return false
}return true
});
E(document).bind("showLayer",function(N,M,L){if(M=="inlineDialog"&&L.popup==D){L.popup.find("#users").focus()
}});
E("#shareContentLink").parents().filter(function(){return this.scrollTop>0
}).scrollTop(0);
H()
};
AJS.toInit(function(F){AJS.I18n.get("com.atlassian.confluence.plugins.share-page");
D=AJS.InlineDialog(F("#shareContentLink"),"shareContentPopup",C,B)
})
})(AJS.$);
AJS.toInit(function ($) {
    $("#action-view-source-link").click(function (e) {
        window.open(this.href, (this.id + "-popupwindow").replace(/-/g, "_"), "width=800, height=600, scrollbars, resizable");
            e.preventDefault();
            return false;
        });
});
AJS.toInit(function ($) {
    $(".view-storage-link, .view-storage-link a").click(function (e) {
        window.open(this.href, (this.id + "-popupwindow").replace(/-/g, "_"), "width=800, height=600, scrollbars, resizable");
            e.preventDefault();
            return false;
        });
});

jQuery.cookie=function(B,I,L){if(typeof I!="undefined"){L=L||{};
if(I===null){I="";
L.expires=-1
}var E="";
if(L.expires&&(typeof L.expires=="number"||L.expires.toUTCString)){var F;
if(typeof L.expires=="number"){F=new Date();
F.setTime(F.getTime()+(L.expires*24*60*60*1000))
}else{F=L.expires
}E="; expires="+F.toUTCString()
}var K=L.path?"; path="+L.path:"";
var G=L.domain?"; domain="+L.domain:"";
var A=L.secure?"; secure":"";
document.cookie=[B,"=",encodeURIComponent(I),E,K,G,A].join("")
}else{var D=null;
if(document.cookie&&document.cookie!=""){var J=document.cookie.split(";");
for(var H=0;
H<J.length;
H++){var C=jQuery.trim(J[H]);
if(C.substring(0,B.length+1)==(B+"=")){D=decodeURIComponent(C.substring(B.length+1));
break
}}}return D
}};
AJS.$(function(C){if(typeof (K15T)!="undefined"){return 
}function B(D){if(typeof (k15t_scrolloffice_messages)!="undefined"&&(typeof (k15t_scrolloffice_messages[D]))!="undefined"){return k15t_scrolloffice_messages[D]
}else{return D
}}function A(D){if((typeof (D)=="string")&&(D.indexOf('action="/confluence/dologin.action"')!=-1)){window.location.href=CONTEXT_PATH+"/login.action?os_destination="+encodeURIComponent(window.location.href)
}}K15T=function(){};
K15T.Popup=function(D,F){var E=this;
if(D){this.height=(D.height||200);
this.width=(D.width||200);
this.url=(D.url||200);
this.title=(D.title||"Application Title");
this.applicationName=(D.applicationName||"Application Name");
this.applicationLink=(D.applicationLink||"http://www.k15t.com");
this.applicationVersion=(D.applicationVersion||"0.0");
this.afterInit=(D.afterInit||function(){})
}if(AJS.Dialog){this.container=new AJS.Dialog(this.width,this.height);
this.element=this.container.popup.element
}else{alert("ERROR: AJS.Dialog not defined.")
}this.element.html("<div class='com-k15t-popup'><div class='title' style='background-image: url("+CONTEXT_PATH+"/download/resources/com.k15t.scroll.scroll-office:ui-required/images/title_bg.png)'>  <h2>"+B("com.k15t.scroll.office.frame.title")+"<span style='float: right;'><a href='' class='com-k15t-scroll-close' style='text-decoration: none; color: #666666;' title='"+B("com.k15t.scroll.office.frame.title.action.close")+"'><img src='"+CONTEXT_PATH+"/download/resources/com.k15t.scroll.scroll-office:ui-required/images/title_btn_close.png' title='"+B("com.k15t.scroll.office.frame.title.action.close")+"' /></a></span>  </h2></div><div class='content settings' style='height: "+(E.height-120)+"px;'>Please wait...</div><div class='content loading' style='text-align: center; height: "+(E.height-120)+"px; display: none;'>  <div class='animation'><img src='"+CONTEXT_PATH+"/download/resources/com.k15t.scroll.scroll-office:ui-required/images/ani.gif' title='Edit Export Settings'/><br/><br/>Please wait a second or two.</div></div><div class='poweredby' style='background-image:url("+CONTEXT_PATH+"/download/resources/com.k15t.scroll.scroll-office:ui-required/images/footer_bg.png)'>  <span class='logo' style='background-image: url("+CONTEXT_PATH+"/download/resources/com.k15t.scroll.scroll-office:ui-required/images/footer_scrolllogo.png)'></span>  <span class='footertext'>"+B("com.k15t.scroll.office.frame.footer.text")+"  </span></div></div>");
this.element.find(".com-k15t-scroll-close").unbind("click").bind("click",function(G){G.preventDefault();
E.close()
});
C.ajax({type:"GET",url:E.url,beforeSend:function(G){E.show()
},success:function(G,I,H){A(G);
E.show(G);
E.afterInit.call(this,G,I,H)
},error:function(H,I,G){E.show(H.responseText)
},dataType:"html"})
};
K15T.Popup.prototype.show=function(D){var E=this;
if(D){this.element.find(".settings").show();
this.element.find(".settings").html(D);
this.element.find(".loading").hide();
this.element.find(".com-k15t-scroll-close").unbind("click").bind("click",function(F){F.preventDefault();
E.close()
});
C("a.com-k15t-scroll-ajaxified").unbind("click").bind("click",function(F){F.preventDefault();
F.stopPropagation();
C.ajax({type:"GET",url:C(this).attr("href"),beforeSend:function(G){E.show()
},error:function(H,I,G){E.show(H.responseText)
},success:function(G,I,H){A(G);
E.show(G)
},dataType:"html"})
});
C("form.com-k15t-scroll-ajaxified").unbind("submit").bind("submit",function(F){F.preventDefault();
F.stopPropagation();
C.ajax({type:"GET",url:C(this).attr("action"),data:C(this).serialize(),beforeSend:function(G){E.show()
},error:function(H,I,G){E.show(H.responseText)
},success:function(G,I,H){A(G);
E.show(G)
},dataType:"html"})
});
this.container.show()
}else{this.element.find(".settings").hide();
this.element.find(".loading").show();
this.container.show()
}};
K15T.Popup.prototype.hide=function(D){this.container.hide()
};
K15T.Popup.prototype.close=function(D){this.element.find(".settings").html("");
this.container.hide()
}
});
SCROLL_VERSION="${project.version}";
AJS.$(function(A){A(document).ready(function(){CONTEXT_PATH=(A("#confluence-context-path").attr("content")||"");
A.getScript(CONTEXT_PATH+"/plugins/com.k15t.scroll.office/i18n.action");
var B=A("#com-k15t-confluence-scroll-office-word-link");
if(B){B.find("span").append("<img id='com-k15t-confluence-scroll-office-word-quick-link' src='"+CONTEXT_PATH+"/download/resources/com.k15t.scroll.scroll-office:ui-required/images/page_go.png' title='One-click Export' style='float:right; position:relative; z-index:1000; padding: 0 2px' />");
A("#com-k15t-confluence-scroll-office-word-quick-link").click(function(C){C.preventDefault();
C.stopPropagation();
var D=new K15T.Popup({width:620,height:555,url:B.attr("href").replace(/settings.action/,"export.action"),title:"Export to Word",applicationName:"Scroll Office",applicationLink:"http://www.k15t.com/display/web/Scroll+Office",applicationVersion:SCROLL_VERSION,afterInit:function(E,G,F){}});
A(this).parents(".ajs-drop-down")[0].hide()
});
B.click(function(D){D.preventDefault();
D.stopPropagation();
var C=new K15T.Popup({width:620,height:555,url:B.attr("href"),title:"Export to Word",applicationName:"Scroll&trade; Office",applicationLink:"http://www.k15t.com/display/web/Scroll+Office",applicationVersion:SCROLL_VERSION,afterInit:function(E){A("#includeLabelList").unbind("click").bind("click",function(){A("#includePageWithLabels").attr("checked","checked")
})
}});
A(this).parents(".ajs-drop-down")[0].hide()
})
}})
});
AJS.toInit(function(){if(AJS.$("#com-k15t-confluence-scroll-office-word-link")){AJS.$("#action-export-word-link").parent().css("display","none")
}});

