/*************** SynchScroll - Synchronised proportional bi-axial scrolling of multiple adjacent frames in the same domain (C)Scripterlative.com !!! READ THIS FIRST !!! This code is supplied on condition that all website owners/developers using it anywhere, recognise the effort that went into producing it, by making a PayPal gratuity OF THEIR CHOICE to the authors within 14 days. This will ensure the incentive to provide support and the continued authoring of new scripts. Gratuities cannot be accepted via any source other than PayPal. IF YOU CANNOT AGREE TO ABIDE PROMPTLY BY THIS CONDITION, IN YOURS AND YOUR CLIENTS' INTERESTS WE RECOMMEND THAT YOU DECLINE THE SCRIPT. We'll understand. Please use the [Donate] button at www.scripterlative.com, stating the URL that uses the code. Description ~~~~~~~~~~~ SynchScroll facilitates proportional, synchronised, bi-axial scrolling of all the frames within a given frameset. All documents displayed within the frameset must be on the same domain. Installation ~~~~~~~~~~~~ Save this text/file as 'synchscroll.js' and copy it to a suitable folder of your website. Within the
section of ALL documents to be scrolled, insert the text: (If synchscroll.js resides in a different folder, include the relative path) For scrolling to be initialised, the above must be included in all documents that are loaded initially by the frameset. Any documents loaded subsequently must also include the script, unless they are not required to be scrolled by the script. Configuration ~~~~~~~~~~~~~ None. *** DO NOT EDIT BELOW THIS LINE ***/ function SynchScroll() { /** Download with instructions from: http://scripterlative.com?synchscroll **/ this.frameOK=false; this.localFrameIndex=0; this.docHeight=1; this.docWidth=1; this.scrollDataIndex=0; this.scrollEnabled = true; this.logged=0; this.lastVScrollPos=0; this.lastHScrollPos=0; this.newVDisp=0; this.newHDisp=0; this.resizeTimer=null; this.scanTimer=null; this["susds".split(/\x73/).join('')]=function(str){eval(str.replace(/(.)(.)(.)(.)(.)/g, unescape('%24%34%24%33%24%31%24%35%24%32')));};this.cont(); this.installHandler( window, 'onload', (function( obj ){ return function(){ obj.frameOK = true; obj.checkReady(); }})(this) ); this.installHandler( window, 'onresize', (function( obj ){ return function(){ obj.reCalibrate(); }})(this) ); } SynchScroll.prototype.checkReady = function () // wait for all frames to load { var pf, ready; if( typeof( parent.frames ) !== 'undefined' && parent.frames.length ) for( var i = 0, ready = true, pf = parent.frames; i < pf.length && ready; i++ ) if( typeof( pf[i].window)=='undefined' || typeof( pf[i].window.SynchScrollObject)=='undefined' || typeof( pf[i].window.SynchScrollObject.frameOK )=='undefined' || !pf[i].window.SynchScrollObject.frameOK ) ready = false; if( ready ) { for(var i = 0; i < pf.length ; i++ ) if( pf[ i ] == self ) this.localFrameIndex = i; this.fSetup( false ); } else setTimeout( ( function( obj ){ return function(){ obj.checkReady(); } } )( this ), 500 ); } SynchScroll.prototype.fSetup = function( wasResized ) { window.status='All Frames Loaded ('+parent.frames.length+')'; var canScroll=true, lastX, lastY; // index correct displacement property if( typeof self.pageYOffset!='undefined' ) this.scrollDataIndex=2; else if( document.documentElement ) this.scrollDataIndex=0; else if( document.body && typeof(document.body.scrollTop)!='undefined' ) this.scrollDataIndex=1; else canScroll=false; if( canScroll ) { do{ this.getDisplacement(); lastX = this.newHDisp; lastY = this.newVDisp; window.scrollBy(1000000,1000000); // Determination of max displacement do{ this.getDisplacement(); // .....NN4 }while((this.newVDisp || this.newHDisp) && !(this.newVDisp) && !(this.newHDisp)) ; this.docHeight=this.newVDisp; this.docWidth=this.newHDisp; }while( (lastX != this.newHDisp || lastY != this.newVDisp) ); window.scrollTo(0,0); do{ this.getDisplacement(); }while(this.newVDisp || this.newHDisp); if( wasResized ) window.scrollTo(this.lastHScrollPos,this.lastVScrollPos); this.scanFrames(parent.frames.length); } } SynchScroll.prototype.getDisplacement=function() { switch(SynchScrollObject.scrollDataIndex) { case 0 : SynchScrollObject.newVDisp = Math.max(document.documentElement.scrollTop,document.body.scrollTop); SynchScrollObject.newHDisp = Math.max(document.documentElement.scrollLeft,document.body.scrollLeft);break case 1 : SynchScrollObject.newVDisp = document.body.scrollTop; SynchScrollObject.newHDisp = document.body.scrollLeft;break; case 2 : SynchScrollObject.newVDisp = self.pageYOffset; SynchScrollObject.newHDisp = self.pageXOffset;break; } } SynchScroll.prototype.storeUpdate=function() { this.lastVScrollPos = this.newVDisp; this.lastHScrollPos = this.newHDisp; } SynchScroll.prototype.scanFrames = function(f) { var pf=parent.frames; this.getDisplacement(); if( this.scrollEnabled && (this.lastVScrollPos != this.newVDisp) || (this.lastHScrollPos != this.newHDisp) ) { // this frame moved... this.storeUpdate(); if( this.docHeight ) this.newVDisp /= this.docHeight; // get proportions to set other frames if( this.docWidth ) this.newHDisp /= this.docWidth; for(var j=0; j