var makefavorite=false;var imageslist,imageslistfavorites;var slideshowsystem=false;var preloadingimage=null,previouscacheimg=null,nextcacheimg=null;var lastimage=null;var picviewerbox=new Array();var picviewerboxInit=new Array();var menuheight=50;var doshrink=false;var shrinking=false;var loadcount=0,preloadcount=0;var processbusy=false;var recentcursor='auto';var aktimage=-1;var loadimage=false;var slideshow=-1;var slideshowBeginn=0;var slideshowEnd=0;var slideshowview=false;var isie6=(navigator.appVersion.indexOf('MSIE 6')!=-1);var picturescrollpos=new Array(0,0);var touchAX,touchAY,touchBX,touchBY;function fadepicviewer(up,a){if(up){a+=Math.min(0.2,((1.0-a)/2)); if(Math.ceil(a*100)<100){setTimeout('fadepicviewer(true,'+a+')',60);}else a=1.0;}else{a+=Math.max(-0.2,((0.0-a)/2)); if(Math.floor(a*100)>0.0){setTimeout('fadepicviewer(false,'+a+')',60);}else{a=0; document.getElementById('pictureshow').style.display='none'; document.getElementById('pictureshowpic').style.display='none'; document.getElementById('pictureshowpic').src=''; document.getElementById('pictureshowmenu').style.display='none'; preloadingimage=null; previouscacheimg=null; nextcacheimg=null; lastimage=null;} javaopacity('pictureshowpic',a);} javaopacity('pictureshow',Math.min(0.9,a)); javaopacity('pictureshowmenu',a);}function setBusyCursor(isbusy){if(typeof(isbusy)=='undefined'){isbusy=processbusy;}else{processbusy=isbusy;} var a='auto';var b=recentcursor; if(isbusy=='true'){a='wait';b='wait';}else if(isbusy=='half'){a='progress';b='progress';} document.getElementById('pictureshow').style.cursor=a; document.getElementById('pictureshowpic').style.cursor=b; document.getElementById('pictureshowmenu').style.cursor=a;}function handleFavoriteSubmit(http){if(http&&http.readyState==4&&http.status==200){var content=http.responseText;if(content=='true'||content=='false'){imageslistfavorites[aktimage]=(content=='true'?true:false);favoriteimageshow();}}}function requestFavoriteDatabase(url,fav){if(typeof GetXMLHttpRequest!='function') return; if(http_request){http_request.abort();}http_request=GetXMLHttpRequest(); if(!http_request) return false; try{var t=new Date();http_request.open('GET','/external/setfavorite.php?filename='+escape(url)+'&q='+fav+'&t='+t.getTime()); http_request.onreadystatechange=function(){handleFavoriteSubmit(http_request);}; http_request.send(null);}catch( myError ){}}function countShowPic(s){var eX=s.match(/sid=[a-zA-Z0-9]{20,60}/); if(s.match(/\/members\/images\//)&&eX){try{var t=new Date();var cI=new Image();cI.src='/external/cnimage.php?f='+escape(s)+'&'+eX[0]+'&t='+t.getTime();}catch(e){}}}function loadImage(){if(loadimage||!slideshowsystem) return; loadimage=true; if(slideshowview&&slideshow!=-1){clearTimeout(slideshow);slideshow=-1;} lastimage=preloadingimage; if(previouscacheimg&&previouscacheimg.src==imageslist[aktimage]){preloadingimage=previouscacheimg;}else if(nextcacheimg&&nextcacheimg.src==imageslist[aktimage]){preloadingimage=nextcacheimg;}else{setBusyCursor('true'); preloadingimage=new Image(); preloadingimage.src=imageslist[aktimage];} if(makefavorite) favoriteimageshow(); loadcount=0; shrinking=true; if(lastimage==null){showRecentImage(false);}else{switchImage(false,1.0);}}function checkPreloadedImages(a,fullchk){if(fullchk) var igck=document.getElementById('pictureshowpic');var r=(a&&a.complete&&a.width>0&&(!fullchk||(igck&&igck.src==a.src&&igck.complete))); return r;}function preloadImagesChk(){if(preloadcount++<30&&(!checkPreloadedImages(nextcacheimg,false)||!checkPreloadedImages(previouscacheimg,false))){setTimeout("preloadImagesChk()",300);}else{setBusyCursor('false');}}function preloadImages(){var p2=(aktimage+1)%imageslist.length; if(lastimage&&lastimage.src==imageslist[p2]){nextcacheimg=lastimage;}else{nextcacheimg=new Image();nextcacheimg.src=imageslist[p2];} var p1=(aktimage-1);if(p1<0) p1=imageslist.length-1; if(lastimage&&lastimage.src==imageslist[p1]){previouscacheimg=lastimage;}else{previouscacheimg=new Image();previouscacheimg.src=imageslist[p1];} preloadcount=0; preloadImagesChk();}function isImgReady(){if(loadcount++>10||checkPreloadedImages(preloadingimage,true)){return true;}return false;}function switchImage(up,a){if(up){a+=((1.0-a)/2); if(Math.ceil(a*100)<100){setTimeout('switchImage(true,'+a+')',60);}else{shrinking=false;loadimage=false;a=1.0; showRecentImage(false); if(slideshowview&&slideshow==-1) slideshow=setTimeout('nextimage()',5000);}}else{a+=((0.0-a)/2); if(Math.floor(a*100)>0.0){setTimeout('switchImage(false,'+a+')',60);}else{a=0; document.getElementById('pictureshowpic').src=''; showRecentImage(true); return;}} javaopacity('pictureshowpic',a);}function showRecentImage(isSwitchImage){var picid=document.getElementById('pictureshowpic'); if(preloadingimage&&picid.src!=preloadingimage.src){picid.src=preloadingimage.src;countShowPic(picid.src);} if(!preloadingimage||(loadcount<999&&!isImgReady())){setTimeout("showRecentImage("+isSwitchImage+")",100);return;} var shrinkanim=true;var dw=preloadingimage.width;var dw2=dw;var dh=preloadingimage.height;var dh2=dh; picviewerbox=getPicViewerBox();var sw=picviewerbox[4]-30;var sh=picviewerbox[5]-(menuheight+20);var isw=Math.max(1,parseInt(picid.width));var ish=Math.max(1,parseInt(picid.height)); if(doshrink){if(dw>sw){var d=dh/dw;dw2=sw;dh2=Math.round(d*sw);} if(dh>sh||dh2>sh){var d=dw/dh;dh2=sh;dw2=Math.round(d*sh);} if(isSwitchImage){dw=dw2;dh=dh2;}else{dw=Math.floor((isw+dw2)/2);dh=Math.floor((ish+dh2)/2);}}else{if(isSwitchImage){}else{dw=Math.ceil((isw+dw)/2); dh=Math.ceil((ish+dh)/2);}} if(Math.abs(isw-dw)<=2&&Math.abs(ish-dh)<=2){dw=dw2;dh=dh2;shrinkanim=false;} with (picid.style){left=Math.max(0,Math.round(sw/2-dw/2))+'px'; top =Math.max(menuheight,Math.round(menuheight+sh/2-dh/2))+'px'; width=Math.max(0,dw)+'px'; height=Math.max(0,dh)+'px';} setBackgroundBox(picviewerbox); positionBackground(true); if(isSwitchImage){switchImage(true,0.0);}else{if(shrinkanim||parseInt(picid.style.width)<=1){setTimeout("showRecentImage(false)",60);}else{shrinking=false; loadimage=false;}} if(loadcount<999&&isImgReady()){loadcount=999;setBusyCursor('half');preloadImages();}}function changedoshrink(){if(shrinking) return; shrinking=true; doshrink=!doshrink; if(!doshrink){recentcursor="url(/graphics/v9/zoom_out.cur),pointer";}else{recentcursor="url(/graphics/v9/zoom_in.cur),pointer";} setBusyCursor(); changeButton(document.getElementById('shrinkbutton'),doshrink); showRecentImage(false); return false;}function getPicViewerBox(){var de=document.documentElement;var db=document.body;var result=[Math.max(0,window.pageXOffset||(db&&db.scrollLeft)||(de&&de.scrollLeft)), Math.max(0,window.pageYOffset||(db&&db.scrollTop)||(de&&de.scrollTop)), window.width||window.offsetwidth ||(de&&de.scrollWidth)||(db&&db.scrollWidth), window.height||window.offsetHeight ||(de&&de.scrollHeight)||(db&&db.scrollHeight), ((de&&de.clientWidth) ? de.clientWidth : (window.innerWidth||(db&&db.clientWidth))), ((de&&de.clientHeight) ? de.clientHeight : (window.innerHeight||(db&&db.clientHeight))) ]; return result;}function setBackgroundBox(b){with (document.getElementById('pictureshow').style){if(isie6){left=b[0]+'px';top=b[1]+'px';width=(b[4])+'px';height=(b[5])+'px';}else{width=(b[2])+'px';height=(b[3])+'px';}}}function positionBackground(force){if(!slideshowsystem) return; picviewerbox=getPicViewerBox(); if(picviewerbox[1]==0) window.scrollTo(picviewerbox[0],1);var newp0=Math.round((picturescrollpos[0]+picviewerbox[0])/2);var newp1=Math.round((picturescrollpos[1]+picviewerbox[1])/2); if(picturescrollpos[0]==newp0&&picturescrollpos[1]==newp1&&!force) return; if(force){newp0=picviewerbox[0];newp1=picviewerbox[1];} picturescrollpos[0]=newp0; picturescrollpos[1]=newp1;var dp=document.getElementById('pictureshowpic'); with (dp){var pw=(offsetWidth ||clientWidth ||style.pixelWidth);var ph=(offsetHeight||clientHeight||style.pixelHeight);var bow=5;if(style.borderWidth) var bow=parseInt(style.borderWidth); pw=parseInt( pw )+bow*2; ph=parseInt( ph )+bow*2;var ll=parseInt(dp.style.left);var lt=parseInt(dp.style.top);var nl=ll;var nt=lt; if(picviewerbox[4]<pw){if(ll>newp0) nl=newp0;else if(ll<picviewerbox[4]+newp0-pw) nl=picviewerbox[4]+newp0-pw;}else{nl=newp0 + Math.floor(picviewerbox[4]/2-parseInt(style.width)/2-bow);} if(picviewerbox[5]<=ph){if(lt>newp1+menuheight) nt=newp1+menuheight;else if(lt<picviewerbox[5]+newp1-ph) nt=picviewerbox[5]+newp1-ph;}else{nt=newp1 + Math.floor(picviewerbox[5]/2-parseInt(style.height)/2+bow*2);} if(nl!=ll) style.left=Math.max(0,nl)+'px'; if(nt!=lt) style.top=Math.max(menuheight,nt)+'px';} with (document.getElementById('pictureshowmenu')){style.width=picviewerbox[4]+'px'; style.left =Math.max(newp0,0)+'px'; style.top =Math.max(Math.min(nt-menuheight,newp1),0)+'px';} setBackgroundBox(picviewerbox);}function previousimage(){if(!loadimage){aktimage--; if(slideshowview){if(aktimage<slideshowBeginn) aktimage=slideshowEnd;}else if(aktimage<0) aktimage=imageslist.length-1; loadImage();} return false;}function nextimage(){if(!loadimage){aktimage++; if(slideshowview){if(aktimage>slideshowEnd) aktimage=slideshowBeginn;}else{aktimage%=imageslist.length;} loadImage();} return false;}function imageclose(){if(!slideshowsystem) return; slideshowsystem=false;var emb=document.getElementsByTagName('embed'); for(var i=0;i<emb.length;i++){emb[i].style.display='';} window.scrollTo(picviewerboxInit[0],picviewerboxInit[1]); fadepicviewer(false,1.0); clearTimeout(slideshow);slideshowview=false;slideshow=-1;changeButton(document.getElementById('slideshowbutton'),slideshowview); document.onresize =null; document.onkeydown=null; document.onscroll=null; loadcount=999; preloadcount=999; return false;}function askForButton(e){if(!e) e=window.event; if(e.target) targ=e.target;else if(e.srcElement) targ=e.srcElement; if(!targ) return;var list=document.getElementById('pictureshowmenu');var listelements=list.getElementsByTagName('a'); for(var i=0;i<listelements.length;i++){if(targ==listelements[i]) return [targ,i,e.type.toLowerCase()];} return;}function handleKeys(e){if(!e) e=window.event; if(e){switch (e.keyCode){case 9:case 34:case 40:case 39:case 13:nextimage();break; case 8:case 33:case 37:case 38:previousimage();break; case 32:changedoshrink();break; case 27:imageclose();break;}} return false;}function changeButton(obj,active){var bp=obj.style.backgroundPosition.split(' ');if(active) var y=-47;else var y=0; obj.style.backgroundPosition=bp[0]+' '+y+'px';}function butnav(e){var el=askForButton(e); if(el){var switcher=false; switch (el[1]){case 0:case 1:case 5:switcher=true;break; case 2:if(!doshrink) switcher=true;break; case 4:if(!slideshowview) switcher=true;break; case 3:if(!imageslistfavorites[aktimage]) switcher=true;break;} if(switcher) changeButton(el[0],(el[2]=='mouseover'));}}function favoriteimageshow(){changeButton(document.getElementById('favoritebutton'),imageslistfavorites[aktimage]);}function favoriteimage(switchto){var newstate; if(typeof(switchto)=='booblean'){newstate=switchto;}else{newstate=!imageslistfavorites[aktimage];} requestFavoriteDatabase(imageslist[aktimage],newstate); return false;}function startslideshow(beginnpic,endpic){if(!slideshowview){if(typeof(beginnpic)=='number'){slideshowBeginn=beginnpic; slideshowEnd =endpic; slideshow=setTimeout('nextimage()',5000);}else{slideshowBeginn=0; slideshowEnd =imageslist.length; slideshow=setTimeout('nextimage()',500);} slideshowview=true;}else{clearTimeout(slideshow);slideshowview=false;slideshow=-1;} changeButton(document.getElementById('slideshowbutton'),slideshowview); return false;}function resizeEvent(e){if(!shrinking){shrinking=true;showRecentImage(false);}}function showimage(e,specimage){if(slideshowsystem) return;var emb=document.getElementsByTagName('embed'); for(var i=0;i<emb.length;i++){emb[i].style.display='none';} if(e==null&&typeof(specimage)=='number'){aktimage=specimage;}else{if(!e) e=window.event; if(e.target) targ=e.target;else if(e.srcElement) targ=e.srcElement;var i=0;while(targ&&targ.tagName.toLowerCase()!='a'&&i++<5){targ=targ.parentNode;} if(!targ||targ=='undefined') return true; for(var i=0;i<imageslist.length;i++){if(imageslist[i].substring(imageslist[i].length-targ.href.length,imageslist[i].length)==targ.href){aktimage=i;break;}}} slideshowsystem=true; if(!document.getElementById('pictureshow')){var bg=document.getElementsByTagName('body')[0];var pictureshowmenu=document.createElement("div"); pictureshowmenu.id="pictureshowmenu";pictureshowmenu.align="center"; with (pictureshowmenu.style){whiteSpace='nowrap';textAlign='center';fontFamily='arial';zIndex='9998';position='absolute';top='0px';left='0px';width='1px';height=(menuheight-1)+'px';backgroundColor='#000';border='0';borderBottom='1px solid #333';} var textstring;var mainlist=document.createElement("ul");with (mainlist.style){margin='0 auto';if(makefavorite){width='390px';}else{width='320px';}marginTop='5px';} for(var ci=0;ci<5;ci++){var list=document.createElement("li");var button=document.createElement("a"); button.href="#"; switch (ci){case 0: with (button.style){backgroundPosition='-5px 0px';marginRight='40px';} button.onclick=previousimage; textstring="Previous"; break; case 1: with (button.style){backgroundPosition='-60px 0px';margin='0 10px';} button.onclick=changedoshrink; button.id="shrinkbutton"; textstring="Zoom"; break; case 2: with (button.style){backgroundPosition='-120px 0px';margin='0 10px';if(!makefavorite){width='1px';overflow='hidden';display='none';}} button.onclick=favoriteimage; button.id="favoritebutton"; textstring="Favorite"; break; case 3: with (button.style){backgroundPosition='-178px 0px';margin='0 10px';} button.onclick=startslideshow; button.id="slideshowbutton"; textstring="Slideshow"; break; case 4: with (button.style){backgroundPosition='-238px 0px';marginLeft='40px';} button.onclick=nextimage; textstring="Next"; break;} button.onmouseout=butnav;button.onmouseover=butnav;var buttontext=document.createTextNode(textstring); button.appendChild(buttontext);list.appendChild(button);mainlist.appendChild(list);} var mainlist2=document.createElement("ul");with (mainlist2.style){position='absolute';top='0';right='0';width='51px';marginTop='5px';} var list=document.createElement("li");list.style.float='right';var button =document.createElement("a");button.style.backgroundPosition='-300px 0';button.href="#";button.onclick=imageclose;button.onmouseout=butnav;button.onmouseover=butnav;var buttontext=document.createTextNode("Close"); button.appendChild(buttontext);list.appendChild(button);mainlist2.appendChild(list); pictureshowmenu.appendChild(mainlist2); pictureshowmenu.appendChild(mainlist);var pictureshowpic=document.createElement("img"); pictureshowpic.id="pictureshowpic"; with (pictureshowpic.style){zIndex='9999';position='absolute';top='0px';left='0px';width='1px';height='1px';border='5px solid #000';} pictureshowpic.onclick=changedoshrink;var pictureshow=document.createElement("div"); pictureshow.id="pictureshow"; with (pictureshow.style){zIndex='9996';backgroundColor='#000';position='absolute';top='0px';left='0px';width='100%';height='100%';} bg.appendChild(pictureshowmenu); bg.appendChild(pictureshowpic); bg.appendChild(pictureshow); recentcursor='url(/graphics/v9/zoom_out.cur),pointer'; doshrink=false; addEvent(pictureshowpic,'touchstart',function (event){var touch=event.touches[0]; touchAX=touch.pageX;touchAY=touch.pageX;}); addEvent(pictureshowpic,'touchmove',function (event){var touch=event.touches[0]; touchBX=touch.pageX;touchBY=touch.pageX;}); addEvent(pictureshowpic,'touchend',function (event){if(Math.abs(touchAX-touchBX)>Math.abs(touchAY-touchBY)){if(touchAX>touchBX){previousimage();}else{nextimage();}}else{if(touchAY>touchBY){previousimage();}else{nextimage();}} window.setTimeout(function(event){resizeEvent(event);},200);});}else{document.getElementById('pictureshowpic').src=imageslist[i]; countShowPic(imageslist[i]);} loadimage=false; loadcount=0; preloadcount=0; addEvent(window,'resize',resizeEvent); addEvent(window,'keydown',handleKeys); addEvent(window,'scroll',positionBackground); document.onresize =resizeEvent; document.onkeydown=handleKeys; document.onscroll =positionBackground; picviewerboxInit=getPicViewerBox(); window.scrollTo(0,1); picviewerbox=getPicViewerBox(); setBackgroundBox(picviewerbox); javaopacity('pictureshow',0.0); javaopacity('pictureshowpic',1.0); javaopacity('pictureshowmenu',0.0); document.getElementById('pictureshow').style.display='block'; with (document.getElementById('pictureshowpic').style){display='inline';width='1px';height='1px';} document.getElementById('pictureshowmenu').style.display='block'; loadImage(); fadepicviewer(true,0.0); return false;}function initslideshow(){var y=0; imageslist=new Array(); imageslistfavorites=new Array();var imgs=document.getElementsByTagName('a'); for(var i=0;i<imgs.length;i++){if(imgs[i].className.indexOf('slideshow')!=-1){if(imgs[i].className.indexOf('isfavorite')!=-1){imageslistfavorites[y]=true;}else{imageslistfavorites[y]=false;} imageslist[y]=imgs[i].href;imgs[i].onclick=showimage;y++;}}}function startSlideshowB(beginn,end){if(slideshowsystem) return false; if(typeof(beginn)!='number'){var beginn=1;var end=imageslist.length;} showimage(null,beginn-1); startslideshow(beginn-1,end-1); return false;}if(typeof addEvent!='function'){function addEvent(elmi,evType,fn,useCapture){if(elmi.addEventListener){elmi.addEventListener(evType,fn,useCapture);return true;}else if(elmi.attachEvent){var r=elmi.attachEvent("on"+evType,fn);return r;}}}if(typeof(autoinitslideshow)!='undefined'){window.setTimeout('initslideshow()',1);}
