(function($){$.fn.imgTooltip=function(){return this.each(function() {var id=$(this).attr("rel");var num=new String('000').substring(new String(id).length).concat(id);$(this).attr("rel","");if(id != undefined) {$(this).hover(function(e){var tipX=e.pageX+5;var tipY=e.pageY - 160;$(this).attr("title","");$(document.body).append('<div id="imgTooltip" style=""><img src="assets/thumbnails/'+num+'_front.jpg" alt="Pobieranie..."/></div>');var tipWidth=$("#imgTooltip").width();var tipHeight=$("#imgTooltip").height();$("#imgTooltip").width(tipWidth);$("#imgTooltip").height(tipHeight);$("#imgTooltip").css("left",tipX).css("top",tipY).fadeIn("medium");$("#imgTooltip > img").error(function(){$(this).attr("src","img/no_thumbnail.gif");});},function(){$("#imgTooltip").remove();$(this).attr("rel",id);});$(this).mousemove(function(e){var tipX=e.pageX+5;var tipY=e.pageY - 160;var tipWidth=$("#imgTooltip").width();var tipHeight=$("#imgTooltip").height();if(tipX+tipWidth > $(window).width()-24)tipX=e.pageX - tipWidth;if($(window).height() < tipY+tipHeight)tipY=e.pageY - tipHeight;$("#imgTooltip").css("left",tipX).css("top",tipY).fadeIn("medium");});$(this).click(function(){$("#imgTooltip").remove();$(this).attr("rel",id);});}});};})(jQuery);function urlencode (str) {var hexStr=function (dec) {return '%'+dec.toString(16).toUpperCase();};var ret='',unreserved=/[\w.-]/;str=(str+'').toString();for (var i=0,dl=str.length; i < dl; i++) {var ch=str.charAt(i);if(unreserved.test(ch)) {ret +=ch;}else  {var code=str.charCodeAt(i);if(code === 32) {ret +='+';}else  if(code < 128) {ret +=hexStr(code);}else  if(code >= 128 && code < 2048) {ret +=hexStr((code >> 6) | 0xC0);ret +=hexStr((code & 0x3F) | 0x80);}else  if(code >= 2048 && code < 65536) {ret +=hexStr((code >> 12) | 0xE0);ret +=hexStr(((code >> 6) & 0x3F) | 0x80);ret +=hexStr((code & 0x3F) | 0x80);}else  if(code >= 65536) {ret +=hexStr((code >> 18) | 0xF0);ret +=hexStr(((code >> 12) & 0x3F) | 0x80);ret +=hexStr(((code >> 6) & 0x3F) | 0x80);ret +=hexStr((code & 0x3F) | 0x80);}}}return ret;}/* ***************************************************************************************** Kartoteka JS** Autor:Michał Cisz (www.cisz.eu)* Wersja:2009-09-18** *****************************************************************************************/var kartoteka={openedWindowsCount:0,cache:[],blockId:'A',cellIdx:1,prisonerId:0,offset:0,limit:50,init:function() {$("#navJoin a").click(function() {kartoteka.window.openPage("join");});$("#navInfo a").click(function() {kartoteka.window.openPage("about");});$("#navPrisoners a").click(function() {kartoteka.block.show();if(kartoteka.block.viewType=="byBlock")kartoteka.block.getBlock(kartoteka.blockId);else  if(kartoteka.block.viewType=="byDate")kartoteka.block.getByDate(kartoteka.offset);});kartoteka.exitBtn.init();kartoteka.block.init();kartoteka.cell.init();kartoteka.prisoner.init();kartoteka.window.init();kartoteka.blockNavi.init();},openedWindowsIncrement:function() {++this.openedWindowsCount;},openedWindowsDecrement:function() {if(--this.openedWindowsCount==0)this.exitBtn.hide();},updateCache:function(name,value) {if(this.cache[name] && (value.hash==this.cache[name].hash))return false;else {this.cache[name]=value;return true;}},getCache:function(name) {if(this.cache[name] && this.cache[name].response)return this.cache[name];else return {response:null,hash:0};},clearCache:function() {this.cache=[];},error:function(id) {if(id=="xhr"){if(confirm("Wystąpił krytyczny błąd. Konieczne jest odświeżenie strony!"))window.location.reload();}}};kartoteka.exitBtn={visible:false,init:function() {$("#exitBtn a").click(function(){kartoteka.exitBtn.click();});},show:function() {if(!this.visible){$("#exitBtn").fadeIn(1000);this.visible=true;}},hide:function(speed) {if(this.visible){if(speed)$("#exitBtn").fadeOut(speed);else $("#exitBtn").fadeOut(500);this.visible=false;}},click:function(speed) {kartoteka.block.hide(speed);kartoteka.cell.hide(speed);kartoteka.prisoner.hide(speed);kartoteka.window.hide(speed);kartoteka.blockNavi.hide(speed);}};kartoteka.blockNavi={visible:false,init:function() {$("#blockNavi #selectorBtn a").hover(function(){clearTimeout(kartoteka.cell.selectorTimeout);$("#blockNavi #selector").show(500);},function() {clearTimeout(kartoteka.cell.selectorTimeout);kartoteka.cell.selectorTimeout=setTimeout(function(){$("#blockNavi #selector").hide(300);},500);});$("#blockNavi #selector a").hover(function(){clearTimeout(kartoteka.cell.selectorTimeout);},function() {clearTimeout(kartoteka.cell.selectorTimeout);kartoteka.cell.selectorTimeout=setTimeout(function(){$("#blockNavi #selector").hide(300);},500);});$("#blockNavi #selector a").click(function(){kartoteka.blockNavi.click(this);});},show:function() {if(!this.visible){$("#blockNavi").fadeIn(1500);this.visible=true;}},hide:function(speed) {if(this.visible){if(speed)$("#blockNavi").fadeOut(speed);else $("#blockNavi").fadeOut(500);this.visible=false;}},click:function(obj) {kartoteka.blockNavi.selectLetter($(obj).html());kartoteka.cell.getCell($(obj).html(),1);kartoteka.cell.show();kartoteka.block.hide(1);kartoteka.prisoner.hide(1);},selectLetter:function(letter) {$("#blockNavi #name").html(letter);}};kartoteka.block={visible:false,viewType:'byBlock',queryTimeout:null,init:function() {$("#searchBtn").click(function(){if($("#query").css("display")=="none")kartoteka.block.searchShow();else kartoteka.block.searchHide();});$("#query > input").keydown(function(){clearTimeout(kartoteka.block.queryTimeout);$("#query span").html("Wpisujesz frazę...");});$("#query > input").keyup(function(){kartoteka.block.queryTask();});$("#query > input").blur(function(){$("#query span").html("");});$("#blockContainer #sorting a").click(function(){kartoteka.block.sort($(this).attr("rel"));});},show:function() {if(!this.visible){kartoteka.openedWindowsIncrement();kartoteka.exitBtn.click(1);$("#blockContainer").fadeIn(1000);$("#searchBtn").fadeIn(1000);this.visible=true;kartoteka.exitBtn.show();}kartoteka.block.searchHide();$("#blockContainer #sorting a[rel='"+this.viewType+"']").css("text-decoration","underline");},hide:function(speed) {if(this.visible){speed=(speed)?speed:500;if(this.queryTimeout)clearTimeout(this.queryTimeout);$("#blockContainer").fadeOut(speed);$("#searchBtn").fadeOut(speed);$("#query").fadeOut(speed);this.visible=false;kartoteka.openedWindowsDecrement();}},getBlock:function(letterId) {var url="site/getBlock/"+letterId;$("#blockContainer .prisoners").html("Pobieranie...");kartoteka.blockId=letterId;$("#blockContainer .navi").html($("#naviByBlockCache").html());$("#blockContainer .navi a").click(function(){kartoteka.block.getBlock($(this).html());});$("#blockContainer .navi a").removeAttr("class");$("#blockContainer .navi a:contains('"+letterId+"')").attr("class","sel");var cache=kartoteka.getCache(url);$.ajax({url:url+"/"+cache.hash,type:"post",complete:function(xhr,status) {var response=null;if(xhr.status==200) {eval("var json="+xhr.responseText);response=json.response;kartoteka.updateCache(url,json);}else  if(xhr.status==304 || cache.response)response=cache.response;else kartoteka.error("xhr");if(response != null){$("#blockContainer .prisoners").html(response);$("#blockContainer .prisoners > a").imgTooltip();}}});},getByDate:function(offset) {var url="site/getByDate/"+offset+"/"+kartoteka.limit;$("#blockContainer .prisoners").html("Pobieranie...");kartoteka.offset=offset;$("#blockContainer .navi").html("...");var cache=kartoteka.getCache(url);$.ajax({url:url+"/"+cache.hash,type:"post",complete:function(xhr,status) {var response=null;if(xhr.status==200) {eval("var json="+xhr.responseText);response=json.response;kartoteka.updateCache(url,json);}else  if(xhr.status==304 || cache.response)response=cache.response;else kartoteka.error("xhr");if(response != null) {$("#blockContainer .prisoners").html(response.data);$("#blockContainer .prisoners > a").imgTooltip();$("#blockContainer .navi").html("");totalPages=Math.ceil(response.total/kartoteka.limit);for (i=0; i<totalPages; i++)$("#blockContainer .navi").append("<a href=\"javascript:void(0)\">"+(i+1)+"</a>");$("#blockContainer .navi a").click(function(){kartoteka.block.getByDate(($(this).html()-1)*kartoteka.limit);});pageIdx=Math.floor(offset/kartoteka.limit)+1;$("#blockContainer .navi a").removeAttr("class");$("#blockContainer .navi a:contains('"+pageIdx+"')").attr("class","sel");}}});},sort:function(byStr) {$("#blockContainer #sorting a[rel!='"+byStr+"']").css("text-decoration","none");$("#blockContainer #sorting a[rel='"+byStr+"']").css("text-decoration","underline");this.searchHide();if(byStr=="byBlock")	{this.viewType="byBlock";this.getBlock(kartoteka.blockId);}else  if(byStr=="byDate") {this.viewType="byDate";this.getByDate(kartoteka.offset);}},showPrisoner:function(url,id) {kartoteka.prisoner.getPrisoner(id);kartoteka.prisoner.show();this.hide(1);},searchShow:function() {$("#query > input").val("");$("#query").fadeIn(500);$("#query > input").focus();$("#query span").html("");},searchHide:function() {$("#query").fadeOut(300);if(this.queryTimeout)clearTimeout(this.queryTimeout);},queryTask:function() {if(this.queryTimeout)clearTimeout(this.queryTimeout);this.queryTimeout=setTimeout(function(){if($("#query > input").val().length > 0)kartoteka.block.search(0);else $("#query span").html("");},300);},search:function(offset) {var query=$("#query > input").val();if(query.length==0)return;query=query.replace("/","");query=query.replace("\\","");var url="site/search/"+urlencode(query)+"/"+offset+"/"+kartoteka.limit;$("#blockContainer .prisoners").html("Pobieranie...");$("#blockContainer .navi").html("...");$("#query span").html("Szukam...");$("#blockContainer #sorting a").css("text-decoration","none");var cache=kartoteka.getCache(url);$.ajax({url:url+"/"+cache.hash,type:"post",complete:function(xhr,status) {var response=null;if(xhr.status==200) {eval("var json="+xhr.responseText);response=json.response;kartoteka.updateCache(url,json);}else  if(xhr.status==304 || cache.response)response=cache.response;else kartoteka.error("xhr");if(response != null) {$("#blockContainer .prisoners").html(response.data);$("#blockContainer .prisoners > a").imgTooltip();$("#blockContainer .navi").html("");totalPages=Math.ceil(response.total/kartoteka.limit);for (i=0; i<totalPages; i++)$("#blockContainer .navi").append("<a href=\"javascript:void(0)\">"+(i+1)+"</a>");$("#blockContainer .navi a").click(function(){kartoteka.block.search(($(this).html()-1)*kartoteka.limit);});pageIdx=Math.floor(offset/kartoteka.limit)+1;$("#blockContainer .navi a").removeAttr("class");$("#blockContainer .navi a:contains('"+pageIdx+"')").attr("class","sel");}$("#query span").html("Wyszukiwanie zakończone");}});}};kartoteka.cell={visible:false,selectorTimeout:null,totalCells:null,init:function() {$("#cellContainer .thumbs .thumb .photo img").fadeTo(1,0.4);$("#cellContainer .thumbs .thumb .photo img").hover(function() {$(this).stop().fadeTo(200,1.0);},function() {$(this).stop().fadeTo(200,0.4);});$("#cellContainer .navi #prev").click(function(){kartoteka.cell.prev();});$("#cellContainer .navi #next").click(function(){kartoteka.cell.next();});$("#cellContainer .thumbs .photo img").error(function() {$(this).attr("src","img/no_thumbnail.gif");});$("#cellContainer .thumbs .photo img").load(function(){$(this).css("visibility","visible");});},show:function() {if(!this.visible){kartoteka.openedWindowsIncrement();kartoteka.exitBtn.click(1);$("#cellContainer").fadeIn(1000);this.visible=true;kartoteka.exitBtn.show();kartoteka.blockNavi.show();}},hide:function(speed) {if(this.visible){if(speed)$("#cellContainer").fadeOut(speed);else $("#cellContainer").fadeOut(500);this.visible=false;kartoteka.openedWindowsDecrement();}},getCell:function(blockId,idx) {$("#cellContainer .navi .label span").html(idx);kartoteka.cellIdx=parseInt(idx);kartoteka.blockId=blockId;this.getBlockInfo(blockId);$("#cellContainer .thumbs .thumb .photo a img").css("visibility","hidden");var url="site/getCell/"+blockId+"/"+idx;var cache=kartoteka.getCache(url);$("#cellContainer .thumbs").fadeOut(200);$.ajax({url:url+"/"+cache.hash,type:"post",complete:function(xhr,status) {var response=null;if(xhr.status==200) {eval("var json="+xhr.responseText);response=json.response;kartoteka.updateCache(url,json);}else  if(xhr.status==304 || cache.response)response=cache.response;else kartoteka.error("xhr");if(response != null) {total=response.length;$("#cellContainer .thumbs .thumb:lt("+(total)+")").show();$("#cellContainer .thumbs .thumb:gt("+(total-1)+")").hide();for (i=0; i<total; i++){id="#cellContainer .thumbs .thumb:eq("+i+")";$(id+" .label a").html(response[i].name.replace('(','<br/>('));$(id+" a").attr("rel",response[i].id);$(id+" a").attr("onclick","kartoteka.cell.showPrisoner("+response[i].id+")");$(id+" a").attr("rel",response[i].id);var num=new String('000').substring(new String(response[i].id).length).concat(response[i].id);$(id+" .photo a img").attr("src","assets/thumbnails/"+num+"_front.jpg");}$("#cellContainer .thumbs").fadeIn(1000);}}});},getBlockInfo:function(blockId) {$("#cellContainer .navi #prev").css("visibility","hidden");$("#cellContainer .navi #next").css("visibility","hidden");var url="site/getBlockInfo/"+blockId;var cache=kartoteka.getCache(url);$("#cellContainer #summary").fadeOut(200);$("#cellContainer #summary .label span").html(blockId);$.ajax({url:url+"/"+cache.hash,type:"post",complete:function(xhr,status) {var response=null;if(xhr.status==200) {eval("json="+xhr.responseText);kartoteka.updateCache(url,json);response=json.response;}else  if(xhr.status==304 || cache.response)response=cache.response;else kartoteka.error("xhr");if(response != null) {$("#cellContainer #summary .info span:eq(0)").html(response.totalPrisoners);$("#cellContainer #summary .info span:eq(1)").html(response.totalCells);$("#cellContainer #summary").fadeIn(1000);kartoteka.cell.totalCells=response.totalCells;if(kartoteka.cellIdx > 1)$("#cellContainer .navi #prev").css("visibility","visible");if(kartoteka.cellIdx < kartoteka.cell.totalCells)$("#cellContainer .navi #next").css("visibility","visible");}}});},prev:function() {if(kartoteka.cellIdx > 1)this.getCell(kartoteka.blockId,kartoteka.cellIdx-1);},next:function() {if(kartoteka.cellIdx < this.totalCells)this.getCell(kartoteka.blockId,kartoteka.cellIdx+1);},showPrisoner:function(id) {kartoteka.prisoner.getPrisoner(id);kartoteka.prisoner.show();this.hide(1);}};kartoteka.prisoner={visible:false,init:function() {$("#prisonerContainer .thumbs img.photo").error(function(){$(this).attr("src","img/no_thumbnail.gif");});$("#prisonerContainer .thumbs img.photo").load(function(){$(this).css("visibility","visible");});$("#prisonerContainer .thumbs a").lightBox({overlayBgColor:		'#000',	overlayOpacity:			0.8,	fixedNavigation:		false,	imageLoading:			'js/jquery/images/loading.gif',	imageBtnPrev:			'js/jquery/images/prevlabel.gif',		imageBtnNext:			'js/jquery/images/nextlabel.gif',		imageBtnClose:			'js/jquery/images/closelabel.gif',	imageBlank:				'js/jquery/images/blank.gif',		containerBorderSize:	10,		containerResizeSpeed:	400,	txtImage:				'Obrazek',txtOf:					'z',	keyToClose:				'c',	keyToPrev:				'p',	keyToNext:				'n',	imageArray:				[],activeImage:			0});},show:function() {if(!this.visible){kartoteka.openedWindowsIncrement();kartoteka.exitBtn.click(1);$("#prisonerContainer").slideDown(1000);this.visible=true;kartoteka.exitBtn.show();kartoteka.blockNavi.show();}},hide:function(speed) {if(this.visible){if(speed)$("#prisonerContainer").slideUp(speed);else $("#prisonerContainer").slideUp(500);this.visible=false;kartoteka.openedWindowsDecrement();}},getPrisoner:function(id) {var url="site/getPrisoner/"+id;var cache=kartoteka.getCache(url);this.getNeighbors(id);$("#prisonerContainer .thumbs img.photo").css("visibility","hidden");$("#prisonerContainer #info .value:eq(0)").html("...");$("#prisonerContainer #info .value2").html("...");$("#prisonerContainer #info .value:eq(1)").html("...");$("#prisonerContainer #info .value:eq(2)").html("...");$("#prisonerContainer #info a.link2Prisoner").attr("title","...");$("#prisonerContainer #info a.link2Prisoner").attr("href",".");$("#prisonerContainer").fadeTo(1,0.85);$.ajax({url:url+"/"+cache.hash,type:"post",complete:function(xhr,status) {var response=null;if(xhr.status==200) {eval("json="+xhr.responseText);kartoteka.updateCache(url,json);response=json.response;}else  if(xhr.status==304 || cache.response)response=cache.response;else kartoteka.error("xhr");if(response != null) {kartoteka.blockNavi.selectLetter(response.block);$("#prisonerContainer #info .value:eq(0)").html(response.number);$("#prisonerContainer #info .value2").html(response.name);$("#prisonerContainer #info .value:eq(1)").html(response.accusation);$("#prisonerContainer #info .value:eq(2)").html(response.hits);$("#prisonerContainer #info a.link2Prisoner").attr("title",response.name);$("#prisonerContainer #info a.link2Prisoner").attr("href",response.url);var img=response.number.substring(0,3);$("#prisonerContainer .thumbs img.photo:eq(0)").attr("src","assets/thumbnails/"+img+"_front.jpg");$("#prisonerContainer .thumbs img.photo:eq(1)").attr("src","assets/thumbnails/"+img+"_left.jpg");$("#prisonerContainer .thumbs img.photo:eq(2)").attr("src","assets/thumbnails/"+img+"_right.jpg");$("#prisonerContainer .thumbs a:eq(0)").attr("href","assets/slide/"+img+"_front.jpg");$("#prisonerContainer .thumbs a:eq(1)").attr("href","assets/slide/"+img+"_left.jpg");$("#prisonerContainer .thumbs a:eq(2)").attr("href","assets/slide/"+img+"_right.jpg");$("#prisonerContainer .thumbs a:eq(0)").attr("title",response.name+" - zdjęcie twarzy");$("#prisonerContainer .thumbs a:eq(1)").attr("title",response.name+" - zdjęcie lewego profilu");$("#prisonerContainer .thumbs a:eq(2)").attr("title",response.name+" - zdjęcie prawego profilu");$("#prisonerContainer").fadeTo(100,1.0);}}});},getNeighbors:function(id) {var url="site/getNeighbors/"+id;var cache=kartoteka.getCache(url);$.ajax({url:url+"/"+cache.hash,type:"post",complete:function(xhr,status) {var response=null;if(xhr.status==200) {eval("json="+xhr.responseText);kartoteka.updateCache(url,json);response=json.response;}else  if(xhr.status==304 || cache.response)response=cache.response;else kartoteka.error("xhr");if(response != null) {$("#prisonerContainer #navi #cell b").html(response.cellIdx);$("#prisonerContainer #navi #block b").html(response.blockId);$("#prisonerContainer #navi #block p").empty();for (i=0; i<response.totalCells; i++)if((i+1) != response.cellIdx)$("#prisonerContainer #navi #block p").append(['<a href="javascript:void(0)" onclick="kartoteka.prisoner.gotoCell(','\'',response.blockId,'\',',(i+1),')">',(i+1),'</a> '].join(''));else $("#prisonerContainer #navi #block p").append('['+(i+1)+'] ');$("#prisonerContainer #navi #cell p").empty();for (i=0; i<response.neighbors.length; i++)$("#prisonerContainer #navi #cell p").append(['<a href="javascript:void(0)" onclick="kartoteka.prisoner.getPrisoner(',response.neighbors[i].id,')"',' rel="',response.neighbors[i].id,'">',response.neighbors[i].name,'</a>'].join(''));$("#prisonerContainer #navi #cell p > a").imgTooltip();$("#prisonerContainer #navi #exit a").attr("onclick","kartoteka.prisoner.gotoCell('"+response.blockId+"',"+response.cellIdx+")");kartoteka.cellIdx=parseInt(response.cellIdx);kartoteka.blockId=response.blockId;}}});},gotoCell:function(blockId,cellIdx) {kartoteka.cell.getCell(blockId,cellIdx);kartoteka.cell.show();this.hide(1);}};kartoteka.window={visible:false,init:function() {},show:function() {if(!this.visible){kartoteka.openedWindowsIncrement();kartoteka.exitBtn.click(1);$("#windowContainer").fadeIn(1000);this.visible=true;kartoteka.exitBtn.show();}},hide:function(speed) {if(this.visible){if(speed)$("#windowContainer").fadeOut(speed);else $("#windowContainer").fadeOut(500);this.visible=false;kartoteka.openedWindowsDecrement();}},getPage:function(id) {var url="site/getPage/"+id;var cache=kartoteka.getCache(url);$("#windowContainer #content div").html("Pobieranie...");$.ajax({url:url+"/"+cache.hash,type:"post",complete:function(xhr,status) {var response=null;if(xhr.status==200) {eval("json="+xhr.responseText);kartoteka.updateCache(url,json);response=json.response;}else  if(xhr.status==304 || cache.response)response=cache.response;else kartoteka.error("xhr");if(response != null) {$("#windowContainer").html(response);}}});},openPage:function(id) {this.getPage(id);this.show();}};$(document.body).ready(function(){var h=$(document.body).height();if(h < 768)$(document.body).height(768);kartoteka.init();});kartoteka.baseHref='http://kartoteka.7ds.pl/';
