var gallerypos=0; var gallerypreloadpos=0; var gallery=new Array(); var galleryelements=new Object(); var galleryconfig=new Object(); // wenn eine slideshow, dann hier die Sekunden galleryconfig["slideshowtime"]=2; // die Navigation wird immer dynamisch positioniert galleryconfig["dynposnav"]=true; // die Navigation wird in das Bild gesetzt (onmouseover-effekt), ansonsten direkt unterhalb galleryconfig["navinimg"]=true; // wird zur Höhe der Nav hinzugefügt, bei galleryconfig["navinimg"] meistens negativ, ansonsten positiv galleryconfig["navborderh"]=-10; //anzahl der Pixel zwischen den Nav-Bildern galleryconfig["navelborderimg"]=6; //anzahl der Pixel zwischen den Pfeil und dem Bild galleryconfig["navelborderpfeil"]=11; //Zeigt eine Lade Msg an galleryconfig["showloadingmsg"]=true; galleryconfig["loadingmsg"]="Gallerie wird geladen ...."; //interne werte var gallerypreloadimg=new Image(); galleryconfig["thumbh"]=200; galleryconfig["pfeilh"]=32; galleryconfig["pfeilloaded"]=false; galleryconfig["blank"]="binary.php?bin=images/emptypixel.gif"; galleryconfig["timer"]=null; galleryconfig["stat"]=0; //9=preload startet, 10=preload finished, 11=gallery init /** * fügt ein Gallerie-Element hinzu * @param name * @param desc * @param isimage * @param url * @param crop * @param thumb * @param alink * @return */ function gallery_addElement(name,desc,isimage,url,crop,thumb,alink) { var element=new Object(); element["name"]=name; if(desc==undefined)desc=""; element["desc"]=desc; element["isimage"]=isimage; element["url"]=isimage?crop:url; element["realurl"]=url; element["thumb"]=thumb; element["alink"]=alink; gallery.push(element); } /** * startet mit dem Preloaden, gallery_preload(0); * @return */ function gallery_preload(num) { ////gallery_log("gallery_preload-start:"+num); if(num==0){ galleryconfig["stat"]=9; if(galleryconfig["showloadingmsg"]){ div=document.createElement("div"); div.innerHTML="

"+galleryconfig["loadingmsg"]+"

