/*********************************************************************************************** // DHTML-library 1.0 Stanislav Saric / sanafir new media & online AG 2001 // Status = finished // Range of functionality: NS4-6 & IE4x - 6.0 on Windows / NS4.x & MSIE5.0 on Macintosh // Comments: none // Copyright 2001: sanafir new media & online AG // http://www.sanafir.de ************************************************************************************************/ // 1. General functions //initiating variables - do not edit here var theObj = ""; var isNav,isIE,macNS,winNS,winIE,macIE; // description: checks for layer-compatible browsers & redirects other browsers to another URL // status: finished function checkDHTML(redirectUrl){ if (parseInt(navigator.appVersion)>=4){ if (navigator.appName == "Netscape"){ isNav = true; } if (navigator.appName.indexOf("Internet Explorer")!= -1){ isIE = true; } } if (!isNav && !isIE){ top.location.href = redirectUrl; } } // description: assigns a variable depending on operating system and browser // status: finished function checkBrowser(){ if (parseInt(navigator.appVersion)>=4){ if (navigator.appName == "Netscape"){ if (navigator.platform.indexOf("Mac") != -1){ macNS = true; //Mac NS } else{ winNS = true; //Win NS } } else{ if (navigator.platform.indexOf("Win") != -1){ winIE = true; //Win IE } else{ macIE = true;//Mac IE } } } } // description: returns width of content region in browser window // status: finished function getWindowWidth(){ if(window.innerWidth){ return window.innerWidth; }else if(document.all){ return document.body.clientWidth; } } // description: returns height of content region in browser window // status: finished function getWindowHeight(){ if(window.innerHeight){ return window.innerHeight; }else if(document.all){ return document.body.clientHeight; } } // description: returns height of document in px // status: finished function getDocumentHeight(){ if(document.layers){ return document.height; }else if(document.getElementById) { return document.body.offsetHeight; } } // description: returns scrolled height in a document // status: finished function getScrollHeight(){ if(document.all){ return document.body.scrollTop; }else{ return pageYOffset; } } // 2. Layer functions // description: returns a reference to a layer object // status: finished // comment: returns no nested NS4-layers function getLayer(obj){ var theObj; if (typeof obj == "string"){ if(document.layers){ theObj = eval("document." + obj); } if(document.all){ theObj = eval("document.all." + obj); }else if(document.getElementById){ theObj = document.getElementById(obj); } }else{ theObj = obj; } return theObj; } // description: writes data in a layer // status: finished function writeLayer(obj,cont){ var theObj = getLayer(obj); if(document.layers){ theObj.document.open(); theObj.document.write(cont); theObj.document.close(); }else{ theObj.innerHTML = cont; } } // description: returns the height of a layer // status: finished // comment: this function returns unreliable results in NS function getLayerHeight(obj){ var theObj = getLayer(obj); if(document.layers){ return theObj.clip.height; } if(document.all){ return theObj.style.pixelHeight; }else if(document.getElementById){ return theObj.offsetHeight; } } // description: returns the width of a layer // status: finished // comment: this function returns unreliable results in NS function getLayerWidth(obj){ var theObj = getLayer(obj); if(document.layers){ return theObj.clip.width; } if(document.all){ return theObj.style.pixelWidth; }else if(document.getElementById){ return theObj.offsetWidth; } } // description: returns the y position of a layer // status: finished function getLayerTop(obj){ var theObj = getLayer(obj); if(document.layers){ return theObj.top; } if(document.all){ return theObj.style.pixelTop; }else if(document.getElementById){ return theObj.offsetTop; } } // description: returns the x position of a layer // finished function getLayerLeft(obj){ var theObj = getLayer(obj); if(document.layers){ return theObj.left; } if(document.all){ return theObj.style.pixelLeft; }else if(document.getElementById){ return theObj.offsetLeft; } } // description: moves a layer to a position // status: finished function moveLayer(obj,x,y){ var theObj = getLayer(obj); if(document.layers){ theObj.moveTo(x,y); } if(document.all){ theObj.style.pixelLeft = x; theObj.style.pixelTop = y; }else if(document.getElementById){ theObj.style.left = eval("\"" + x + "px\""); theObj.style.top = eval("\"" + y + "px\""); } } // description: moves a layer by certain x,y values // status: finished function moveLayerBy(obj,deltaX,deltaY){ var theObj = getLayer(obj); if(document.layers){ theObj.moveBy(deltaX,deltaY); } if(document.all){ theObj.style.pixelLeft += deltaX; theObj.style.pixelTop += deltaY; }else if(document.getElementById){ theObj.style.left = eval("\"" + parseInt(getLayerLeft(obj)+deltaX) + "px\""); theObj.style.top = eval("\"" + parseInt(getLayerTop(obj)+deltaY) + "px\""); } } // description: sets the z-index of a layer // status: finished function setZIndex(obj,zOrder){ var theObj = getLayer(obj); if(document.layers){ theObj.zIndex = zOrder; } if(document.all){ theObj.style.zIndex = zOrder; }else if(document.getElementById){ theObj.style.zIndex = zOrder; } } // description: reads the z-index of a layer // status: finished function getZIndex(obj){ var theObj = getLayer(obj); if(document.layers){ return theObj.zIndex; } if(document.all){ return theObj.style.zIndex; }else if(document.getElementById){ return theObj.style.zIndex; } } // description: sets a layer visible // status: finished function showLayer(obj){ var theObj = getLayer(obj); if(document.layers){ theObj.visibility = "show"; } if(document.all){ theObj.style.visibility = "visible"; }else if(document.getElementById){ theObj.style.visibility = "visible"; } } // description: sets a layer invisible // status: finished function hideLayer(obj){ var theObj = getLayer(obj); if(document.layers){ theObj.visibility = "hide"; } if(document.all){ theObj.style.visibility = "hidden"; }else if(document.getElementById){ theObj.style.visibility = "hidden"; } } // description: clipping a layer (t=top,r=right,b=bottom,l=left) // status: finished function clipLayer(obj,t,r,b,l){ var theObj = getLayer(obj); if(document.layers){ theObj.clip.top = t; theObj.clip.right = r; theObj.clip.bottom = b; theObj.clip.left = l; //theObj.clip.width = ; //theObj.clip.height = ; } if(document.all){ theObj.style.clip = eval("\"rect(" + t + "px " + r + "px " + b + "px " + l + "px)\""); }else if(document.getElementById){ theObj.style.clip = eval("\"rect(" + t + "px " + r + "px " + b + "px " + l + "px)\""); } } // description: returns clipping values of a layer (t=top,r=right,b=bottom,l=left) // write those values: "t","r","b","l" when you call the function i.e. getClipLayer('layer','r') // status: finished function getClipLayer(obj,V){ var theObj = getLayer(obj); if(document.layers){ if(V=="t") return theObj.clip.top; if(V=="r") return theObj.clip.right; if(V=="b") return theObj.clip.bottom; if(V=="l") return theObj.clip.left; }else{ var s = new String(theObj.style.clip); var w = s.split("px"); if(V=="t") return w[0].substring(5,w[0].length); if(V=="r") return parseInt(w[1]); if(V=="b") return parseInt(w[2]); if(V=="l") return parseInt(w[3]); } } // description: sliding clipping of a layer (t=top,r=right,b=bottom,l=left) // following parameters: // obj = the layer // V = which clipping-property following entries are allowed:('t'=top,'r'=right,'b'=bottom,'l'=left) // Val = the steps of clipping in pixel // En = the EndPosition of the clipping-property // speed = the speed of sliding in milliseconds // EXAMPLE: slideClip('mylayer','b',-1,100,10); // !!! make sure the clipping values (start- and endPosition) are dividable by the steps of clipping !!! // !!! make also sure the layer has already clipping-values before you call this function !!! // status: finished function slideClip(obj,V,Val,En,speed){ var theObj = getLayer(obj); Vx = V; Valx = Val; objx = obj; Enx = En; speedx = speed; if (getClipLayer(obj,V)==En){ clearTimeout(TI); }else{ TI = setTimeout("sc(objx,Vx,Valx)",speed); } } // belongs to function above function sc (obj,V,Val){ var theObj = getLayer(obj); if(document.layers){ if(V=="t"){theObj.clip.top = getClipLayer(obj,V) + Val;} if(V=="r"){theObj.clip.right = getClipLayer(obj,V) + Val;} if(V=="b"){theObj.clip.bottom = getClipLayer(obj,V) + Val;} if(V=="l"){theObj.clip.left = getClipLayer(obj,V) + Val;} }else{ t = (V=="t") ? parseInt(getClipLayer(obj,"t")) + Val + "px " : getClipLayer(obj,"t")+ "px "; r = (V=="r") ? getClipLayer(obj,"r") + Val + "px " : getClipLayer(obj,"r") + "px "; b = (V=="b") ? getClipLayer(obj,"b") + Val + "px " : getClipLayer(obj,"b") + "px "; l = (V=="l") ? getClipLayer(obj,"l") + Val + "px" : getClipLayer(obj,"l") + "px"; theObj.style.clip = eval("\"rect(" + t + r + b + l + ")\""); } slideClip(obj,Vx,Valx,Enx,speedx); } // description: sliding a layer // following parameters: // obj = the layer // X = the steps of horizontal sliding in pixel // Y = the steps of vertcal sliding in pixel // XEn = the horizontal EndPosition // YEn = the vertical EndPosition // speed = the speed of sliding in milliseconds // EXAMPLE: slideLayer('mylayer',2,2,500,500,10); // !!! make sure the sliding values (start- and endPosition) are dividable by the steps of sliding !!! // status: finished function slideLayer(obj,X,Y,XEn,YEn,speed){ var theObj = getLayer(obj); Xxx = X; Yxx = Y; objxx = obj; XEnxx = XEn; YEnxx = YEn; speedxx = speed; Xarr = false; Yarr = false; var ycord = getLayerTop(obj); var xcord = getLayerLeft(obj); if(xcord == XEn){Xarr=true;} if(ycord == YEn){Yarr=true;} if (Xarr==true && Yarr==true){ if(!slidingEnded){ slidingEnded = true; // CLEFT } clearTimeout(TIx); }else{ TIx = setTimeout("sl(objxx,Xxx,Yxx)",speed); } } // belongs to function above function sl(obj,deltaX,deltaY){ if(Xarr==true){ moveLayerBy(obj,0,deltaY); }else if(Yarr==true){ moveLayerBy(obj,deltaX,0); }else{ moveLayerBy(obj,deltaX,deltaY); } slideLayer(obj,Xxx,Yxx,XEnxx,YEnxx,speedxx); }