YUI.add("print",function(b){function a(c){this._initPrintListener(c)}a.prototype={_initPrintListener:function(c){b.on("click",this._print,c)},_print:function(j){j.preventDefault();var h=function(){};var d=j.currentTarget.ancestor(".pot_lightbox");if(d){var l=d.ancestor("div");var c={position:l.getComputedStyle("position"),top:l.getComputedStyle("top"),left:l.getComputedStyle("left")};l.setStyles({position:"absolute",top:0,left:0});var k=d.one(".yui-widget-bd");var g={height:k.getStyle("height")};k.setStyle("height","100%");if(d.hasClass("iframe")){var f=b.Node.getDOMNode(d.one("iframe"));d.one("iframe").set("scrolling","no");var i={height:d.one("iframe").getComputedStyle("height")};d.one("iframe").setStyle("height",f.contentWindow.document.body.scrollHeight+"px");d.one("iframe").addClass("full_width")}h=function(){b.later(1000,this,function(){l.setStyles(c);d.removeClass("full_width");k.setStyles(g);if(f){d.one("iframe").setStyles(i);d.one("iframe").removeClass("full_width");d.one("iframe").set("scrolling","")}},{},false)}}window.print();h()}};b.Print=a},"@VERSION@",{requires:["node","event"]});YUI().use("node",function(c){var a=function(d){if(d.type==="mouseout"){c.one(".fake_file .fake_button a").setStyle("color","#543c9e")}else{c.one(".fake_file .fake_button a").setStyle("color","#000")}};var b=c.one("#file_upload");if(b){b.on("mouseover",a);b.on("mouseout",a)}c.all('.content .key_links a[href="/datatool/"]').addClass("popup").addClass("data_tool");c.on("click",function(h){var g=h.target;if(g.get("nodeName")!="A"&&g.get("parentNode").get("nodeName")!="A"){return}else{if(g.get("parentNode")){if(g.get("parentNode").get("nodeName")=="A"){g=g.get("parentNode")}}}if(g.hasClass("popup")){h.preventDefault();var f="",d=g.get("href");if(g.hasClass("microsite")){f="status=1,toolbar=1,location=1,menubar=1,directories=1,resizable=1,scrollbars=1,height=800,width=1024"}else{if(g.hasClass("old_microsite")){f="status=1,toolbar=1,location=1,menubar=1,directories=1,resizable=1,scrollbars=1,height=480,width=640"}else{if(g.hasClass("career_app")){f="status=1,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,height=620,width=650"}else{if(g.hasClass("map")){f="status=1,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,height=740,width=880"}else{if(g.hasClass("analyst_meeting")){f="status=1,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=1,height=740,width=892"}else{if(g.hasClass("video")){f="status=1,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,height=580,width=924"}else{if(g.hasClass("media_player")){f="status=1,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,height=605,width=924"}else{if(g.hasClass("audio")){f="status=1,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,height=603,width=925"}else{if(g.hasClass("slideshow")){f="status=1,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,height=605,width=923"}else{if(g.hasClass("transcript")){f="status=1,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,height=600,width=600"}else{if(g.hasClass("market_image")){f="status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0,height=580,width=967"}else{if(g.hasClass("note")){f="status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=1,height=600,width=550"}else{if(g.hasClass("note_wide")){f="status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=1,height=600,width=920"}else{if(g.hasClass("data_tool")){d=d.replace("datatool","data-tool");f="status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=1,height=680,width=967"}else{f="status=1,toolbar=1,location=1,menubar=1,directories=1,resizable=1,scrollbars=1,height=768,width=1024"}}}}}}}}}}}}}}window.open(d,"_blank",f)}else{if(g.hasClass("download")&&g.get("nodeName").toUpperCase()=="A"&&g.get("href").lastIndexOf(".pdf")==(g.get("href").length-4)){h.preventDefault();f="status=1,toolbar=1,location=1,menubar=1,directories=1,resizable=1,scrollbars=1,height=768,width=1024";window.open(g.get("href"),"_blank",f)}}},"body",this)});function openWindow(a){window.open(a,"_blank","status=1,toolbar=1,location=1,menubar=1,directories=1,resizable=1,scrollbars=1,height=768,width=1024")}YUI.add("modal",function(d){var b=d.UA,c=d.Lang;function a(e){this._initModality()}a.ATTRS={modal:{value:false,setter:function(e){this._setModality(e)}}};a.prototype={_initModality:function(){this._setModality(this.get("modal"))},_setModality:function(g){if(g){this._buildMask();if(!this._modalityListeners){this._modalityListeners=[];this._modalityListeners.push(d.before(function(){this.showMask()},this,"show"));this._modalityListeners.push(d.on("click",function(){d.lightbox.hide()},d.one("#lightbox_mask")));this._modalityListeners.push(d.after(function(){this.hideMask()},this,"hide"))}}else{if(this._modalityListeners){for(var f=0,e=this._modalityListeners.length;f<e;f++){d.detach(this._modalityListeners[f])}delete this._modalityListeners;this._removeMask()}}},_removeMask:function(){var f=this._mask,e;if(f){f=d.Node.getDOMNode(f);this.hideMask();e=f.parentNode;if(e){e.removeChild(f)}this._mask=null}},_buildMask:function(){var e=this._mask;if(!e){var f=document.createElement("div");f.className="mask";f.innerHTML="&#160;";e=f.cloneNode(true);e.id=this.get("contentBox").get("id")+"_mask";document.body.insertBefore(e,document.body.firstChild);this._mask=d.one(e);if(b.gecko&&b.os=="mac"){this._mask.addClass("block-scrollbars")}this._stackMask()}},_stackMask:function(){if(this._mask){var e=this.get("zIndex");if(!c.isUndefined(e)&&c.isNumber(e)){this._mask.setStyle("zIndex",e-1)}}},showMask:function(){if(this.get("modal")&&this._mask){d.one("body").addClass("masked");this.sizeMask();this._mask.setStyle("display","block")}},sizeMask:function(){if(this._mask){var f=this._mask,g=this._mask.get("docWidth"),e=this._mask.get("docHeight");f.setStyle("height",e+"px");f.setStyle("width",g+"px")}},hideMask:function(){var f=d.one("#stwrapper");if(f!=undefined&&f.getStyle("visibility")==="visible"){var e=d.one(".share");e.simulate("click")}if(this.get("modal")&&this._mask){this._mask.setStyle("display","none");d.one("body").removeClass("masked")}}};d.Modal=a},"@VERSION@",{requires:["node-event-simulate"]});YUI.add("widget-position-fixed",function(b){function a(c){this._initFixedCenter()}a.ATTRS={fixedCenter:{value:false,setter:function(c){this._setFixedCenter(c)}}};a.prototype={_initFixedCenter:function(c){this._setFixedCenter(this.get("fixedCenter"))},_setFixedCenter:function(d){if(d){if(!this._positionFixedListeners){this._positionFixedListeners=[];this._positionFixedListeners.push(b.after(function(){this.center()},this,"show"));this._positionFixedListeners.push(b.after("resize",function(){if(this.get("visible")){this.center()}},window,this));this._positionFixedListeners.push(b.after(function(){this.unsetFixPosition()},this,"hide"))}}else{if(this._positionFixedListeners){for(var e=0,c=this._positionFixedListeners.length;e<c;e++){b.detach(this._positionFixedListeners[e])}delete this._positionFixedListeners}}},center:function(){var d=true;var c=this.get("boundingBox").get("region");if((c.right-c.left)>this.get("boundingBox").get("winWidth")){d=false}if((c.bottom-c.top)>this.get("boundingBox").get("winHeight")){d=false}if(d&&(b.UA.ie<6||b.UA.ie>=7)){this.setFixPosition()}this._center()},_center:function(){var f=10,g=this.get("boundingBox").get("offsetWidth"),e=this.get("boundingBox").get("offsetHeight"),h=this.get("boundingBox").get("winHeight"),d=this.get("boundingBox").get("winWidth"),c,i;if(g<d){c=(d/2)-(g/2)+this.get("boundingBox").get("docScrollX")}else{c=f+this.get("boundingBox").get("docScrollX")}if(e<h){i=(h/2)-(e/2)+this.get("boundingBox").get("docScrollY")}else{i=f+this.get("boundingBox").get("docScrollY")}this._setX(c);this._setY(i)},setFixPosition:function(){this.get("boundingBox").setStyle("position","fixed")},unsetFixPosition:function(){this.get("boundingBox").setStyle("position","absolute")}};b.WidgetPositionFixed=a});YUI.add("widget-close",function(b){function a(c){this._initClose()}a.ATTRS={close:{value:false,setter:function(c){this._setClose(c)}}};a.prototype={_initClose:function(c){b.before(function(){this._setClose(this.get("close"))},this,"show")},_setClose:function(e){if(e){b.one("#"+this.get("contentBox").get("id")+" .close").removeClass("hide");if(!this._closeListeners){this._closeListeners=[];this._closeListeners.push(b.one("#"+this.get("contentBox").get("id")+" .close").on("click",function(h){h.preventDefault();var g=b.one("#stwrapper");if(g!=undefined&&g.getStyle("visibility")==="visible"){var f=b.one(".share");f.simulate("click")}this.hide()},this))}}else{b.one("#"+this.get("contentBox").get("id")+" .close").addClass("hide");if(this._closeListeners){for(var d=0,c=this._closeListeners.length;d<c;d++){b.detach(this._closeListeners[d])}delete this._closeListeners}}}};b.Close=a});YUI.add("height-adjust",function(b){function a(c){this._initHeightAdjust()}a.ATTRS={height_adjust:{value:true,setter:function(c){this._setHeightAdjust(c)}}};a.prototype={_initHeightAdjust:function(c){this._setHeightAdjust(this.get("height_adjust"))},_setHeightAdjust:function(e){if(e){if(!this._heightAdjustListeners){this._heightAdjustListeners=[];this._heightAdjustListeners.push(b.before(function(){if(this.get("boundingBox").get("winHeight")<this.get("boundingBox").get("offsetHeight")){this.get("contentBox").one(".yui-widget-bd").setStyle("height",((this.get("boundingBox").get("winHeight"))*0.7)+"px");if(!this.get("contentBox").hasClass("iframe")){this.get("contentBox").one(".yui-widget-bd").addClass("height_adjust")}else{this.get("contentBox").one("iframe").setStyle("height",((this.get("boundingBox").get("winHeight"))*0.7)+"px")}}},this,"show"));this._heightAdjustListeners.push(b.on(function(){this.get("contentBox").one(".yui-widget-bd").setStyle("height","auto").removeClass("height_adjust")},this,"hide"))}}else{if(this._heightAdjustListeners){for(var d=0,c=this._heightAdjustListeners.length;d<c;d++){b.detach(this._heightAdjustListeners[d])}delete this._heightAdjustListeners}}}};b.HeightAdjust=a});YUI.add("lightbox-shareable",function(b){function a(c){this._initLightboxShareable()}a.ATTRS={shareable:{value:true,setter:function(c){this._setLightboxShareable(c)}},shareable_href:{value:"http://www.potashcorp.com",setter:function(c){this._setLightboxShareableHref(c)}}};a.prototype={_initLightboxShareable:function(c){this._setLightboxShareable(this.get("shareable"))},_setLightboxShareable:function(c){if(c){if(this.get("contentBox").one("#share_lightbox")){this.get("contentBox").one("#share_lightbox").removeClass("hide")}b.initShare(this.get("shareable_href"))}else{if(this.get("contentBox").one("#share_lightbox")){this.get("contentBox").one("#share_lightbox").addClass("hide")}}},_setLightboxShareableHref:function(c){}};b.LightBoxShareable=a});YUI.add("lightbox-printable",function(b){function a(c){this._initLightboxPrintable()}a.ATTRS={printable:{value:true,setter:function(c){this._setLightboxPrintable(c)}}};a.prototype={_initLightboxPrintable:function(c){this._setLightboxPrintable(this.get("printable"))},_setLightboxPrintable:function(e){if(e){if(this.get("contentBox").one(".print")){this.get("contentBox").one(".print").removeClass("hide")}if(!this._lightboxPrintableListeners){this._lightboxPrintableListeners=[];this._lightboxPrintableListeners.push(b.before(function(){b.one("body").addClass(this.get("contentBox").get("id"));this.set("printable",true);if(this.get("contentBox").hasClass("no_print")||(this.get("contentBox").hasClass("iframe")&&!this.get("contentBox").hasClass("force_print"))){this.set("printable",false)}},this,"show"));this._lightboxPrintableListeners.push(b.after(function(){b.one("body").removeClass(this.get("contentBox").get("id"))},this,"hide"))}}else{if(this.get("contentBox").one(".print")){this.get("contentBox").one(".print").addClass("hide")}if(this._lightboxPrintableListeners){for(var d=0,c=this._lightboxPrintableListeners.length;d<c;d++){b.detach(this._lightboxPrintableListeners[d])}delete this._lightboxPrintableListeners}}}};b.LightBoxPrintable=a});YUI.add("lightbox-loading",function(b){function a(c){this._initLoading()}a.ATTRS={loading:{value:false,setter:function(c){this._setLoading(c)}}};a.prototype={_initLoading:function(c){this._setLoading(this.get("loading"))},_setLoading:function(c){return},showLoading:function(){b.loading_lightbox.render();b.loading_lightbox.show()}};b.LightboxLoading=a});YUI.add("widget-io",function(b){function a(c){this._initIO()}a.ATTRS={io:{value:true,setter:function(c){},uri:{value:""}}};a.prototype={io_cfg:{},_initIO:function(c){this.io_cfg={method:"",timeout:20000,on:{start:this._start,complete:this._complete,success:this._success,failure:this._failure,end:this._end},context:this,headers:{"X-Transaction":"POST Request","Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},arguments:{start:"test",complete:"",success:"",failure:"",end:""},data:"",configurable:b.Array(["method","arguments","data","form"]),set:function(e,d){if(b.Array.indexOf(this.configurable,e)>-1){this[e]=d}},reset:function(){b.Array.each(this.configurable,function(e,d){this[e]=""},this)}}},call:function(c){var e=new Date();this.set("uri",c);c+=(c.indexOf("?")==-1)?"?":"&";c+=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds());b.io(c,this.io_cfg)},_reset:function(){this.io_cfg.reset()},_start:function(){if(this.get("loading")){this.showLoading()}},_complete:function(){},_success:function(f,h,d){if(h.responseText!==undefined){try{var c=b.JSON.parse(h.responseText);this._beforeSuccess();if(this._tryRedirect(c,d)){return}this.updateContent(c);if(b.one("#form_wrapper input")){b.one("#form_wrapper input").focus()}this._afterSuccess(c);this._formSuccess(c,d);this._tableHighlightSuccess(c);this._clearBeforeAndAfterSuccess();this._reset();if(window.addGlossaryListeners){addGlossaryListeners()}}catch(g){this._failure(null,{statusText:g})}}else{this._failure(g)}},_failure:function(f,e,c){var d={header:'<span class="error">'+e.statusText+"</span>",body:"<p>There was an error retrieving the data. Please try again.</p>",footer:"<p>If the problem persists please contact us</p>"};this.updateContent(d)},_end:function(){},showIframe:function(c,e){var f="?";if(c.indexOf("?")!=-1){f="&"}if(e!=""){e='class="'+e+'"'}var d=b.Node.create('<iframe src="'+c+f+'iframe=1" id="iframe" '+e+' frameborder="0"></iframe>');this.updateContent({body:d});this.show()},updateContent:function(c){this._updateHeader(c.header);this._updateBody(c.body);this._updateFooter(c.footer);if(b.loading_lightbox){b.loading_lightbox.hide()}this.show()},_updateHeader:function(c){if(!c||c==""){this.set("headerContent"," ")}else{this.set("headerContent",c)}},_updateBody:function(c){if(!c||c==""){this.set("bodyContent"," ")}else{this.set("bodyContent",c)}},_updateFooter:function(c){if(!c||c==""){this.set("footerContent"," ")}else{this.set("footerContent",c)}},resetContent:function(){this.updateContent({header:"",body:"",footer:""})},_beforeSuccess:function(){},_afterSuccess:function(){},_formSuccess:function(c,d){if(this.get("contentBox").one("form")){this._submitForm.call(this,c)}},_tableHighlightSuccess:function(c){if(this.get("contentBox").all(".highlightTable")&&b.Lang.isFunction(highlightTables)){highlightTables()}},_submitForm:function(d,f){var c=this.get("contentBox").all("form.ajax_form");c.each(function(g,e){g.on("submit",function(h,i){h.preventDefault();i.io_cfg.set("method",this.get("method"));i.io_cfg.set("form",{id:this});var j=this.get("action").match(/redirect=[^&]*&?/);if(j){i.io_cfg.set("arguments",{success:{redirect:j[0].split("=")[1]}})}i.call(this.get("action"))},null,this)},this)},_tryRedirect:function(f,c){if(f.body){try{var g=b.JSON.parse(f.body);if(g){window.location=c.success.redirect;return true}}catch(d){return false}}},_clearBeforeAndAfterSuccess:function(){this._beforeSuccess=function(){};this._afterSuccess=function(){}}};b.WidgetIO=a},"@VERSION@",{requires:["json","io-form"]});YUI.add("zu-lightbox",function(a){a.Lightbox=a.Base.build("zu-lightbox",a.Overlay,[a.Modal,a.WidgetPositionFixed,a.Close,a.LightboxLoading,a.WidgetIO,a.HeightAdjust,a.LightBoxPrintable,a.LightBoxShareable]);a.after(function(){a.one("body").setStyle("overflow","hidden")},a.Lightbox,"hide")},"@VERSION@",{requires:["overlay","modal","widget-position-fixed","widget-close","lightbox-loading","height-adjust","widget-io","lightbox-printable","lightbox-shareable"]});YUI().use("pot_tools","zu-lightbox","print",function(a){a.setLightboxLinks=function(g,f,d){a.lightbox.set("shareable_href",f.get("href"));if(f.hasClass("zu_lightbox")||f.hasClass("external")){g.preventDefault();var c=f.get("className").split(" ");if(c.length>1){for(var b in c){if(c[b]=="small"||c[b]=="medium"||c[b]=="large"||c[b]=="xlarge"||c[b]=="full_width"||c[b]=="force_print"||c[b]=="iframe"){a.one("#lightbox").addClass(c[b])}}}if(f.hasClass("no_print")){a.lightbox.set("printable",false)}if(f.hasClass("iframe")){if(f.hasClass("force_print")){a.lightbox.set("printable",true)}a.lightbox.set("shareable",false);a.lightbox.showIframe(f.get("href"),f.get("id"))}else{if(f.hasClass("external")){a.lightbox.set("printable",false);a.lightbox.set("shareable",false);if(f.hasClass("follow")){openWindow(f.get("href"));if(d==true){a.lightbox.hide()}}else{a.lightbox.call("/external_gateway/?link="+encodeURIComponent(f.get("href"))+"&text="+encodeURI(f.get("innerHTML")));if(!f.hasClass("small")){a.one("#lightbox").addClass("small")}}}else{a.lightbox.set("printable",true);a.lightbox.set("shareable",true);a.lightbox.call(f.get("href"))}}return}};a.initLightboxLinks=function(){a.on("click",function(c){var b=c.currentTarget;a.setLightboxLinks(c,b,true)},"body a",this);a.on("click",function(c){var b=c.target;if(b.get("nodeName")!="A"){return}a.setLightboxLinks(c,b,true)},".pot_lightbox .yui-widget-bd",this);a.on("click",function(c){var b=c.target;if(b.get("nodeName")!="A"){return}a.setLightboxLinks(c,b,false)},"#data_pot_lightbox .yui-widget-bd",this);if(window.LightboxClickIntercept){LightboxClickIntercept.detach();delete LightboxClickIntercept}};a.initLightbox=function(){a.loading_lightbox=null;var b=a.Node.create('<div id="lightbox" class="pot_lightbox"><div class="utilities"><a href="#" class="print">Print</a> </div><a href="#" class="close">X</a><div class="yui-widget-hd"></div><div class="yui-widget-bd yui-gf"></div><div class="yui-widget-ft"></div></div>');a.one("body").append(b);a.lightbox=new a.Lightbox({contentBox:"#lightbox",modal:true,close:true,loading:true,fixedCenter:true,visible:false,centered:true,zIndex:10000});var c=a.Node.create('<div id="loading_lightbox" class="pot_lightbox"><a href="#" class="close hide">X</a><div class="yui-widget-hd"><span>Loading...</span></div><div class="yui-widget-bd yui-gf"><div style="text-align:center"><img src="/common/images/interface/skins/lightbox/loading.gif" /></div></div><div class="yui-widget-ft"></div></div>');a.one("body").append(c);a.loading_lightbox=new a.Lightbox({contentBox:"#loading_lightbox",modal:false,close:false,loading:false,fixedCenter:true,visible:false,centered:true,zIndex:10000});a.before(function(){if(a.UA.ie==7){document.body.setAttribute("scroll","no")}else{a.one("body").addClass("hide_overflow")}},a.lightbox,"show");a.before(function(){var d=a.one("#lightbox").get("className").split(" ");if(d.length>1){a.one("#lightbox").set("className","pot_lightbox")}this.resetContent();if(a.UA.ie==7){document.body.setAttribute("scroll","auto")}else{a.one("body").removeClass("hide_overflow")}},a.lightbox,"hide");a.lightbox.render();a.lightbox.hide();a.loading_lightbox.render();a.loading_lightbox.hide();a.initLightboxLinks()};a.initPotTools=function(){if(a.PotTools){new a.PotTools()}};a.initPrint=function(){a.Printer=new a.Print(".print")};a.initShare=function(b){var c=SHARETHIS.addEntry({url:b},{button:false,onmouseover:false});if(a.one("#share_lightbox")===undefined||a.one("#share_lightbox")===null){var f=a.Node.create('<span id="share_lightbox"><span>|</span>  <a title="Share" class="share" href="javascript:void(0);">Share</a></span>');var e=a.one(".pot_lightbox .utilities");e.appendChild(f)}var d=a.Node.getDOMNode(a.one("#share_lightbox"));c.attachButton(d)};a.initClose=function(){a.on("click",function(){alert("closing ...");window.close()},"#bd .close")};a.init=function(){a.initLightbox();a.initPotTools();a.initPrint();a.initClose()};a.init()});
