(function($){if($.browser.mozilla){$.fn.disableTextSelect=function(){return this.each(function(){$(this).css({MozUserSelect:"none"})})};$.fn.enableTextSelect=function(){return this.each(function(){$(this).css({MozUserSelect:""})})}}else if($.browser.msie){$.fn.disableTextSelect=function(){return this.each(function(){$(this).bind("selectstart.disableTextSelect",function(){return false})})};$.fn.enableTextSelect=function(){return this.each(function(){$(this).unbind("selectstart.disableTextSelect")})}}else{$.fn.disableTextSelect=
function(){return this.each(function(){$(this).bind("mousedown.disableTextSelect",function(){return false})})};$.fn.enableTextSelect=function(){return this.each(function(){$(this).unbind("mousedown.disableTextSelect")})}}})(jQuery);
(function($){var types=["DOMMouseScroll","mousewheel"];$.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var i=types.length;i;)this.addEventListener(types[--i],handler,false);else this.onmousewheel=handler},teardown:function(){if(this.removeEventListener)for(var i=types.length;i;)this.removeEventListener(types[--i],handler,false);else this.onmousewheel=null}};$.fn.extend({mousewheel:function(fn){return fn?this.bind("mousewheel",fn):this.trigger("mousewheel")},unmousewheel:function(fn){return this.unbind("mousewheel",
fn)}});function handler(event){var args=[].slice.call(arguments,1),delta=0,returnValue=true;event=$.event.fix(event||window.event);event.type="mousewheel";if(event.wheelDelta)delta=event.wheelDelta/120;if(event.detail)delta=-event.detail/3;args.unshift(event,delta);return $.event.handle.apply(this,args)}})(jQuery);
(function($){var style=document.createElement("div").style,moz=style["MozBorderRadius"]!==undefined,webkit=style["WebkitBorderRadius"]!==undefined,radius=style["borderRadius"]!==undefined||style["BorderRadius"]!==undefined,mode=document.documentMode||0,noBottomFold=$.browser.msie&&($.browser.version<8&&!mode||mode<8),expr=$.browser.msie&&function(){var div=document.createElement("div");try{div.style.setExpression("width","0+0");div.style.removeExpression("width")}catch(e){return false}return true}();
$.support=$.support||{};$.support.borderRadius=moz||webkit||radius;function sz(el,p){return parseInt($.css(el,p))||0}function hex2(s){var s=parseInt(s).toString(16);return s.length<2?"0"+s:s}function gpc(node){while(node){var v=$.css(node,"backgroundColor"),rgb;if(v&&v!="transparent"&&v!="rgba(0, 0, 0, 0)"){if(v.indexOf("rgb")>=0){rgb=v.match(/\d+/g);return"#"+hex2(rgb[0])+hex2(rgb[1])+hex2(rgb[2])}return v}if(node.nodeName.toLowerCase()=="html")break;node=node.parentNode}return"#ffffff"}function getWidth(fx,
i,width){r=function(a){return Math.round(width*a)};switch(fx){case "round":return r(1-Math.cos(Math.asin(i/width)));case "cool":return r(1+Math.cos(Math.asin(i/width)));case "sharp":return r(1-Math.cos(Math.acos(i/width)));case "bite":return r(Math.cos(Math.asin((width-i-1)/width)));case "slide":return r(Math.atan2(i,width/i));case "jut":return r(Math.atan2(width,width-i-1));case "curl":return r(Math.atan(i));case "tear":return r(Math.cos(i));case "wicked":return r(Math.tan(i));case "long":return r(Math.sqrt(i));
case "sculpt":return r(Math.log(width-i-1,width));case "dogfold":case "dog":return i&1?i+1:width;case "dog2":return i&2?i+1:width;case "dog3":return i&3?i+1:width;case "fray":return i%2*width;case "notch":return width;case "bevelfold":case "bevel":return i+1}}$.fn.corner=function(options){if(this.length==0){if(!$.isReady&&this.selector){var s=this.selector,c=this.context;$(function(){$(s,c).corner(options)})}return this}return this.each(function(index){var $this=$(this),o=[$this.attr($.fn.corner.defaults.metaAttr)||
"",options||""].join(" ").toLowerCase(),keep=/keep/.test(o),cc=(o.match(/cc:(#[0-9a-f]+)/)||[])[1],sc=(o.match(/sc:(#[0-9a-f]+)/)||[])[1],width=parseInt((o.match(/(\d+)px/)||[])[1])||10,re=/round|bevelfold|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dogfold|dog/,fx=(o.match(re)||["round"])[0],fold=/dogfold|bevelfold/.test(o),edges={T:0,B:1},opts={TL:/top|tl|left/.test(o),TR:/top|tr|right/.test(o),BL:/bottom|bl|left/.test(o),BR:/bottom|br|right/.test(o)},strip,
pad,cssHeight,j,bot,d,ds,bw,i,w,e,c,common,$horz;if(!opts.TL&&!opts.TR&&!opts.BL&&!opts.BR)opts={TL:1,TR:1,BL:1,BR:1};if($.fn.corner.defaults.useNative&&fx=="round"&&(radius||moz||webkit)&&!cc&&!sc){if(opts.TL)$this.css(radius?"border-top-left-radius":moz?"-moz-border-radius-topleft":"-webkit-border-top-left-radius",width+"px");if(opts.TR)$this.css(radius?"border-top-right-radius":moz?"-moz-border-radius-topright":"-webkit-border-top-right-radius",width+"px");if(opts.BL)$this.css(radius?"border-bottom-left-radius":
moz?"-moz-border-radius-bottomleft":"-webkit-border-bottom-left-radius",width+"px");if(opts.BR)$this.css(radius?"border-bottom-right-radius":moz?"-moz-border-radius-bottomright":"-webkit-border-bottom-right-radius",width+"px");return}strip=document.createElement("div");$(strip).css({overflow:"hidden",height:"1px",minHeight:"1px",fontSize:"1px",backgroundColor:sc||"transparent",borderStyle:"solid"});pad={T:parseInt($.css(this,"paddingTop"))||0,R:parseInt($.css(this,"paddingRight"))||0,B:parseInt($.css(this,
"paddingBottom"))||0,L:parseInt($.css(this,"paddingLeft"))||0};if(typeof this.style.zoom!=undefined)this.style.zoom=1;if(!keep)this.style.border="none";strip.style.borderColor=cc||gpc(this.parentNode);cssHeight=$(this).outerHeight();for(j in edges){bot=edges[j];if(bot&&(opts.BL||opts.BR)||!bot&&(opts.TL||opts.TR)){strip.style.borderStyle="none "+(opts[j+"R"]?"solid":"none")+" none "+(opts[j+"L"]?"solid":"none");d=document.createElement("div");$(d).addClass("jquery-corner");ds=d.style;bot?this.appendChild(d):
this.insertBefore(d,this.firstChild);if(bot&&cssHeight!="auto"){if($.css(this,"position")=="static")this.style.position="relative";ds.position="absolute";ds.bottom=ds.left=ds.padding=ds.margin="0";if(expr)ds.setExpression("width","this.parentNode.offsetWidth");else ds.width="100%"}else if(!bot&&$.browser.msie){if($.css(this,"position")=="static")this.style.position="relative";ds.position="absolute";ds.top=ds.left=ds.right=ds.padding=ds.margin="0";if(expr){bw=sz(this,"borderLeftWidth")+sz(this,"borderRightWidth");
ds.setExpression("width","this.parentNode.offsetWidth - "+bw+'+ "px"')}else ds.width="100%"}else{ds.position="relative";ds.margin=!bot?"-"+pad.T+"px -"+pad.R+"px "+(pad.T-width)+"px -"+pad.L+"px":pad.B-width+"px -"+pad.R+"px -"+pad.B+"px -"+pad.L+"px"}for(i=0;i<width;i++){w=Math.max(0,getWidth(fx,i,width));e=strip.cloneNode(false);e.style.borderWidth="0 "+(opts[j+"R"]?w:0)+"px 0 "+(opts[j+"L"]?w:0)+"px";bot?d.appendChild(e):d.insertBefore(e,d.firstChild)}if(fold&&$.support.boxModel){if(bot&&noBottomFold)continue;
for(c in opts){if(!opts[c])continue;if(bot&&(c=="TL"||c=="TR"))continue;if(!bot&&(c=="BL"||c=="BR"))continue;common={position:"absolute",border:"none",margin:0,padding:0,overflow:"hidden",backgroundColor:strip.style.borderColor};$horz=$("<div/>").css(common).css({width:width+"px",height:"1px"});switch(c){case "TL":$horz.css({bottom:0,left:0});break;case "TR":$horz.css({bottom:0,right:0});break;case "BL":$horz.css({top:0,left:0});break;case "BR":$horz.css({top:0,right:0});break}d.appendChild($horz[0]);
var $vert=$("<div/>").css(common).css({top:0,bottom:0,width:"1px",height:width+"px"});switch(c){case "TL":$vert.css({left:width});break;case "TR":$vert.css({right:width});break;case "BL":$vert.css({left:width});break;case "BR":$vert.css({right:width});break}d.appendChild($vert[0])}}}}})};$.fn.uncorner=function(){if(radius||moz||webkit)this.css(radius?"border-radius":moz?"-moz-border-radius":"-webkit-border-radius",0);$("div.jquery-corner",this).remove();return this};$.fn.corner.defaults={useNative:true,
metaAttr:"data-corner"}})(jQuery);
(function($){$.fn.pngFix=function(settings){settings=$.extend({blankgif:"blank.gif"},settings);var ie55=navigator.appName=="Microsoft Internet Explorer"&&parseInt(navigator.appVersion)==4&&navigator.appVersion.indexOf("MSIE 5.5")!=-1;var ie6=navigator.appName=="Microsoft Internet Explorer"&&parseInt(navigator.appVersion)==4&&navigator.appVersion.indexOf("MSIE 6.0")!=-1;if($.browser.msie&&(ie55||ie6)){$(this).find("img[src$=.png]").each(function(){$(this).attr("width",$(this).width());$(this).attr("height",
$(this).height());var prevStyle="";var strNewHTML="";var imgId=$(this).attr("id")?'id="'+$(this).attr("id")+'" ':"";var imgClass=$(this).attr("class")?'class="'+$(this).attr("class")+'" ':"";var imgTitle=$(this).attr("title")?'title="'+$(this).attr("title")+'" ':"";var imgAlt=$(this).attr("alt")?'alt="'+$(this).attr("alt")+'" ':"";var imgAlign=$(this).attr("align")?"float:"+$(this).attr("align")+";":"";var imgHand=$(this).parent().attr("href")?"cursor:hand;":"";if(this.style.border){prevStyle+="border:"+
this.style.border+";";this.style.border=""}if(this.style.padding){prevStyle+="padding:"+this.style.padding+";";this.style.padding=""}if(this.style.margin){prevStyle+="margin:"+this.style.margin+";";this.style.margin=""}var imgStyle=this.style.cssText;strNewHTML+="<span "+imgId+imgClass+imgTitle+imgAlt;strNewHTML+='style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+imgAlign+imgHand;strNewHTML+="width:"+$(this).width()+"px;"+"height:"+$(this).height()+"px;";
strNewHTML+="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"+"(src='"+$(this).attr("src")+"', sizingMethod='scale');";strNewHTML+=imgStyle+'"></span>';if(prevStyle!="")strNewHTML='<span style="position:relative;display:inline-block;'+prevStyle+imgHand+"width:"+$(this).width()+"px;"+"height:"+$(this).height()+"px;"+'">'+strNewHTML+"</span>";$(this).hide();$(this).after(strNewHTML)});$(this).find("*").each(function(){var bgIMG=$(this).css("background-image");if(bgIMG.indexOf(".png")!=-1){var iebg=
bgIMG.split('url("')[1].split('")')[0];$(this).css("background-image","none");$(this).get(0).runtimeStyle.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+iebg+"',sizingMethod='scale')"}});$(this).find("input[src$=.png]").each(function(){var bgIMG=$(this).attr("src");$(this).get(0).runtimeStyle.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader"+"(src='"+bgIMG+"', sizingMethod='scale');";$(this).attr("src",settings.blankgif)})}return jQuery}})(jQuery);
(function(jQuery){jQuery.hotkeys={version:"0.8",specialKeys:{8:"backspace",9:"tab",13:"return",16:"shift",17:"ctrl",18:"alt",19:"pause",20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"del",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"*",107:"+",109:"-",110:".",111:"/",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12",
144:"numlock",145:"scroll",191:"/",224:"meta"},shiftNums:{"`":"~","1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")","-":"_","=":"+",";":": ","'":'"',",":"<",".":">","/":"?","\\":"|"}};function keyHandler(handleObj){if(typeof handleObj.data!=="string")return;var origHandler=handleObj.handler,keys=handleObj.data.toLowerCase().split(" ");handleObj.handler=function(event){if(this!==event.target&&(/textarea|select/i.test(event.target.nodeName)||event.target.type==="text"))return;
var special=event.type!=="keypress"&&jQuery.hotkeys.specialKeys[event.which],character=String.fromCharCode(event.which).toLowerCase(),key,modif="",possible={};if(event.altKey&&special!=="alt")modif+="alt+";if(event.ctrlKey&&special!=="ctrl")modif+="ctrl+";if(event.metaKey&&!event.ctrlKey&&special!=="meta")modif+="meta+";if(event.shiftKey&&special!=="shift")modif+="shift+";if(special)possible[modif+special]=true;else{possible[modif+character]=true;possible[modif+jQuery.hotkeys.shiftNums[character]]=
true;if(modif==="shift+")possible[jQuery.hotkeys.shiftNums[character]]=true}for(var i=0,l=keys.length;i<l;i++)if(possible[keys[i]])return origHandler.apply(this,arguments)}}jQuery.each(["keydown","keyup","keypress"],function(){jQuery.event.special[this]={add:keyHandler}})})(jQuery);(function($){$.fn.loadingMsg=function(msg,cssDiv,cssH1){$div=$("<div>").css(cssDiv);$h1=$("<h1>").css("background","white").css(cssH1).text(msg);$div.append($h1);return $(this).append($div)}})(jQuery);
(function($){$.fn.modalWindow=function(param){return $(this).click(function(){$(param.place).append($("<div>").css(param.css).append(param.data).append($(param.msg).css({cursor:"pointer"}).click(function(){$($(this).parent()).remove()})).corner());return false})}})(jQuery);
(function($){$.fn.helpTip=function(msg,style,position){if($(this).data("binded"))return $(this);if(!style)style={};if(typeof position=="undefined")position={lr:"center",tb:"topAll"};$(this).data("binded",true).data("lr",position.lr).data("tb",position.tb).data("$div",$("<div>").css(style).css({opacity:0,position:"absolute",zIndex:"1000"}).corner().append(msg)).append($(this).data("$div")).bind("centering",function(){$div=$(this).data("$div");var magic=parseInt($div.css("paddingLeft"),10)+parseInt($div.css("paddingRight"),
10);var magic2=parseInt($div.css("paddingBottom"),10);var left,top;var lr=$(this).data("lr");if(lr=="center")left=$(this).position().left+($(this).width()-$div.width()-magic)/2;else if(lr=="left")left=$(this).position().left;else if(lr=="leftAll")left=$(this).position().left-$div.width();else if(lr=="right")left=$(this).width()-$div.width();else if(lr=="rightAll")left=$(this).width();else if(parseInt(lr,10)!=Number.NaN)left=parseInt(lr,10);var t=$(this).position().top;var tb=$(this).data("tb");if(tb==
"top")top=t-$div.height()-magic2;else if(tb=="topAll")top=t-$div.height()-magic2;else if(tb=="center")top=t+($(this).height()-$div.height())/2-magic2;else if(tb=="bottom")top=t+$(this).height()-$div.height();else if(tb=="bottomAll")top=t+$(this).height();$div.css({left:left,top:top})}).mouseover(function(){$div=$(this).data("$div");$div.css({opacity:0.6});$(this).trigger("centering")}).mouseout(function(){$(this).data("$div").css({opacity:0})}).data("mousemoveTimer",-1).mousemove(function(){$(this).trigger("centering")});
return $(this)}})(jQuery);(function($){$.fn.menu=function(){$divs=$(this).find("div");if(!$.browser.msie)$divs.corner("bottom");var reg=[];for(var i in $divs)reg.push($(i).attr("reg"));reg=reg.join("|");$self=$(this);$.Router.bind(reg,function(hash){$self.trigger("setActive",[hash])});$(this).bind("setActive",function(th,hash){$("#debug").append("<div>"+hash+"</div>");var $divs=$(this).find("div");for(var i=0;i<$divs.length;i++)if((new RegExp($($divs[i]).attr("reg"),"ig")).exec(hash)!=null){if(!$($divs[i]).hasClass("active"))$($divs[i]).addClass("active")}else $($divs[i]).removeClass("active")})}})(jQuery);
(function($){$.fn.content=function(){$(this).data("destr",function(){}).data("src","").bind("setContent",function(th,src,duration,soft){$(this).stop(true,true).animate({opacity:0},duration,function(){if($(this).data("soft"))$(this).get(0).innerHTML="";$(this).empty().data("src",src).animate({opacity:1},duration).append(src).data("soft",soft)})})}})(jQuery);
(function($){$.fn.slider=function(obj){var self=this;this._init=function(obj){$(this).data("binded",true).data("isHoriz",obj.isHoriz).data("Data",obj.Data).data("img",{W:obj.imgW,H:obj.imgH}).data("slider",{W:obj.W,H:obj.H}).data("setAt",obj.setAt).data("mouse",{down:false}).mouseenter(function(){if($(this).data("slider")["W"]<$(this).data("$content").width()||$(this).data("slider")["H"]<$(this).data("$content").height())self.sliderShow()}).mouseleave(function(){self.sliderHide()}).data("$html",$("<div>").addClass("RGall_Slider").disableTextSelect().css({width:eval($(this).data("slider").W),
height:eval($(this).data("slider").H),overflow:"hidden"}).appendTo($(this)).animate({scrollLeft:0},{duration:0})).data("$content",$("<div>").addClass("sliderContent").disableTextSelect().appendTo($(this).data("$html"))).data("$sliderBar",$("<div>").hide().addClass("sliderBar").disableTextSelect().css({cursor:"pointer",background:"#EEEEEE",position:"absolute",zIndex:2}).appendTo($.browser.msie?$(this):$(this).data("$html")).corner()).data("$sliderButton",$("<div>").addClass("sliderButton").disableTextSelect().css({cursor:"pointer",
background:"gray",position:"absolute",zIndex:3,opacity:0.2}).mousedown(function(e){$(self).data("mouse",{down:true});$(this).css("background","#454545")}).mouseup(function(e){$(self).data("mouse",{down:false});$(this).css("background","gray");return false}).appendTo($(this).data("$sliderBar")).corner());var self=this;$("body").mouseup(function(e){$ob=$(self).data("$sliderButton");if(typeof $ob!="undefined")$ob.trigger("mouseup")});if($(this).data("isHoriz"))this._initHoriz();else this._initVertical()};
var addScrollOnHover=function($obj,condition,time){$obj.data("scroll_interval",-1).mouseover(function(){$(this).data("scroll_interval",setInterval(function(){$(self).stop(true,false).data("$html").animate(condition,time)},200))}).mouseout(function(){var l=$(this).data("scroll_interval");if(l>=0){clearInterval($(this).data("scroll_interval"));$(this).data("scroll_interval",-1)}})};this._initHoriz=function(){$(this).data("$content").css({width:$(self).data("img").W*$(self).data("Data").length,height:$(self).data("slider").H});
$(this).data("$sliderLeft",$("<div>").css({position:"absolute",zIndex:2,background:"url(App_Themes/default/pics/imgs.png) no-repeat -"+131+"px 0px",width:36,height:90,top:-5,left:-20})).data("$sliderRight",$("<div>").css({position:"absolute",zIndex:2,background:"url(App_Themes/default/pics/imgs.png) no-repeat -"+168+"px 0px",width:36,height:90,top:-5,left:$(self).data("$html").width()-15}));addScrollOnHover($(this).data("$sliderLeft"),{scrollLeft:"-=40"},{duration:220,easing:"linear"});addScrollOnHover($(this).data("$sliderRight"),
{scrollLeft:"+=40"},{duration:220,easing:"linear"});$(this).data("$sliderLeft").add($(this).data("$sliderRight")).appendTo($.browser.msie?$(this):$(this).data("$html"));var topBar=$.browser.msie?$(this).height()-24:$(self).data("$content").height()-24;$(this).data("$sliderBar").css({width:$(self).data("slider").W,height:4,top:eval(topBar),left:0}).click(function(e){var left=e.pageX-$(this).offset().left-$(self).data("$sliderButton").width()/2;left*=$(self).data("$content").width()/$(self).data("$html").width();
$(self).data("$html").animate({scrollLeft:left},{duration:200,easing:"linear"})});var sliderW=$(this).data("slider").W;var w=Math.pow(sliderW,2)/($(this).data("img").W*$(this).data("Data").length);if(w>sliderW||w<0)w=sliderW;$(this).data("$sliderButton").css({width:w,height:14,top:-5}).mousedown(function(e){var left=e.pageX-$(self).data("$html").offset().left-$(this).width()/2;left*=$(self).data("$content").width()/$(self).data("$html").width();$(self).data("$html").animate({scrollLeft:left},{duration:120,
easing:"linear"})});$("body").mousemove(function(e){if(typeof $(self).data("mouse")!="undefined"&&$(self).data("mouse").down){var $html=$(self).data("$html");var left=e.pageX-$html.offset().left-$(self).data("$sliderButton").width()/2;left*=$(self).data("$content").width()/$html.width();$html.stop(true,true).animate({scrollLeft:left},{duration:50,easing:"linear"})}});$(this).data("$html").mousewheel(function(e,dir){$(this).stop(false,false).animate({scrollLeft:eval($(this).scrollLeft()-100*dir)},
{duration:200,easing:"linear"});return false}).scroll(function(){self.initPic({left:$(this).scrollLeft()});$(self).data("$sliderButton").css({left:eval($(this).scrollLeft()*$(this).width()/$(self).data("$content").width())})});var data=$(this).data("Data");if(typeof data=="undefined"||data.length==0)return $(this);for(var i=0;i<data.length;i++){var $span=$("<span>").helpTip($(data[i]).data("name").replace(/_+/g," "),{whiteSpace:"nowrap",color:"black",background:"#FFFFFF",font:"normal normal normal 12px Helvetica, sans-sefif",
padding:"5px 10px 5px 10px"},{lr:"left",tb:"top"}).disableTextSelect().css({display:"block","float":"left",width:eval($(this).data("img").W),height:eval($(this).data("img").H)}).append($(data[i]).data("$img").disableTextSelect());$(this).data("$content").append($span)}$(this).trigger("setAtFunc",[$(this).data("setAt")])};this._initVertical=function(){var magicTop=50;$(this).data("$content").css({width:$(self).data("slider").W,height:$(self).data("img").H*$(self).data("Data").length});$(this).data("$sliderTop",
$("<div>").css({position:"absolute",zIndex:20,background:"url(App_Themes/default/pics/imgs.png) no-repeat 0px -"+35+"px",width:125,height:37,top:magicTop,left:-5})).data("$sliderBotton",$("<div>").css({position:"absolute",zIndex:20,background:"url(App_Themes/default/pics/imgs.png) no-repeat 0px -"+72+"px",width:125,height:37,top:$(self).data("slider").H+40,left:-5}));addScrollOnHover($(this).data("$sliderTop"),{scrollTop:"-=60"},{duration:220,easing:"linear"});addScrollOnHover($(this).data("$sliderBotton"),
{scrollTop:"+=60"},{duration:220,easing:"linear"});$(this).data("$sliderTop").add($(this).data("$sliderBotton")).appendTo($.browser.msie?$(this):$(this).data("$html"));var rightBar=3;$(this).data("$sliderBar").css({width:4,height:$(self).data("slider").H,top:magicTop+20,left:eval(rightBar)}).click(function(e){var top=e.pageY-$(this).offset().top-$(self).data("$sliderButton").height()/2;top*=$(self).data("$content").height()/$(self).data("$html").height();$(self).data("$html").animate({scrollTop:top},
{duration:200,easing:"linear"})});var sliderH=$(this).data("slider").H;var h=Math.pow(sliderH,2)/($(this).data("img").H*$(this).data("Data").length);if(h>sliderH||h<0)h=sliderH;$(this).data("$sliderButton").css({width:10,height:h,left:-3}).mousedown(function(e){var top=e.pageY-$(self).data("$html").offset().top-$(this).height()/2;top*=$(self).data("$content").height()/$(self).data("$html").height();$(self).data("$html").animate({scrollTop:top},{duration:120,easing:"linear"})});$("body").mousemove(function(e){if(typeof $(self).data("mouse")!=
"undefined"&&$(self).data("mouse").down){var $html=$(self).data("$html");var top=e.pageY-$html.offset().top-$(self).data("$sliderButton").height()/2;top*=$(self).data("$content").height()/$html.height();$html.stop(true,true).animate({scrollTop:top},{duration:50,easing:"linear"})}});$(this).data("$html").mousewheel(function(e,dir){$(this).stop(false,false).animate({scrollTop:eval($(this).scrollTop()-120*dir)},{duration:200,easing:"linear"});return false}).scroll(function(){self.initPic({top:$(this).scrollTop()});
$(self).data("$sliderButton").css({top:eval($(this).scrollTop()*$(this).height()/$(self).data("$content").height())})});var data=$(this).data("Data");if(typeof data=="undefined"||data.length==0)return $(this);for(var i=0;i<data.length;i++){var $div=$("<div>").helpTip($(data[i]).data("name").replace(/_+/g," "),{whiteSpace:"nowrap",color:"black",background:"#DDDDFF",font:"normal normal normal 14px Helvetica, sans-sefif",padding:"5px 10px 5px 10px"},{lr:"rightAll",tb:"center"}).disableTextSelect().css({display:"block",
width:eval($(this).data("img").W),height:eval($(this).data("img").H)}).append($(data[i]).data("$img").disableTextSelect());$(this).data("$content").append($div)}$(this).trigger("setAtFunc",[$(this).data("setAt")])};$(this).data("wasSetAtFunc",false);$(this).bind("setAtFunc",function(event,setAt){if(setAt===null)return false;var isHoriz=$(this).data("isHoriz");var imgWH=isHoriz?$(this).data("img").W:$(this).data("img").H;var sliderWH=isHoriz?$(this).data("slider").W:$(this).data("slider").H;var scrollTo=
setAt*imgWH-(sliderWH-imgWH)/2;if(isHoriz&&scrollTo<0)scrollTo=0;if(isHoriz&&!$(this).data("wasSetAtFunc")){$(this).data("wasSetAtFunc",true);$(this).data("$html").scrollLeft(scrollTo)}else{var css=isHoriz?{scrollLeft:eval(scrollTo)}:{scrollTop:eval(scrollTo)};$(this).data("$html").animate(css,{duration:300,easing:"linear"})}self.initPic({id:setAt})});this.initPic=function(obj){var needCount=$(this).data("isHoriz")?Math.floor($(this).data("$html").width()/$(this).data("img").W)+4:Math.floor($(this).data("$html").height()/
$(this).data("img").H)+4;var first=obj.left?Math.floor(obj.left/$(this).data("img").W)-1:obj.top?Math.floor(obj.top/$(this).data("img").H)-1:Math.floor(obj.id-needCount/2);var data=$(this).data("Data");if(first<0)first=0;else if(first>data.length)first=data.legnth-needCount;for(var i=first;i<first+needCount;i++)if(data[i])$(data[i]).trigger("init")};$(this).data("sliderHideTimer",-1);this.sliderHide=function(){var timer=$(self).data("sliderHideTimer");if(!$(self).data("mouse").down){if(timer!=-1){clearTimeout(timer);
$(self).data("sliderHideTimer",-1)}$(self).data("$sliderBar").hide(200)}else{if(timer!=-1)clearTimeout(timer);$(self).data("sliderHideTimer",setTimeout(function(){self.sliderHide()},100))}};this.sliderShow=function(){$(self).data("$sliderBar").stop(true,true).show(200)};if($(this).data("binded")==true)$(this).unbind().stop(true,true).data("binded",false).animate({opacity:"0"},300,function(){$(this).data("$html").get(0).innerHTML="";$(this).empty().removeData().slider(obj).animate({opacity:1},300)});
else this._init(obj);return $(this)}})(jQuery);
(function($){$.fn.filter=function(funcSearch,funcInit){this.filterFunc=funcSearch;this.filterInit=funcInit;this.$keyword=$(this).find(".inputs input");this.filter=function(keyword){var obj=[];var filter_op=$(this).find(".filter_option");for(var i=0;i<filter_op.length;i++)obj[$(filter_op[i]).attr("key")]=$(filter_op[i]).find("input").attr("checked");if(typeof keyword!="undefined")obj["word"]=keyword;else if(this.$keyword.val()!=this.$keyword.attr("help_value"))obj["word"]=this.$keyword.val();var sort_op=
$(this).find(".sort_options");obj["sortBy"]=sort_op.find(":selected").text();this.filterFunc(obj)};var self=this;this.keywordLast="";this.$keyword.attr("help_value",this.$keyword.attr("value")).click(function(){self.filterInit();if($(this).attr("value")==$(this).attr("help_value"))$(this).attr("value","")}).focusout(function(){if($(this).attr("value")=="")$(this).attr("value",$(this).attr("help_value"))});setInterval(function(){var t=self.$keyword;t.trigger("change");if(self.keywordLast!=t.val()&&
t.val()!=t.attr("help_value")){self.keywordLast=t.val();self.filter()}},1E3);$(this).find(".sort_options select").change(function(){self.filter()});$(this).find(".filter_option").find("span").click(function(){$input=$($(this).parent()).find("input");$input.attr("checked",!$input.attr("checked"));self.filter()}).end().find("input").click(function(){self.filter()})}})(jQuery);
(function($){$.fn.tableView=function(collectionName,arr){$(this).empty().css("paddingLeft",200).append($("<div>").css({background:"white",color:"gray",textAlign:"center",fontSize:"40px",padding:"20px",fontFamily:"Helvetica"}).append(collectionName.replace(/_+/g," ")).append($(" <sup> collection </sup>").css("fontSize","0.5em")));$cont=$("<div>").css("paddingLeft","20px");$(this).append($cont);for(var i=0;i<arr.length;i++){size=$(arr[i]).data("$img").data("sizeFull");$("<div>").css({"float":"left",
width:size.W,height:size.H}).helpTip($(arr[i]).data("name").replace(/_+/g," "),{whiteSpace:"nowrap",color:"black",background:"#DDDDFF",font:"normal normal normal 14px Helvetica, sans-sefif",padding:"5px 20px 5px 20px"}).append($(arr[i]).data("$img")).appendTo($cont);$(arr[i]).trigger("init")}return $(this)}})(jQuery);
(function($){$.fn.itemView=function(){return $(this).bind("setContent",function(e,slider,collection,item,image,positionInSlider){$(this).get(0).innerHTML="";$(this).empty();var $all=$("<div>").attr("class","itemView");var $sliderContainer=$("<div>").css({"float":"left","padding-top":20});var $slider=$("<div>").width(200).slider({Data:slider,imgW:120,imgH:120,W:120,H:460,isHoriz:false,setAt:positionInSlider});$sliderContainer.append($slider);$info=$("<div>").css({"float":"left"});$infoCol=$("<div>").css({background:"white",
width:240,height:170,"padding-top":20});$infoItem=$("<div>").css({background:"white",width:240,height:330});$infoCol.add($infoItem).css({"padding-left":10});$info.append($infoCol).append($infoItem);$divImage=$("<div>").css({width:500,height:500,overflow:"hidden"}).click(function(){RGall.setStateByMove("item",1)}).mousewheel(function(e,dir){RGall.setStateByMove("view",-dir);return false});$video=$("<div>");$diagram=$("<div>");$comment=$("<div>").css({background:"white",padding:"0 0 0 20px",opacity:0.7}).mouseenter(function(){$(this).css("opacity",
1)}).mouseleave(function(){$(this).css("opacity",0.7)});$all.append($sliderContainer).append($info).append($divImage).append($video).append($diagram).append($comment);$(this).append($all);$infoCol.append($("<h1>").append(collection.name.replace(/_+/g," ")).append($("<sup>").text(" [collection]"))).append("<p>"+collection.date.getDate()+"/"+(date.getMonth()+1)+"/"+collection.date.getFullYear()+"</p>"+"<br />").append("<p>"+collection.description+"</p>");$(this).data("$slider",$slider).data("$infoCol",
$infoCol).data("$infoItem",$infoItem).data("$divImage",$divImage).data("$video",$video).data("$diagram",$diagram).data("$comment",$comment).data("commentID",collection.id);$(this).trigger("setItem",[item,image,positionInSlider])}).bind("setItem",function(e,item,image,positionInSlider){var $di2=$(this).data("$diagram").slideDown(400,function(){$(this).empty()});var $infoItem=$(this).data("$infoItem").empty();var diagramAndVideo=$("<p>");if(item.diagram)diagramAndVideo.append($("<a>").attr("href",item.diagram).text("diagram").click(function(){if($(this).data("appended")){$("html,body").animate({scrollTop:$di2.offset().top},
500);return false}$(this).data("appended",true);$di2.append($("<div>").css("textAlign","center").append($("<div>").addClass("loading").append($("<h1>").text("Loading..."))).append($(new Image).load(function(){$di2.find("div.loading").remove();$("html,body").animate({scrollTop:$di2.offset().top},500)}).attr("src",item.diagram+"#"+Math.random()).css("maxWidth",950)).slideUp(400));return false}));if(item.diagram!=""&&item.video!="")diagramAndVideo.append(" or ");if(item.video!="")diagramAndVideo.append($("<a>").attr("href",
item.video).text("video")).modalWindow({place:"#content",data:item.video,msg:$("<h1> Close video</h1>").css({paddingTop:15,fontSize:32,color:"white",textAlign:"center"}),css:{background:"gray",opacity:0.5,position:"absolute",zIndex:100,padding:25,left:200,top:10}});$infoItem.append("<h1>"+item.name.replace(/_+/g," ")+" <sup> [model] </sup></h1>").append($("<p>").append(item.date.getDate()+"/"+(item.date.getMonth()+1)+"/"+item.date.getFullYear())).append("<br />").append(item.description!=""?$("<p>").html(item.description):
"").append("<br />").append(diagramAndVideo).append(diagramAndVideo.find("a").length>0?"<br />":"").append($("<p>").append("pieces: "+item.pieces)).append($("<p>").append("connection: "+item.connection)).append($("<p>").append("folder: "+item.folder));$(this).trigger("setView",[image,positionInSlider])}).bind("setView",function(e,image,positionInSlider){$(image).trigger("init");$(this).data("$divImage").stop(true,true).animate({opacity:0},400,function(){$(this).empty().animate({opacity:1},200).append($(image).data("$img"))});
$(this).trigger("sliderSetAt",[positionInSlider])}).bind("sliderSetAt",function(e,pos){if(pos==null)return;$(this).data("$slider").trigger("setAtFunc",[pos])}).bind("setComments",function(e,time){var $self=$(this);setTimeout(function(){$self.data("$comment").empty();(function(){var e=document.createElement("script");e.src=document.location.protocol+"//connect.facebook.net/en_US/all.js";e.async=true;document.getElementById("fb-root").appendChild(e)})();$self.data("$comment").append('<fb:comments xid="'+
$self.data("commentID")+'" numposts="10" width="920"  simple\t= \'true\' reverse =\'true\' send_notification_uid=100001045748645></fb:comments>')},time)})}})(jQuery);
(function($){$._Router=function(Eventers){var self=this;this._map=[];this.hash=document.location.hash;this.init=function(){self.hash="#";setInterval(self.recheck,150)};this._block=false;this.block=function(){self._block=true};this.unblock=function(){self._block=false};this.isBlock=function(){return self._block};this.hashChanged=function(){for(var i=0;i<self._map.length;i++)if(self._map[i].reg.exec(self.hash)!=null)if(self._map[i].func(self.hash)===false)break};this.setHash=function(new_hash){self.block();
if(document.location.hash!=new_hash){document.location.hash=new_hash;self.hash=new_hash;self.hashChanged()}self.unblock()};this.recheck=function(){if(!self.isBlock()){var new_hash=document.location.hash;if(new_hash!=self.hash){self.hash=new_hash;self.hashChanged()}}};this.bind=function(regex,callback){self._map.push({reg:new RegExp(regex,"i"),func:callback});if(self._map[self._map.length-1].reg.exec(self.hash)!=null)return self.hash;return false};this.getHash=function(){return document.location.hash};
this.init()};$.Router=new $._Router})(jQuery);(function($){$.fn.postImageLoader=function(s,styles){if(!$(this).hasClass("postImageLoaderLoaded")){$(this).addClass("postImageLoaderLoaded");var $objs=$(this).find(s);for(var i=0;i<$objs.length;i++)$($objs[i]).append($("<img>").css(styles).attr("src",$($objs[i]).attr("src")))}return $(this)}})(jQuery);
Core={_log:null,_err:null,_events:null,init:function(){if(Core.Log){Core._log=new Core.Log;Core.Send.log("Core.init()","Loger inited")}if(Core.Events){Core._events=new Core.Events;Core.Send.log("Core.init()","Events inited")}if(Core.Err){Core._err=new Core.Err;Core.Send.log("Core.init()","Err inited")}},printLog:function($out){if(this._log)this._log.connectWith($out)},Send:{log:function(caller,descr,type){if(Core._log!=null)Core._log.add({caller:caller,descr:descr,type:type?type:"log"})},error:function(caller,
descr){Core.Send.log(caller,descr,"error")},critical:function(caller,descr){Core.Send.log(caller,descr,"critical");throw new Error("Critical Error!    \n\n"+caller+" \n>> "+descr);}}};
Core.Log=function(){this._msgs=[];this._$out=null;this._Msg=function(time,type,caller,descr){this.time=time;this.type=type;this.caller=caller;this.descr=descr};this.add=function(msg){date=new Date;this._msgs.push(new this._Msg(date.getHours()+":"+date.getMinutes()+":"+date.getSeconds()+" ("+date.getDate()+"/"+(date.getMonth()+1)+"/"+date.getYear()+")",msg.type,msg.caller,msg.descr));var t=this._msgs[this._msgs.length-1];if(this._$out!=null)this._$out.prepend("<h4>"+t.type+"<span>"+t.time+"</span>"+
' : </h4> <h3 class="'+t.type+'">'+t.caller+" >> "+t.descr+"</h3>")};this.connectWith=function($out){this._$out=$out;for(var i=0;i<this._msgs.length;i++){var t=this._msgs[i];this._$out.prepend("<h4>"+t.type+"<span>"+t.time+"</span>"+' : </h4> <h3 class="'+t.type+'">'+t.caller+" >> "+t.descr+"</h3>")}}};
Core.Events=function(){this.groups=[];this.Group=function(groupName){return{$obj:$({}),name:groupName,events:[]}};this.Event=function(eventName){return{name:eventName,callsCounter:0,bindCounter:0}};this.getGroupId=function(group){for(var i=0;i<this.groups.length;i++)if(this.groups[i].name==group)return i;return'there is not group: "'+group+'"'};this.getEventID=function(group,event){var groupID=this.getGroupId(group);if(typeof groupID=="string")return groupID;for(var i=0;i<this.groups[groupID].events.length;i++)if(this.groups[groupID].events[i].name==
event)return{group:groupID,event:i};return'there is not event: "'+event+'" in group: "'+group+'"'};this.addGroup=function(group){var gr=this.getGroupId(group);if(typeof gr!="string")Core.Send.error("Core.Events.addGroup()","there is already group with name: "+gr);else this.groups.push(this.Group(group));return group};this.addEvent=function(group,event){var gr=this.getGroupId(group);if(typeof gr=="string"){Core.Send.error("Core.Events.addEvent()",gr);return false}else this.groups[gr].events.push(this.Event(event));
return event};this.bind=function(group,event,func){var IDs=this.getEventID(group,event);if(typeof IDs=="string"){Core.Send.error("Core.Events.bind()",IDs);return false}var t=this.groups[IDs.group];t.events[IDs.event].bindCounter++;t.$obj.bind(event,func)},this.emit=function(group,event){var IDs=this.getEventID(group,event);if(typeof IDs=="string"){Core.Send.error("Core.Events.bind()",IDs);return false}var t=this.groups[IDs.group];t.events[IDs.event].callsCounter++;t.$obj.trigger(event)}};
RGall={$slider:{},_col_all:[],_col_mask:[],_col_sorted:[],query:[],currentSortBy:"name",currentFilterBy:"",_refreshSlider:function(col,setAt){RGall.$slider.slider({Data:col,imgW:90,imgH:90,W:600,H:100,isHoriz:true,setAt:setAt})},_parseQuery:function(str){var query=str.split("#");var col=query[1].split("/");var vi=false,di=false;if(query[2]){var filter=query[2].split(",");vi=filter[0]=="vi"||filter[1]=="vi";di=filter[0]=="di"||filter[1]=="di"}return{col:col[1],item:col[2],view:col[3],video:vi,diagram:di}},
_getCollectionID:function(name){for(var i=0;i<RGall._col_all.length;i++)if($(RGall._col_all[i]).data("name")==name)return i;return-1},_block:false,isBlock:function(){return RGall._block},block:function(){RGall._block=true},unblock:function(){RGall._block=false},setStateByIds:function(id){},setStateByMove:function(move,dir){var ID=0;for(var i=0;i<RGall._col_sorted.length;i++)if($(RGall._col_sorted[i]).data("name")==RGall.query["col"]){ID=i;break}if(move=="collection"){ID+=dir;if(ID>=0&&ID<RGall._col_sorted.length)$.Router.setHash("/"+
$(RGall._col_sorted[ID]).data("name"));return}if(move=="item"||move=="view"){RGall._col_sorted[ID].setStateByMove(move,dir);return}throw"RGall.setStateByMove move = "+move+" this is very very bad";},setStateByAddress:function(str){var query=RGall._parseQuery(str);RGall.query=query;if(query["col"]==""||query["col"]=="!rand!"){var rand_id=RGall.G.rand(RGall._col_sorted.length);$.Router.setHash("/"+$(RGall._col_sorted[rand_id]).data("name")+RGall.G.makeValideAddress([query["item"],query["view"]]));return}var id=
RGall._getCollectionID(query["col"]);if(id==-1){var names=[];for(var i=0;i<RGall._col_all.length;i++)names.push(RGall._col_mask?$(RGall._col_all[i]).data("name"):false);id=RGall.G.minHemming(query["col"],names);$.Router.setHash("/"+$(RGall._col_all[id]).data("name")+RGall.G.makeValideAddress([query["item"],query["view"]]))}else{var realID=$(RGall._col_all[id]).data("id");for(var i=0;i<RGall._col_all.length;i++)if(i!=id)RGall._col_all[i].deselect();var IDinSorted=-1;for(var i=0;i<RGall._col_sorted.length;i++)if($(RGall._col_sorted[i]).data("id")==
realID){IDinSorted=i;break}if(IDinSorted==-1)IDinSorted=0;if($(RGall._col_all[id]).data("id")!=$(RGall._col_sorted[IDinSorted]).data("id")){$.Router.setHash("/"+$(RGall._col_sorted[IDinSorted]).data("name"));return}RGall.$slider.trigger("setAtFunc",[IDinSorted]);RGall._col_all[id].select(query)}},init:function(obj){if(obj==null)Core.Send.critical({caller:"RGall.init(param)",descr:"param is null, but it must be list of strings.."});RGall.$slider=$("#slider");for(var i=0;i<obj.length;i++){var tmp={id:obj[i].id,
n:obj[i].n,d:"",de:"",di:obj[i].di,vi:obj[i].vi};RGall._col_all.push(new RGall.Collection(tmp))}RGall._col_sorted=RGall.G.sort(RGall._col_all,"name");Core.Send.log("RGall.init()","there are "+RGall._col_all.length+" collections");$("#filter").filter(RGall.filter,RGall.initItemsNames);RGall.$slider.slider({Data:RGall._col_sorted,imgW:90,imgH:90,W:600,H:100,isHoriz:true,setAt:null});var hash=$.Router.bind("#/.*",RGall.setStateByAddress);if(hash)RGall.setStateByAddress(hash)},wasInitItemsNames:false,
initItemsNames:function(){if(RGall.wasInitCollectionsItemsName)return;RGall.wasInitCollectionsItemsName=true;$.getJSON("/getJSonItemsName.aspx",function(data){for(var i=0;i<data.length;i++)for(var k=0;k<RGall._col_all.length;k++)if($(RGall._col_all[k]).data("id")==data[i].id){RGall._col_all[k].initModelsName(data[i].n);break}})},sort:function(activeCollections,sortBy){RGall._col_sorted=RGall.G.sort(activeCollections,sortBy);var ActiveID=-1;for(var i=0;i<RGall._col_sorted.length;i++)if($(RGall._col_sorted[i]).data("isSelected")){ActiveID=
i;break}if(ActiveID==-1){RGall._refreshSlider(RGall._col_sorted,0);$.Router.setHash("/"+$(RGall._col_sorted[0]).data("name"));return}RGall._refreshSlider(RGall._col_sorted,ActiveID);RGall._col_sorted[i].select({})},filter:function(expr){if(typeof expr=="undefined")Core.Send.critical("RGall.filter(expr)","expr cannot be a undefined");Core.Send.log("RGall.filter(expr)","called filter with values word = '"+expr["word"]+"', video = "+expr["video"]+", diagram = "+expr["diagram"]);RGall.currentFilterBy=
expr;var all=RGall._col_all;var mask=[];for(var i=0;i<all.length;i++)mask.push(!(!$(all[i]).data("diagram")&&expr["diagram"]||!$(all[i]).data("video")&&expr["video"]||!all[i].hasWord(expr["word"])&&expr["word"]));RGall.currentSortBy=expr["sortBy"];var need=[];for(var i=0;i<all.length;i++)if(mask[i])need.push(RGall._col_all[i]);RGall.sort(need,RGall.currentSortBy)},G:{Col:{opacity:0.7,smallWH:0.85,hoverWH:0.9},makeValideAddress:function(names){var result="";var bool=false;for(var i=names.length-1;i>=
0;i--){if(typeof names[i]!="undefined"&&names[i]!="")bool=true;if(bool)result="/"+(typeof names[i]=="undefined"?"":names[i])+result}return result},sort:function(need_array,sortBy){return need_array.sort(function(a,b){var a_arg=$(a).data(sortBy);var b_arg=$(b).data(sortBy);return a_arg<b_arg?-1:a_arg>b_arg?1:0})},gallery:"http://kusudama.me/gallery/",rand:function(i){return Math.floor(Math.random()*i)},minHemming:function(val,vals){var min=Number.POSITIVE_INFINITY;var id=-1;for(var i=0;i<vals.length;i++){var now=
Math.abs(val.length-vals[i].length);if(min<now)continue;for(var k=0;k<Math.min(val.length,vals[i].length);k++)if(val[k]!=vals[i][k])now++;if(now<min){id=i;min=now;if(min==0)break}}return id}}};
RGall.Collection=function(param){Core.Send.log("RGall.Collection","created with name: "+param.n);$(this).data("id",param.id).data("name",param.n).data("date",param.d).data("descr",param.de).data("diagram",param.di).data("video",param.vi).data("$img",$(new Image).css("opacity",0)).data("items",null).data("itemsName",[]).data("inited",false).data("isSelected",false);var self=this;this.hasWord=function(word){if(word){var myRe=new RegExp(word,"ig");if(myRe.exec($(this).data("name"))!=null)return true;
var names=$(this).data("itemsName");for(var i=0;i<names.length;i++)if(myRe.exec(names[i])!=null)return true;return false}return true};$(this).data("init",function(){if($(this).data("inited"))return this;$(this).data("inited",true);Core.Send.log("RGall.Collection.init()","inited collection: "+$(this).data("name"));$(this).data("$img").attr("src",RGall.G.gallery+$(this).data("name")+"/"+"default.jpg#"+Math.random());$(this).data("$img").css({opacity:0,cursor:"pointer"}).error(function(){Core.Send.error("RGall.Collection.init() ",
"Can't load picture: "+$(this).attr("src"))}).load(function(){var w=$(this).width();var h=$(this).height();var sCoef=RGall.G.Col.smallWH;var hCoef=RGall.G.Col.hoverWH;$(this).data("base",{W:w,H:h}).data("small",{W:w*sCoef,H:h*sCoef}).data("hover",{W:w*hCoef,H:h*hCoef});var size=$(self).data("isSelected")?$(this).data("base"):$(this).data("small");$(this).css({width:size.W,height:size.H}).animate({opacity:$(self).data("isSelected")?1:RGall.G.Col.opacity},400)}).mouseover(function(){if(!$(self).data("isSelected")){var size=
$(this).data("hover");$(this).stop(true,true).animate({opacity:1,width:size.W,height:size.H},250)}}).mouseout(function(){if(!$(self).data("isSelected")){var size=$(this).data("small");$(this).animate({opacity:RGall.G.Col.opacity,width:size.W,height:size.H},250)}}).click(function(){$.Router.setHash("/"+$(self).data("name"))});return this});this.initModelsName=function(names){$(self).data("itemsName",names)};this.initing=false;this.initModels=function(query){if($(this).data("items")){if(!query.item)this.showAllItems();
else this.showItem(query);return}var $div=$("<div>").loadingMsg("loading...",{height:"300!important"},{fontSize:25,textAlign:"center","margin-left":300,"padding-top":40,color:"#CCCCCC"}).css("opacity",0);setTimeout(function(){$div.animate({opacity:1},400)},1E3);$("#content").trigger("setContent",[$div,200,false]);if(this.initing)return;this.initing=true;RGall.block();$(this).data("items",[]);$.getJSON("/getJSonCollection.aspx?collection="+$(this).data("name"),function(sData){var date=sData["date"];
$(self).data("date",new Date(date.Y,date.M,date.D)).data("descr",sData["text"]);var arr=[];for(var i=0;i<sData["kusudamas"].length;i++){sData["kusudamas"][i].collection=$(self).data("name");sData["kusudamas"][i].info=sData["info"];arr.push(new RGall.Item(sData["kusudamas"][i]))}$(self).data("items",arr);RGall.unblock();self.filterAndSortItems();if(!query.item)self.showAllItems();else self.showItem(query);this.initing=false})};this.fulfilCondition=function(it,cond){if(cond["diagram"]&&$(it).data("diagram")==
"")return false;if(cond["video"]&&$(it).data("video")=="")return false;if(cond["word"]&&!($(it).data("name")+$(this).data("name")).toLowerCase().match(cond["word"].toLowerCase()))return false;return true};this.filterAndSortItems=function(){var items=$(this).data("items");var sortItems=[];for(var i=0;i<items.length;i++){if(!this.fulfilCondition(items[i],RGall.currentFilterBy))continue;sortItems.push(items[i])}sortItems=RGall.G.sort(sortItems,RGall.currentSortBy);$(this).data("sortedItems",sortItems)};
this._deselectAllItems=function(except){var positionInSlider=-1;var $items=typeof except=="undefined"?$(this).data("items"):$(this).data("sortedItems");if(typeof except=="undefined"||!except)except={itemID:-1,viewID:-1};for(var i=0,counter=0;i<$items.length;i++){var $views=$($items[i]).data("views");for(var k=0;k<$views.length;k++){if(i!=except.itemID||k!=except.viewID)$($($views[k]).data("Preview")).trigger("deselect");else{positionInSlider=counter;if(!$(this).data("showItemPrevQuery"))$($($views[k]).data("Preview")).trigger("deselect")}counter++}}return positionInSlider};
this.showAllItems=function(){$(this).data("showItemPrevQuery",false);this.filterAndSortItems();this._deselectAllItems();var itemsPreviews=[];var items=$(this).data("sortedItems");for(var i=0;i<items.length;i++){var views=$(items[i]).data("views");for(var k=0;k<views.length;k++)itemsPreviews=itemsPreviews.concat($(views[k]).data("Preview"))}$("#content").trigger("setContent",[eval($("<div>").tableView($(this).data("name"),itemsPreviews)),150,true])};this._makeValidQuery=function(query){var items=$(this).data("sortedItems");
var itemsNames=[];for(var i=0;i<items.length;i++)itemsNames.push($(items[i]).data("name"));var viewName=typeof query["view"]!="undefined"?query["view"]:"";if(query["item"]==""||query["item"]=="!rand!"){$.Router.setHash("/"+query["col"]+"/"+itemsNames[RGall.G.rand(itemsNames.length)]+"/"+viewName);return false}if(query["item"]=="!first!"||query["item"]=="!last!"){var id=query["item"]=="!first!"?0:itemsNames.length-1;$.Router.setHash("/"+query["col"]+"/"+itemsNames[id]+"/!first!");return false}var itemID=
RGall.G.minHemming(query["item"],itemsNames);if(query["item"]!=itemsNames[itemID]){$.Router.setHash("/"+query["col"]+"/"+itemsNames[itemID]+"/"+viewName);return false}var itemViewValidation=items[itemID].itemViewValidName(query["view"]);if(!itemViewValidation.valid){$.Router.setHash("/"+query["col"]+"/"+query["item"]+"/"+itemViewValidation.name);return false}return{itemID:itemID,viewID:itemViewValidation.id}};$(this).data("showItemPrevQuery",false);this.showItem=function(query){this.filterAndSortItems();
var ids=this._makeValidQuery(query);if(!ids)return;var positionInSlider=this._deselectAllItems(ids);var col={id:$(this).data("id"),name:$(this).data("name"),date:$(this).data("date"),description:$(this).data("descr")};$it=$($(this).data("sortedItems")[ids.itemID]);var item={name:$it.data("name"),date:$it.data("date"),description:$it.data("description"),folder:$it.data("folder"),connection:$it.data("connection"),pieces:$it.data("pieces"),video:$it.data("video"),diagram:$it.data("diagram")};var view=
$($it.data("views")[ids.viewID]);$(view.data("Preview")).trigger("select");if(!$(this).data("showItemPrevQuery")){var slider_items=$(this).data("sortedItems");var slider=[];for(var i=0;i<slider_items.length;i++){var views=$(slider_items[i]).data("views");for(var k=0;k<views.length;k++)slider.push($(views[k]).data("Preview"))}$(this).data("showItemDiv",$("<div>").itemView());$div=$(this).data("showItemDiv");$div.trigger("setContent",[slider,col,item,view,positionInSlider]);$("#content").trigger("setContent",
[$div,300,true]);$div.trigger("setComments",[600])}else{$div=$(this).data("showItemDiv");prevQuery=$(this).data("showItemPrevQuery");if(prevQuery.item!=query.item)$div.trigger("setItem",[item,view,positionInSlider]);else $div.trigger("setView",[view,positionInSlider])}$(this).data("showItemPrevQuery",query)};this.setStateByMove=function(move,dir){this.filterAndSortItems();var prevQuery=$(this).data("showItemPrevQuery");var items=$(this).data("sortedItems");var activeName=prevQuery.item;var itemID=
-1;for(var i=0;i<items.length;i++)if($(items[i]).data("name")==activeName){itemID=i;break}if(itemID==-1)return;if(move=="item"){itemID+=dir;if(itemID<0||itemID>=items.length){RGall.setStateByMove("collection",dir);return}$.Router.setHash("/"+prevQuery.col+"/"+$(items[itemID]).data("name")+"/"+(dir>0?"!first!":"!last!"));return}if(move=="view"){var views=$(items[itemID]).data("views");var activeName=prevQuery.view;var viewID=-1;for(var i=0;i<views.length;i++)if($(views[i]).data("name")==activeName){viewID=
i;break}if(viewID==-1)return;viewID+=dir;if(viewID<0||viewID>=views.length){this.setStateByMove("item",dir);return}$.Router.setHash("/"+prevQuery.col+"/"+prevQuery.item+"/"+$(views[viewID]).data("name"));return}else throw"RGall.Collection.setStateByMove move = "+move+"this is very bad";};this.deselect=function(){$(this).data("showItemPrevQuery",false);if($(this).data("isSelected")){$(this).data("isSelected",false);var size=$(this).data("$img").data("small");$(this).data("$img").animate({width:size.W,
height:size.H,opacity:RGall.G.Col.opacity},{duration:200})}};this.select=function(query){$(this).data("isSelected",true);this.initModels(query);var size=$(this).data("$img").data("base");if(size)$(this).data("$img").stop(true,true).animate({width:size.W,height:size.H,opacity:1},{duration:200})}};
RGall.Item=function(obj){$(this).data("CurentID",0).data("collection",obj["collection"]).data("name",obj["name"]).data("description",obj["text"]).data("folder",obj["folder"]).data("video",obj["video"]).data("diagram",obj["diagram"]).data("connection",obj["connection"]).data("pieces",obj["pices"]).data("date",new Date(obj["date"].Y,obj["date"].M,obj["date"].D)).data("info",obj["info"]);var tmp=obj["models"];var views=[];for(var i=0;i<tmp.length;i++)views.push(new RGall.ItemView({name:obj["name"]},
{src:RGall.G.gallery+obj["collection"]+"/"+obj["name"]+"/"+tmp[i]["src"]+obj["info"].lowsrc+obj["info"].format,hash:"#/"+obj["collection"]+"/"+obj["name"]+"/"+tmp[i]["src"],sizeFull:{W:120,H:120},sizeNormal:{W:"95%",H:"95%"},sizeHover:{W:"100%",H:"100%"},opacity:{normal:0.7,hover:1}},{name:tmp[i]["src"],address:RGall.G.gallery+obj["collection"]+"/"+obj["name"]+"/"+tmp[i]["src"]+obj["info"].format,size:{W:500,H:500}}));$(this).data("views",views);this.itemViewValidName=function(name){var views=$(this).data("views");
if(!name||typeof name=="undefined")name="!first!";if(name=="!first!"||name=="!last!"){var id=name=="!first!"?0:views.length-1;return{id:id,name:$(views[id]).data("name"),valid:false}}var names=[];for(var i=0;i<views.length;i++){names.push($(views[i]).data("name"));if($(views[i]).data("name")==name)return{id:i,name:name,valid:true}}if(name=="!rand!"){var i=RGall.G.rand(names.length);return{id:i,name:names[i],valid:false}}var i=RGall.G.minHemming(name,names);return{id:i,name:names[i],valid:false}}};
RGall.ItemView=function(data,preview,view){var Preview=function(data,preview){$(this).data("$img",$(new Image).css("opacity",0)).data("name",data["name"]).data("init",false).bind("select",function(){$(this).data("$img").trigger("select")}).bind("deselect",function(){$(this).data("$img").trigger("deselect")});$(this).data("$img").data("src",preview["src"]).data("hash",preview["hash"]).data("selected",false).data("sizeFull",preview["sizeFull"]).data("sizeHover",preview["sizeHover"]).data("sizeNormal",
preview["sizeNormal"]).data("opacity",preview["opacity"]).bind("select",function(){$(this).data("selected",true);var size=$(this).data("sizeFull");if($(this).width()!=0)$(this).animate({width:size.W,height:size.H,opacity:"1"},200);else $(this).css({width:size.W,height:size.H,opacity:"1"})}).bind("deselect",function(){$(this).data("selected",false);var size=$(this).data("sizeNormal");if($(this).width()!=0)$(this).animate({width:size.W,height:size.H,opacity:$(this).data("opacity")["normal"]},200);else $(this).css({width:size.W,
height:size.H,opacity:$(this).data("opacity")["normal"]})});$(this).bind("init",function(){if($(this).data("init"))return;$(this).data("init",true);var start_size=$(this).data("$img").data("selected")?$(this).data("$img").data("sizeFull"):$(this).data("$img").data("sizeNormal");$(this).data("$img").css({cursor:"pointer",width:start_size.W,height:start_size.H}).attr("src",preview["src"]+"#"+Math.random()).error(function(){return false}).load(function(){$(this).animate({opacity:$(this).data("selected")?
1:$(this).data("opacity")["normal"]},{duration:200})}).mouseover(function(){if($(this).data("selected"))return;var size=$(this).data("sizeHover");$(this).stop(true,true).animate({opacity:$(this).data("opacity")["hover"],width:size.W,height:size.H},{duration:200})}).mouseout(function(){if($(this).data("selected"))return;var size=$(this).data("sizeNormal");$(this).animate({opacity:$(this).data("opacity")["normal"],width:size.W,height:size.H},{duration:200})}).click(function(){if($(this).data("selected"))return;
$.Router.setHash($(this).data("hash"))})})};$(this).data("Preview",new Preview(data,preview));$(this).data("name",view["name"]).data("$img",$(new Image).css({opacity:0})).data("src",view["address"]).data("init",false).bind("init",function(){if($(this).data("init"))return;$(this).data("init",true);$(this).data("$img").attr("src",$(this).data("src")).error(function(){return false}).load(function(){$(this).animate({opacity:1},300)}).mouseover(function(){}).mouseout(function(){})})};
Tutorial={init:function(){$.Router.bind("^(#)?tutorial(/.*)?$",function(){var link=$.Router.getHash().split("tutorial/")[1];$links=$("#pgTutorials .links");$linksDivs=$links.children();$linksDivs.corner("top").css({"float":"left",padding:"5px 15px 4px 15px",margin:"15px 5px 0px 0px"});for(var i=0;i<$linksDivs.length;i++)if($($linksDivs[i]).find("a").attr("href")==$.Router.getHash())$($linksDivs[i]).css({background:"#CDCDCD"});else $($linksDivs[i]).css({background:"white"});if(typeof link=="undefined"||
link=="")$($linksDivs[0]).css({background:"#CDCDCD"});$links.find("a").css({color:"#444444",fontSize:"larger",textDecoration:"none"});$root=typeof link=="undefined"?$($("#pgTutorials .tutorial")[0]):$("#pgTutorials ."+link);$root.find("p").css({fontSize:"larger",padding:"10px 0 10px 0",textIndent:"20px"});$root.find(".tutorialImgs").css({textAlign:"center",padding:"10px 0px 10px 0px"});var $div=$("<div>").css({padding:"0px 20px 0px 210px"}).append($("#pgTutorials .links").clone()).append($("<div>").css("clear",
"both").css({backgorund:"gray",height:"1px",width:"700px",overflow:"hidden",background:"#CDCDCD",marginBottom:"15px"}).text(" ")).append($root.postImageLoader(".tutorialImgs",{maxWidth:"750px"}).clone());$("#content").trigger("setContent",[$div,100,true])})}};
$(function(){if($.browser.msie)jQuery.fx.off=true;$.Router.bind("^(#)?$",function(){$.Router.setHash("/!rand!")});hash=document.location.hash;if(hash==""||hash=="#")$.Router.setHash("/!rand!");$("div.donateCont").css("opacity",0.7).mouseover(function(){$(this).css("opacity",1)}).mouseout(function(){$(this).css("opacity",0.7)});Core.init();$("#debug").hide();$("#content").content();$(".hidden").css("opacity",0);$("#menu").menu();$.Router.bind("^(#)?links(/.*)?$",function(){$("#content").trigger("setContent",
[$("#pgLinks").clone(),200,true])});$.Router.bind("^(#)?about(/.*)?$",function(){$("#content").trigger("setContent",[$("#pgAuthors").clone(),200,true])});$.Router.bind("^(#)?donate(/.*)?$",function(){$("#content").trigger("setContent",[$("#pgDonate").clone(),200,true])});Tutorial.init();RGall.init(GLOBAL_PATH);$(document).bind("keydown","Ctrl+left",function(){RGall.setStateByMove("collection",-1)}).bind("keydown","Ctrl+right",function(){RGall.setStateByMove("collection",+1)}).bind("keydown","Ctrl+up",
function(){RGall.setStateByMove("view",-1)}).bind("keydown","Ctrl+down",function(){RGall.setStateByMove("view",+1)});$("#randomizer").css({cursor:"pointer",position:"absolute",top:0,width:300,height:190}).data("canRand",true).click(function(){if($(this).data("canRand")){$.Router.setHash("/!rand!/!rand!/!rand!");$(this).data("canRand",false);var $self=$(this);setTimeout(function(){$self.data("canRand",true)},1E3)}});$(window).resize(function(){var t=($("body").width()-$("#all").width())/2;if(Math.abs(parseInt($("body").css("margin-left"),
10)-t)>10)$("body").css("margin-left",t>0?t:0)});$(window).trigger("resize");$(document).pngFix()});

