/************************************************** ** (C)J.Schranz (juergen.schranz@a1.net) 02.2k1,04.04.2001 ** All rights reserved. Unauthorized copying, reproduction and/or use of the whole or parts of ** this content or the idea in one way or another is disallowed an needs to be approved explicitley ** in a written form by Jürgen Schranz. made in austria Version 1.1.1 27.04.2001 Version 1.1.2 10.06.2001*/ //=====DECLARES===== document.to=0; //timeout var fd=null; //Fade-Object // //=====OBJECT_CLASS===== var JSFade_class=new Array(); function JSFade() { if (!JSFade.prototype.gallery) return; this.aSpeed=0; //average time this.iSpeed=0; //number of measured timevalues this.instance=JSFade_class.length; //points to this class JSFade_class[this.instance]=this; //save array-number where the pointer stored this.matrix=new Object(); this.matrix.cols=3; //columns in matrix this.matrix.rows=3; //rows in matrix this.matrix.padding=2; //padding between fields/pictures this.matrix.border=0; //0=no border for each field this.matrix.bordercolor="#ffffff"; //color of border for fields this.matrix.lock=""; //lock fields e.g. ="1/1,2/1" (col 1 row 1, col 2 row 1) this.matrix._alock=new Array(); //Array von lock this.matrix.width=100; //width of each picture this.matrix.height=100; //height of each picture this.matrix.imgBG="Fade_base.gif"; //base-picture for matrix this.matrix.imgTransparent="Transparent.gif"; //transparent picture for mouse-over layer this.matrix.imgFadeIn="Fade.gif"; //fade-in picture this.matrix.imgFadeInTime=500; this.matrix.imgFadeOut="Fade_away.gif"; //fade-out picture this.matrix.imgFadeOutTime=2300; this.matrix.count=eval(this.matrix.cols*this.matrix.rows);//number of fields //this.matrix.show=new Function('alert("Hello");'); this.matrix.show=new Function("JSFade_class["+this.instance+"]._matrix_show();"); //prints the matrix on screen this.matrix.onMouseOver=new Function("index","JSFade_class["+this.instance+"]._matrix_onMouseOver(index);"); this.matrix.onMouseOut=new Function("index","JSFade_class["+this.instance+"]._matrix_onMouseOut(index);"); this.matrix.onMouseClick=new Function("index","JSFade_class["+this.instance+"]._matrix_onMouseClick(index);"); this.mfields=this.matrix.count; this.delay=0; //delay before display next picture this.random_l1=true; //true=get 1st-level pictures by chance this.random_l2=true; //false=get mouseover pictures with same index as 1st-level picture otherwise choose by chance this.random_matrix=true; //false=show gallery in a line (Matrix 0,1...n), true=show in random order this.ClearOnMouseOut=true; //true=set blankimg afte on_mouse_out this.DontUseFader=false; //true=fader will not be used this.DontDispPicFromGallery2=false; //true=no picture from gallery2 will display on initialization this.vwMatrix=0; //actual choosed field in matrix this.vwGallery=0; //actual choosed pictures from gallery this.browser=(navigator.appName=="Netscape") ? "NS" : "IE"; this.vwJS=0; this.gx=null; this.gallery1=new Array(); //pictures which will be displayed first this.gallery2=new Array(); //pictures which will be displayed onMouseOver this.i=0; this.view=new Object(); this.view.matrix_show=new Array(); //which fields in actual lap already shown this.view.matrix=new Array(); //which fields are free and for omit displaying twice for (i=0;i"); this.error=false; if(_JSFade_Gallery.arguments.length==1) { if(typeof(aGallery)=="number") { //if aGallery is a number switch(aGallery) { case 1: //1=base gallery aGallery="gallery1"; break; case 2: //2=mouseover gallery aGallery="gallery2"; break; } } if(typeof(aGallery)=="object") { this.aGallery=aGallery; } else if(typeof(this[aGallery])=="undefined") { aGallery=this[aGallery]=new Array(); } //assign new gallery else if(typeof(this[aGallery])=="object") { aGallery=this[aGallery]; } //get gallery else { //parameter is not valid this.error=true; alert("ERROR defining gallery-array\nObject: class.JSFade.gallery\n\n"+ "Given Parameter must be a string or an array-object."); } //alert(_JSFade_Gallery.arguments.length+", type="+typeof(aGallery)); } this.aGallery=aGallery; //assign array to this instance this.oGallery=null; this.oGallery=new Object(); //define object for sub-methods //---functions--- this.oGallery.set=new Function("imgsrc","return JSFade_class["+this.instance+"]._gallery_set(JSFade_class["+this.instance+"].aGallery,imgsrc);"); this.oGallery.load=new Function("icnt","return JSFade_class["+this.instance+"]._gallery_load(JSFade_class["+this.instance+"].aGallery,icnt);"); this.oGallery.loaded=new Function("idir","return JSFade_class["+this.instance+"]._gallery_loaded(JSFade_class["+this.instance+"].aGallery,idir);"); this.oGallery.match=new Function("index","return JSFade_class["+this.instance+"]._gallery_match(JSFade_class["+this.instance+"].aGallery,index);"); this.oGallery.func=new Function("f","return JSFade_class["+this.instance+"]._gallery_func(JSFade_class["+this.instance+"].aGallery,f);"); //---properties--- this.oGallery.ipath=new Function("p","return JSFade_class["+this.instance+"]._gallery_ipath(JSFade_class["+this.instance+"].aGallery,p);"); this.oGallery.count=new Function("var ag=JSFade_class["+this.instance+"].aGallery; if (!ag.length) { return 0; } else if (ag[0].empty) { return 0; } else { return eval(ag.length); }"); this.oGallery.img=this.aGallery; //new Function("return JSFade_class["+this.instance+"].aGallery;"); if(_JSFade_Gallery.arguments.length!=1||typeof(aGallery)!="object") { //if no gallery-array is given this.error=true; alert("ERROR: argument incorrect.\nObject: class.JSFade.gallery\n\n"+ "Wrong number of arguments or no image-object used.\n"+ "Please use an existing image-object as argument."); } if(this.error) { //if an error has been found var i; //clear all functions and return false; for(i in this.oGallery) { if(typeof(this.oGallery[i])=="function") { this.oGallery[i]=new Function("return false;"); } } return this.oGallery; } if(aGallery.length==0) this._gallery_set(this.aGallery,""); //set defaultvalues return this.oGallery; } // //---SUB-METHOD-TO-GALLERY:_CREATES_NEW_IMAGE_OBJECT--- function _JSFade_Gallery_Set(a,imgsrc) { //a -gallery-array //imgsrc -filename of picture var gx=null; if(a.length==0) { //gallery has no entries, create preferences for gallery gx=a[0]=new Object(); gx.ipath="./images"; gx.func=""; gx.empty=true; } else if(a.length==1&&a[0].empty) { //only preferences exist, use gallery-index=0 gx=a[0]; gx.empty=false; } else { //otherwise create new gallery-entry gx=a[a.length]=new Object(); } if(a[0].ipath.length) { if(a[0].ipath.charAt(a[0].ipath.length-1)!="/") { a[0].ipath+="/"; }} var isrc=""; if(imgsrc.length) { isrc=(imgsrc.charAt(0)=="/")?imgsrc.slice(1):imgsrc; } gx.name=a[0].ipath+isrc; gx.item=isrc; if(isrc.length&&isrc.lastIndexOf(".")>=0) { gx.item=isrc.slice(0,isrc.lastIndexOf(".")); } gx.ext=""; if(isrc.length&&isrc.lastIndexOf(".")>=0) { gx.ext=isrc.slice(isrc.lastIndexOf(".")+1); } gx.d=""; gx.area=new Function("item","d","this.item=item;this.d=(!d)?document:d;"); gx.img_onerror=new Function("this.error=true;return true;"); gx.img=new Image(); gx.img.error=false; gx.img.onerror=gx.img_onerror; return gx; } // //===PRELOAD_IMAGES=== function _JSFade_Gallery_Load(igallery,icnt) { //igallery -image array //cnt -number of images to load var i=0; if (this.gallery(igallery).loaded("img")) return false; //---load_max_of_(icnt)_new_pictures--- var ig_cnt=0; for (var ig in igallery) { var ig_obj=igallery[ig].img; if (igallery[ig].name.length>0 && ig_obj.src.length==0 && ig_obj.error==false) { ig_obj.src=igallery[ig].name; ig_cnt++; } if (ig_cnt>=((_JSFade_Gallery_Load.arguments.length==1) ? igallery.length : icnt)) break; //load maximum number of pictures } return true; } //===CHECK_FOR_LOADED_IMAGES=== function _JSFade_Gallery_Loaded(igallery,idir) { //igallery -image array //idir -image-object (if not given, igallery is an image-object itself) var ig,ig_obj; this.doLoad=this.bLoaded=0; for (ig=0;ig0) { if (ig_obj.error==null) ig_obj.error=false; this.doLoad++; if (ig_obj.complete || ig_obj.error) this.bLoaded++; } } //alert("cntGallery="+igallery.length+"\n"+doLoad+"/"+bLoaded); return ((eval(this.doLoad-this.bLoaded)<0) ? 0 : eval(this.doLoad-this.bLoaded)); } // //===SEARCH_FOR_A_PICTURE_IN_THE_GALLERY=== function _JSFade_Gallery_Match(a,v) { if(typeof(v)=="number") { if(v0) { if (this.gallery1[ig].img.complete) this.mfields++; } } if (!this.mfields) { // if no picture currently loaded if (this.gallery(1).loaded("img")==0) this.gallery(1).load(1); // load a picture, if nothing in loading state if (this.gallery(2).loaded("img")==0) this.gallery(2).load(1); // load a picture, if nothing in loading state //alert("load pictures"); document.to=setTimeout("javascript:JSFade_class["+this.instance+"]._slideshow()",100); // and try this member-function again return; } this.mfields=eval(this.bLoaded); // get number of loaded pictures from gallery1 this.timeslot=eval((new Date()).getTime()-this.timeslotT) // elapsed time since last slideshow this.timeslotT=(new Date()).getTime(); // get time for time-measurement slideshow window.status="bLoaded="+this.bLoaded+" , doLoad="+this.doLoad+", mfields="+this.mfields+", time="+this.timeslot; if (this.view.matrix_show.length>=this.mfields) { this.view.matrix_show=new Array(); if (this.matrix._alock.length>0) { for (i=0;i=this.matrix.count) { this.view.matrix_show=new Array(); this.vwMatrix=0; } } for(this.x=0;this.x=0) { // field not empty this.bkupMatrix=this.match(this.view.matrix,-1); // search for empty field if (this.bkupMatrix>=0) { // if found then save fieldplace if (this.match(this.matrix._alock,this.bkupMatrix)<0) { // field is not locked this.vwMatrix=this.bkupMatrix; } else { // field locked, try next field //this.view.matrix[vwMatrix]=999; this.vwMatrix++; if (this.vwMatrix>=this.matrix.count) this.vwMatrix=0; } } else if(this.vwMatrix==this.lastMatrix) { // if it was the same field before this.vwMatrix++; if (this.vwMatrix>=this.matrix.count) this.vwMatrix=0; } } if (this.match(this.view.matrix_show,this.vwMatrix)<0) { // if displayed in current round, try again if (this.match(this.matrix._alock,this.vwMatrix)<0) { break; } else { //this.view.matrix[vwMatrix]=999; this.vwMatrix++; if (this.vwMatrix>=this.matrix.count) this.vwMatrix=0; } } this.vwMatrix++; if (this.vwMatrix>=this.matrix.count) this.vwMatrix=0; } //window.status="Matrix Field="+this.vwMatrix+", Value="+this.view.matrix[this.vwMatrix]; //window.status="Matrix "+eval(this.mfields-this.view.matrix.length)+"/"+this.mfields+"... "+this.vwMatrix+">>"+this.view.matrix.join(); if (this.view.matrix_show.length==(this.mfields-1)) { this.view.matrix_show=new Array(); if (this.matrix._alock.length>0) { for (i=0;i=this.gallery1.length) { // reset gallery-history, if the whole set of gallery is shown this.vwGallery=this.view.gallery[this.view.gallery.length-1]; this.view.gallery=new Array(); this.view.gallery[0]=this.vwGallery; } if(this.random_l1) { this.vwGallery=Math.round(Math.random()*(this.gallery1.length-1)); } else { this.vwGallery=eval(this.view.gallery.length); if (this.vwGallery>=this.gallery1.length) this.vwGallery=0; } for (this.x=0;this.x0&&this.gallery1[this.vwGallery].img.complete) { this.bkupMatrix=this.match(this.view.matrix,this.vwGallery); if (this.bkupMatrix>=0&&this.gallery1.length<=this.matrix.count) { //if(this.gallery1.length==1||this.match(this.view.gallery,this.vwGallery)<0) { //if(!this.DontUseFader) JS_swapImage('f'+eval(this.bkupMatrix+1),'',this.imgs.FadeOut[0].name,0); //JS_swapImage('p'+eval(this.bkupMatrix+1),'',this.imgs.BG[0].name,0); this.view.matrix[this.bkupMatrix]=-1; break; //} } else if(this.gallery1.length==1) { break; } else if(this.bkupMatrix<0&&this.match(this.view.gallery,this.vwGallery)<0) { break; } } this.vwGallery++; if (this.vwGallery>=this.gallery1.length) this.vwGallery=0; } if(this.x==this.gallery1.length&&this.gallery1[this.vwGallery].img.error) { //if selected picture has a load-error for(this.x=0;this.x0&&this.gallery1[this.x].img.complete) { this.vwGallery=this.x; break; } } if(this.x==this.gallery1.length) return; //if no complete loaded picture was found, stop the slide show } //window.status="Gallery "+eval(this.gallery1.length-this.view.gallery.length)+"/"+this.gallery1.length+"... "+this.vwGallery+">>"+this.view.gallery.join(); //---FADE_OLD_PICTURE--- //alert(this.view.gallery.length+">\n"+this.vwMatrix+"\n"+this.vwGallery); if(!this.DontUseFader) JS_swapImage('f'+eval(this.vwMatrix+1),'',this.imgs.FadeIn[0].name,0); if (this.gallery(1).loaded("img")==0) this.gallery(1).load(1); if (this.gallery(2).loaded("img")==0) this.gallery(2).load(2); this.speed-=eval((new Date()).getTime()); this.speed=Math.abs(this.speed); this.aSpeed=eval(((this.aSpeed*this.iSpeed)+this.speed)/(this.iSpeed+1)); this.iSpeed++; //window.status=this.speed+"\n"+this.aSpeed+" ("+this.iSpeed+")"; this.gDelay=eval(this.delay+((this.browser=="IE"&&!this.DontUseFader)?this.matrix.imgFadeOutTime:2)); //window.status="browser="+this.browser+", DontUseFader="+this.DontUseFader+", delay="+this.gDelay+", last timeslot="+this.timeslot; document.to=setTimeout("javascript:JSFade_class["+this.instance+"]._slideshow_fading()", this.gDelay); } // //===FADE_TO_NEW_PICTURE_IN_PREVIOUSLY_DEFINED_PLACE=== function _JSFade_SlideShow_Fading() { if (document.to) clearTimeout(document.to); if (this.bkupMatrix>=0&&this.gallery1.length<=this.matrix.count) { if(!this.DontUseFader) JS_swapImage('f'+eval(this.bkupMatrix+1),'',this.imgs.FadeOut[0].name,0); JS_swapImage('p'+eval(this.bkupMatrix+1),'',this.imgs.BG[0].name,0); } //---SAVE_MATRIX_POSITION_AND_NEW_SELECTED_PICTURE--- this.view.matrix_show[this.view.matrix_show.length]=this.vwMatrix; this.view.matrix[this.vwMatrix]=this.vwGallery; this.view.gallery[this.view.gallery.length]=this.vwGallery; //---FADE_TO_NEW_PICTURE--- JS_swapImage('p'+eval(this.vwMatrix+1),'',this.gallery1[this.vwGallery].name,0); if(!this.DontUseFader) JS_swapImage('f'+eval(this.vwMatrix+1),'',this.imgs.FadeOut[0].name,0); document.to=setTimeout("javascript:JSFade_class["+this.instance+"]._slideshow()",this.matrix.imgFadeInTime); if(!this.DontUseFader) this.DontUseFader=(this.aSpeed>400)?true:false; } // //===ONMOUSE_OVER_MATRIX:_FADE_TO_PORTRAIT=== function _JSFade_Matrix_OnMouseOver(img) { if (document.to) clearTimeout(document.to); if (this.gallery(2).loaded("img")==0) this.gallery(2).load(1); //---NEW_PICTURE_NOT_CURRENTLY_DISPLAYED:_THEN_FADE_AND_FORGET_IT--- if (this.vwMatrix>=0 && this.match(this.view.matrix,this.vwMatrix)<0) { if(!this.DontUseFader) JS_swapImage('f'+eval(this.vwMatrix+1),'',this.imgs.FadeOut[0].name,0); this.vwMatrix=-1; } if(!this.random_l2) { //---SELECT_PORTRAIT_WITH_SAME_INDEX_AS_LAYER-1_PORTRAIT--- this.vwJS=this.view.matrix[eval(img-1)]; if(this.vwJS<0||this.vwJS>this.gallery2.length) { if(this.vwJS!=999) JS_swapImage('p'+eval(img),'',this.imgs.BG[0].name,0); return; } } else { //---SELECT_NEW_PORTRAIT--- if (this.view.js.length>=this.gallery2.length) this.view.js=new Array(); this.vwJS=Math.round(Math.random()*(this.gallery2.length-1)); for (this.x=0;this.x=this.gallery2.length) { this.vwJS=0; } } if(this.x==this.gallery2.length&&!this.gallery2[this.vwJS].img.complete) { document.to=setTimeout("javascript:JSFade_class["+this.instance+"]._slideshow()",2000); return; } } //window.status="Portrait "+eval(this.gallery2.length-this.view.js.length)+"/"+this.gallery2.length+"... "+this.vwJS+">>"+this.view.js.join(); var mx=0; //---IF_A_PICTURE_IS_CURRENTLY_ON_PLACE_OF_PORTRAIT--- if (this.ClearOnMouseOut) { if ((mx=this.match(this.view.matrix_show,eval(img-1)))>=0) { //---REMOVE_PICTURE_FROM_MATRIX--- var i=0,res=""; var re=new RegExp(".*","ig"); var rx=new RegExp("[/]","ig"); for (var x=0;x=0) { this.gx=this.view.gallery.slice(i+1,this.view.gallery.length); this.view.gallery=this.view.gallery.slice(0,i).concat(this.gx); //alert(x+" found:"+res+"\n"+this.view.gallery); } //alert("Img.no."+x+", stored in Array "+i+"\n"+this.gx.length+"\n"+this.view.gallery.length); break; } } //---RELEASE_PLACE_IN_MATRIX--- this.gx=this.view.matrix_show.slice(mx+1,this.view.matrix_show.length); this.view.matrix_show=this.view.matrix_show.slice(0,mx).concat(this.gx); } this.view.matrix[eval(img-1)]=eval(-1); } this.view.js[this.view.js.length]=this.vwJS; if(!this.DontUseFader) JS_swapImage('f'+img,'',this.imgs.FadeOut[0].name,0); //this.x=JS_findObj('p'+img); this.x.oSrc=this.x.src; //save last shown picture JS_swapImage('p'+img,'',this.gallery2[this.vwJS].name,0); } // //===ONMOUSE_OUT_MATRIX:_FADE_PORTRAIT=== function _JSFade_Matrix_OnMouseOut(img) { this.vm=this.view.matrix[eval(img-1)]; if (this.ClearOnMouseOut||this.vm==999||this.view.matrix[eval(img-1)]<0) { JS_swapImgRestore(); } else { JS_swapImage('p'+img,'',this.gallery1[this.vm].name,0); } document.to=setTimeout("javascript:JSFade_class["+this.instance+"]._slideshow()",this.matrix.imgFadeInTime); } // //===ONMOUSE_CLICK_MATRIX:_START_PREDEFINED_FUNCTION=== function _JSFade_Matrix_OnMouseClick(img) { this.vm=this.view.matrix[eval(img-1)]; //var pn=(this.vm==999||this.vm<0)?"":this.gallery1[this.vm].item; if(typeof(this.gallery2[0].func)=='function') this.gallery2[0].func(img,this.vm); document.to=setTimeout("javascript:JSFade_class["+this.instance+"]._slideshow()",500); } // //===PRINT_MATRIX=== function _JSFade_Matrix_Show() { this.imgs=new Object(); //load background- and fader-pictures this.imgs.BG=new Array(); this.imgs.Transparent=new Array(); this.imgs.FadeIn=new Array(); this.imgs.FadeOut=new Array(); with(this.gallery(this.imgs.BG)) { ipath(this.gallery1[0].ipath); set(this.matrix.imgBG); load(); } with(this.gallery(this.imgs.Transparent)) { ipath(this.gallery1[0].ipath); set(this.matrix.imgTransparent); load(); } with(this.gallery(this.imgs.FadeIn)) { ipath(this.gallery1[0].ipath); set(this.matrix.imgFadeIn); load(); } with(this.gallery(this.imgs.FadeOut)) { ipath(this.gallery1[0].ipath); set(this.matrix.imgFadeOut); load(); } if (this.matrix.lock.length>0) { this.matrix._alock=this.matrix.lock.split(","); //alert(this.matrix._alock.length); for (i=0;i'); write(''); write(''); //if (this.browser=="IE") document.write('
'); //this.browser="IE"; if (this.browser=="IE") { write(''); layer.name="JSGallery"; write(GetLayerTag(layer)); } write(''); var i,j,v; for(i=0;i'); for(j=1;j<=this.matrix.cols;j++) { v=eval((i*this.matrix.cols)+j); if(typeof(this.gallery2[0].func)=='function') { write(''); } write(''); } // write('
' +'
'); if(!this.DontUseFader) { //if(this.browser=="IE") { write(layer.endtag); layer.left="0px"; layer.name="JSFader"; layer.endtag=""; write(GetLayerTag(layer)); //} //dw('
'); write(''); for(i=0;i'); for(j=1;j<=this.matrix.cols;j++) { v=eval((i*this.matrix.cols)+j); if(typeof(this.gallery2[0].func)=='function') { write(''); } write(''); } write('
' +'
'); /*if (this.browser=="IE")*/ write(layer.endtag); } if (this.browser=="IE") write(""); write(''); write(''); write(''); } //---DISPLAY_ONE_PORTRAIT_ANYWHERE_IN_MATRIX-- if(this.DontDispPicFromGallery2) return; this.vwMatrix=Math.round(Math.random()*(this.mfields-1)); //this.view.matrix[this.vwMatrix]=999; //JS_swapImage('p'+eval(this.vwMatrix+1),'',"./juergen/js_pink1.gif",0); this.view.matrix[this.vwMatrix]=Math.round(Math.random()*(this.gallery2.length-1)); JS_swapImage('p'+eval(this.vwMatrix+1),'',this.gallery2[this.view.matrix[this.vwMatrix]].name,0); this.view.matrix[this.vwMatrix]=999; this.vwMatrix=-1; } // //===RUN_THE_FADER=== function _JSFade_Run() { document.to=setTimeout("javascript:JSFade_class["+this.instance+"]._slideshow()",500); } // //===EXTERNAL_FUNCTIONS_[IMPORTED_BECAUSE_OF_EXISTING] function JS_callJS(jsStr) { //v2.0 return eval(jsStr); } function JS_findObj(n, d) { //v3.0 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i0) tag = ' name="'+l.name+'" id="'+l.name+'"'; if (l.klasse.length>0) tag += ' class="'+l.klasse+'"'; if (browser=="NS") { tag = "0) tag += ' left="'+l.left+'"'; if (l.top.length>0) tag += ' top="'+l.top+'"'; if (l.width.length>0) tag += ' width="'+l.width+'"'; if (l.height.length>0) tag += ' height="'+l.height+'"'; tag += ' visibility="' + ((l.visibility) ? 'show"' : 'hide"'); l.endtag=''; } else { tag = '