/*---------- Copyright 2010 Neotek Limited (http://www.neotek.co.nz). All rights reserved. -----------*/
function favouriteclick(e){try{var srcel=Event.Get(e).src;var id=srcel.getAttribute('productid');var cssclass=srcel.className;if(id!=null){var action='Remove';if(cssclass!='favourite')action='Add';top.neotekscript('/Catalog/Favourites.aspx?Action='+action+'&ProductID='+id+'&AJAX=1',null,processScriptLocal);}}catch(e){alert(e.message);}}function processScriptLocal(xmlHttp){if(xmlHttp.readyState==4){if(xmlHttp.status==200){var scripts=xmlHttp.responseXML.getElementsByTagName("scripts")[0];if(scripts!=null){var script='';for(var i=0;i<scripts.childNodes.length;i++){try{if(scripts.childNodes[i].textContent!=null){script=scripts.childNodes[i].textContent;}else{script=scripts.childNodes[i].text;}eval(script);}catch(e){alert(script+e.message);}}}else{alert('Failed to get a response!');}}}}function favouriteSet(id,state){var el=document.getElementById('favourite'+id);if(el!=null){if(state==true){el.title=el.ontitle;el.className='favourite';}else{el.title=el.offtitle;el.className='notfavourite';}}}var ProductImages={Show:function(){var nodes=document.getElementsByTagName('IMG');var lth=nodes.length;for(var i=0;i<lth;++i){var o=nodes[i].getAttribute('path');if(o!=null){nodes[i].src=o;nodes[i].style.display='block';nodes[i].style.filter='alpha(opacity=100)';}}},Hide:function(){var nodes=document.getElementsByTagName('IMG');var lth=nodes.length;for(var i=0;i<lth;++i){var o=nodes[i].getAttribute('path');if(o!=null)nodes[i].style.display='none';}},Check:function(){var o=document.getElementById('chkShowImages');if(!!!o)alert('chkShowImages Element not found');if(o.checked){ProductImages.Show();}else{ProductImages.Hide();}},Checked:function(){var o=document.getElementById('chkShowImages');if(!!!o)alert('chkShowImages Element not found');var ShowImages='true'
if(o.checked){ShowImages='true';}else{ShowImages='false';}var url='/Catalog/ProductView.aspx'+QueryString('ShowImages',ShowImages)
top.neotekText(url,null);ProductImages.Check();}};function ShowLoadingImage(){var oo=document.getElementById('ItemPanel');oo.innerHTML='';var div=document.createElement('div');div.style.textAlign='center';div.innerHTML='<img src="/Owner/Skin/images/progress.gif" />';oo.appendChild(div);}function ChangeProductView(){var o=document.getElementById('ListStyle');var view=o.options[o.selectedIndex];view=view.getAttribute('ViewID');ShowLoadingImage();top.neotekText('/Catalog/ProductView.aspx'+QueryString('ChangeView',view),ProductViewCallback);}function ChangeSearchMode(){var o=document.getElementById('ListSearchMode');var mode=o.options[o.selectedIndex];mode=mode.getAttribute('ModeID');ShowLoadingImage();window.location='/Catalog/ProductView.aspx'+QueryString('SearchMode',mode);}function ChangePage(PageNum){ShowLoadingImage();window.location='/Catalog/ProductView.aspx'+QueryString('PageNo',PageNum);}function QueryString(key,value){var url=window.location.search;if(url.length>1)url=url.substring(1);else return null;var querystring='';var keyValuePairs=url.split("&");for(var i=0;i<keyValuePairs.length;++i){var k=keyValuePairs[i].split('=')[0];if(k.toLowerCase()!=key.toLowerCase()){if(k.toLowerCase()=='ref'||k.toLowerCase()=='id'||k.toLowerCase()=='txtsearch'||k.toLowerCase()=='tempview'){querystring+='&'+keyValuePairs[i];}}}querystring+='&'+key+'='+value;return'?'+querystring.substring(1);}function UpdatePageSize(e){e=e||window.event;var o=e.target||e.srcElement;window.location='/Catalog/ProductView.aspx'+QueryString('PageSize',o.value);}function ProductViewCallback(retVal){var o=document.getElementById('ItemPanel');if(o){o.innerHTML=retVal;var scriptNodes=o.getElementsByTagName('script');var lth=scriptNodes.length;for(var i=0;i<lth;++i){if(scriptNodes[i].src!=''){var script=document.createElement('script');script.src=scriptNodes[i].src.toString();o.appendChild(script);}else eval(scriptNodes[i].innerHTML);}}}function ShowInventoryPopup(e,id){var settings={URL:'/Catalog/InventoryPopup.aspx?Ajax=1&ProductId='+id,Title:'Inventory',ShowClose:true,Position:e,ShowTriangle:false,Width:400,DoFade:false,CloseOnLoseFocus:false};top.cancelPropagation(e);top.NeotekPopup.Show(settings);e=e||window.event;var obj=e.target||e.srcElement;if(obj.className=='NoStock'){ShowInventoryPopupEtaTab(0);}}function ShowInventoryPopupEtaTab(count){if(count>10)return;if(top.$('invETATab')){top.ShowTab(1);}else{setTimeout('ShowInventoryPopupEtaTab('+(count+1)+')',500);}}function ShowImage(e,imageURL){var settings={src:imageURL,ShowClose:false,Position:e,AutoResize:true,DoFade:false,CloseOnLoseFocus:true};top.cancelPropagation(e);top.NeotekPopup.Show(settings);}function ShowTab(num){var stock=document.getElementById('invStockTbl');var eta=document.getElementById('invETATbl');if(num==0){stock.style.display='block';eta.style.display='none';}else{stock.style.display='none';eta.style.display='block';}}function OnUnloadCheck(){var hasItems=false;var df=document.forms['OrderPad'];if(df){if(df.Qty){if(df.Qty.length){for(var i=0;i<df.Qty.length;i++){var qty;if(df.Qty[i].value==""){qty=0;}else{qty=df.Qty[i].value}var orgQty;if(df.OrgQty[i].value==""){orgQty=0;}else{orgQty=df.OrgQty[i].value}if((qty-orgQty)>0){hasItems=true;break}}}else if(df.OrgQty!=undefined){var orgQty;var qty;if(df.OrgQty.value==""){orgQty=0;}else{orgQty=parseInt(df.OrgQty.value);}if(df.Qty.value==""){qty=0;}else{qty=parseInt(df.Qty.value);}if((qty-orgQty)>0){hasItems=true;}}else{hasItems=(df.Qty.value!='');}}}if(hasItems){if(confirm('You have items not yet submitted to your basket.\n Would you like to add these to your basket now?')){var vals=top.getFormValues(df);top.neotekscript(df.action,vals);}}}window.onbeforeunload=OnUnloadCheck;//IE "can't run from freed script" error if onunload tried.(IE7,Vista)