"; galleryconfig["showloadingdiv"]=div; document.getElementById("gallery_mainimga").appendChild(div); } } if(num==gallery.length&&!galleryconfig["pfeilloaded"]){ ////gallery_log("gallery_preload-start:pfeil"); gallerypreloadimg=new Image(); if(window.addEventListener) { // Standard gallerypreloadimg.addEventListener("load", gallery_preloaded_navpfeil, false); } else if(window.attachEvent) { // IE gallerypreloadimg.attachEvent('onload', gallery_preloaded_navpfeil); } //else gallery_preloaded(); gallerypreloadimg.src=document.getElementById("gallery_linkimg_gop").src; return; } gallerypreloadpos=num; type=num>=gallery.length; pos=type?num-gallery.length:num; if(pos>=gallery.length){ //gallery_log("gallery_preload:finished"); if(galleryconfig["stat"]<10)galleryconfig["stat"]=10; gallerypreloadimg=null; return; } //gallery_log("gallery_preload-pos:"+pos+":"+gallery.length+":"+type+":"+gallery[pos]["isimage"]); var src = gallery[pos]["thumb"]; if(type){ if(gallery[pos]["isimage"]==0)gallery_preload(num+1); src = gallery[pos]["url"]; } //gallery_log("start:"); gallerypreloadimg=new Image(); if(window.addEventListener) { // Standard ////gallery_log("window.addEventListener"); gallerypreloadimg.addEventListener("load", gallery_preloaded, false); gallerypreloadimg.src=src; } else if(window.attachEvent) { // IE // //gallery_log("window.attachEvent"); gallerypreloadimg.src=src; gallerypreloadimg.attachEvent('onload', gallery_preloaded); gallerypreloadimg.src=src; } //else gallery_preloaded(); } /** * ein zwischenschritt um navw zu berechnen * @return */ function gallery_preloaded_navpfeil() { galleryconfig["pfeilloaded"]=true; galleryconfig["pfeilh"]=gallerypreloadimg.width; ////gallery_log("navw:"+galleryconfig["pfeilh"]); gallery_preload(gallerypreloadpos); } /** * sollte aufgerufen werden, wenn das Bild gecached ist * @return */ function gallery_preloaded() { //gallery_log("gallery_preloaded:"+gallerypreloadimg.src); //gallery_log("gallery_preloaded:"+gallerypreloadpos+":"+gallery.length); if(gallerypreloadpos==0){ galleryconfig["thumbh"]=gallerypreloadimg.height; galleryconfig["thumbw"]=gallerypreloadimg.width; }else if(gallerypreloadpos>=gallery.length) { pos=gallerypreloadpos-gallery.length; gallery[pos]["h"]=gallerypreloadimg.height; gallery[pos]["w"]=gallerypreloadimg.width; //gallery_log("gallery_preloaded-hw:"+gallery[pos]["h"]+":"+gallery[pos]["w"]+":"+gallerypreloadimg.src); } if(gallerypreloadpos==gallery.length){//jetzt beginnen wir die Gallery anzuzeigen gallery_init(); } gallery_preload(gallerypreloadpos+1); } /** * simples log * @param msg * @return */ function gallery_log(msg) { /*if(navigator.userAgent.toLowerCase().indexOf("msie")<0)return; el=document.getElementById("log"); el.innerHTML=msg+"
"+el.innerHTML;*/ } /** * startet die Gallerie, initialisiert die Elemente * @return */ function gallery_init() { //gallery_log("init:"); document.getElementById("galleryimagetext_all").innerHTML=""+gallery.length; galleryelements["bigimg"]=document.getElementById("gallery_mainimg"); galleryelements["bigimg_a"]=document.getElementById("gallery_mainimga"); galleryelements["stat_cur"]=document.getElementById("galleryimagetext_cur"); galleryelements["desc"]=document.getElementById("gallery_desc"); galleryelements["link1"]=document.getElementById("gallery_linkimg1a"); galleryelements["link2"]=document.getElementById("gallery_linkimg2a"); galleryelements["link3"]=document.getElementById("gallery_linkimg3a"); galleryelements["link4"]=document.getElementById("gallery_linkimg4a"); galleryelements["img1"]=document.getElementById("gallery_linkimg1"); galleryelements["img2"]=document.getElementById("gallery_linkimg2"); galleryelements["img3"]=document.getElementById("gallery_linkimg3"); galleryelements["img4"]=document.getElementById("gallery_linkimg4"); galleryelements["imgcur"]=document.getElementById("gallery_linkimg_cur"); galleryelements["divnav"]=document.getElementById("gallerynav"); galleryelements["divbigimg"]=document.getElementById("galleryimgcontainer"); galleryconfig["stat"]=11; gallery_show_img(); } /** * das Bild ist geladen, aufbau der Gallerie * @return */ function gallery_show_img_loaded() { //gallery_log("show_img_loaded"); if(galleryconfig["showloadingmsg"]){ galleryelements["bigimg_a"].removeChild(galleryconfig["showloadingdiv"]); galleryconfig["showloadingmsg"]=false; galleryconfig["showloadingdiv"]=null; } element=gallery[gallerypos]; //gallery_log("gallery_show_img-h:"+element["h"]+":"+element["url"]); //Url für Big Img stezen galleryelements["bigimg_a"].href="javascript:popUpImage('"+element["realurl"]+"','"+element["name"]+"');gallery_imgpopup();"; // Bild anzeigen galleryelements["bigimg"].src=element["isimage"]?element["url"]:element["thumb"]; //Beschreibugn setzen div=document.createElement("div"); if(element["isimage"]==1)div.innerHTML=unescapeHTML(element["desc"]); else div.innerHTML=element["alink"]+"
"+unescapeHTML(element["desc"])+"
"; gallery_log(div.innerHTML); galleryelements["desc"].replaceChild(div,galleryelements["desc"].firstChild); //Status setzen galleryelements["stat_cur"].innerHTML=""+(gallerypos+1); //Mittleres Bild setzen galleryelements["imgcur"].src=element["thumb"]; cvisibile=1; //gallery_log("show_img_loaded1"); //Linkes Bild 2 setzen var length=gallery.length; //gallery_log("show_img_loaded11"); if(gallerypos>1){ cvisibile++; //gallery_log("show_img_loaded12"); gallery_set_navlinkimg(1,gallery[gallerypos-2]["thumb"],"javascript:gallery_go("+(gallerypos-2)+");"); //gallery_log("show_img_loaded132"); } else gallery_set_navlinkimg_blank(1); //gallery_log("show_img_loaded1333"); //Linkes Bild 1 setzen if(gallerypos>0){ cvisibile++; gallery_set_navlinkimg(2,gallery[gallerypos-1]["thumb"],"javascript:gallery_go("+(gallerypos-1)+");"); } else gallery_set_navlinkimg_blank(2); //Rechtes Bild 1 setzen if(galleryposw)xPos-=(wnav-w)/2; else xPos+=(w-wnav)/2; //Y Berechnen tempEl = srctop.offsetParent; while (tempEl != null) { yPos += tempEl.offsetTop; tempEl = tempEl.offsetParent; } if(galleryconfig["navinimg"]) {//Navigation sitzt unten im Img yPos+=element["h"]-galleryconfig["thumbh"]+galleryconfig["navborderh"]; }else {//Navigation sitzt unterhalb des Bildes yPos+=element["h"]+galleryconfig["navborderh"]; nav.style.visibility="visible"; } // Position setzen nav.position="absolute"; nav.style.display="inline"; nav.style.top=yPos+"px"; nav.style.left=xPos+"px"; } if(galleryconfig["slideshowtime"]) { if(galleryconfig["timer"]!=null)window.clearTimeout(galleryconfig["timer"]); galleryconfig["timer"]=window.setTimeout("gallery_next()", galleryconfig["slideshowtime"]*1000); } } /** * setzt die Navigation auf Blank * @param num * @return */ function gallery_set_navlinkimg_blank(num) { galleryelements["link"+num].href="#"; galleryelements["img"+num].src=galleryconfig["blank"]; } /** * setzet die Nav auf eine bestimmte Url * @param num * @param imgurl * @param href * @return */ function gallery_set_navlinkimg(num,imgurl, href) { galleryelements["link"+num].href=href; galleryelements["img"+num].src=imgurl; } /** * zeigt ein neues Bild in der Gallerie * @return */ function gallery_show_img() { var imgp=new Image(); element=gallery[gallerypos]; //gallery_log("gallery_show_img:"+imgp.src); if(window.addEventListener) { // Standard imgp.addEventListener("load", gallery_show_img_loaded, false); } else if(window.attachEvent) { // IE imgp.attachEvent('onload', gallery_show_img_loaded); } else gallery_show_img_loaded(); imgp.src=element["isimage"]?element["url"]:element["thumb"]; } /** * springt zu diesem Bild * @param num * @return */ function gallery_go(num) { gallery_stoptimer(); gallerypos=num; gallery_show_img(); } /** * springt zum nächsten Element * @return */ function gallery_previous() { gallery_stoptimer(); gallerypos--; if(gallerypos<0)gallerypos=0; else gallery_show_img(); } /** * springt zum nächsten Element * @return */ function gallery_next() { gallery_stoptimer(); gallerypos++; if(gallerypos>=gallery.length)gallerypos=0; if(gallery.length>1)gallery_show_img(); } /** * öffnet das Bild * @return */ function gallery_imgpopup() { if(galleryconfig["slideshowtime"]) { if(window.addEventListener) { // Standard ////gallery_log("window.addEventListener"); imgWin.addEventListener("unload", gallery_restarttimer, false); } else if(window.attachEvent) { // IE imgWin.attachEvent('onunload', gallery_restarttimer); } gallery_stoptimer(); if(galleryconfig["navinimg"])galleryelements["divnav"].style.visibility="hidden"; } } /** * Startet den Timer erneut * @return */ function gallery_stoptimer() { if(galleryconfig["timer"]!=null)window.clearTimeout(galleryconfig["timer"]); galleryconfig["timer"]=null; } /** * Startet den Timer erneut * @return */ function gallery_restarttimer() { if(galleryconfig["slideshowtime"]) { gallery_stoptimer(); galleryconfig["timer"]=window.setTimeout("gallery_next()", galleryconfig["slideshowtime"]*1000); } } /** * anzeigen der Navigation * @return */ function gallery_onmouseover(){ if(galleryconfig["stat"]<11)return; if(galleryconfig["navinimg"])galleryelements["divnav"].style.visibility="visible"; }/** * anzeigen der Navigation * @return */ function gallery_onmouseout(){ if(galleryconfig["stat"]<11)return; if(galleryconfig["navinimg"])galleryelements["divnav"].style.visibility="hidden"; } function unescapeHTML(html) { var htmlNode = document.createElement("DIV"); htmlNode.innerHTML = html; if(htmlNode.textContent!=undefined)return htmlNode.textContent; // IE return htmlNode.innerText; // FF }