if(!jQuery)throw"need jQuery";
if(!jQuery.cookie)jQuery.cookie=function(a,d,b){if(typeof d!="undefined"){b=b||{};if(d===null){d="";b.expires=-1}var c="";if(b.expires&&(typeof b.expires=="number"||b.expires.toUTCString)){if(typeof b.expires=="number"){c=new Date;c.setTime(c.getTime()+b.expires*24*60*60*1E3)}else c=b.expires;c="; expires="+c.toUTCString()}var e=b.path?"; path="+b.path:"",f=b.domain?"; domain="+b.domain:"";b=b.secure?"; secure":"";document.cookie=[a,"=",encodeURIComponent(d),c,e,f,b].join("")}else{d=null;if(document.cookie&&
document.cookie!=""){b=document.cookie.split(";");for(c=0;c<b.length;c++){e=jQuery.trim(b[c]);if(e.substring(0,a.length+1)==a+"="){d=decodeURIComponent(e.substring(a.length+1));break}}}return d}};
var browseHistory={splitSyn:["$",","],historyPosDiv:"historyPosDiv",historyDivContainer:"historyDivContainer",historyDivId:"historyDiv",currentIndex:0,showRecorder:3,nextRecorder:2,maxRecorder:10,defaultImgSelector:"#browseHistoryImg",defaultURLSelector:"#browseHistoryText",cookieIdx:"clicked",init:function(){var a=this,d=$("#"+a.historyDivContainer),b=$("#"+a.historyPosDiv);if(d.size()===0&&b.size()>0){d=$("<div id='"+a.historyDivContainer+"'></div>").css({position:"absolute",left:0,top:0,width:b.width(),
height:b.height(),zIndex:9999}).appendTo("#WRAP");d.offset(b.offset());var c;$("#"+a.historyDivContainer+", #"+a.historyPosDiv).mouseenter(function(){if(c){clearTimeout(c);c=null}if(a.parse().length>0){a.showHistory();a.$historyDiv.show()}}).mouseleave(function(){c=setTimeout(function(){a.$historyDiv.hide()},200)});a.$historyDiv=function(){var e=$("#"+a.historyDivId);if(e.size()===0)e=$("<div id='"+a.historyDivId+"'></div>").css({position:"absolute",left:0,top:d.height(),zIndex:9999}).hide().appendTo(d);
e.append($("<div id='historyPrebtn'></div><div id='history-margin-top'></div><div id='history-main'><ul id='historyList'></ul></div><div id='history-margin-bottom'></div><div id='historyNextbtn'></div>"));e.find("#historyPrebtn").click(function(){if(!(a.currentIndex<=0)){if(a.currentIndex-a.nextRecorder<=0)a.currentIndex=0;else a.currentIndex-=a.nextRecorder;a.showHistory(a.currentIndex)}});e.find("#historyNextbtn").click(function(){var f=a.parse().length-1-a.nextRecorder;if(!(a.currentIndex>=f)){if(a.currentIndex+
a.nextRecorder>=f)a.currentIndex=f;else a.currentIndex+=a.nextRecorder;a.showHistory(a.currentIndex)}});return e}();$.cookie("clicked")&&a.showHistory()}},log:function(a,d){if(!a||!a.text||!a.link)throw"first argument need text and link.";if(d)this.cookieIdx=d;var b=$.cookie(this.cookieIdx)||"",c=this.splitSyn;if(b.length>0){var e=b.split(c[1]),f=e.length;if(b.indexOf(a.link)!=-1){for(;f--;)e[f].indexOf(a.link)!=-1&&e.splice(f,1);b=e.join(c[1])}if(e.length>=this.maxRecorder)b=e.slice(1).join(c[1]);
if(b.length>0)b+=c[1]}b+=[a.text,c[0],a.link].join("");$.cookie(this.cookieIdx,b,window.location.hostname.indexOf("payeasy.com.tw")!=-1?{domain:"payeasy.com.tw",path:"/"}:{})},parse:function(){var a=$.cookie(this.cookieIdx)||"",d=this.splitSyn,b=a.split(d[1]),c,e=[];a!==""&&$.each(b,function(f,g){c=g.split(d[0]);e.unshift({text:c[0],link:c[1]})});return e},makeSingleHTML:function(a){var d="";if(typeof a.link!="undefined"&&typeof a.text!="undefined")d=["<li><a href='",a.link[0]==="/"?"http://www.payeasy.com.tw/":
"",a.link,"' target='_self'><img onerror=\"this.src='http://www.payeasy.com.tw/HappyS/notExist.jpg'\" src='",a.text[0]==="/"?"http://www.payeasy.com.tw/":"",a.text,"' /></a></li>"].join("");return d},makeAllHTML:function(a){this.currentIndex=a=a||0;var d=this.parse(),b=this.showRecorder;if(d.length===0)return"";var c=[],e=this.makeSingleHTML;c.push("<ul>");$.each(d,function(f,g){if(a>f)return true;if(b>0){c.push(e(g));b--}});c.push("</ul>");return c.join("")},showHistory:function(a){if(a>this.parse().length)a=
this.parse().length-this.nextRecorder-1;else if(a<0)a=0;this.$historyDiv.find("ul").replaceWith($(browseHistory.makeAllHTML(a)))}};$(function(){browseHistory.init();var a=$(browseHistory.defaultImgSelector),d=$(browseHistory.defaultURLSelector);if(a.size()!==0){a=a.attr("src")||a.val();d=d.size()===0?window.location.href:d.val();browseHistory.log({text:a,link:d})}});

