function validate(n,t){var f=!1,i=n.value.replace("$","");if(!isNaN(i)&&i>0){var e=+i,r=new Array(t.length),u=0;for(idx=0;idx<t.length;idx++)denomination=t[idx],denomination!=0&&denomination<=e&&(r[u]=denomination,u++);r.length=u;isValidDenomination(i,[],r)?SumAmounts()>rewardvalue?showAlert("Your request has exceeded your reward value."):f=!0:showAlert("The amount entered must equal a combination of the following gift cards.\n\n"+DenominationToString(t))}else n.value="";return f}function isValidDenomination(n,t,i){var r=!1,e=new Array(t.length+1),u,h,f;for(idx=0;idx<t.length;idx++)e[idx]=t[idx];var o=t.length,c=i.length,s=i[o],l=n/s;for(c==1&&(r=n%s==0),u=0;u<=l&&!r;u++)if(o==c-1){for(h=u*s,f=0;f<o;f++)h+=t[f]*i[f];r=h==n}else e[e.length-1]=u,r=isValidDenomination(n,e,i);return r}function Intercept(n,t,i){frm=document.forms[0];n==13&&(t.value.length==0||t.value=="0"||validate(t,i))&&frm.submit()}function DenominationToString(n){for(result="",idx=0;idx<n.length;idx++)n[idx]>0&&(result.length>0&&(result+=idx==n.length-1?" or ":", "),result+="$"+n[idx]);return result}function getAbsX(n){return n.x?n.x:getAbsPos(n,"Left")}function getAbsY(n){return n.y?n.y:getAbsPos(n,"Top")}function getAbsPos(n,t){for(iPos=0;n!=null;)iPos+=n["offset"+t],n=n.offsetParent;return iPos}function hpconv_show(n){var i=document.getElementById("voucher_"+n),t=document.getElementById("hpconv_"+n),r=+t.style.width.replace("px","");t.style.left=getAbsX(i)+"px";t.style.left=t.style.left.replace("px","")-(r/2-8);t.style.top=getAbsY(i)+23+"px";t.style.visibility="visible"}function hpconv_hide(n){var t=document.getElementById("hpconv_"+n);t!=null&&(t.style.visibility="hidden")}function hpconv_display(n,t,i){var r=document.getElementById("val_"+t),u;r!=null&&(i==0&&(i=140),isNaN(n.value)?r.innerHTML="0":(u=n.value*i,r.innerHTML=formatCurrency(Math.round(u))))}function formatCurrency(n){n=n.toString().replace(/\$|\,/g,"");isNaN(n)&&(n="0");sign=n==(n=Math.abs(n));n=Math.floor(n*100+.50000000001);cents=n%100;n=Math.floor(n/100).toString();cents<10&&(cents="0"+cents);for(var t=0;t<Math.floor((n.length-(1+t))/3);t++)n=n.substring(0,n.length-(4*t+3))+","+n.substring(n.length-(4*t+3));return(sign?"":"-")+n}function formatCurrencyWithCents(n){n=n.toString().replace(/\$|\,/g,"");isNaN(n)&&(n="0");sign=n==(n=Math.abs(n));n=Math.floor(n*100+.50000000001);cents=n%100;n=Math.floor(n/100).toString();cents<10&&(cents="0"+cents);for(var t=0;t<Math.floor((n.length-(1+t))/3);t++)n=n.substring(0,n.length-(4*t+3))+","+n.substring(n.length-(4*t+3));return(sign?"":"-")+n+"."+(cents.length>2?cents.substring(0,2):cents)}function OpenInfoWindow(n,t,i){window.open(n,null,"height="+i+",width="+t+",status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes")}function thermo_position(n,t,i,r){var f=document.getElementById(n),u=document.getElementById(t),e=+u.style.width.replace("px","");u.style.left=i+"px";u.style.top=r+"px";u.style.visibility="visible"}function keepAlive(){}function ajaxRequest(n){if(http_request=!1,window.XMLHttpRequest)http_request=new XMLHttpRequest,http_request.overrideMimeType&&http_request.overrideMimeType("text/xml");else if(window.ActiveXObject)try{http_request=new ActiveXObject("Msxml2.XMLHTTP")}catch(t){try{http_request=new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}if(!http_request)return!1;http_request.open("GET",n,!0);http_request.send(null)}function createCookie(n,t,i){var r,u;i?(r=new Date,r.setTime(r.getTime()+i*864e5),u="; expires="+r.toGMTString()):u="";document.cookie=n+"="+t+u+"; path=/"}function readCookie(n){for(var r=n+"=",u=document.cookie.split(";"),t,i=0;i<u.length;i++){for(t=u[i];t.charAt(0)==" ";)t=t.substring(1,t.length);if(t.indexOf(r)==0)return t.substring(r.length,t.length)}return null}function eraseCookie(n){createCookie(n,"",-1)}keepAlive()