/*
 *  (c) 2000-2015 deviantART, Inc. All rights reserved.
 */
DWait.ready(["jms/lib/gmi.js","jms/lib/difi.js","jms/lib/jquery/jquery.current.js"],function(){window.Gruser=GMIBase.extend({}),window.GMFrame_BluesBar||(window.GMFrame_BluesBar=GMIBase.extend({})),$(window).load(function(){if("connect"==window.location.href.split("?")[1]){PubSub.publish("Location.replace",window.location.origin);var e=4,t=window.location.host.split(".")[0],i=$('.ccomment-form[gmi-typeid="'+e+'"]').first();DiFi.pushPost("User","getMentorSuggestion",[t],function(e,n){if(e&&n.response.content){var s=$('<div class="mentor-hint-box suggestion"></div>').html(n.response.content.hint_msg);i.before(s),PubSub.subscribe({eventname:"WriterAnywhere.hooked",subscriber:this,callback:function(e,t){t.writer.setText(n.response.content.prepopulated_comment),t.writer.$node.focus(),t.writer.move_caret_to_end()}}),$(":gmi(TalkPostWrapper)").gmi1().talkpost.commentwriter.activate(),PubSub.subscribe({eventname:"Comments.posted",subscriber:this,callback:function(){s.removeClass("suggestion").addClass("thanks").html(n.response.content.thanks_msg),DiFi.pushPost("User","recordMentoringAction",[t]),DiFi.send()}})}}),DiFi.send()}}),window.DWait&&DWait.run("jms/pages/gruzecontrol/gruser.js")});
DWait.ready(["jms/lib/browser.js","jms/lib/station.js","jms/lib/difi.js","jms/lib/glbl.js","jms/lib/popup2.js","jms/lib/jquery/jquery.current.js","jms/lib/gmi.js"],function(){window.GPage||(window.GPage=GMIBase.extend({gmiConstructor:function(){}})),window.BluesBar={hiddenMenu:function(e,t,i,s){if($(".popup2-gruser").length)return Popup2.hideAll(),!1;var n,a,r,o,u,l;if(window.event&&(event.cancelBubble=!0),this.menu_on||!t&&this.treshold&&this.treshold>(new Date).valueOf())return!1;if(this.ieFix(e),this.gmi_called||(this.gmi_called=!0,DWait.ready(["jms/lib/gmi.js","jms/pages/gruzecontrol/gmframe_bluesbar.js"],this.frameReady.bind(this))),a=e.getAttribute("href").split("#").pop(),l=a.split("-").pop(),"give"!=l&&(e.className+=" active"),this.menu_on=e,n=new Popup2("BluesBar","body",{classes:"gruser-"+l+" popup2-gruser popup2-bluesbar",content:$("#"+a).clone(!0).show(),destroy:!0,created:function(){(e.offsetWidth>257||i)&&this.$node.css("width",$(e).width()+13+"px")},hidden:this.hiddenMenuDone.bind(this)}),l in{stats:1,stats2:1,activity:1}&&(n.render(),this.verify(l,n.$node.first().get(0),e)),r=n.position($(e)),u=n.position($(e).parent().parent()),o=u.bottom-r.bottom-2,o>10||l in{give:1,stats2:1}||Glbl("Site.is_mobile")||this.zNodes(e,120),l in{stats:1,stats2:1}&&!GMI.query("GMFrame_BluesBar")[0]&&(r.left=190,r.right=191),"buttons"==l&&(r.left-=192,r.right-=192),n.show(r),s)try{s(n)}catch(d){}return this.callFrame(n),!1},verify:function(e,t,i){var s,n,a;if(s=(t.getElementsByTagName("difi")||[])[0]){if(!this[e+"_node"]){switch(e in{stats:1,stats2:1}?(n=document.createElement("span"),n.className="bars"):(n=document.createElement("div"),n.className="ploading",n.style.paddingTop="16px",n.innerHTML="Loading..."),this[e+"_node"]=n,a=(n=GMI.query("GMFrame_BluesBar")[0])?n.gmi_args.id:GMI.up(i,"GMFrame_Gruser").gmi_args.id,e){case"activity":DiFi.pushPrivateGet("GrusersUserpageinfoModule","getActivityDetails",[GMI.query("Gruser")[0].gmi_args.id,a],this.difiReady.bind(this,e));break;case"stats":case"stats2":DiFi.pushPrivateGet("GrusersModules","displayModule",[GMI.query("Gruser")[0].gmi_args.id,a,"stats_pageviews",{}],this.difiReady.bind(this,e));break;default:throw Error("?? "+e)}DiFi.timer(1)}s.parentNode.replaceChild(this[e+"_node"],s)}},difiReady:function(e,t,i){"activity"==e&&(this[e+"_node"].className=""),this[e+"_node"].innerHTML=t?i.response.content.html:"[error: "+i.response.content+"]",e in{stats:1,stats2:1}&&this.animateGraph(this[e+"_node"])},animateGraph:function(e){var t;for(t=e.getElementsByTagName("span"),i=0;i!=t.length;i++)"bar"==t[i].className&&(23>i?Station.push(t[i],"top",{from:44,to:44,time:25*(t.length-i)},{from:44,to:0,time:150,f:Interpolators.pulse}):t[i].setAttribute("style","display:hidden"))},hiddenMenuMouse:function(e){if(Glbl("Site.is_mobile"))return!1;var t;BluesBar.mouseover_timer&&(clearTimeout(BluesBar.mouseover_timer),BluesBar.mouseover_timer=null),t=(e.getElementsByTagName("span")||[])[0],this.ieFix(e),!this.menu_on&&t&&"bluestip"==t.className&&t!=BluesBar.last_mouseover&&(BluesBar.last_mouseover=t,Station.run(t,"opacity",{from:0,to:1,time:155,f:Interpolators.sineCurve}),e.onmouseout=this.hiddenMenuOut),this.menu_on&&this.menu_on!=e&&(Popup2.hideAll(),this.hiddenMenu(e,!0))},hiddenMenuClick:function(){return window.event&&(event.stopPropagation&&event.stopPropagation(),event.preventDefault(),event.cancelBubble=!0),!1},ieFix:function(e){var t;Browser.isIE&&(t=(e.getElementsByTagName("span")||[])[0],t&&!t.style.width&&(t.style.width=t.parentNode.offsetWidth+"px"))},hiddenMenuOut:function(){BluesBar.mouseover_timer=setTimeout("BluesBar.last_mouseover = null",10)},hiddenMenuDone:function(){this.menu_on.className=this.menu_on.className.replace(/\s*active\b/g,""),this.zNodes(this.menu_on,20),this.treshold=(new Date).valueOf()+200,this.menu_on=!1,this.callFrame(null)},zNodes:function(e,t){var s,n,a;if(!Browser.isIE)for(GMI.up(e,"GPage")?s=[e.parentNode.parentNode]:(n=GMI.up(e,"Gruser").gmi_node,s=[n.getElementsByTagName("div")[1]],s.push((document.getElementById("top")||document.getElementById("overhead")||document.getElementById("head")).lastChild),a=GMI.query(n,"GPage")[0],a.findBluesBar&&s.push(a.findBluesBar("gmbutton2admin"))),i=0;i!=s.length;i++)s[i]&&1==s[i].nodeType&&(s[i].style.zIndex=t+i)},frameReady:function(){this.linked_frame||(this.linked_frame=GMI.query("GMFrame_BluesBar")[0])},callFrame:function(e){this.linked_frame&&this.linked_frame.currentPopupIs&&this.linked_frame.currentPopupIs(e)},graphHover:function(e,t){var i,s,n;if(i=t.target||t.srcElement,i&&1==i.nodeType){for(s=e.getElementsByTagName("span")[0],s.innerHTML=(i.getAttribute("title")||"").split(":").join(":<strong>")+"</strong>",n=-15;i=i.nextSibling;n++);s.style.left=Math.min(80,Math.max(-20,7*n))+"px"}},graphOut:function(e){e.getElementsByTagName("span")[0].innerHTML=""}},window.DWait&&DWait.run("jms/pages/gruzecontrol/bluesbar.js")});
DWait.ready(["jms/lib/gmi.js"],function(){window.GUserPoll=GMIBase.extend({}),window.DWait&&DWait.run("jms/pages/gruzecontrol/guserpoll.js")});
DWait.ready(["jms/lib/gmi.js"],function(){window.GBadge=GMIBase.extend({}),window.DWait&&DWait.run("jms/pages/gruzecontrol/gbadge.js")});
DWait.ready(["jms/lib/jquery/plugins/jquery.noleakyscroll.js","jms/legacy/modals.js","jms/lib/php.js","jms/lib/jquery/jquery.current.js"],function(){DWait.init("Grusers.modal",function(s){var a=$(s),r=PHP.userlink(a.data("username"),a.data("symbol"))+"'s "+a.data("title");return a.on("click","a",function(s){s.preventDefault();var e={width:a.data("width"),height:a.data("height")||375},t=$("<div>").addClass("gruser_modal");$('<h2 style="color:#768e81"></h2>').html(r).appendTo(t),$('<iframe class="gruser_iframe" frameBorder="0" src="'+a.data("src")+'" />').appendTo(t).noleakyscroll({leak_when_noscrollbar:!0}).css(e);var o=Modals.factory(t,{cssShadows:!0,showCloseButton:!0,showButtonsSeparator:!1,extraClassy:"grusers_modal"});return o.addButton("Close","smbutton-lightgreen",function(){return Modals.pop("closed"),!1}),Modals.push(o),!1}),!1}),window.DWait&&DWait.run("jms/pages/grusers/modals.js")});
DWait.ready(["jms/lib/bind.js","jms/lib/jquery/jquery.current.js"],function(){window.Linkify=function(){function i(i){return i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;").replace(/>/g,"&gt;")}function n(n,a){var e,s,u=a.match(r),c=n?i(a):a;return u&&(s=n?i(u[1]):u[1],e=t.test(s)?s:"http://"+s,c=c.replace(s,'<a href="'+e+'">'+s+"</a>")),c}var r=/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/i,t=/^[a-z][\w-]+:/;return function(i,r){return jQuery.map((i+"").split(/\s+/),n.bind(this,r)).join(" ")}}(),window.DWait&&DWait.run("jms/lib/linkify.js")});
DWait.ready(["jms/lib/jquery/jquery.current.js",".domready"],function(){DWait.init("CollectionWatchButton.init",function(t){var a=$(t),c=function(t){t.preventDefault(),a.off("click.watch"),DiFi.pushPost("Gallections","toggle_watch",[a.data("gruserid"),RESOURCE_FAVCOLLECTIONS,a.data("galleryid"),!a.hasClass("watched")],i),DiFi.send()},i=function(t,i){if(t){a.toggleClass("watched"),a.html("<span>"+(a.hasClass("watched")?"Unwatch":"+Watch")+" Collection</span>");var n=a.data("ga_click_event");n.action="click_"+(a.hasClass("watched")?"unwatch":"watch")+"_button",a.data("ga_click_event",n)}else ddt.log("curation","toggle_watch failed",i),alert("Failed to toggle watch on this collection.");a.on("click.watch",c)};a.on("click.watch",c)}),window.DWait&&DWait.run("jms/pages/curation/collection_watch_button.js")});if(window.DWait){DWait.count()}