var _Q=new _qobj();function _qobj(){this.cookie=new _qcookie();this.url=new _qurl();this.visitor=new _qvisitor();this.script=new _qscript();this.text=new _qstring();this.validate=new _qvalidator();this.number=new _qnumber();this.func=new _qfunc();};function _qcookie(){this.set=function(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}else{var expires="";}
document.cookie=name+"="+value+expires+"; path=/";};this.get=function(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' '){c=c.substring(1,c.length);}
if(c.indexOf(nameEQ)==0){return c.substring(nameEQ.length,c.length);}}
return null;};this.erase=function(cookie_name){var cookie_date=new Date();cookie_date.setTime(cookie_date.getTime()-1);document.cookie=cookie_name+="=; expires="+cookie_date.toGMTString();};this.exists=function(name){if(this.get(name)!=null){return true;}else{return false;}};};function _qurl(){this.get=function(){return document.location;};this.params=function(){var variables=[],hash;var collection=window.location.href.slice(window.location.href.indexOf('?')+1).split('&');for(var i=0;i<collection.length;i++){hash=collection[i].split('=');variables.push(hash[0]);variables[hash[0]]=hash[1];}
return variables;};this.param=function(id){var params=this.params();if(params[id]==null){return'';}else{return params[id];}};this.domain=function(){return document.domain;};};function _qvisitor(){this.cookie=new _qcookie();this.storage=new _qstorage();this.user_agent=function(){return navigator.userAgent;};this.browser=function(){agent=this.user_agent();if(agent.match(/chrome/gi)){return"Chrome";}
else if(agent.match(/safari/gi)){return"Safari";}
else if(agent.match(/MSIE 6/gi)){return"IE6";}
else if(agent.match(/MSIE 7/gi)){return"IE7";}
else if(agent.match(/MSIE 8/gi)){return"IE8";}
else if(agent.match(/firefox/gi)){return"Firefox";}
else{return"Unknown";}};this.os=function(){return navigator.platform;};this.uid=function(){var cookie=new _qcookie();var text=new _qstring();if(cookie.exists('_qvid')){return cookie.get('_qvid');}else{var qvid=text.createUUID();cookie.set('_qvid',qvid,300);return qvid;}};};function _qstring(){this.encode=function(str){return _qBase64.encode(str);};this.decode=function(encodedstr){return _qBase64.decode(encodedstr);};this.contains=function(needle,haystack,case_sensitive){if(!case_sensitive){needle=needle.toLowerCase();haystack=haystack.toLowerCase();}
if(haystack.match(needle)){return true;}else{return false;}};this.urlformat=function(str){str=str.replace(/[^a-zA-Z 0-9]+( )/g,'');str=str.replace(/( )/g,"-");str=str.toLowerCase();return str;};this.asVariable=function(str){str=str.replace(/[^a-zA-Z 0-9]+( )/g,'');str=str.replace(/( )/g,"_");str=str.replace(/-/g,"_");str=str.toLowerCase();return str;};this.trim=function(string){return string.replace(/^\s+|\s+$/g,"");};this.ltrim=function(string){return string.replace(/^\s+/,"");};this.rtrim=function(string){return string.replace(/\s+$/,"");};this.createUUID=function(){var s=[],itoh='0123456789ABCDEF';for(var i=0;i<36;i++)s[i]=Math.floor(Math.random()*0x10);s[14]=4;s[19]=(s[19]&0x3)|0x8;for(var i=0;i<36;i++)s[i]=itoh[s[i]];s[8]=s[13]=s[18]=s[23]='-';return s.join('');};};function _qscript(){this.load=function(scripturl,callback){var script=document.createElement("script");script.type="text/javascript";script.src=scripturl;script.onload=callback;script.onreadystatechange=function(){if(this.readyState=='complete'){callback();};};document.getElementsByTagName('HEAD').item(0).appendChild(script);};this.remove=function(url){var filetype='js';var targetelement=(filetype=="js")?"script":(filetype=="css")?"link":"none";var targetattr=(filetype=="js")?"src":(filetype=="css")?"href":"none";var allsuspects=document.getElementsByTagName(targetelement);for(var i=allsuspects.length;i>=0;i--){if(allsuspects[i]&&allsuspects[i].getAttribute(targetattr)!=null&&allsuspects[i].getAttribute(targetattr).indexOf(filename)!=-1){allsuspects[i].parentNode.removeChild(allsuspects[i]);};};};this.load_jQuery=function(callback){if(!callback)callback=null;this.load('http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js',callback);};this.load_jQueryUI=function(callback){if(!callback)callback=null;this.load('http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js',callback);};this.load_prototype=function(callback){if(!callback)callback=null;this.load('http://ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js',callback);};this.load_mootools=function(callback){if(!callback)callback=null;this.load('http://ajax.googleapis.com/ajax/libs/mootools/1.2.4/mootools-yui-compressed.js',callback);};this.load_scriptaculous=function(callback){if(!callback)callback=null;this.load('http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.3/scriptaculous.js',callback);};};function _qvalidator(){this.email=function(email){return/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email);};this.zipcode=function(postal){return/(^\d{5}$)|(^\d{5}-\d{4}$)/.test(postal);};this.phone=function(phone){phone=phone.replace(/(\-| |\(|\))/gi,"");return/^(1\s*[-\/\.]?)?(\((\d{3})\)|(\d{3}))\s*[-\/\.]?\s*(\d{3})\s*[-\/\.]?\s*(\d{4})\s*(([xX]|[eE][xX][tT])\.?\s*(\d+))*$/.test(phone);};this.human=function(){return confirm("Sorry to bother you, but I need to know if you are a human. Simply click ok to continue");};};function _qnumber(){this.comma=function(nStr){nStr+='';x=nStr.split('.');x1=x[0];x2=x.length>1?'.'+x[1]:'';var rgx=/(\d+)(\d{3})/;while(rgx.test(x1)){x1=x1.replace(rgx,'$1'+','+'$2');}
return x1+x2;};this.dollar=function(num){num=num.toString().replace(/\$|\,/g,'');if(isNaN(num))
num="0";sign=(num==(num=Math.abs(num)));num=Math.floor(num*100+0.50000000001);cents=num%100;num=Math.floor(num/100).toString();if(cents<10)
cents="0"+cents;for(var i=0;i<Math.floor((num.length-(1+i))/3);i++)
num=num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));return(((sign)?'':'-')+'$'+num+'.'+cents);};};function _qstorage(){var cookie=new _qcookie();var text=new _qstring();this.set=function(key,value){value=value.toString();key=text.asVariable(key);var encodedversion=text.encode(value);cookie.set('_qdb_'+key,encodedversion,365);};this.get=function(key){key=text.asVariable(key);return text.decode(cookie.get('_qdb_'+key));};this.remove=function(key){key=text.asVariable(key);cookie.erase('_qdb_'+key);};this.show=function(){var style="<style>._Qdb_dump td { border-bottom:solid 1px #CCCCCC; } ._Qdb_dump th { background-color:#666666; color:#FFFFFF; text-align:left; } </style>";var table='<div id="_Q_db"><table class="datagrid _Qdb_dump" border="0" cellspacing="0" cellpadding="4" style="background-color:#F8F8F8; border:solid 1px #444444; font-family:Helvetica; font-size:11px;" align="" width="300"><tr><th>&nbsp;</th><th>Name</th><th>Value</th></tr>';var cookies=document.cookie.replace(/ /g,"").split(";");for(var i=0;i<cookies.length;i++){cookiePair=cookies[i].split("=");name=cookiePair[0];if(name.match(/_qdb_/)){name=name.replace('_qdb_','');table=table+'<tr style="background-color:#F8F8F8;" id="_qdb_'+i+'"><td><a href="#" onclick="_Q.visitor.storage.remove(\''+name+'\'); element = document.getElementById(\'_qdb_'+i+'\'); element.parentNode.removeChild(element); return false;">X</a></td><td>'+name+'</td><td>'+text.trim(text.decode(cookiePair[1]))+'</td></tr>';};};table=table+'<tr><td colspan="3"><a href="#" onclick="var new_name = prompt(\'Key\'); var new_value=prompt(\'Value\'); _Q.visitor.storage.set(new_name, new_value); var table_container = document.getElementById(\'_Q_db\'); table_container.innerHTML = (_Q.visitor.storage.show()); return false;">+Add</a></td></tr></table></div>';return style+table;}};function _qfunc(){this.inject=function(thefunction,callback){window[thefunction]=window[thefunction].pushObserver(function(){callback();});}}
Function.prototype.pushObserver=function(observer){var options={execute_method:true};if(arguments[1]&&arguments[1].execute_method!=undefined){options.execute_method=arguments[1].execute_method}var __original_method__=this;var observed_function=function(){var observer_return=observer();if(options.execute_method){return __original_method__.apply(this,arguments)}else{return observer_return}};observed_function.__observed=this;return observed_function};Function.prototype.popObserver=function(){return this.__observed||this};Function.prototype.unObserve=function(){var m=this;while(m.__observed){m=m.popObserver()};return m};JSON={encode:function(input){if(!input){return'null'}switch(input.constructor){case String:return'"'+input+'"';break;case Number:return input.toString();break;case Array:var buf=[];for(i in input){buf.push(JSON.encode(input[i]))}return'['+buf.join(', ')+']';break;case Object:var buf=[];for(k in input){buf.push(k+' : '+JSON.encode(input[k]))}return'{ '+buf.join(', ')+'} ';break;default:return'null';break}}};var _qBase64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(input){var output="";var chr1,chr2,chr3,enc1,enc2,enc3,enc4;var i=0;input=_qBase64._utf8_encode(input);while(i<input.length){chr1=input.charCodeAt(i++);chr2=input.charCodeAt(i++);chr3=input.charCodeAt(i++);enc1=chr1>>2;enc2=((chr1&3)<<4)|(chr2>>4);enc3=((chr2&15)<<2)|(chr3>>6);enc4=chr3&63;if(isNaN(chr2)){enc3=enc4=64}else if(isNaN(chr3)){enc4=64}output=output+this._keyStr.charAt(enc1)+this._keyStr.charAt(enc2)+this._keyStr.charAt(enc3)+this._keyStr.charAt(enc4)}return output},decode:function(input){var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(i<input.length){enc1=this._keyStr.indexOf(input.charAt(i++));enc2=this._keyStr.indexOf(input.charAt(i++));enc3=this._keyStr.indexOf(input.charAt(i++));enc4=this._keyStr.indexOf(input.charAt(i++));chr1=(enc1<<2)|(enc2>>4);chr2=((enc2&15)<<4)|(enc3>>2);chr3=((enc3&3)<<6)|enc4;output=output+String.fromCharCode(chr1);if(enc3!=64){output=output+String.fromCharCode(chr2)}if(enc4!=64){output=output+String.fromCharCode(chr3)}}output=_qBase64._utf8_decode(output);return output},_utf8_encode:function(string){string=string.replace(/\r\n/g,"\n");var utftext="";for(var n=0;n<string.length;n++){var c=string.charCodeAt(n);if(c<128){utftext+=String.fromCharCode(c)}else if((c>127)&&(c<2048)){utftext+=String.fromCharCode((c>>6)|192);utftext+=String.fromCharCode((c&63)|128)}else{utftext+=String.fromCharCode((c>>12)|224);utftext+=String.fromCharCode(((c>>6)&63)|128);utftext+=String.fromCharCode((c&63)|128)}}return utftext},_utf8_decode:function(utftext){var string="";var i=0;var c=c1=c2=0;while(i<utftext.length){c=utftext.charCodeAt(i);if(c<128){string+=String.fromCharCode(c);i++}else if((c>191)&&(c<224)){c2=utftext.charCodeAt(i+1);string+=String.fromCharCode(((c&31)<<6)|(c2&63));i+=2}else{c2=utftext.charCodeAt(i+1);c3=utftext.charCodeAt(i+2);string+=String.fromCharCode(((c&15)<<12)|((c2&63)<<6)|(c3&63));i+=3}}return string}};;(function(jQuery){jQuery.fn.extend({elastic:function(){var mimics=['paddingTop','paddingRight','paddingBottom','paddingLeft','fontSize','lineHeight','fontFamily','width','fontWeight'];return this.each(function(){if(this.type!='textarea'){return false}var $textarea=jQuery(this),$twin=jQuery('<div />').css({'position':'absolute','display':'none','word-wrap':'break-word'}),lineHeight=parseInt($textarea.css('line-height'),10)||parseInt($textarea.css('font-size'),'10'),minheight=parseInt($textarea.css('height'),10)||lineHeight*3,maxheight=parseInt($textarea.css('max-height'),10)||Number.MAX_VALUE,goalheight=0,i=0;if(maxheight<0){maxheight=Number.MAX_VALUE}$twin.appendTo($textarea.parent());var i=mimics.length;while(i--){$twin.css(mimics[i].toString(),$textarea.css(mimics[i].toString()))}function setHeightAndOverflow(height,overflow){curratedHeight=Math.floor(parseInt(height,10));if($textarea.height()!=curratedHeight){$textarea.css({'height':curratedHeight+'px','overflow':overflow})}}function update(){var textareaContent=$textarea.val().replace(/&/g,'&amp;').replace(/  /g,'&nbsp;').replace(/<|>/g,'&gt;').replace(/\n/g,'<br />');var twinContent=$twin.html();if(textareaContent+'&nbsp;'!=twinContent){$twin.html(textareaContent+'&nbsp;');if(Math.abs($twin.height()+lineHeight-$textarea.height())>3){var goalheight=$twin.height()+lineHeight;if(goalheight>=maxheight){setHeightAndOverflow(maxheight,'auto')}else if(goalheight<=minheight){setHeightAndOverflow(minheight,'hidden')}else{setHeightAndOverflow(goalheight,'hidden')}}}}$textarea.css({'overflow':'hidden'});$textarea.keyup(function(){update()});$textarea.live('input paste',function(e){setTimeout(update,250)});update()})}})})(jQuery);;(function($){$.fn.jqm=function(o){var p={overlay:50,overlayClass:'jqmOverlay',closeClass:'jqmClose',trigger:'.jqModal',ajax:F,ajaxText:'',target:F,modal:F,toTop:F,onShow:F,onHide:F,onLoad:F};return this.each(function(){if(this._jqm)return H[this._jqm].c=$.extend({},H[this._jqm].c,o);s++;this._jqm=s;H[s]={c:$.extend(p,$.jqm.params,o),a:F,w:$(this).addClass('jqmID'+s),s:s};if(p.trigger)$(this).jqmAddTrigger(p.trigger);});};$.fn.jqmAddClose=function(e){return hs(this,e,'jqmHide');};$.fn.jqmAddTrigger=function(e){return hs(this,e,'jqmShow');};$.fn.jqmShow=function(t){return this.each(function(){t=t||window.event;$.jqm.open(this._jqm,t);});};$.fn.jqmHide=function(t){return this.each(function(){t=t||window.event;$.jqm.close(this._jqm,t)});};$.jqm={hash:{},open:function(s,t){var h=H[s],c=h.c,cc='.'+c.closeClass,z=(parseInt(h.w.css('z-index'))),z=(z>0)?z:3000,o=$('<div></div>').css({height:'100%',width:'100%',position:'fixed',left:0,top:0,'z-index':z-1,opacity:c.overlay/100});if(h.a)return F;h.t=t;h.a=true;h.w.css('z-index',z);if(c.modal){if(!A[0])L('bind');A.push(s);}
else if(c.overlay>0)h.w.jqmAddClose(o);else o=F;h.o=(o)?o.addClass(c.overlayClass).prependTo('body'):F;if(ie6){$('html,body').css({height:'100%',width:'100%'});if(o){o=o.css({position:'absolute'})[0];for(var y in{Top:1,Left:1})o.style.setExpression(y.toLowerCase(),"(_=(document.documentElement.scroll"+y+" || document.body.scroll"+y+"))+'px'");}}
if(c.ajax){var r=c.target||h.w,u=c.ajax,r=(typeof r=='string')?$(r,h.w):$(r),u=(u.substr(0,1)=='@')?$(t).attr(u.substring(1)):u;r.html(c.ajaxText).load(u,function(){if(c.onLoad)c.onLoad.call(this,h);if(cc)h.w.jqmAddClose($(cc,h.w));e(h);});}
else if(cc)h.w.jqmAddClose($(cc,h.w));if(c.toTop&&h.o)h.w.before('<span id="jqmP'+h.w[0]._jqm+'"></span>').insertAfter(h.o);(c.onShow)?c.onShow(h):h.w.show();e(h);return F;},close:function(s){var h=H[s];if(!h.a)return F;h.a=F;if(A[0]){A.pop();if(!A[0])L('unbind');}
if(h.c.toTop&&h.o)$('#jqmP'+h.w[0]._jqm).after(h.w).remove();if(h.c.onHide)h.c.onHide(h);else{h.w.hide();if(h.o)h.o.remove();}return F;},params:{}};var s=0,H=$.jqm.hash,A=[],ie6=$.browser.msie&&($.browser.version=="6.0"),F=false,i=$('<iframe src="javascript:false;document.write(\'\');" class="jqm"></iframe>').css({opacity:0}),e=function(h){if(ie6)if(h.o)h.o.html('<p style="width:100%;height:100%"/>').prepend(i);else if(!$('iframe.jqm',h.w)[0])h.w.prepend(i);f(h);},f=function(h){try{$(':input:visible',h.w)[0].focus();}catch(_){}},L=function(t){$()[t]("keypress",m)[t]("keydown",m)[t]("mousedown",m);},m=function(e){var h=H[A[A.length-1]],r=(!$(e.target).parents('.jqmID'+h.s)[0]);if(r)f(h);return!r;},hs=function(w,t,c){return w.each(function(){var s=this._jqm;$(t).each(function(){if(!this[c]){this[c]=[];$(this).click(function(){for(var i in{jqmShow:1,jqmHide:1})for(var s in this[i])if(H[this[i][s]])H[this[i][s]].w[i](this);return F;});}this[c].push(s);});});};})(jQuery);;var currentlist;$(document).ready(function(){showTab(self.document.location.hash.substring(1));if(self.document.location.hash.substring(1)=="random"){get_idea(function(data){$('#bl-title').val(data).removeClass("empty").addClass("full");$('#bl-list').focus();});}
$('.navigation a.create-list').click(function(){showTab('new');$('#bl-title').focus().val("");return false;});$('.navigation a.popular').click(function(){showTab('popular');return false;});$('.navigation a.recent').click(function(){showTab('newest');return false;});$('.navigation a.list-roulette').click(function(){showTab('new');$('#get-idea').click();$('#bl-list').focus();});if($('#make-cash-toggle').attr('checked')){$('#make-cash').slideDown();}else{$('#make-cash').hide();}
$('#create-list-button').click(function(){$(this).slideUp(function(){$('#enter-list').slideDown();$('#isposting').val(1);});return false;})
$('#aai-results a').click(function(){$('#make-cash').toggle();});$('#autosearch').click(function(){if($(this).attr('checked')){$('#make-cash-selector').show();$('#check-availability').show();}else{$('#make-cash-selector').hide();$('#check-availability').hide();}});$('#get-idea').click(function(){$(this).addClass("generating");get_idea(function(data){$('#get-idea').removeClass("generating");$('#bl-title').val(data).removeClass("empty").addClass("full");});return false;});if($('#autosearch').attr('checked')){$('#make-cash-selector').show();$('#check-availability').show();}else{$('#make-cash-selector').hide();$('#check-availability').hide();}
var aai=_Q.cookie.get("aai");if(aai!=null&&aai!=""){$('#aai-results a').html(aai);$('#make-cash').hide();$('#using-aai').show();$('#make-cash input').val(aai);}else{$('#aai-results a').html("Amazon ID");}
$('#save-aai').click(function(){aai=$('#aai-field').val();_Q.cookie.set("aai",aai,4000);if(aai!=null&&aai!=""){$('#aai-results a').html(aai);$('#make-cash').hide();$('#using-aai').show();}else{$('#aai-results a').html("Amazon ID");$('#make-cash').hide();$('#using-aai').show();}});$('#close-aai').click(function(){$('#make-cash').slideUp();$('#save-aai').show();});$('.tabs a').click(function(){return showTab($(this).attr("href").replace("#",""));});$('#search-form').submit(function(){$('#search .results').addClass("searching").html("Searching");search($('#search-form q').val(),function(data){});return false;});$('#bl-title, textarea#bl-list').keyup(function(){focusCheck($(this));}).focus(function(){focusCheck($(this));}).blur(function(){$(this).removeClass("focused");});$('#bl-title').focus();focusCheck($('#bl-list'));$('#save-list-link').click(function(){if(!$(this).hasClass("saving")){var valid=true;if($('#bl-title').val().length<2){valid=false;$('#bl-title').addClass("error").attr('title','To Short!');}
if($('#bl-list').val().length<2){valid=false;$('#bl-list').addClass("error").attr('title','To Short!');}
if(valid==true){$(this).addClass("saving");$('#saving-status').addClass("saving");saveList(function(data){setTimeout(function(){document.location='/'+data.id+'?first=true';},600);});}}
return false;});$('#check-availability').click(function(){if($(this).hasClass('check-availability')){$('#save-list-link').hide();$('.write').slideUp(function(){$('#check-modal').slideDown();});$(this).removeClass('check-availability').addClass('back-to-list');checkList();}else{$('#check-modal').slideUp(function(){$('.write').slideDown();$('#save-list-link').show();});$(this).removeClass('back-to-list').addClass('check-availability');}});});$('document').ready(function(){$('#bl-list').elastic();$("#bl-list").keypress(function(e){$('input#sharing-url').hide();if(e.keyCode==13){}});url_id=getUrlVar('id');if(url_id!=null){startLoading("Getting List","We're did we put that...");$.get('db.php?a=get&id='+url_id,function(data){endLoading();$('#bl-title').val(data.title[0]);$('#bl-list').val(data.list[0]);});}
$('.view-mode ul, .view-mode h2').hover(function(){},function(){$(this).removeClass('hover');});$('.view-mode ul, .view-mode h1').click(function(){});$('#add-to-cart-link').click(function(){var link='';$('.add-to-cart input:checked').each(function(){link=escape($(this).val())+'|'+link;});var addToCartLink='createcart.php?auth='+authkey+'&items='+(link);$.get(addToCartLink,function(data){if(data.match(/http/)){window.location=(decodeURI(data));}});return false;});});function getUrlVar(name)
{var vars=[],hash;var hashes=window.location.href.slice(window.location.href.indexOf('?')+1).split('&');var answer=null;for(var i=0;i<hashes.length;i++)
{hash=hashes[i].split('=');vars.push(hash[0]);vars[hash[0]]=hash[1];if(hash[0]==name){answer=hash[1];}}
if(answer!=null){return answer;}else{return undefined;}}
function saveList(callback){var callbackfunction=callback;var aai=_Q.cookie.get('aai');var anonid=_Q.visitor.uid();if($('#autosearch').attr("checked")==true){var autosearch="true";}else{var autosearch="false";}
list=($('#bl-list').val().replace(/\&/gi,"[amp]"));ref=$('#ref-input').val();$.post('/services/list/put.php','ref='+ref+'&anonid='+anonid+'&autosearch='+autosearch+'&aai='+aai+'&title='+encodeURI($('#bl-title').val())+'&list='+list,function(data){endLoading();$('#bl-list').val("");$('#bl-title').val("");callbackfunction(data)},'json');}
function checkLoading(){if($('.listy-item.processing').length==0){endLoading();$('.add-to-cart input[type=checkbox]').click(function(){calculateTotal();});$('.listy-item').hover(function(){$(this).addClass("hover");},function(){$(this).removeClass("hover");}).click(function(){if($('input',$(this)).attr("checked")==true){$(this).removeClass("selected");$('input',$(this)).attr("checked",false);}else{$(this).addClass("selected");$('input',$(this)).attr("checked",true);}
calculateTotal();});$('.listy-item').each(function(){if($('input',$(this)).attr("checked")==true){$(this).removeClass("selected");$('input',$(this)).attr("checked",false);}});calculateTotal();}}
function calculateTotal(){var total=0;$('.listy-item input:checked').each(function(){var price=$('.price',$(this).parent().parent()).html();price=Number(price.replace('$',''));total=price+total;});$('#total-price').html("$"+(total));}
function startLoading(status,message){}
function endLoading(){$('#status').fadeOut();}
function getLatest(callback){var callbackfunction=callback;$.get('/plugins/latest/index.php',function(data){callbackfunction(data);});}
function search(q,callback){var callbackfunction=callback;showTabs('search');$.get('/plugins/search/index.php?q='+encodeURI(q)+'&auth='+authkey+'&',function(data){$('#search .results').html(data)
callbackfunction(data);});}
function showTab(id){$.ajaxSetup({cache:false});$('.tab-content').hide();$('.tabs a').addClass("inactive").removeClass("active");$('.'+id+'-tab').addClass("active").removeClass("inactive");if(id=="newest"){document.location='#newest';$('#newest').show();$('#newest .results').html("<div class='loading'>Loading Newest Lists</div>");getLatest(function(data){$('.newest-button').addClass('active');$('.popular-button').removeClass('active');$('#newest .results').html(data);});}else if(id=="popular"){$('.popular-tab').addClass("active").removeClass("inactive");document.location='#popular';$('#popular').show();$('#popular .results').html("<div class='loading'>Loading Popular Lists</div>");$.get('/plugins/popular/',function(data){$('#popular .results').html(data);$('#popular .results').removeClass('loading');});}else if(id=="new"){document.location='#new';$('#new').show();}else if(id=="my"){document.location='#my';$('#my').show();$.get('/plugins/my/',function(data){$('#my .results').html(data);$('#my .results').removeClass('loading');});}else if(id=="search"){document.location='#search';$('#search').show();}else{$('.new-tab').addClass("active").removeClass("inactive");$('#new').show();}
return false;}
function focusCheck(obj){$(obj).removeClass("error");if($(obj).val().length==0){$(obj).addClass("focused empty ").removeClass("full");}else{$(obj).addClass("focused full").removeClass("empty");}}
function get_idea(callback){var callback=callback;$.ajaxSetup({cache:false});$.getJSON('/services/list/idea.php',function(data){callback(data);$.ajaxSetup({cache:true});});}
function checkList(){listItems=$('#bl-list').val().split(new RegExp("\\n","g"));$('#check-modal ul').html("");for(i=0;i<listItems.length;i++){if(listItems[i].length>0){$('#check-modal ul').append('<li class="listy-item item-'+i+' processing"><h3></h3></li>');}}
processList(function(data){if(data.price==null){$('#check-modal ul li.item-'+data.index+' h3').addClass("no-offer").html('<span class="price no-offers">No offers available</span>'+' '+data.title).parent().removeClass("processing");}else{$('#check-modal ul li.item-'+data.index+' h3').html('<span class="price">'+data.price+'</span>'+' '+data.title).parent().removeClass("processing");}});};$(document).ready(function(){if(_Q.cookie.get('anonid')==null){_Q.cookie.set('anonid',_Q.visitor.uid(),100000);}});function var_safe(str){str=str.replace(' ','_');str=str.replace(/[^a-zA-Z 0-9\_]+/g,'');return str;}
function processList(callback){if($('body').hasClass("view")){pagetype="view";}else{pagetype="create";}
var callbackfunction=callback;if(pagetype=="create"){listItems=$('#bl-list').val().split(new RegExp("\\n","g"));}else{listItems=[];$('.list-container li h3').each(function(){listItems[listItems.length]=$(this).html();});}
for(i=0;i<listItems.length;i++){if(typeof(useaai)!="undefined"){aai=useaai;}else{aai='printfu-20';}
if(listItems[i].length>0){$.getJSON('/services/cart/lookup.php?q='+encodeURI(listItems[i])+'&aai='+aai+'&auth='+authkey+'&i='+i,function(data){var index=0;title=data[0].title[0];price=data[0].price[0];detailURL=data[0].url[0];artwork=data[0].artwork[0];index=Number(data[0].i);offerid=data[0].offerid;var datapacket={index:index,title:title,price:price,url:detailURL,artwork:artwork,offerid:offerid};callbackfunction(datapacket);});}}}
function randrange(minVal,maxVal,floatVal)
{var randVal=minVal+(Math.random()*(maxVal-minVal));return typeof floatVal=='undefined'?Math.round(randVal):randVal.toFixed(floatVal);}
