
(function(a){var r=a.fn.domManip,d="_tmplitem",q=/^[^<]*(<[\w\W]+>)[^>]*$|\{\{\! /,b={},f={},e,p={key:0,data:{}},h=0,c=0,l=[];function g(e,d,g,i){var c={data:i||(d?d.data:{}),_wrap:d?d._wrap:null,tmpl:null,parent:d||null,nodes:[],calls:u,nest:w,wrap:x,html:v,update:t};e&&a.extend(c,e,{nodes:[],parent:d});if(g){c.tmpl=g;c._ctnt=c._ctnt||c.tmpl(a,c);c.key=++h;(l.length?f:b)[h]=c}return c}a.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(f,d){a.fn[f]=function(n){var g=[],i=a(n),k,h,m,l,j=this.length===1&&this[0].parentNode;e=b||{};if(j&&j.nodeType===11&&j.childNodes.length===1&&i.length===1){i[d](this[0]);g=this}else{for(h=0,m=i.length;h<m;h++){c=h;k=(h>0?this.clone(true):this).get();a.fn[d].apply(a(i[h]),k);g=g.concat(k)}c=0;g=this.pushStack(g,f,i.selector)}l=e;e=null;a.tmpl.complete(l);return g}});a.fn.extend({tmpl:function(d,c,b){return a.tmpl(this[0],d,c,b)},tmplItem:function(){return a.tmplItem(this[0])},template:function(b){return a.template(b,this[0])},domManip:function(d,l,j){if(d[0]&&d[0].nodeType){var f=a.makeArray(arguments),g=d.length,i=0,h;while(i<g&&!(h=a.data(d[i++],"tmplItem")));if(g>1)f[0]=[a.makeArray(d)];if(h&&c)f[2]=function(b){a.tmpl.afterManip(this,b,j)};r.apply(this,f)}else r.apply(this,arguments);c=0;!e&&a.tmpl.complete(b);return this}});a.extend({tmpl:function(d,h,e,c){var j,k=!c;if(k){c=p;d=a.template[d]||a.template(null,d);f={}}else if(!d){d=c.tmpl;b[c.key]=c;c.nodes=[];c.wrapped&&n(c,c.wrapped);return a(i(c,null,c.tmpl(a,c)))}if(!d)return[];if(typeof h==="function")h=h.call(c||{});e&&e.wrapped&&n(e,e.wrapped);j=a.isArray(h)?a.map(h,function(a){return a?g(e,c,d,a):null}):[g(e,c,d,h)];return k?a(i(c,null,j)):j},tmplItem:function(b){var c;if(b instanceof a)b=b[0];while(b&&b.nodeType===1&&!(c=a.data(b,"tmplItem"))&&(b=b.parentNode));return c||p},template:function(c,b){if(b){if(typeof b==="string")b=o(b);else if(b instanceof a)b=b[0]||{};if(b.nodeType)b=a.data(b,"tmpl")||a.data(b,"tmpl",o(b.innerHTML));return typeof c==="string"?(a.template[c]=b):b}return c?typeof c!=="string"?a.template(null,c):a.template[c]||a.template(null,q.test(c)?c:a(c)):null},encode:function(a){return(""+a).split("<").join("&lt;").split(">").join("&gt;").split('"').join("&#34;").split("'").join("&#39;")}});a.extend(a.tmpl,{tag:{tmpl:{_default:{$2:"null"},open:"if($notnull_1){_=_.concat($item.nest($1,$2));}"},wrap:{_default:{$2:"null"},open:"$item.calls(_,$1,$2);_=[];",close:"call=$item.calls();_=call._.concat($item.wrap(call,_));"},each:{_default:{$2:"$index, $value"},open:"if($notnull_1){$.each($1a,function($2){with(this){",close:"}});}"},"if":{open:"if(($notnull_1) && $1a){",close:"}"},"else":{_default:{$1:"true"},open:"}else if(($notnull_1) && $1a){"},html:{open:"if($notnull_1){_.push($1a);}"},"=":{_default:{$1:"$data"},open:"if($notnull_1){_.push($.encode($1a));}"},"!":{open:""}},complete:function(){b={}},afterManip:function(f,b,d){var e=b.nodeType===11?a.makeArray(b.childNodes):b.nodeType===1?[b]:[];d.call(f,b);m(e);c++}});function i(e,g,f){var b,c=f?a.map(f,function(a){return typeof a==="string"?e.key?a.replace(/(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g,"$1 "+d+'="'+e.key+'" $2'):a:i(a,e,a._ctnt)}):e;if(g)return c;c=c.join("");c.replace(/^\s*([^<\s][^<]*)?(<[\w\W]+>)([^>]*[^>\s])?\s*$/,function(f,c,e,d){b=a(e).get();m(b);if(c)b=j(c).concat(b);if(d)b=b.concat(j(d))});return b?b:j(c)}function j(c){var b=document.createElement("div");b.innerHTML=c;return a.makeArray(b.childNodes)}function o(b){return new Function("jQuery","$item","var $=jQuery,call,_=[],$data=$item.data;with($data){_.push('"+a.trim(b).replace(/([\\'])/g,"\\$1").replace(/[\r\t\n]/g," ").replace(/\$\{([^\}]*)\}/g,"{{= $1}}").replace(/\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g,function(m,l,j,d,b,c,e){var i=a.tmpl.tag[j],h,f,g;if(!i)throw"Template command not found: "+j;h=i._default||[];if(c&&!/\w$/.test(b)){b+=c;c=""}if(b){b=k(b);e=e?","+k(e)+")":c?")":"";f=c?b.indexOf(".")>-1?b+c:"("+b+").call($item"+e:b;g=c?f:"(typeof("+b+")==='function'?("+b+").call($item):("+b+"))"}else g=f=h.$1||"null";d=k(d);return"');"+i[l?"close":"open"].split("$notnull_1").join(b?"typeof("+b+")!=='undefined' && ("+b+")!=null":"true").split("$1a").join(g).split("$1").join(f).split("$2").join(d?d.replace(/\s*([^\(]+)\s*(\((.*?)\))?/g,function(d,c,b,a){a=a?","+a+")":b?")":"";return a?"("+c+").call($item"+a:d}):h.$2||"")+"_.push('"})+"');}return _;")}function n(c,b){c._wrap=i(c,true,a.isArray(b)?b:[q.test(b)?b:a(b).html()]).join("")}function k(a){return a?a.replace(/\\'/g,"'").replace(/\\\\/g,"\\"):null}function s(b){var a=document.createElement("div");a.appendChild(b.cloneNode(true));return a.innerHTML}function m(o){var n="_"+c,k,j,l={},e,p,i;for(e=0,p=o.length;e<p;e++){if((k=o[e]).nodeType!==1)continue;j=k.getElementsByTagName("*");for(i=j.length-1;i>=0;i--)m(j[i]);m(k)}function m(j){var p,i=j,k,e,m;if(m=j.getAttribute(d)){while(i.parentNode&&(i=i.parentNode).nodeType===1&&!(p=i.getAttribute(d)));if(p!==m){i=i.parentNode?i.nodeType===11?0:i.getAttribute(d)||0:0;if(!(e=b[m])){e=f[m];e=g(e,b[i]||f[i],null,true);e.key=++h;b[h]=e}c&&o(m)}j.removeAttribute(d)}else if(c&&(e=a.data(j,"tmplItem"))){o(e.key);b[e.key]=e;i=a.data(j.parentNode,"tmplItem");i=i?i.key:0}if(e){k=e;while(k&&k.key!=i){k.nodes.push(j);k=k.parent}delete e._ctnt;delete e._wrap;a.data(j,"tmplItem",e)}function o(a){a=a+n;e=l[a]=l[a]||g(e,b[e.parent.key+n]||e.parent,null,true)}}}function u(a,d,c,b){if(!a)return l.pop();l.push({_:a,tmpl:d,item:this,data:c,options:b})}function w(d,c,b){return a.tmpl(a.template(d),c,b,this)}function x(b,d){var c=b.options||{};c.wrapped=d;return a.tmpl(a.template(b.tmpl),b.data,c,b.item)}function v(d,c){var b=this._wrap;return a.map(a(a.isArray(b)?b.join(""):b).filter(d||"*"),function(a){return c?a.innerText||a.textContent:a.outerHTML||s(a)})}function t(){var b=this.nodes;a.tmpl(null,null,null,this).insertBefore(b[0]);a(b).remove()}})(jQuery)
$.fn.infiniteScroller=function(direction){function repeat(str,num){var Arr=[num+1].join(str);return Arr;}
return this.each(function(){var $wrapper=$('> div',this).css('overflow','hidden'),$slider=$wrapper.find('> ul'),$items=$slider.find('> li'),$single=$items.filter(':first');if(direction==="horz"){var singleWidth=$single.outerWidth(),visible=Math.ceil($wrapper.innerWidth()/singleWidth);}else{var singleHeight=$single.outerHeight(),visible=Math.ceil($wrapper.innerHeight()/singleHeight);}
var currentPage=1,pages=Math.ceil($items.length/visible);if(($items.length%visible)!==0){$slider.append(repeat('<li class="empty" />',visible-($items.length%visible)));$items=$slider.find('> li');}
$items.filter(':first').before($items.slice(-visible).clone().addClass('cloned'));$items.filter(':last').after($items.slice(0,visible).clone().addClass('cloned'));$items=$slider.find('> li');if(direction==="horz"){$wrapper.scrollLeft(singleWidth*visible);}else{$wrapper.scrollTop(singleHeight*visible);}
function gotoPage(page,direction){var dir=page<currentPage?-1:1,n=Math.abs(currentPage-page),left=singleWidth*dir*visible*n,top=singleHeight*dir*visible*n;if(direction==="horz"){$wrapper.filter(':not(:animated)').animate({scrollLeft:'+='+left},500,function(){if(page===0){$wrapper.scrollLeft(singleWidth*visible*pages);page=pages;}else if(page>pages){$wrapper.scrollLeft(singleWidth*visible);page=1;}
currentPage=page;});}else{$wrapper.filter(':not(:animated)').animate({scrollTop:'+='+top},500,function(){if(page===0){$wrapper.scrollTop(singleHeight*visible*pages);page=pages;}else if(page>pages){$wrapper.scrollTop(singleWidth*visible);page=1;}
currentPage=page;});}
return false;}
if(direction==="horz"){$wrapper.after('<a class="arrow back">&lt;</a><a class="arrow forward">&gt;</a>');$('a.back',this).click(function(){return gotoPage(currentPage-1,direction);});$('a.forward',this).click(function(){return gotoPage(currentPage+1,direction);});$(this).bind('goto',function(event,page){gotoPage(page,direction);});}
$(this).bind('next',function(){gotoPage(currentPage+1,direction);});});};
(function($)
{$.fn.extend({tagdragon:function(options)
{return this.each(function()
{$.tagdragonz(this,options);});},tagdragon_configure:function(options)
{return this.trigger("tagdragon_configure",[options]);},tagdragon_load:function()
{return this.trigger("tagdragon_load");},tagdragon_clear:function()
{return this.trigger("tagdragon_clear");}});$.tagdragonz=function(input,options)
{var tagbox=input;var defaults={field:'tags',url:'jsontags.php',tagsep:',',enclose:'',max:10,cache:true,delay:500,charMin:1,dblClick:true,postData:null,visible:true,dataType:'json',onRenderItem:function(row)
{return row.tag;},onSelectItem:function(val){return true;},onSelectedItem:function(val){return true;},onLoadList:function(filter){return true;},onLoadedList:function(results){return true;}};options=$.extend(defaults,options);input=$(tagbox).find('#'+options.field);$(input).attr("autocomplete","off");var lkup=document.createElement('div');$(lkup).attr({'id':'tagbox-lkup'});$(lkup,tagbox).hide();input.after(lkup);var lkuplst=document.createElement('ol');$(lkup,tagbox).append(lkuplst);var cursor=-1;var length=0;var loading=false;var loaded=false;var cacheLst={lastSearch:"",data:[]};var inserted=false;var preg_escape=function(str)
{return(str+'').replace(/([\/\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!<>\|\:])/g,"\\$1");};var hideLkup=function()
{$(lkuplst,tagbox).empty();$(lkup,tagbox).hide();loaded=false;inserted=false;};var insertTag=function(filter,tag)
{var cur=input.val();var words=tag.split(' ').length;var enclose=(words>1)?options.enclose.length>0?options.enclose:'':'';cur=cur.replace(eval('/'+preg_escape(filter)+'$/i'),enclose+tag+enclose);input.val(cur);cursor=-1;};var parseFilter=function(val)
{if(options.tagsep.length===0)
{return val;}
if(val.indexOf(options.tagsep)>-1)
{if(options.tagsep==' '){val=val.substring(val.lastIndexOf(options.tagsep)+1,val.length);}
else{val=$.trim(val.substring(val.lastIndexOf(options.tagsep)+1,val.length));}}
return val;};var addItem=function(val,filter,index)
{if(!options.visible){return;}
var row=val;val=options.onRenderItem(val,index,length,filter);var li=document.createElement('li');lkuplst.appendChild(li);var aLink=document.createElement('a');$(aLink).attr({'href':'#'});$(aLink,tagbox).text(val);$(aLink,tagbox).addClass(index%2===0?'td-odd':'td-even');$(aLink,tagbox).html($(aLink,tagbox).text().replace(eval('/('+preg_escape(filter)+')/gi'),"<em>$1</em>"));li.appendChild(aLink);$(aLink).click(function(e)
{options.onSelectItem(row);insertTag(filter,val);options.onSelectedItem(row);e.preventDefault();cacheLst={lastSearch:parseFilter(input.val())};hideLkup();input.focus();});};var loadShowList=function(filter,data)
{$(lkuplst,tagbox).empty();length=data.length;cacheLst={lastSearch:filter,data:data};cursor=-1;for(var i=0;i<data.length&&i<options.max;i++)
{addItem(data[i],filter,i);}
if(options.visible){$(lkup,tagbox).show();}
loading=false;loaded=true;options.onLoadedList(data);};var loadList=function()
{inserted=false;var filter=parseFilter(input.val());if(cacheLst.lastSearch==filter)
{loadShowList(filter,cacheLst.data);return;}
options.onLoadList(filter);$(lkuplst,tagbox).empty();$(".loader",tagbox).show();$.ajax({type:"POST",url:options.url,data:$.extend({tag:filter,max:options.max},options.postData),dataType:options.dataType,cache:options.cache,success:function(json)
{$(".loader",tagbox).hide();if(filter!=parseFilter(input.val())){loadList();}
else{loadShowList(filter,json);}},error:function(XMLHttpRequest,textStatus,errorThrown)
{length=0;cacheLst={lastSearch:"",data:[]};loading=false;loaded=false;options.onLoadedList(false);}});};var triggerLoad=function()
{if(inserted){return false;}
else
{var filter=parseFilter(input.val());if(filter.length>=options.charMin)
{loading=true;setTimeout(function(){loadList();},options.delay);}
else{hideLkup();}}};$(input).focus(function(e)
{if(cacheLst.lastSearch!=parseFilter(input.val())){triggerLoad();}});$(input).blur(function(e)
{setTimeout(function(e){hideLkup();},250);});input.dblclick(function(e)
{if(options.dblClick&&!loading)
{triggerLoad();}});$(lkuplst,tagbox).blur(function(e)
{hideLkup();});var handleSpecials=function(e)
{e=e||window.event;var key=e.charCode||e.keyCode;if(!loaded){return true;}
switch(key)
{case 9:cursor=((cursor+1)<length)?cursor+1:cursor;if(cursor<length)
{$('li:eq('+cursor+')',tagbox).addClass('hl');if((cursor-1)>-1){$('li:eq('+(cursor-1)+')',tagbox).removeClass('hl');}
e.preventDefault();}
break;case 40:cursor=((cursor+1)<length)?cursor+1:cursor;if(cursor<length)
{$('li:eq('+cursor+')',tagbox).addClass('hl');if((cursor-1)>-1){$('li:eq('+(cursor-1)+')',tagbox).removeClass('hl');}
e.preventDefault();}
break;case 38:cursor=(cursor-1>=0)?cursor-1:cursor;if(cursor>=0)
{$('li:eq('+cursor+')',tagbox).addClass('hl');$('li:eq('+(cursor+1)+')',tagbox).removeClass('hl');e.preventDefault();}
break;case 13:if(cursor>=0&&cursor<length)
{var row=cacheLst.data[cursor];options.onSelectItem(row);insertTag(parseFilter(input.val()),$('li:eq('+(cursor)+')',tagbox).text());options.onSelectedItem(row);e.preventDefault();cacheLst={lastSearch:parseFilter(input.val())};hideLkup();}
break;case 27:hideLkup();e.preventDefault();break;}};var handleKey=function(e)
{e=e||window.event;var key=e.charCode||e.keyCode;if(key==13){return true;}
if(key>8&&key<46&&key!=32){return false;}
if(loading===false){triggerLoad();}
if(options.visible){$(lkup,tagbox).show();}};$(input).keyup(handleKey);$(input).keydown(handleSpecials);$(tagbox).bind("tagdragon_configure",function(){$.extend(options,arguments[1]);});$(tagbox).bind("tagdragon_load",function(){triggerLoad();});$(tagbox).bind("tagdragon_clear",function(){hideLkup();});};})(jQuery);
jQuery.fn.extend({everyTime:function(interval,label,fn,times){return this.each(function(){jQuery.timer.add(this,interval,label,fn,times);});},oneTime:function(interval,label,fn){return this.each(function(){jQuery.timer.add(this,interval,label,fn,1);});},stopTime:function(label,fn){return this.each(function(){jQuery.timer.remove(this,label,fn);});}});jQuery.extend({timer:{global:[],guid:1,dataKey:"jQuery.timer",regex:/^([0-9]+(?:\.[0-9]*)?)\s*(.*s)?$/,powers:{'ms':1,'cs':10,'ds':100,'s':1000,'das':10000,'hs':100000,'ks':1000000},timeParse:function(value){if(value==undefined||value==null)
return null;var result=this.regex.exec(jQuery.trim(value.toString()));if(result[2]){var num=parseFloat(result[1]);var mult=this.powers[result[2]]||1;return num*mult;}else{return value;}},add:function(element,interval,label,fn,times){var counter=0;if(jQuery.isFunction(label)){if(!times)
times=fn;fn=label;label=interval;}
interval=jQuery.timer.timeParse(interval);if(typeof interval!='number'||isNaN(interval)||interval<0)
return;if(typeof times!='number'||isNaN(times)||times<0)
times=0;times=times||0;var timers=jQuery.data(element,this.dataKey)||jQuery.data(element,this.dataKey,{});if(!timers[label])
timers[label]={};fn.timerID=fn.timerID||this.guid++;var handler=function(){if((++counter>times&&times!==0)||fn.call(element,counter)===false)
jQuery.timer.remove(element,label,fn);};handler.timerID=fn.timerID;if(!timers[label][fn.timerID])
timers[label][fn.timerID]=window.setInterval(handler,interval);this.global.push(element);},remove:function(element,label,fn){var timers=jQuery.data(element,this.dataKey),ret;if(timers){if(!label){for(label in timers)
this.remove(element,label,fn);}else if(timers[label]){if(fn){if(fn.timerID){window.clearInterval(timers[label][fn.timerID]);delete timers[label][fn.timerID];}}else{for(var fn in timers[label]){window.clearInterval(timers[label][fn]);delete timers[label][fn];}}
for(ret in timers[label])break;if(!ret){ret=null;delete timers[label];}}
for(ret in timers)break;if(!ret)
jQuery.removeData(element,this.dataKey);}}}});jQuery(window).bind("unload",function(){jQuery.each(jQuery.timer.global,function(index,item){jQuery.timer.remove(item);});});;if(window.jQuery)(function($){if($.browser.msie)try{document.execCommand("BackgroundImageCache",false,true)}catch(e){};$.fn.rating=function(options){if(this.length==0)return this;if(typeof arguments[0]=='string'){if(this.length>1){var args=arguments;return this.each(function(){$.fn.rating.apply($(this),args);});};$.fn.rating[arguments[0]].apply(this,$.makeArray(arguments).slice(1)||[]);return this;};var options=$.extend({},$.fn.rating.options,options||{});$.fn.rating.calls++;this.not('.star-rating-applied').addClass('star-rating-applied').each(function(){var control,input=$(this);var eid=(this.name||'unnamed-rating').replace(/\[|\]/g,'_').replace(/^\_+|\_+$/g,'');var context=$(this.form||document.body);var raters=context.data('rating');if(!raters||raters.call!=$.fn.rating.calls)raters={count:0,call:$.fn.rating.calls};var rater=raters[eid];if(rater)control=rater.data('rating');if(rater&&control)
control.count++;else{control=$.extend({},options||{},($.metadata?input.metadata():($.meta?input.data():null))||{},{count:0,stars:[],inputs:[]});control.serial=raters.count++;rater=$('<span class="star-rating-control"/>');input.before(rater);rater.addClass('rating-to-be-drawn');if(input.attr('disabled'))control.readOnly=true;rater.append(control.cancel=$('<div class="rating-cancel"><a title="'+control.cancel+'">'+control.cancelValue+'</a></div>').mouseover(function(){$(this).rating('drain');$(this).addClass('star-rating-hover');}).mouseout(function(){$(this).rating('draw');$(this).removeClass('star-rating-hover');}).click(function(){$(this).rating('select');}).data('rating',control));};var star=$('<div class="star-rating rater-'+control.serial+'"><a title="'+(this.title||this.value)+'">'+this.value+'</a></div>');rater.append(star);if(this.id)star.attr('id',this.id);if(this.className)star.addClass(this.className);if(control.half)control.split=2;if(typeof control.split=='number'&&control.split>0){var stw=($.fn.width?star.width():0)||control.starWidth;var spi=(control.count%control.split),spw=Math.floor(stw/control.split);star.width(spw).find('a').css({'margin-left':'-'+(spi*spw)+'px'})};if(control.readOnly)
star.addClass('star-rating-readonly');else
star.addClass('star-rating-live').mouseover(function(){$(this).rating('fill');$(this).rating('focus');}).mouseout(function(){$(this).rating('draw');$(this).rating('blur');}).click(function(){$(this).rating('select');});if(this.checked)control.current=star;input.hide();input.change(function(){$(this).rating('select');});star.data('rating.input',input.data('rating.star',star));control.stars[control.stars.length]=star[0];control.inputs[control.inputs.length]=input[0];control.rater=raters[eid]=rater;control.context=context;input.data('rating',control);rater.data('rating',control);star.data('rating',control);context.data('rating',raters);});$('.rating-to-be-drawn').rating('draw').removeClass('rating-to-be-drawn');return this;};$.extend($.fn.rating,{calls:0,focus:function(){var control=this.data('rating');if(!control)return this;if(!control.focus)return this;var input=$(this).data('rating.input')||$(this.tagName=='INPUT'?this:null);if(control.focus)control.focus.apply(input[0],[input.val(),$('a',input.data('rating.star'))[0]]);},blur:function(){var control=this.data('rating');if(!control)return this;if(!control.blur)return this;var input=$(this).data('rating.input')||$(this.tagName=='INPUT'?this:null);if(control.blur)control.blur.apply(input[0],[input.val(),$('a',input.data('rating.star'))[0]]);},fill:function(){var control=this.data('rating');if(!control)return this;if(control.readOnly)return;this.rating('drain');this.prevAll().andSelf().filter('.rater-'+control.serial).addClass('star-rating-hover');},drain:function(){var control=this.data('rating');if(!control)return this;if(control.readOnly)return;control.rater.children().filter('.rater-'+control.serial).removeClass('star-rating-on').removeClass('star-rating-hover');},draw:function(){var control=this.data('rating');if(!control)return this;this.rating('drain');if(control.current){control.current.data('rating.input').attr('checked','checked');control.current.prevAll().andSelf().filter('.rater-'+control.serial).addClass('star-rating-on');}
else
$(control.inputs).removeAttr('checked');control.cancel[control.readOnly||control.required?'hide':'show']();this.siblings()[control.readOnly?'addClass':'removeClass']('star-rating-readonly');},select:function(value,wantCallBack){var control=this.data('rating');if(!control)return this;if(control.readOnly)return;control.current=null;if(typeof value!='undefined'){if(typeof value=='number')
return $(control.stars[value]).rating('select',undefined,wantCallBack);if(typeof value=='string')
$.each(control.stars,function(){if($(this).data('rating.input').val()==value)$(this).rating('select',undefined,wantCallBack);});}
else
control.current=this[0].tagName=='INPUT'?this.data('rating.star'):(this.is('.rater-'+control.serial)?this:null);this.data('rating',control);this.rating('draw');var input=$(control.current?control.current.data('rating.input'):null);if((wantCallBack||wantCallBack==undefined)&&control.callback)control.callback.apply(input[0],[input.val(),$('a',control.current)[0]]);},readOnly:function(toggle,disable){var control=this.data('rating');if(!control)return this;control.readOnly=toggle||toggle==undefined?true:false;if(disable)$(control.inputs).attr("disabled","disabled");else $(control.inputs).removeAttr("disabled");this.data('rating',control);this.rating('draw');},disable:function(){this.rating('readOnly',true,true);},enable:function(){this.rating('readOnly',false,false);}});$.fn.rating.options={split:0,starWidth:16};$(function(){$('input[type=radio].star').rating();});})(jQuery);
(function($){$.fn.expander=function(options){var opts=$.extend({},$.fn.expander.defaults,options);var delayedCollapse;return this.each(function(){var $this=$(this);var o=$.meta?$.extend({},opts,$this.data()):opts;var cleanedTag,startTags,endTags;var allText=$this.html();var startText=allText.slice(0,o.slicePoint).replace(/\w+$/,'');startTags=startText.match(/<\w[^>]*>/g);if(startTags){startText=allText.slice(0,o.slicePoint+startTags.join('').length).replace(/\w+$/,'');}
if(startText.lastIndexOf('<')>startText.lastIndexOf('>')){startText=startText.slice(0,startText.lastIndexOf('<'));}
var endText=allText.slice(startText.length);if(!$('span.details',this).length){if(endText.replace(/\s+$/,'').split(' ').length<o.widow){return;}
if(endText.indexOf('</')>-1){endTags=endText.match(/<(\/)?[^>]*>/g);for(var i=0;i<endTags.length;i++){if(endTags[i].indexOf('</')>-1){var startTag,startTagExists=false;for(var j=0;j<i;j++){startTag=endTags[j].slice(0,endTags[j].indexOf(' ')).replace(/(\w)$/,'$1>');if(startTag==rSlash(endTags[i])){startTagExists=true;}}
if(!startTagExists){startText=startText+endTags[i];var matched=false;for(var s=startTags.length-1;s>=0;s--){if(startTags[s].slice(0,startTags[s].indexOf(' ')).replace(/(\w)$/,'$1>')==rSlash(endTags[i])&&matched==false){cleanedTag=cleanedTag?startTags[s]+cleanedTag:startTags[s];matched=true;}};}}}
endText=cleanedTag&&cleanedTag+endText||endText;}
$this.html([startText,'<span class="read-more">',o.expandPrefix,'<a href="#">',o.expandText,'</a>','</span>','<span class="details">',endText,'</span>'].join(''));}
var $thisDetails=$('span.details',this),$readMore=$('span.read-more',this);$thisDetails.hide();$readMore.find('a').click(function(){$readMore.hide();if(o.expandEffect==='show'&&!o.expandSpeed){o.beforeExpand($this);$thisDetails.show();o.afterExpand($this);delayCollapse(o,$thisDetails);}else{o.beforeExpand($this);$thisDetails[o.expandEffect](o.expandSpeed,function(){$thisDetails.css({zoom:''});o.afterExpand($this);delayCollapse(o,$thisDetails);});}
return false;});if(o.userCollapse){$this.find('span.details').append('<span class="re-collapse">'+o.userCollapsePrefix+'<a href="#">'+o.userCollapseText+'</a></span>');$this.find('span.re-collapse a').click(function(){clearTimeout(delayedCollapse);var $detailsCollapsed=$(this).parents('span.details');reCollapse($detailsCollapsed);o.onCollapse($this,true);return false;});}});function reCollapse(el){el.hide().prev('span.read-more').show();}
function delayCollapse(option,$collapseEl){if(option.collapseTimer){delayedCollapse=setTimeout(function(){reCollapse($collapseEl);option.onCollapse($collapseEl.parent(),false);},option.collapseTimer);}}
function rSlash(rString){return rString.replace(/\//,'');}};$.fn.expander.defaults={slicePoint:100,widow:4,expandText:'read more',expandPrefix:'&hellip; ',collapseTimer:0,expandEffect:'fadeIn',expandSpeed:'',userCollapse:true,userCollapseText:'[collapse expanded text]',userCollapsePrefix:' ',beforeExpand:function($thisEl){},afterExpand:function($thisEl){},onCollapse:function($thisEl,byUser){}};})(jQuery);
(function($){var Smakprov={Constants:{JSON:{baseUrl:"/json",feedNew:"newsmakprov",feedPopular:"popularsmakprov",feedPopularDay:"popularsmakprovday",feedPopularWeek:"popularsmakprovweek",feedPopularMonth:"popularsmakprovmonth",feedPopularYear:"popularsmakprovyear"}},General:{getPageId:function(){var bodyId=$("body").attr("id");return bodyId;},getBrowserVersion:function(){var browserVer=$("body").attr("class");return browserVer;q},loadRating:function(){},loadExpanders:function(){$('p.read-more').expander({slicePoint:200,expandText:'(läs hela)',collapseTimer:0,userCollapseText:'[^]'});},loadExternalLinks:function(){$('a.external').click(function(){window.open(this.href);return false;});}},ShelfHandler:{init:function(){var self=this;switch(Smakprov.General.getPageId()){case"start":self.menuHandler.call(self,"popularasmakprov");var first=$("nav.menu ul li:first-child a");first.click();break;}},autoLoad:function(){var self=this,autoload=true,startCounter=15;$(".shelf-box").mouseover(function(){autoload=false;}).mouseout(function(){autoload=true;});setInterval(function(){if(autoload){self.fillShelf.call(self,Smakprov.Constants.JSON.feedPopular,startCounter,startCounter+14);}},8000);},menuHandler:function(){var self=this,menu=$(".shelf-top nav.menu").fadeIn(500);$("li a",menu).click(function(event){event.preventDefault();$($(event.target).parent("li").addClass("selected").siblings("li").removeClass("selected"));var stream=$(event.target).attr("title");self.reload.call(self,stream,1,15);});},reload:function(stream,start,end){var self=this,$content=$(".shelf-content"),$books=$content.find("table");$books.fadeOut(100);setTimeout(function(){$content.empty();self.fillShelf.call(self,stream,start,end);},100);},fillShelf:function(stream,start,end){var self=this,stream=stream||Smakprov.Constants.JSON.feedPopular,start=start||1,end=end||14;$.getJSON(Smakprov.Constants.JSON.baseUrl+"/"+stream+'/'+start+'/'+end+'/medium',function(data){$.each(data.books,function(index,value){var title=data.books[index].title,imgsrc=data.books[index].image,isbn=data.books[index].isbn,href="/bok/"+isbn;self.addBookToShelf.call(self,title,imgsrc,isbn,href,index);});});},addBookToShelf:function(title,imgsrc,isbn,href,delay){var elemStart='<table class="wrapper '+isbn+'"><tr><td><div class="shadow"><div class="cropper">',elemEnd='</div></div></td></tr></table>',elemItem='<a href="'+href+'" title="'+title+'"><img src="'+imgsrc+'"  alt="'+title+'" />',elemHighlight='<img src="/assets/images/book-cover-highlite.png" class="highlite" alt="" /></a>';$(".shelf-content").append(elemStart+elemItem+elemHighlight+elemEnd);if(Smakprov.General.getBrowserVersion()!=="ie7"){setTimeout(function(){$("table."+isbn).animate({opacity:"1.0"},100);},50*delay);}}},ScrollerHandler:{init:function(){switch(Smakprov.General.getPageId()){case"start":break;case"book":this.startScroller(Smakprov.Constants.JSON.baseUrl+'/'+Smakprov.Constants.JSON.feedPopular+'/1/15/medium',$(".popular-books"),"vert");break;default:}},startScroller:function(requestUrl,targetEl,direction){var callBack=function(items){var scrollerWrapper=$("> div.wrapper",targetEl).append("<ul></ul>"),scrollerTarget=$("ul",scrollerWrapper),autoscrolling=true;$('#scroller').tmpl(items).appendTo(scrollerTarget);targetEl.infiniteScroller(direction).mouseover(function(){autoscrolling=false;}).mouseout(function(){autoscrolling=true;});setInterval(function(){if(autoscrolling){targetEl.trigger('next');}},8000);};this.getJSON(requestUrl,callBack,direction);},getJSON:function(requestUrl,onCompleteFunc,direction){$.getJSON(requestUrl,function(data){var items=[];if(direction==="horz"){$.each(data.books,function(index){var title=data.books[index].title;var image=data.books[index].image;var href="/bok/"+data.books[index].isbn;var item='<li><div class="cover"><a href="'+href+'"><img src="'+image+'" alt="'+title+'" /></a></div><a class="title" href="'+title+'" title="'+title+'">'+title+'</a></li>';items.push(item);});}
else{$.each(data.books,function(index){items.push({title:data.books[index].title,imgSource:data.books[index].image,href:"/bok/"+data.books[index].isbn});});}
if(onCompleteFunc){onCompleteFunc(items);}});}},SearchHandler:{init:function(){if(Smakprov.General.getPageId()!=="smakprov"){this.bindHandlers();this.loadTagDragon("tagbox");}},bindHandlers:function(){var searchWrapper=$("#search-form .form-item")
searchLabel=$("label",searchWrapper);$('input:not(.initialized)',searchWrapper).each(function(){$(this).bind('focus',function(){$(searchWrapper).addClass('focus');}).bind('blur',function(){searchWrapper.removeClass('focus');if($(this).val().length<=0&&!$(this).is(':hidden')){searchLabel.fadeIn(100);}}).bind('keydown',function(e){if(!e){e=window.event;}
switch(e.keyCode){case 16:case 17:case 18:case 20:case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 9:case 13:case 27:return true;default:}
var length=$(this).val().length;if(length>=0&&$(this).is(':visible')){searchLabel.fadeOut(100);}});}).addClass('initialized');$("input[value=]",searchWrapper).focus().siblings("label").show();},loadTagDragon:function(elemId){$('#'+elemId).tagdragon({'field':'searchbox','url':'/autocomplete/index',delay:400,cache:false,onRenderItem:function(val,index,total,filter){return val.tag.replace(/<\/?[^>]+>/gi,'');},onSelectItem:function(val){},onSelectedItem:function(val){var form=$("#global-search"),input=form.find("#searchbox").val(val.id);form.submit();}});},spellCheck:function(query,spellUrl,wrapperArea,contentArea){if(query===null||query.length===0){return;}
$.getJSON(spellUrl+'/'+query,function(json){var suggestion=json.suggestion;if(suggestion!==null&&suggestion.length>0){$(contentArea).text(suggestion);$(wrapperArea).fadeIn('slow').oneTime(10000,function(i){$(this).slideUp('slow');});}
else{$(wrapperArea).fadeOut('normal');}});}},ClickTracking:{init:function(){var self=this;$(".affiliate-click").click(function(event){event.preventDefault();var elem=$(event.target),category="Affiliate click",action=elem.attr("name"),label=elem.attr("title"),value=1,href=elem.attr("href");self.pushEvent(category,action,label,value,href);});$(".review-click").click(function(event){event.preventDefault();var elem=$(event.target),category="Review click",action="Read",label=elem.attr("name"),value=1,href=elem.attr("href");self.pushEvent(category,action,label,value,href);});},pushEvent:function(category,action,label,value,href){href=href||"";value=value||"1";if(typeof _gaq!=='undefined'){_gaq.push(['_trackEvent',category,action,label,value]);}
if(href!==""){window.open(encodeURI(href));}}},FacebookEventSubscriber:{init:function(delay){var self=this;delay=delay||500;$(document).oneTime(delay,function(){if(typeof FB!=='undefined')
{self.hookupEvents();}});},pushEvent:function(category,action,label){if(typeof _gaq!=='undefined')
{_gaq.push(['_trackEvent',category,action,label]);}},pushLike:function(href){var isbn13=href.match("\\d{13}","g");if(isbn13!==null){$.post('/facebook/like',{isbn13:isbn13[0]});}
if(isbn13!==null){this.pushEvent('FaceBook','LikeBook',isbn13[0]);}
else{this.pushEvent('FaceBook','Like',href);}},pushComment:function(response,href){var isbn13=document.location.href.match("\\d{13}","g");if(isbn13!==null){$.post('/facebook/comment',{isbn13:isbn13[0]});}
if(response.session!==null){if(isbn13!==null){this.pushEvent('FaceBook','CommentBook',isbn13[0]);}
else{this.pushEvent('FaceBook','Comment',response.session.uid);}}},pushUserStatus:function(response){if(response.session!==null){this.pushEvent('FaceBook',response.status,response.session.uid);}},hookupEvents:function(){var self=this;FB.Event.subscribe('edge.create',function(href,widget){self.pushLike(href);});FB.Event.subscribe('comments.add',function(response){self.pushComment(response);});FB.Event.subscribe('auth.statusChange',function(response){self.pushUserStatus(response);});FB.Event.subscribe('auth.login',function(response){});FB.Event.subscribe('auth.logout',function(response){location.reload();});FB.Event.subscribe('auth.sessionChange',function(response){});}},SmakprovViewer:{init:function(){var self=this;if(Smakprov.General.getPageId()==="smakprov"){var wrapper=$("#smakprov"),header=wrapper.find("header"),footer=wrapper.find("footer"),viewer=wrapper.find("iframe.viewer").css("display","none"),windowHeight=$(window).height(),headerHeight=0,footerHeight=0;if(eval(header.length)===1){headerHeight=100;}
if(eval(footer.length)===1){footerHeight=40;}
if(eval(windowHeight)===0){self.setResizedHeight.call(self,viewer,headerHeight,footerHeight);}else{this.setViewerHeight(viewer,windowHeight,headerHeight,footerHeight);self.setResizedHeight.call(self,viewer,headerHeight,footerHeight);}
viewer.show();}},setViewerHeight:function(viewer,windowHeight,headerHeight,footerHeight){var newHeight=eval(windowHeight-headerHeight-footerHeight);viewer.height(newHeight);},setResizedHeight:function(viewer,headerHeight,footerHeight){var self=this;$(window).resize(function(){var windowHeight=$(window).height();self.setViewerHeight.call(self,viewer,windowHeight,headerHeight,footerHeight);});}},BookRating:{init:function(){this.loadRating();$(".clear-rating").live("click",this.clearRating);},loadRating:function(){$.fn.rating.options.cancel='';$('.auto-submit-star').rating({half:false,required:true,callback:function(value,link){$.post('/rating/rate',{value:value});}});},clearRating:function(){var elem=$(this),value=elem.attr("title");$.post('/rating/rate',{value:value},function(data){Smakprov.BookRating.removeRow(elem);});},removeRow:function(elem){var row=elem.parents().filter(".book");$(row).fadeOut(500).oneTime(500,function(){$(this).remove();});}},LoadSocialPlugins:{init:function(){if(Smakprov.General.getPageId()==="book")
this.bookPage();},startPage:function(){var wrapper=$(".fbc-startpage"),fb_activity_html='<fb:activity site="www.smakprov.se" recommendations="true"></fb:activity>',fb_likebox_html='<fb:like-box href="www.facebook.com/smakprov"></fb:like-box>',fb_activity_wrapper=wrapper.find(".fb-activity").removeClass("content-loader").append(fb_activity_html),fb_likebox_wrapper=wrapper.find(".fb-likebox").removeClass("content-loader").append(fb_likebox_html);},bookPage:function(){var share_wrapper=$(".share"),twitter_tweet_html='<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="Smakprov">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>',twitter_tweet_wrapper=share_wrapper.find(".twitter-tweet").removeClass("content-loader").append(twitter_tweet_html).show();}},Init:function(){var S=Smakprov;S.BookRating.init();S.General.loadExpanders();S.General.loadExternalLinks();S.ShelfHandler.init();S.SearchHandler.init();S.ScrollerHandler.init();S.SmakprovViewer.init();S.FacebookEventSubscriber.init(500);S.ClickTracking.init();}};$(document).ready(Smakprov.Init);})(jQuery);
