﻿function onlyNumsAllowed(e,numberType,allowNegative,allowReturn,allowSpace){if(allowSpace==undefined){allowSpace=false}var iKeyCode;if(window.event){ev=window.event;iKeyCode=ev.keyCode}else{if(e.which){ev=e;iKeyCode=e.which}}if(iKeyCode==8){return true}if(iKeyCode==47||(iKeyCode!=32&&iKeyCode<44)||iKeyCode>57||(!allowNegative&&iKeyCode==45)||(numberType!="float"&&iKeyCode==46)||(iKeyCode==13&&!allowReturn)||(iKeyCode==32&&!allowSpace)){try{if(window.event){ev.keyCode=null}else{if(e.which){ev.which=null}}}catch(e){}return false}}function disableControl(controlName){document.getElementById(controlName).disabled=true;return true}function toggleVisibility(elementName){}function floatElement(elementName){if(document.getElementById(elementName).style.display=="none"){document.getElementById(elementName).style.display="block"}else{document.getElementById(elementName).style.display="none"}}function createHTTPRequest(handler){var req=null;if(typeof window.ActiveXObject!="undefined"){req=new ActiveXObject("Microsoft.XMLHTTP");req.onreadystatechange=handler}else{req=new XMLHttpRequest();req.onload=handler}return req}var xmlhttp=createHTTPRequest(completeRequest);function ajaxAddItemToBasket(product,supplier,qty,agreementNo){qty=parseInt(qty);if(isNaN(qty)){qty=1}var siteRoot=document.getElementById("siteRoot").innerHTML;var locStr=new String(window.location);locStr=locStr.toLowerCase();if(locStr.indexOf("checkout.aspx")>0){alert("You cannot add items to a basket whilst you are checking out...")}else{Dialog.info(" ",{windowParameters:{className:"alert_lite",width:250,height:120,showEffect:Element.show,hideEffect:Element.fade},showProgress:false});window.status="";xmlhttp.open("GET",siteRoot+"/supply/catalogue/addItemToBasket.aspx?spn="+product+"&sid="+supplier+"&qty="+qty+"&agreement="+agreementNo+"&hash="+Math.random(),true);xmlhttp.send(null)}}function ajaxRemoveItemFromBasket(product,supplier,agreementNo,itemID){var siteRoot=document.getElementById("siteRoot").innerHTML;var locStr=new String(window.location);locStr=locStr.toLowerCase();if(locStr.indexOf("checkout.aspx")>0){alert("You cannot remove items from a basket whilst you are checking out...")}else{Dialog.info(" ",{windowParameters:{className:"alert_lite",width:250,height:120,showEffect:Element.show,hideEffect:Element.fade},showProgress:false});window.status="";xmlhttp.open("GET",siteRoot+"/supply/catalogue/addItemToBasket.aspx?action=remove&spn="+product+"&sid="+supplier+"&agreement="+agreementNo+"&item="+itemID+"&hash="+Math.random(),true);xmlhttp.send(null)}}function ajaxEmptyBasket(){var siteRoot=document.getElementById("siteRoot").innerHTML;xmlhttp.open("GET",siteRoot+"/orders/emptyBasket.aspx?hash="+Math.random(),true);xmlhttp.send(null)}function completeRequest(){var siteRoot=document.getElementById("siteRoot").innerHTML;if((xmlhttp.readyState==4)&&(xmlhttp.status==200)){try{var res=xmlhttp.responseText.split("|");var cLocation=new String(document.location);try{if(cLocation.indexOf("comparisonsView.aspx")>=0){var d=window.opener.document;d.getElementById("basketItemID").innerHTML=res[6];d.getElementById("basketItemCount").innerHTML="&nbsp;"+res[1];d.getElementById("basketSubTotal").innerHTML="&nbsp;"+res[2];d.getElementById("basketDeliveryTotal").innerHTML="&nbsp;"+res[3];d.getElementById("basketGrandTotal").innerHTML="&nbsp;"+res[4];d.getElementById("basketItemSummary").innerHTML=res[14];if(panBasketDetails!=""){if(res[15]<=0){d.getElementById(panBasketDetails).style.display="none"}else{d.getElementById(panBasketDetails).style.display="block"}}}else{document.getElementById("basketItemID").innerHTML=res[6];document.getElementById("basketItemCount").innerHTML="&nbsp;"+res[1];document.getElementById("basketSubTotal").innerHTML="&nbsp;"+res[2];document.getElementById("basketDeliveryTotal").innerHTML="&nbsp;"+res[3];document.getElementById("basketGrandTotal").innerHTML="&nbsp;"+res[4];document.getElementById("basketItemSummary").innerHTML=res[14];if(panBasketDetails!=""){if(res[15]<=0){document.getElementById(panBasketDetails).style.display="none"}else{document.getElementById(panBasketDetails).style.display="block"}}}}catch(e){}if(res[0]=="addItem"||res[0]=="removeItem"){if(res[5]==""){var msg=res[9];if(msg==""){msg=res[10]}Dialog.setInfoMessage(msg+'<br/><br/><input type="button" value="'+res[13]+'" class="basketButtonsLight" onclick="Dialog.closeInfo()">&nbsp;&nbsp;<input type="button" value="'+res[12]+'" class="basketButtonsLight" onclick="document.location.href = \''+res[16]+"'\">");window.status="";window.status=res[11]}else{var msg="<b>"+res[10]+"</b>";Dialog.setInfoMessage(msg);setTimeout("Dialog.closeInfo()",1000);window.status="";window.status=res[11];var locStr=new String(window.location);if(locStr.indexOf("viewBasket.aspx")>0){document.location.href="viewBasket.aspx"}}}xmlhttp=createHTTPRequest(completeRequest)}catch(e){Dialog.closeInfo();xmlhttp=createHTTPRequest(completeRequest)}}else{}}var xmlhttpFavourites=createHTTPRequest(completeRequestFavourites);function ajaxItemToFavourites(product,supplier,action,linkName){var siteRoot=document.getElementById("siteRoot").innerHTML;Dialog.info(" ",{windowParameters:{className:"alert_lite",width:250,height:80,showEffect:Element.show,hideEffect:Element.fade},showProgress:false});window.status="";xmlhttpFavourites.open("GET",siteRoot+"/supply/catalogue/addItemToFavourites.aspx?spn="+product+"&sid="+supplier+"&action="+action+"&linkName="+linkName+"&hash="+Math.random(),true);xmlhttpFavourites.send(null)}function completeRequestFavourites(){var siteRoot=document.getElementById("siteRoot").innerHTML;if((xmlhttpFavourites.readyState==4)&&(xmlhttpFavourites.status==200)){try{var res=xmlhttpFavourites.responseText.split("|");Dialog.setInfoMessage(res[3]);setTimeout("Dialog.closeInfo()",1000);if(res[0]=="1"&&res[2]!=""){document.getElementById(res[2]).innerHTML=res[4]}window.status="";window.status=res;xmlhttpFavourites=createHTTPRequest(completeRequestFavourites)}catch(e){xmlhttpFavourites=createHTTPRequest(completeRequestFavourites)}}else{}}function confirmDelete(text){var agree=confirm(text);if(agree){return true}else{return false}}var xmlhttpPO=createHTTPRequest(completeRequestPO);function ajaxCheckPO(key1,poTextbox,supplierID,lblField,lblCheckedField){var siteRoot=document.getElementById("siteRoot").innerHTML;var thePO=document.getElementById(poTextbox).value;var checkedPO=document.getElementById(lblCheckedField).innerHTML;thePO=thePO.toUpperCase();checkedPO=checkedPO.toUpperCase();if(thePO!=""&&thePO!=checkedPO){xmlhttpPO.open("GET",siteRoot+"/supply/orders/checkPO.aspx?key1="+key1+"&supplier="+supplierID+"&po="+thePO+"&lbl="+lblField+"&checkedValueField="+lblCheckedField+"&hash="+Math.random(),true);xmlhttpPO.send(null)}}function completeRequestPO(){var siteRoot=document.getElementById("siteRoot").innerHTML;if((xmlhttpPO.readyState==4)&&(xmlhttpPO.status==200)){try{var res=xmlhttpPO.responseText.split("|");document.getElementById(res[1]).innerHTML=res[2];document.getElementById(res[0]).innerHTML=res[3];xmlhttpPO=createHTTPRequest(completeRequestPO)}catch(e){xmlhttpPO=createHTTPRequest(completeRequestPO)}}else{}}var typeAheadInfo={last:0,accumString:"",delay:500,timeout:null,reset:function(){this.last=0;this.accumString=""}};function typeAhead(){if(window.event&&!window.event.ctrlKey){var now=new Date();if(typeAheadInfo.accumString==""||now-typeAheadInfo.last<typeAheadInfo.delay){var evt=window.event;var selectElem=evt.srcElement;var charCode=evt.keyCode;if(charCode==9){return true}if(charCode==10){return true}if(charCode==13){return true}var newChar=String.fromCharCode(charCode).toUpperCase();typeAheadInfo.accumString+=newChar;var selectOptions=selectElem.options;var txt,nearest;for(var i=0;i<selectOptions.length;i++){txt=selectOptions[i].text.toUpperCase();nearest=(typeAheadInfo.accumString>txt.substr(0,typeAheadInfo.accumString.length))?i:nearest;if(txt.indexOf(typeAheadInfo.accumString)==0){clearTimeout(typeAheadInfo.timeout);typeAheadInfo.last=now;typeAheadInfo.timeout=setTimeout("typeAheadInfo.reset()",typeAheadInfo.delay);selectElem.selectedIndex=i;evt.cancelBubble=true;evt.returnValue=false;return false}}if(nearest!=null){selectElem.selectedIndex=nearest}}else{clearTimeout(typeAheadInfo.timeout)}typeAheadInfo.reset()}return true}function SubmitAndDisableButton(){window.setTimeout("disableButton('"+window.event.srcElement.id+"')",0)}function disableButton(buttonID){document.getElementById(buttonID).disabled=true}function openWindow(url,name,top,width,height){winContent=window.open(url,name,"right=0, top="+top+",width="+width+",height="+height+", toolbar=no,scrollbars=yes,status=no, resizable=yes");winContent.focus()}function mfs_toggle(controlID,toggleStatus,associatedID){if(document.getElementById("mfs_tr2_"+controlID).style.display=="none"||toggleStatus==1){document.getElementById("mfs_tr2_"+controlID).style.display="";document.getElementById("mfs_tr3_"+controlID).style.display="";document.getElementById("mfs_img_expand_"+controlID).style.display="none";document.getElementById("mfs_img_collapse_"+controlID).style.display="inline";if(associatedID!=""){document.getElementById("mfs_outer_"+associatedID).style.display="none"}}else{document.getElementById("mfs_tr2_"+controlID).style.display="none";document.getElementById("mfs_tr3_"+controlID).style.display="none";document.getElementById("mfs_img_expand_"+controlID).style.display="inline";document.getElementById("mfs_img_collapse_"+controlID).style.display="none";if(associatedID!=""){document.getElementById("mfs_outer_"+associatedID).style.display="block"}}}function capLock(e,divName){kc=e.keyCode?e.keyCode:e.which;sk=e.shiftKey?e.shiftKey:((kc==16)?true:false);if(((kc>=65&&kc<=90)&&!sk)||((kc>=97&&kc<=122)&&sk)){document.getElementById(divName).style.visibility="visible"}else{document.getElementById(divName).style.visibility="hidden"}}function pageWidth(){return window.innerWidth!=null?window.innerWidth:document.documentElement&&document.documentElement.clientWidth?document.documentElement.clientWidth:document.body!=null?document.body.clientWidth:null}function pageHeight(){return window.innerHeight!=null?window.innerHeight:document.documentElement&&document.documentElement.clientHeight?document.documentElement.clientHeight:document.body!=null?document.body.clientHeight:null}function posLeft(){return typeof window.pageXOffset!="undefined"?window.pageXOffset:document.documentElement&&document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft?document.body.scrollLeft:0}function posTop(){return typeof window.pageYOffset!="undefined"?window.pageYOffset:document.documentElement&&document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop?document.body.scrollTop:0}function posRight(){return posLeft()+pageWidth()}function posBottom(){return posTop()+pageHeight()}var FADINGTOOLTIP=document.getElementById("FADINGTOOLTIP");var wnd_height,wnd_width;var tooltip_height,tooltip_width;var tooltip_shown=false;var transparency=100;var timer_id=1;window.onload=WindowLoading;window.onresize=UpdateWindowSize;document.onmousemove=AdjustToolTipPosition;function DisplayTooltip(tooltip_text){FADINGTOOLTIP.innerHTML=tooltip_text;tooltip_shown=(tooltip_text!="")?true:false;if(tooltip_text!=""){tooltip_height=(FADINGTOOLTIP.style.pixelHeight)?FADINGTOOLTIP.style.pixelHeight:FADINGTOOLTIP.offsetHeight;transparency=0;ToolTipFading()}else{clearTimeout(timer_id);FADINGTOOLTIP.style.visibility="hidden"}}function AdjustToolTipPosition(e){if(tooltip_shown){offset_y=(event.clientY+tooltip_height-document.body.scrollTop+30>=wnd_height)?-15-tooltip_height:20;FADINGTOOLTIP.style.visibility="visible";FADINGTOOLTIP.style.left=Math.min(wnd_width-tooltip_width-10,Math.max(3,event.clientX+6))+document.body.scrollLeft+"px";FADINGTOOLTIP.style.top=event.clientY+offset_y+document.body.scrollTop+"px"}}function WindowLoading(){FADINGTOOLTIP=document.getElementById("FADINGTOOLTIP");if(FADINGTOOLTIP==null){return}tooltip_width=(FADINGTOOLTIP.style.pixelWidth)?FADINGTOOLTIP.style.pixelWidth:FADINGTOOLTIP.offsetWidth;tooltip_height=(FADINGTOOLTIP.style.pixelHeight)?FADINGTOOLTIP.style.pixelHeight:FADINGTOOLTIP.offsetHeight;UpdateWindowSize()}function ToolTipFading(){if(transparency<=100){FADINGTOOLTIP.style.filter="alpha(opacity="+transparency+")";transparency+=5;timer_id=setTimeout("ToolTipFading()",35)}}function UpdateWindowSize(){wnd_height=document.body.clientHeight;wnd_width=document.body.clientWidth}function setSearchHints(ddlID,aceID){dd=document.getElementById(ddlID);ace=$find(aceID);if(dd.value=="S1"||dd.value=="S1.1"||dd.value==""){ace.set_serviceMethod("GetSearchTerms_Catalogue")}else{ace.set_serviceMethod("GetSearchTerms_None")}}var IE=document.all?true:false;if(document.captureEvents&&Event.MOUSEMOVE){document.captureEvents(Event.MOUSEMOVE)}document.onmousemove=getMouseXY;var tempX=0;var tempY=0;var _popupTarget;var TimeToFade=1000;var _scrollTop=window.pageYOffset||document.documentElement.scrollTop||0;var _scrollLeft=window.pageXOffset||document.documentElement.scrollLeft||0;function lookupDeliveryCallback(arg,context){if(arg==""){return false}var add=false;var dv=document.getElementById("popupDeliveryRates");if(!dv){dv=document.createElement("div");dv.setAttribute("id","popupDeliveryRates");add=true}dv.style.position="absolute";dv.style.left=tempX+"px";dv.style.top=(tempY-175)+"px";dv.style.height=170+"px";dv.innerHTML=arg;if(add){dv.FadeState=-2;dv.style.filter="alpha(opacity = 0)";dv.style.opacity=0;document.body.appendChild(dv)}if(dv.FadeState!="2"){fade(dv.id)}}function getMouseXY(e){if(!e){var e=window.event}if(IE){tempX=event.clientX+document.documentElement.scrollLeft;tempY=event.clientY+document.documentElement.scrollTop}else{tempX=e.pageX+_scrollLeft;tempY=e.pageY+_scrollTop}if(tempX<0){tempX=0}if(tempY<0){tempY=0}return true}function fade(eid){var element=document.getElementById(eid);if(element==null){return}if(element.FadeState==null){if(element.style.opacity==null||element.style.opacity==""||element.style.opacity=="1"){element.FadeState=2}else{element.FadeState=-2}}if(element.FadeState==1||element.FadeState==-1){element.FadeState=element.FadeState==1?-1:1;element.FadeTimeLeft=TimeToFade-element.FadeTimeLeft}else{element.FadeState=element.FadeState==2?-1:1;element.FadeTimeLeft=TimeToFade;setTimeout("animateFade("+new Date().getTime()+",'"+eid+"')",33)}}function animateFade(lastTick,eid){var curTick=new Date().getTime();var elapsedTicks=curTick-lastTick;var element=document.getElementById(eid);if(element.FadeTimeLeft<=elapsedTicks){element.style.opacity=element.FadeState==1?"1":"0";element.style.filter="alpha(opacity = "+(element.FadeState==1?"100":"0")+")";if(element.FadeState==1){element.style.display="block"}else{element.style.display="none"}element.FadeState=element.FadeState==1?2:-2;return}element.FadeTimeLeft-=elapsedTicks;var newOpVal=element.FadeTimeLeft/TimeToFade;if(element.FadeState==1){newOpVal=1-newOpVal}element.style.opacity=newOpVal;element.style.filter="alpha(opacity = "+(newOpVal*100)+")";setTimeout("animateFade("+curTick+",'"+eid+"')",33)}function findPos(obj){var curleft=curtop=0;if(obj.offsetParent){do{curleft+=obj.offsetLeft;curtop+=obj.offsetTop}while(obj=obj.offsetParent);return[curleft,curtop]}}function showExtendedSearch(spanID,selectID){var theSpan=document.getElementById(spanID);var theSelect=document.getElementById(selectID);theSpan.style.display="none";theSelect.style.display="block";theSelect.focus()}function extendedSearch(selectID){var theSelect=document.getElementById(selectID);var theIndex=theSelect.selectedIndex;document.location=theSelect.options[theIndex].value}function displayExtendedAttributesCallback(arg,context){if(arg==""){return false}var res=arg.split("¦");var pLeft=250;var pTop=200;if(res[0]!=""){var sourcePanel=document.getElementById(res[0]);var pos=findPos(sourcePanel);pLeft=pos[0];pTop=pos[1];if(IE){pLeft=pLeft+2-sourcePanel.offsetLeft}}var add=false;var dv=document.getElementById("popupAttributes");if(!dv){dv=document.createElement("div");dv.setAttribute("id","popupAttributes");add=true}dv.style.position="absolute";dv.style.left=pLeft+"px";dv.style.top=pTop+"px";dv.style.backgroundColor="white";dv.innerHTML=res[1];if(add){dv.FadeState=-2;dv.style.filter="alpha(opacity = 0)";dv.style.opacity=0;document.body.appendChild(dv)}if(dv.FadeState!="2"){fade(dv.id)}if(dv.style.display=="none"){dv.style.display="block"}}function hasClass(ele,cls){return ele.className.match(new RegExp("(\\s|^)"+cls+"(\\s|$)"))}function addClass(ele,cls){if(!this.hasClass(ele,cls)){ele.className+=" "+cls}}function removeClass(ele,cls){if(hasClass(ele,cls)){var reg=new RegExp("(\\s|^)"+cls+"(\\s|$)");ele.className=ele.className.replace(reg," ")}}function height(){if(document.all){return document.body.offsetHeight}else{if(document.layers){return document.body.document.height}}}function copyToClipboard(s){if(window.clipboardData&&clipboardData.setData){clipboardData.setData("Text",s)}}function removeItem(action,sku){try{var trackingObject=createITT();trackingObject.ACTION=action;trackingObject._S_SKU=sku;trackingObject.submit_action()}catch(e){}}function validateCustomerField(sender,args){args.IsValid=true;if(args.Value!=""){if(typeof window.ActiveXObject!="undefined"){var oXMLHTTP=new ActiveXObject("Microsoft.XMLHTTP")}else{var oXMLHTTP=new XMLHttpRequest()}var siteRoot=document.getElementById("siteRoot").innerHTML;var valKey=sender.attributes.getNamedItem("validation_key").nodeValue;var Url=siteRoot+"/ajax/validateCustomerField.ashx?value="+args.Value+"&key="+valKey;oXMLHTTP.open("GET",Url,false);try{oXMLHTTP.send(null);if(oXMLHTTP.responseText=="1"){args.IsValid=true}else{args.IsValid=false}}catch(e){alert("XMLHTTPRequest failed");return""}}}function ajaxGetData(action,url){var xmlhttpMissingPrices=createHTTPRequest(function completeRequestMissingPrices(){if((xmlhttpMissingPrices.readyState==4)&&(xmlhttpMissingPrices.status==200)){try{var res=xmlhttpMissingPrices.responseText.split("^^");if(res[0]=="pricing"){updatePrice(res)}if(res[0]=="breadcrumbs"){updateBreadCrumbs(res)}if(res[0]=="deliveryRates"){lookupDeliveryCallback(res[1],"")}if(res[0]=="altsearch"){updateAltSearch(res)}}catch(e){}}else{}});xmlhttpMissingPrices.open(action,url,true);xmlhttpMissingPrices.send(null)}function checkTextAreaMaxLength(textBox,e,length){var mLen=textBox.MaxLength;if(null==mLen){mLen=length}var maxLength=parseInt(mLen);if(!checkSpecialKeys(e)){if(textBox.value.length>maxLength-1){if(window.event){e.returnValue=false}else{e.preventDefault()}}}}function checkSpecialKeys(e){if(e.keyCode!=8&&e.keyCode!=46&&e.keyCode!=37&&e.keyCode!=38&&e.keyCode!=39&&e.keyCode!=40){return false}else{return true}};