(function(){var l=this,o=l.mQuery=l.$=function(A,B){return o.fn.init(A,B);};o.fn=o.prototype={init:function(A,B){var i;this.EB=null;if((typeof A=='string')&&(i=document.getElementById(A))){this.EB=i;}if(typeof A=='object'){this.EB=A;}return this;},EB:null};o.extend=o.fn.extend=function(){var J=arguments[0],I=arguments.length,H=1;if(!J)return;if(typeof J==='boolean'&&J){J=o.fn;}for(;H<I;H++){var G=arguments[H];for(var F in G){var L=G[F];J[F]=L;}}};o.fn.extend(true,{getValue:function(){if(!(this.EB&&this.EB.value))return'';return this.EB.value;},getLValue:function(){return encodeURIComponent(this.getValue());},posLeft:function(P){var x=0;while(P){x+=P.offsetLeft;P=P.offsetParent;}return x;},posTop:function(P){var x=0;while(P){x+=P.offsetTop;P=P.offsetParent;}return x;}});o.preloadImage=o.prototype.preloadImage={};o.fn.extend(o.preloadImage,{MG:[],add:function(I,F){this.MG.push({"S":I,"OL":F});},load:function(){var im=o.preloadImage.MG;for(var i in im){if(im[i].S !=''&&im[i].S !=null){im[i].DT=new Image();im[i].DT.src=im[i].S;}if(im[i].OL&&typeof im[i].OL=='function')im[i].DT.onload=im[i].OL(im[i].S);}}});window.onload=o.preloadImage.load;o.dom=o.prototype.dom={};o.fn.extend(o.dom,{getSibling:function(E,N,T){if(E){T=T||'class';var cn=E.childNodes;for(var i=0,F=false;i<cn.length;i++){switch(T){case'id':if(cn[i].id&&cn[i].id==N)F=cn[i];break;case'class':if(cn[i].className&&cn[i].className==N)F=cn[i];break;case'node':if(cn[i].nodeName.toLowerCase()==N)F=cn[i];break;}if(typeof F=='object')return F;}}return null;}});o.iG=o.prototype.iG={};o.fn.extend(o.iG,{install:function(id){with(this){set_thumb(id);set_view(id);set_loc(id);}},set_thumb:function(id){var dv=document.getElementById(id+'_thumb');var nav=o.dom.getSibling(dv,'it_nav');this.st_nav(id,nav);this.st_share(id,o.dom.getSibling(dv,'it_share'));this.st_img(id,o.dom.getSibling(dv,'it_list'));},st_nav:function(id,dv){var d=o.dom.getSibling(dv,'left');d.onmouseover=function(){$(this.parentNode).iG.moveBG(0,-27);};d.onmouseout=function(){$(this.parentNode).iG.moveBG(0,0);};d.onclick=function(){$(this).iG.thumb.moveLeft(id);};d=o.dom.getSibling(dv,'right');d.onmouseover=function(){$(this.parentNode).iG.moveBG(0,-54);};d.onmouseout=function(){$(this.parentNode).iG.moveBG(0,0);};d.onclick=function(){$(this).iG.thumb.moveRight(id);};},st_share:function(id,dv){with(dv){onmouseover=nextSibling.onmouseover=function(){$(this).share.show();};onmouseout=nextSibling.onmouseout=function(){$(this).share.hide();};}},st_img:function(id,dv){var cn=dv.getElementsByTagName('em');for(var i=0;i<cn.length;i++)cn[i].onclick=function(){$(this).iG.view.showImg(id);};},set_view:function(id){var dv=document.getElementById(id+'_view');var iv=o.dom.getSibling(dv,'iv_img');this.sv_rating(id,o.dom.getSibling(dv,'iv_rating'),iv);this.sv_nav(id,o.dom.getSibling(dv,'iv_nav'));o.dom.getSibling(iv,'img','node').onload=function(){o.iG.sv_img(id,iv);};},set_loc:function(id){var pos=parseInt(o.loc.getAttr('PhoID'));var data=eval(id);if(isNaN(pos)||pos==''||pos<=0||pos>data.length)return;data.current=pos;o.iG.view.changeImage(id,data);},sv_nav:function(id,dv){var d=dv.firstChild;o.dom.getSibling(d,'prev').onclick=function(){$(this).iG.view.movePrev(id);};o.dom.getSibling(d,'next').onclick=function(){$(this).iG.view.moveNext(id);};},sv_rating:function(id,dv,iv){var st=o.dom.getSibling(o.dom.getSibling(dv,'set'),'stars');st.onmouseout=function(){$(this).iG.moveBG(-120,0);};st.setAttribute('image',this.image_rating(o.dom.getSibling(iv,'img','node').src));var cn=st.childNodes;for(var i=0,pos=-120+24;i<cn.length;i++,pos+=24){cn[i].setAttribute('pos',pos);cn[i].setAttribute('rating',i);cn[i].setAttribute('bg_rat',id);cn[i].onmouseover=function(){$(this.parentNode).iG.moveBG(this.getAttribute('pos'),0);};cn[i].onclick=function(){$(this).iG.set_rating();};}},check_rating:function(id){if(o.ajax.xh==null||!this.rating_valid())return;var V=document.getElementById(id+'_view'),I=o.dom.getSibling(V,'iv_img'),R=o.dom.getSibling(V,'iv_rating');R.style.display="none";var img=o.dom.getSibling(I,'img','node'),st=o.dom.getSibling(o.dom.getSibling(R,'set'),'stars');st.setAttribute('image',this.image_rating(img.src));var rt;if((rt=this.rating_exists(this.image_rating(img.src)))!==false)this.srt_show(R,rt);else this.ss_show(R);R.style.display="block";},rating_valid:function(){o.cookie.set('test','exists',1);return o.cookie.get('test')==''? false:true;},rating_exists:function(S){var D=o.cookie.get(S);return(D==""||D=="null")? false:D;},set_rating:function(id){var b=o.fn.EB;o.ajax.get('/rating/set/'+b.getAttribute('rating')+'/'+this.image_rating(b.parentNode.getAttribute('image')),function(D){o.iG.sr_show(D,b);});},image_rating:function(st){var pos;if((pos=st.indexOf('photos/view/'))<0)return st;return st.substring(pos+('photos/view/').length);},sr_show:function(dt,dv){if(dt===false)return;var id=dv.getAttribute('bg_rat');var d=o.dom.getSibling(document.getElementById(id+'_view'),'iv_rating'),S=o.dom.getSibling(d,'set'),I=o.dom.getSibling(d,'info');o.cookie.set(dv.parentNode.getAttribute('image'),dv.getAttribute('rating'),30);S.style.display='none';o.dom.getSibling(I,'stars').style.backgroundPosition=dv.getAttribute('pos')+'px 0px';I.style.display='block';},srt_show:function(dv,D){var S=o.dom.getSibling(dv,'set'),I=o.dom.getSibling(dv,'info');S.style.display='none';o.dom.getSibling(I,'stars').style.backgroundPosition=-120+24+D*24+'px 0px';I.style.display='block';},ss_show:function(dv){var S=o.dom.getSibling(dv,'set'),I=o.dom.getSibling(dv,'info');S.style.display='block';I.style.display='none';},sv_img:function(id,dv){var L=o.fn.posLeft(dv),T=o.fn.posTop(dv),H=parseInt(dv.offsetHeight),W=parseInt(dv.offsetWidth);var sp=o.dom.getSibling(dv,'prev');sp.onclick=function(){$(this).iG.view.movePrev(id);};with(sp.style){left=L+'px';top=T+'px';height=H+'px';display='block';}sp=o.dom.getSibling(dv,'next');sp.onclick=function(){$(this).iG.view.moveNext(id);};with(sp.style){left=L+W-parseInt(sp.offsetWidth)+'px';top=T+'px';height=H+'px';display='block';}sp=o.dom.getSibling(dv,'load_progress_big');sp.style.display='none';this.check_rating(id);},moveBG:function(x,y){o.fn.EB.style.backgroundPosition=x+'px '+y+'px';},marginLeft:function(x){o.fn.EB.style.marginLeft=x+'px';}});o.iG.thumb={};o.fn.extend(o.iG.thumb,{is_rotate:false,moveLeft:function(id){with(this){if(is_rotate)return;var data=eval(id);if(data.page==1)return;data.page--;setInfo(id,data);moveList(id,data);}},moveRight:function(id){with(this){if(is_rotate)return;var data=eval(id);if(data.page==data.pages)return;data.page++;setInfo(id,data);moveList(id,data);}},setInfo:function(id,data){var L=o.dom.getSibling(document.getElementById(id+'_thumb'),'it_info').getElementsByTagName('span');var f=(data.page-1)*6+1,l=f+5;if(l>data.length)l=data.length;L[0].innerHTML=f+' - '+l;},x_start:0,x_stop:0,x_delta:50,x_dir:1,x_U:null,timer:null,moveList:function(id,data){with(this){var L=o.dom.getSibling(document.getElementById(id+'_thumb'),'it_list');x_U=L.firstChild;is_rotate=true;x_start=x_U.style.marginLeft ? parseInt(x_U.style.marginLeft):0;x_stop=-(data.page-1)*L.offsetWidth;x_dir=x_start<x_stop ? 1:-1;timer=window.setInterval(function(){var dir=o.iG.thumb.x_dir;o.iG.thumb.x_start+=dir*o.iG.thumb.x_delta;if((dir<0&&o.iG.thumb.x_start<=o.iG.thumb.x_stop)||(dir>0&&o.iG.thumb.x_start>=o.iG.thumb.x_stop)){window.clearInterval(o.iG.thumb.timer);o.iG.thumb.timer=null;o.iG.thumb.is_rotate=false;o.iG.thumb.x_start=o.iG.thumb.x_stop;}$(x_U).iG.marginLeft(o.iG.thumb.x_start);},30);}}});o.iG.view={};o.fn.extend(o.iG.view,{showImg:function(id){var data=eval(id);data.current=o.fn.EB.getAttribute('data');var T=o.fn.EB.getAttribute('title');var src=o.fn.EB.style.backgroundImage;this.setInfo(id,data);this.setTitle(id,T);this.setImg(id,src.substring(4,src.length-1).replace('/thumb/','/view/'),T);this.setLoc(id,data);},setInfo:function(id,data){var L=o.dom.getSibling(document.getElementById(id+'_view'),'iv_nav').getElementsByTagName('li');L[1].firstChild.innerHTML='photo '+data.current+' of '+data.length;},setTitle:function(id,TL){var T=o.dom.getSibling(o.dom.getSibling(document.getElementById(id+'_view'),'iv_img'),'title');T.innerHTML=TL;T.style.display=TL==''?'none':'block';},setImg:function(id,src,T){var L=o.dom.getSibling(document.getElementById(id+'_view'),'iv_img');var D=o.dom.getSibling(L,'load_progress_big'),I=o.dom.getSibling(L,'img','node');with(D.style){left=o.fn.posLeft(I)+'px';top=o.fn.posTop(I)+'px';width=parseInt(I.offsetWidth)+'px';height=parseInt(I.offsetHeight)+'px';display='block';}if(src.charAt(0)=='"')src=src.substring(1,src.length-1);I.src=src;I.alt=T;},setLoc:function(id,data){window.location='#PhoID='+data.current;if(doc_title)document.title=doc_title;return;},movePrev:function(id){var data=eval(id);if(data.current==1)return;data.current--;this.changeImage(id,data);},moveNext:function(id){var data=eval(id);if(data.current==data.length)return;data.current++;this.changeImage(id,data);},changeImage:function(id,data){var L=o.dom.getSibling(document.getElementById(id+'_thumb'),'it_list');var cn=L.getElementsByTagName('em');for(var i=0;i<cn.length;i++)if(cn[i].getAttribute('data')==data.current)return $(cn[i]).iG.view.showImg(id);}});o.menuTree=o.prototype.menuTree={};o.extend(o.menuTree,{make:function(){var U=o.fn.EB.firstChild;this.command(U);this.hide(U);this.current(U);},command:function(U){var a=U.getElementsByTagName('a');for(var i=0;i<a.length;i++)a[i].onclick=function(){return $(this).menuTree.show();};},hide:function(U){for(var j=U.firstChild;j;j=j.nextSibling){var k=j.firstChild.nextSibling;if(k){k.style.display="none";this.hide(k.firstChild);}}},current:function(U){var a=U.getElementsByTagName('a');for(var i=0;i<a.length;i++)if(this.isVE(a[i].className.split(' '),'current')>=0){var k=a[i].parentNode;for(var j=k;!(j.nodeName=='DIV'&&this.isVE(j.className.split(' '),'tree')>=0);j=j.parentNode){if(j.nodeName=='DIV'&&j.style.display=='none'){j.style.display='block';}}k=k.nextSibling;if(k)k.style.display='block';break;}},show:function(){var N=o.fn.EB.parentNode.nextSibling;if(!N||N.style.display !="none")return true;this.hide(N.firstChild);this.anim(N);return false;},anim:function(D){if(this.isVE(D.className.split(' '),'leaf')>=0)this.hide(D.firstChild);D.style.display="block";},isVE:function(A,V){for(var i=0;i<A.length;i++)if(A[i]==V)return i;return-1;}});o.cookie=o.prototype.cookie={};o.extend(o.cookie,{set:function(N,V,D){var E="";if(D){var dt=new Date();dt.setTime(dt.getTime()+(D*24*60*60*1000));E="; expires="+dt.toGMTString();}document.cookie=N+"="+V+E+"; path=/";},get:function(N){var NE=N+"=",V="";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var z=0,c=ca[i];while(c.charAt(z)==" ")z++;if(c.indexOf(NE,z)==z){V=c.substring(z+NE.length);break;}}return V;},clear:function(N){this.set(N,"",-1);}});o.ajax=o.prototype.ajax={};o.extend(o.ajax,{xh:null,init:function(){var X=null;if(window.XMLHttpRequest){X=new XMLHttpRequest();if(X.overrideMimeType)X.overrideMimeType('text/xml');}else if(window.ActiveXObject){try{X=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{X=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){}}}this.xh=X;},get:function(U,F,OS){var X=this.xh;if(X==null)return;OS=OS||true;if(U.indexOf('?')<0)U+='?';else U+='&';U+='mr='+(new Date()).getTime();X.onreadystatechange=function(){o.ajax.PR(F);};X.open("GET",U,OS);X.send(null);},PR:function(F){var X=this.xh;if(X.readyState==4&&X.status==200){try{var v=eval("("+X.responseText+")");}catch(e){v=false;}return F(v);}}});o.ajax.init();o.loc=o.prototype.loc={};o.fn.extend(o.loc,{getAttr:function(N){var wl=window.location.href,pos;if((pos=wl.indexOf('#'))<0)return;var L=wl.substring(pos+1).split('&');for(var i=0;i<L.length;i++){var items=L[i].split('=');if(items[0]==N)return items[1];}return'';}});o.share=o.prototype.share={};o.fn.extend(o.share,{timer:null,obj:null,show:function(){var K=o.fn.EB;this.clear_timer();if(K.className=='addthis_toolbox')return;with(K.nextSibling.style){left=o.fn.posLeft(K)+'px';top=o.fn.posTop(K)+parseInt(K.offsetHeight)+3+'px';display='block';}},hide:function(){with(this){obj=o.fn.EB;timer=window.setTimeout(set_timer,100);}},clear_timer:function(){with(this){if(timer !=null){window.clearTimeout(timer);timer=null;obj=null;}}},set_timer:function(){var K=o.share.obj;if(!K)return;if(K.className !='addthis_toolbox')K=K.nextSibling;K.style.display='none';}});})();
