var JSON=JSON||{};if(!JSON.parse){JSON.parse=function(jsonString){jsonString=jsonString.replace(/[\n\r]/g,"");return eval('('+jsonString+')');};}
jx={getHTTPObject:function(){var http=false;if(typeof ActiveXObject!='undefined'){try{http=new ActiveXObject("Msxml2.XMLHTTP");}
catch(e){try{http=new ActiveXObject("Microsoft.XMLHTTP");}
catch(E){http=false;}}}else if(window.XMLHttpRequest){try{http=new XMLHttpRequest();}
catch(e){http=false;}}
return http;},load:function(url,callback,format){var http=this.init();if(!http||!url)return;if(!format)var format="text";format=format.toLowerCase();if(http.overrideMimeType){if(format.charAt(0)=="j"){http.overrideMimeType('application/json');}else{http.overrideMimeType('text/xml');}}
var now="uid="+new Date().getTime();url+=(url.indexOf("?")+1)?"&":"?";url+=now;http.open("GET",url,true);http.onreadystatechange=function(){if(http.readyState==4){if(http.status==200){var result="";if(http.responseText)result=http.responseText;if(format.charAt(0)=="j"){result=JSON.parse(result);}
if(callback)callback(result);}else{if(error)error(http.status);}}}
http.send(null);},init:function(){return this.getHTTPObject();}}
function error(){}
function addEvent(element,type,handler){if(element.addEventListener){element.addEventListener(type,handler,false);}else{if(!handler.$$guid)handler.$$guid=addEvent.guid++;if(!element.events)element.events={};var handlers=element.events[type];if(!handlers){handlers=element.events[type]={};if(element["on"+type]){handlers[0]=element["on"+type];}}
handlers[handler.$$guid]=handler;element["on"+type]=handleEvent;}};addEvent.guid=1;function removeEvent(element,type,handler){if(element.removeEventListener){element.removeEventListener(type,handler,false);}else{if(element.events&&element.events[type]){delete element.events[type][handler.$$guid];}}};function handleEvent(event){var returnValue=true;event=event||fixEvent(((this.ownerDocument||this.document||this).parentWindow||window).event);if(event.target.nodeType==3){event.target=event.target.parentNode;}
var handlers=this.events[event.type];for(var i in handlers){this.$$handleEvent=handlers[i];if(this.$$handleEvent(event)===false){returnValue=false;}}
return returnValue;};function fixEvent(event){event.preventDefault=fixEvent.preventDefault;event.stopPropagation=fixEvent.stopPropagation;event.target=event.target||event.srcElement;return event;};fixEvent.preventDefault=function(){this.returnValue=false;};fixEvent.stopPropagation=function(){this.cancelBubble=true;};var onready_handlers={};var onread_count=0;function onReady(handler){onready_handlers[onread_count++]=handler;}
function init(){if(arguments.callee.done)return;arguments.callee.done=true;for(var i in onready_handlers){onready_handlers[i]();}}
if(document.addEventListener){document.addEventListener('DOMContentLoaded',init,false);}
(function(){/*@cc_on
if(document.body){try{document.createElement('div').doScroll('left');
return init();} catch(e) {}}
/*@if (false) @*/if(/loaded|complete/.test(document.readyState))return init();/*@end @*/if(!init.done)setTimeout(arguments.callee,50);})();_prevOnload=window.onload;window.onload=function(){if(typeof _prevOnload==='function')_prevOnload();init();};function $s(id){var elem=document.getElementById(id);if(elem){if(elem.id!=id){for(var i=1;i<document.all[id].length;i++){if(document.all[id][i].id==id){return document.all[id][i];}}}}
return elem;};function $c(tag){return document.createElement(tag);}
url_encode=encodeURIComponent||escape;function lightbox(content){var l=$c('div');l.id='light';var c=$c('div');c.className='content';var close=$c('span');close.title="Click to close";addEvent(close,'click',function(e){e.preventDefault();document.body.removeChild(l);});close.innerHTML=content+'<a class="close" href="#">Close window</a>';c.appendChild(close);l.appendChild(c);document.body.insertBefore(l,document.body.firstChild);/*@cc_on
 var i=$c('iframe');i.id='back';i.style.height=$s('content').offsetHeight*1.1;
l.insertBefore(i,c);i.frameborder="0";i.doc=i.contentWindow.document;i.doc.open();
i.doc.close();i.doc.body.style.backgroundColor="#000";
/*@if (false) @*/var b=$c('span');b.id='back';l.insertBefore(b,c);/*@end @*/document.body.scrollTop=0;}
(function(){if(!window.jQuery)
return;window.Rating={};window.Rating.JSON_TARGET="/json_processor.php";window.Rating.controlOver=function(){var note=$(this).parents("TABLE:first").find(".product_rating_note:first");note.data("message",note.html());note.html("Click to rate");};window.Rating.controlOut=function(){var note=$(this).parents("TABLE:first").find(".product_rating_note:first");if(note.find("IMG").size()>0)
return;var oldMessage=note.data("message")||"";note.html(oldMessage);}
window.Rating.controlStarClick=function(){var ratingToSet=$(this).parent().index()+1;var control=$(this).parents("TABLE:first").find(".rating:first");var note=$(this).parents("TABLE:first").find(".product_rating_note:first");var prompt=$(this).parents("TABLE:first").find(".product_rating_prompt:first");var callback=function(data){if(data.error||!data.rating){note.html(data.error);}else{note.html("You've rated this "+data.rating+" out of 5 stars.");note.data("message",note.html());if(data.avg_rating){var avg=parseInt(data.avg_rating);control.removeClass("worst bad fair good best");switch(avg){case 5:control.addClass("best");break;case 4:control.addClass("good");break;case 3:control.addClass("fair");break;case 2:control.addClass("bad");break;case 1:control.addClass("worst");break;}}}};var target=Rating.JSON_TARGET+"?cmd=json_rate_product"
+"&rating="+ratingToSet
+"&id="+control.attr("barcode");$.ajax({type:"POST",url:target,dataType:"json",success:callback,complete:function(){if(note.find("IMG").size())note.html("");}});note.html("<img src=\"http://assets.fishpond.co.nz/progress.gif\" border=\"0\" alt=\"Please wait...\" title=\"Please wait...\" />");}})();