var imshoppingRoot="http://www.imshopping.com";
var imshoppingScriptRootUrl="http://www.imshopping.com/answer/keepdoggiesafe";
var sendFullHTML= false;
var needToRefreshForQuestionAnswer = false;
var assistanceRequestId = null;

var bannerHTML= [];
bannerHTML.push('<input id="imshoppingRoot" type="hidden" value="http://www.imshopping.com"/>');
bannerHTML.push('<input id="imshoppingScriptRootUrl" type="hidden" value="http://www.imshopping.com/answer/keepdoggiesafe"/>');
bannerHTML.push('');
bannerHTML.push('	<div id="assistanceButtonBlock" style="z-index:20000;">');
bannerHTML.push('		<div style="width:42px;height:141px;cursor: pointer;background-color:#D7E7F7;" id="assistanceButton"></div>');
bannerHTML.push('		<span id="soundContainer"></span>');
bannerHTML.push('	</div>');

bannerHTML= bannerHTML.join("");

var mode='';var d=document;var dt=new Date();var ims_key=true;var UtilInit={newElement:function(A,B){var C=document;var D=UtilInit.createElement(C,A);if(B){for(key in B){if(key=="cssFloat"&&UtilInit.isIE()){D.style.styleFloat=B[key]}else{D.style[key]=B[key]}}}return D},createElement:function(C,A){var B=C.createElement(A);if(typeof (B)!="object"){B=C.standardCreateElement(A)}return B},isIE:function(){return(navigator.appName=="Microsoft Internet Explorer")},isIE6:function(){return(navigator.appVersion.indexOf("MSIE 6")!=-1)},canUseFixedPosition:function(){return(UtilInit.isIE6()||(UtilInit.isIE()&&UtilInit.detectDoctype()==null))?false:true},getWindowWidth:function(){var A=0;if(self.innerHeight){A=self.innerWidth}else{if(document.documentElement&&document.documentElement.clientHeight){A=document.documentElement.clientWidth}else{if(document.body){A=document.body.clientWidth}}}return A},getWindowHeight:function(){var A=0;if(self.innerHeight){A=self.innerHeight}else{if(document.documentElement&&document.documentElement.clientHeight){A=document.documentElement.clientHeight}else{if(document.body){A=document.body.clientHeight}}}return A},detectDoctype:function(){var B=/\s+(X?HTML)\s+([\d\.]+)\s*([^\/]+)*\//gi;var A=false;if(typeof document.namespaces!="undefined"){A=document.all[0].nodeType==8?B.test(document.all[0].nodeValue):false}else{A=document.doctype!=null?B.test(document.doctype.publicId):false}if(A){A=new Object();A.xhtml=RegExp.$1;A.version=RegExp.$2;A.importance=RegExp.$3;if(A.xhtml.toLowerCase()!="xhtml"){return null}return A}else{return null}},log:function(B){if(window.console){if(typeof (B)=="object"){var A="";for(prop in B){A+=prop+"="+B[prop]+";"}console.log(A)}else{console.log(B)}}},getElementsByClassName:function(F,D){if(D==null){D=document}if(D.getElementsByClassName){return D.getElementsByClassName(F)}var C=new Array();var B=D.getElementsByTagName("*");var A=B.length;var E=new RegExp("(^|\\s)"+F+"(\\s|$)");for(i=0,j=0;i<A;i++){if(E.test(B[i].className)){C[j]=B[i];j++}}return C}};var WidgetInit={isTest:function(){return window.mode&&(window.mode=="test"||window.mode=="testStatic")},getButtonLeft:function(){var A=UtilInit.getWindowWidth();var B=document.getElementById("assistanceButton");if(!B){return A}if(B.clientWidth){return A-B.clientWidth}else{return A-B.offsetWidth}},getButtonHeight:function(){var A=document.getElementById("assistanceButton");if(A){if(A.clientHeight){return A.clientHeight}else{return A.offsetHeight}}return 0},getParams:function(){this.params={};var J=null;if(this.isTest()){J=document.getElementById("imsWidgetTestScript")}else{J=document.getElementById("imsWidgetScript")}UtilInit.log("WidgetInit.getParams: s=");UtilInit.log(J);if(J){var A=J.getAttribute("src");var G=A.indexOf("?");if(G==-1){return }var B=A.substr(G+1);if(B.length>3){var C=B.split("&");for(var D=0;D<C.length;D++){var H=C[D].split("=");this.params[H[0]]=H[1];UtilInit.log("WidgetInit.getParams: this.params["+H[0]+"]="+H[1])}}}if(!this.params.defaultStatusImageUrl){var E=null;var F=document.getElementById("ims_key");if(F){E=F.firstChild;if(E){this.params.defaultStatusImageUrl=E.src}}}if(!this.params.defaultStatusImageUrl){var I=document.getElementById("ims_assistance");if(I){var E=I.firstChild;if(E){this.params.defaultStatusImageUrl=E.src}}}if(!this.params.defaultStatusImageUrl){this.params.defaultStatusImageUrl="http://widgets.imshopping.com/images/assistance.png"}},isMultipleLaunch:function(){return(this.params&&this.params.multi=="true")},insertStaticButton:function(){var C=document.getElementById("ims_assistance");if(C){return }var B={zIndex:20001,scrolling:"no",display:"block",overflow:"visible",position:"absolute",left:"0",top:"0"};var A=UtilInit.newElement("div",B);A.id="ims_assistance";A.className="ims_assistance";A.innerHTML="<img src='http://widgets.imshopping.com/meijer/images/buttonImg'/>";document.body.insertBefore(A,document.body.firstChild)},hasStaticButton:function(){var B=document.getElementById("ims_assistance");if(B){return true}var A=UtilInit.getElementsByClassName("ims_assistance");if(A.length>0){return true}return false},insertWidgetButton:function(){if(document.getElementById("assistanceButton")){return }if(!this.isMultipleLaunch()&&this.hasStaticButton()){return }var C=document.body;if(!C){return }var B=UtilInit.canUseFixedPosition()?"fixed":"absolute";var A={zIndex:20001,scrolling:"no",display:"block",overflow:"visible",position:B,cursor:"pointer"};this._outerDiv=UtilInit.newElement("div",A);this._outerDiv.id="assistanceButton";this._outerDiv.className="ims_assistance";this._outerDiv.innerHTML="<img src='"+this.params.defaultStatusImageUrl+"'/>";document.body.insertBefore(this._outerDiv,C.firstChild);this.setButtonPosition()},setButtonPosition:function(){var B=document.getElementById("assistanceButton");if(!B){return }var E="mr";if(this.params&&this.params.pos){E=this.params.pos}var A=UtilInit.getWindowHeight();var C=this.getButtonHeight();var D=Math.round((A/2)-(C/2));if(E=="tl"){B.style.top=0;B.style.left=0}else{if(E=="tr"){if(UtilInit.canUseFixedPosition()){B.style.top=0;B.style.right=0}else{if(UtilInit.isIE6()){B.style.left="auto";if(document.documentElement&&(document.documentElement.scrollTop>0||document.documentElement.scrollLeft>0)){B.style.top=document.documentElement.scrollTop+"px";B.style.right=(B.style.right=="1px")?"0px":"1px"}else{B.style.top=document.body.scrollTop+"px";B.style.right=(B.style.right=="1px")?"0px":"1px"}}else{B.style.top=document.body.scrollTop+"px";B.style.right=-document.body.scrollLeft+"px"}}}else{if(E=="bl"){B.style.bottom=0;B.style.left=0}else{if(E=="br"){B.style.bottom=0;if(UtilInit.canUseFixedPosition()){B.style.right=0}else{B.style.left=this.getButtonLeft()+"px"}}else{if(E=="ml"){B.style.top=D+"px";B.style.left=0}else{if(UtilInit.canUseFixedPosition()){B.style.top=D+"px";B.style.right=0}else{if(UtilInit.isIE6()){B.style.left="auto";if(document.documentElement&&(document.documentElement.scrollTop>0||document.documentElement.scrollLeft>0)){B.style.top=D+document.documentElement.scrollTop+"px";B.style.right=(B.style.right=="1px")?"0px":"1px"}else{B.style.top=D+document.body.scrollTop+"px";B.style.right=(B.style.right=="1px")?"0px":"1px"}}else{B.style.top=D+document.body.scrollTop+"px";B.style.right=-document.body.scrollLeft+"px"}}}}}}}},mode:"ask",showAnswerStatus:function(){var B=document.getElementById("assistanceButton");if(!B){B=document.getElementById("ims_assistance")}if(!B){return }var A=B.firstChild;if(A){A.src=(this.params&&this.params.alert)?unescape(this.params.alert):imshoppingRoot+"/images/version2resources/answered.png"}WidgetInit.mode="details"},showLoading:function(){if(!document.getElementById("imsLoading")){var B=UtilInit.getWindowWidth();var E=UtilInit.getWindowHeight();var A=Math.round(B/2-100)+"px";var D=Math.round(E/2-50)+"px";var C={zIndex:20001,display:"block",position:"absolute",left:A,top:D,textAlign:"center",padding:"20px",border:"10px solid #acacac",backgroundColor:"#fff",width:"200px",fontSize:"18px",fontWeight:"bold",fontFamily:"Arial"};this.loading=UtilInit.newElement("div",C);this.loading.id="imsLoading";this.loading.innerHTML="Loading...";document.body.insertBefore(this.loading,document.body.firstChild)}else{document.getElementById("imsLoading").innerHTML="Loading...";document.getElementById("imsLoading").style.display="block"}},unInstall:function(){var D=document.getElementById("imsWidgetScript");if(D){D.parentNode.removeChild(D);var F=document.getElementById("assistanceButton");if(F){F.parentNode.removeChild(F)}var E=UtilInit.getElementsByClassName("ims_assistance");if(E.length>0){for(var B=0;B<E.length;B++){E[B].onclick=null}}else{var C=document.getElementById("ims_assistance");if(C){C.onclick=null}}var A=document.getElementById("imsAskQuestionWidgetContainer");if(A){A.parentNode.removeChild(A)}}},launcher:function(){if(window.WidgetUI){WidgetUI.showWidget()}else{WidgetInit.showLoading();var A=document;var B=A.createElement("script");if(typeof (B)!="object"){B=A.standardCreateElement("script")}var C=new Date();B.src=imshoppingScriptRootUrl+"/askQuestionWidget.script?dt="+C.getTime();if(WidgetInit.params&&WidgetInit.params.assistanceRequestId){B.src+="&assistanceRequestId="+WidgetInit.params.assistanceRequestId}if(WidgetInit.params&&WidgetInit.params.productId){B.src+="&productId="+WidgetInit.params.productId}B.type="text/javascript";A.getElementsByTagName("head")[0].appendChild(B)}return false},install:function(){if(this.isTest()){this.unInstall()}this.getParams();if(this.params&&this.params.mode&&this.params.mode=="testStatic"){this.insertStaticButton()}this.insertWidgetButton();var C=UtilInit.getElementsByClassName("ims_assistance");if(C.length>0){for(var A=0;A<C.length;A++){C[A].onclick=WidgetInit.launcher}}else{var B=document.getElementById("ims_assistance");if(B){B.onclick=WidgetInit.launcher}}if(WidgetInit.getCookie(WidgetInit.LastUpdatedDateCookieName)==null){WidgetInit.setLastUpdatedDateCookie()}this.startPolling();if(!UtilInit.canUseFixedPosition()){window.attachEvent("onscroll",function(){WidgetInit.setButtonPosition()},false)}},imsKeyAlert:function(){var A="ims_key not found";alert(A)},lastAnsweredQuestion:null,updateAnswerStatus:function(){if(document.getElementById("assistanceButton")!=null||document.getElementById("ims_assistance")!=null){var B=new AJAST.JsHttpRequest();if(B!=null){B.onreadystatechange=function(){if(B.readyState==4){if(typeof WidgetInit.lastAnsweredQuestion!="undefined"&&WidgetInit.lastAnsweredQuestion!=null){WidgetInit.showAnswerStatus();WidgetInit.setLastUpdatedDateCookie()}else{if(document.getElementById("assistanceRequestId")==null||(document.getElementById("assistanceRequestId")!=null&&document.getElementById("assistanceRequestId").value=="")){if(WidgetInit.pollingProcess()){return }}}}}}var A=imshoppingScriptRootUrl+"/updateAnswerStatus.action?date="+new Date();var C=WidgetInit.getCookie(WidgetInit.PoolingCookieName);if(C!=null){A+="&questionIds="+C}else{return }var D=WidgetInit.getCookie(WidgetInit.LastUpdatedDateCookieName);if(D!=null){A+="&lastUpdateTime="+D}else{A+="&lastUpdateTime="+new Date().getTime()}B.open("GET",A);B.send()}},startPolling:function(){if(this.params&&this.params.alert&&this.params.alert!=""&&WidgetInit.checkWidgetPoolingCookie()){this.updateAnswerStatus()}},pollingProcess:function(){if(this.params&&this.params.alert&&this.params.alert!=""&&WidgetInit.checkWidgetPoolingCookie()){t=setTimeout("WidgetInit.updateAnswerStatus()",10000);return true}else{if(!this.params){UtilInit.log("this.params is null")}if(!this.params.alert){UtilInit.log("this.params.alert is undefined")}}},checkWidgetPoolingCookie:function(){var A=WidgetInit.getCookie(WidgetInit.PoolingCookieName);if(A!=null){return true}return false},getCookie:function(C){var A=document.cookie;var B=C+"=";if(A.length>0){begin=A.indexOf(B);if(begin!=-1){begin+=B.length;end=A.indexOf(";",begin);if(end==-1){end=A.length}return unescape(A.substring(begin,end))}}return null},setLastUpdatedDateCookie:function(){if(document.getElementById("assistanceRequestId")==null||(document.getElementById("assistanceRequestId")!=null&&document.getElementById("assistanceRequestId").value=="")){var A=new Date();A.setTime(A.getTime()+WidgetInit.PoolingCookieExpires);document.cookie=WidgetInit.LastUpdatedDateCookieName+"="+new Date().getTime()+"; expires="+A.toUTCString()+"; path=/"}},installOnload:function(){if(window.addEventListener){window.addEventListener("load",function(){WidgetInit.install()},false)}else{if(window.attachEvent){window.attachEvent("onload",function(){WidgetInit.install()},false)}}},PoolingCookieName:"poolingQuestionIds",LastUpdatedDateCookieName:"lastUpdatedDate",PoolingCookieExpires:1000*60*20};if(WidgetInit.isTest()){WidgetInit.install()}else{WidgetInit.installOnload()};if(typeof AJAST=="undefined"){AJAST={}}(function(){if(typeof AJAST.Sequence=="undefined"){AJAST.Sequence=0}if(typeof AJAST.MaxPost=="undefined"){AJAST.MaxURL=2083}if(typeof AJAST.pollingInterval=="undefined"){AJAST.pollingInterval=25}if(typeof AJAST.maxInterval=="undefined"){AJAST.maxInterval=15000}if(typeof AJAST.INCOMING=="undefined"){AJAST.INCOMING={}}if(typeof AJAST.JsHttpRequest=="undefined"){AJAST.JsHttpRequest=function(){var me=this;me.readyState=0;me.status=404;me.statusText="Requested resource cannot be accessed at this time";me.responseText="";me.responseXML=null;me.elapsedTime=0;me.sequence=++AJAST.Sequence;me.maxInterval=AJAST.maxInterval;me.pollingInterval=AJAST.pollingInterval;me.setRequestHeader=function(){};me.onreadystatechange=function(){};me.respondToReadyState=function(){};me.setRequestHeader=function(){};me.getResponseHeader=function(){return""};me.getAllResponseHeaders=function(){return""};me.initialize=function(){me.readyState=0};me.open=function(method,url,asynchronous){me.readyState=1;me.respondToReadyState(1);me.onreadystatechange();if(url.match(/\?/)){_url=url.replace(/\?/,"?s="+me.sequence+"&")}else{_url=url+"?ajast_s="+me.sequence}};me.send=function(body){if(typeof body!="undefined"){if(typeof body=="object"){if(typeof JSON=="undefined"){me.status=400;me.statusText="AJAST does not support sending native Javascript objects without first loading json2.js from http://www.json.org";return callback()}else{_post=JSON.stringify(body)}}else{_post=body}}me.readyState=2;me.onreadystatechange();generateScriptTag(_url,0)};me.abort=function(){if(_checkTimer){clearInterval(_checkTimer)}_checkTimer=null;if(_aborted){return }_aborted=true;collectGarbage()};var _head=document.getElementsByTagName("HEAD")[0];var _startTime=new Date().getTime();var _aborted=false;var _post=null;var _node;var _url;var _timepassed=0;var _checkTimer=null;function callback(){if(_checkTimer){clearInterval(_checkTimer)}_checkTimer=null;if(_aborted){return }_aborted=true;var t;t=getResponseValue("status");if(t!=null){me.status=t}t=getResponseValue("statusText");if(t!=null){me.statusText=t}t=getResponseValue("responseText");if(t!=null){me.responseText=t}collectExtras();collectGarbage();if(me.responseText.match(/\s*</)){try{var parser=new DOMParser();me.responseXML=parser.parseFromString(me.responseText,"text/xml")}catch(e){me.responseXML=null}}if(me.status==100&&_post){var pieces=me.statusText.split(/\s+/);try{return generateScriptTag(_url,pieces[2],pieces[5])}catch(e){}}var _endTime=new Date().getTime();me.elapsedTime=(_endTime-_startTime)/1000;me.readyState=4;me.onreadystatechange()}function generateScriptTag(url,postOffset,key){if(_post){var prefix="&ajast_l="+_post.length;if(key){prefix+="&ajast_k="+key}prefix+="&ajast_p=";var maxPostLen=AJAST.MaxURL-(url.length+prefix.length);var payload=encodeURIComponent(_post.substring(postOffset)).substring(0,maxPostLen);url+=prefix+payload;if(url.length==AJAST.MaxURL){var offset=url.substring(url.length-2).indexOf("%");if(offset>-1){url=url.substring(0,url.length-(2-offset))}}}_node=document.createElement("script");_node.type="text/javascript";_node.src=url;_node.onload=function(){callback()};_node.onreadystatechange=function(){if(this.readyState=="complete"||this.readyState=="loaded"){return callback()}};_checkTimer=setInterval(function(){_timepassed+=me.pollingInterval;if(null!=getResponseValue("status")||_timepassed>me.maxInterval){clearInterval(_checkTimer);callback()}},me.pollingInterval);_aborted=false;me.readyState=3;me.onreadystatechange();_head.appendChild(_node)}function getResponseValue(type){try{var val=eval("AJAST.INCOMING.t"+me.sequence+"."+type);if(typeof val!="undefined"&&val!=null){return val}}catch(e){}return null}function collectGarbage(){try{_head.removeChild(_node);eval("delete AJAST.INCOMING.t"+me.sequence+";")}catch(e){}}function collectExtras(){var response=eval("AJAST.INCOMING.t"+me.sequence);if(typeof response=="undefined"){return }for(var n in response){if(n=="status"){continue}if(n=="statusText"){continue}if(n=="responseText"){continue}me[n]=response[n]}}}}})();
