(function(){window.shuffle_array=function(ar){var i=ar.length;$.each(ar,function(i){this.index=i;});while(i){var j=Math.floor(Math.random()*i);var v=ar[--i];ar[i]=ar[j];ar[j]=v;}};function split_querystring(search){var queryString={};if(search.length==0){return queryString;}
var str=null;if(search.charAt(0)=='?'){str=search.substring(1);}else{str=search;}
var ar1=str.split('&');for(var i=0;i!=ar1.length;i++){var ar2=ar1[i].split('=');queryString[decodeURIComponent(ar2[0])]=decodeURIComponent(ar2[1]);}
return queryString;}
window.query_params=split_querystring(location.search);if(-1==document.referrer.indexOf(location.host)){if(query_params['gid']){$.cookie('gid',query_params['gid'],{path:'/'});}else{$.cookie('gid',null,{path:'/'});}}})();$(function(){window.on_load_history=function(data){shuffle_array(data);var container=$("#history_map");container.css("display","block")
.css("width","210px")
.css("height","210px");var count=30;$.each(data,function(){if(count==0)return;var a=$(document.createElement("a"));a.attr("href","/widget/"+this.widget_id+".html")
.css("display","block")
.css("float","left")
.css("width","37px")
.css("height","37px")
.css("padding","0")
.css("margin","1.5px")
.css("overflow","hidden")
.css("backgroundImage","url('/history.jpg')")
.css("backgroundRepeat","no-repeat")
.css("backgroundPosition",(this.index*-37)+"px 0px");container.append(a);count--;});container.append($(document.createElement("div")).css("clear","both"));};$.getScript("/history.json");});(function(){var special_items=[];var special_items_strong=[];window._sw_init_gallery_special_data=function(_special_items,_special_items_strong){if(_special_items){special_items=_special_items;shuffle_array(special_items);}
if(_special_items_strong){special_items_strong=_special_items_strong;shuffle_array(special_items_strong);}};window.load_special=function(count,callback,is_strong_only){var using_sp_items;if(count<=special_items_strong.length||is_strong_only){using_sp_items=special_items_strong;}else{using_sp_items=special_items_strong;var require_diff=count-special_items_strong.length;for(var i=0;i<require_diff;i++){using_sp_items.push(special_items[i]);}}
var result=[];for(var i=0;i<count;i++){if(0==using_sp_items.length){break;}
var ar=[];$.each(using_sp_items,function(){for(var i=0;i<this.priority;i++){ar.push(this);}});var rand=Math.floor(Math.random()*(ar.length));var item=ar[rand];result.push(item);using_sp_items=$.grep(using_sp_items,function(_item){return _item!=item;});}
callback(result);};})();