/**** (C)Scripterlative.com

synchDivScroll.

Description
~~~~~~~~~~~
 Provides synchronised proportional manual scrolling of groups of overflowed or scrollable divs.
 
 Info: http://scripterlative.com?synchdivscroll

 These instructions may be removed but not the above text.

 Please notify any suspected errors in this text or code, however minor.

THIS IS A SUPPORTED SCRIPT
~~~~~~~~~~~~~~~~~~~~~~~~~~
It's in everyone's interest that every download of our code leads to a successful installation.
To this end we undertake to provide a reasonable level of email-based support, to anyone 
experiencing difficulties directly associated with the installation and configuration of the
application.

Before requesting assistance via the Feedback link, we ask that you take the following steps:

1) Ensure that the instructions have been followed accurately.

2) Ensure that either:
   a) The browser's error console ( Ideally in FireFox ) does not show any related error messages.
   b) You notify us of any error messages that you cannot interpret.

3) Validate your document's markup at: http://validator.w3.org or any equivalent site.   
   
4) Provide a URL to a test document that demonstrates the problem.
 
Installation
~~~~~~~~~~~~
 Save this text/file as 'synchdivscroll.js', and place it in a folder associated with your web pages.

 Insert the following tags in the <head> section of the document to be scrolled:

 <script type='text/javascript' src='synchdivscroll.js'></script>

 (If synchdivscroll.js resides in a different folder, include the relative path)

Configuration
~~~~~~~~~~~~~
 Within the <body> section at any point below all the involved scrollable divs, insert the 
 following code, replacing the parameters with the IDs of the divs in the synchronised group:

  <script type='text/javascript'>

   new SynchDivScroll('DivA', 'DivB' [, DivN]);

  </script>

 Any further synchronised div groups can be initialised within the same pair of <script> tags.
 Remember IDs are case sensitive.
 
 Example
 -------
 Synchronise a pair of divs with IDs 'dataA' & 'dataB':
 
  <script type='text/javascript'>

   new SynchDivScroll('dataA', 'dataB');

  </script>
  
Scroll On Load
~~~~~~~~~~~~~~
If any div within a synchronised group is scrolled prior to the initialisation of the script, 
(perhaps as the result of the action of another script, or a # anchor in the address bar), the 
script will scroll the other divs in the group to the proportional displacement.

GratuityWare
~~~~~~~~~~~~
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 donation OF THEIR CHOICE
to the authors. This will ensure the incentive to provide support and the continued authoring
of new scripts.

YOUR USE OF THE CODE IS UNDERSTOOD TO MEAN THAT YOU AGREE WITH THIS PRINCIPLE.

You may donate at www.scripterlative.com, stating the URL to which the donation applies.

** DO NOT EDIT BELOW THIS LINE **/

function SynchDivScroll()
{
 this.constructor.timedAssist = true;  
 this.logged=0;
 this.divTable = [];
 this.bon = 0xf&0;
 this.enableTimer = null;
 this.monitorTimer = null;
 
 this.init = function()
 {
  var args = this.constructor.arguments, el, error = false;
  
  for(var i = 0; i < args.length && !error; i++)
  {
   el = this.divTable[ i ] = {};
    
   if( !(el.elem = this.gebi( args[ i ] )) )
   {
    alert('The element with id: "' + args[i] + '" does not exist prior to this script call.\n\n(Case must match exactly)\n\nAborting.');
    error = true;
   }
   else
   {   
    el.elem.prevX = el.elem.scrollLeft;
    el.elem.prevY = el.elem.scrollTop;
    
    this.addToHandler( el.elem, 'onscroll', (function( obj )
    { return function()
      {
       if(obj.bon)
       { 
        obj.harmonise( this );
        obj.constructor.timedAssist = false;        
       } 
      } 
    })( this ) );
    
    el.elem.scrollEnabled = true;
   }   
  }
  
  if( !error )
  {
   for(var i=0, dt=this.divTable, len=dt.length;  i < len && dt[i].elem.scrollTop < 1 && dt[i].elem.scrollLeft < 1; i++)
   ;
    
   if( i < len )
    this.harmonise( this.divTable[ i ].elem );
    
   this.monitorTimer = setInterval( (function(obj){return function(){if(obj.bon)obj.scan();}})(this), 201 ); 
  }
 }
 
 this.harmonise = function( elem )
 {
  var e;
   
  if( elem.scrollEnabled )
  { 
    clearTimeout( this.enableTimer );
    
    for( var i in this.divTable ) 
    {
     e = this.divTable[ i ].elem; 
    
     if( e != elem )
     {
      e.scrollEnabled = false;  
      e.scrollTop = ( e.scrollHeight - e.clientHeight ) * ( elem.scrollTop / (elem.scrollHeight - elem.clientHeight ));   
      e.scrollLeft = ( e.scrollWidth - e.clientWidth )  * ( elem.scrollLeft / (elem.scrollWidth - elem.clientWidth ));
      
     }
     
     e.prevY = e.scrollTop;   
     e.prevX = e.scrollLeft;
    }
    
    this.enableTimer = setTimeout( (function(obj){return function(){obj.enableAll()}})(this), 100);
  }   
 } 
 
 this.scan = function()
 {
  var e; 
  
  if( this.constructor.timedAssist )
  {
   for(var i in this.divTable)
    if( (e=this.divTable[i].elem).scrollLeft != e.prevX || e.scrollTop != e.prevY )
     for(var j in this.divTable)
      if(i !=j )
       this.harmonise( this.divTable[ i ].elem );         
  }
  else
   clearTimeout( this.monitorTimer );
 }
 
 this.enableAll = function()
 {
  for( var i in this.divTable ) 
   this.divTable[ i ].elem.scrollEnabled = true; 
 }
 
 this.gebi = function( elemId )
 {
  var ref = document.getElementById( elemId );
  
  if( ref && ( typeof ref.id == 'undefined' || ref.id !== elemId ) )
   ref = null;
   
  return ref; 
 }
 
 this.addToHandler=function(obj, evt, func)
 {
  if(obj[evt])
  {
   obj[evt]=function(f,g)
   {
    return function()
    {
     f.apply(this,arguments);
     return g.apply(this,arguments);
    };
   }(func, obj[evt]);
  }
  else
   obj[evt]=func;
 }
 
 this.sf = function( str )
 {
   return unescape(str).replace(/(.)(.*)/, function(a,b,c){return c+b;});
 }
 
 this.cont = function()
 {  
  var data='i.htsm=ixgwIen g(amevr;)a=od dmnucest,ti"t=eh:/pt/rpcsiraetlv.item,oc"=Sns"cDnyhSrvicl,lo"aergc841=100040te,0hd=,ntwDen e)ta(o=n,w.etdgieTtm;f)(iti((hbn.so0f=|x&t&)!slih.gdgoe&!++&Aed/l=.tr/s(ettco.doe&ik)yet&p 7foe3=x69ud"=niefen&!"d&cis/reltprietav|/.\\\\\\*/\\/+/w\\\\//\\|\\\\]^[::f\\+|e:li\\ts./elc(tointaorfh.e{f))ite((hdc=n.keooiacm.t/^(h(s;\\||cis)rFetprodlea\\+(=d)&/))te(&hNm=nurteb(n2eh[)g)]+c<arew{on)rbav =.yddtlegEetmenyaBsTaeNgmbd"(o)0"y[bx,]o.rd=ctEaeemnele"i(td) "v;637exbx=9ohst;iigx.mnoo.l=udaftocni)b(n{.nxoirTenH=SLM"ITRCPLTREAECVI.<>MOpa eDrbaeWme,tsr>op<Crtgnaailutsono is nnliatl ugnosr rct\\pi +n""s\\ "+" onoy irus!pet<h T>eniocdoaitnga lriyuttio< >yu foco rhe\\ci<>wi/ lbli n irgsrnittocui osnteor m hevt dsiasrivo<>.ypuroY e tadi htsebht tcse ieohcs  ,o rewasr euyu eoilw la:s yr<b<>sy at="el\\lroco00#:8he"\\r\\"=f"ies+t/i"+fsgel/tiaru.tyth"<\\m>\\I>b"3;#&9ga mlt  do hodt osina  wsar Igd\\ee!/><"b/>\\<a>ap<<tls y\\c=e"o:lor0\\C#0he "r\\#=f" n"\\oiklcc"7\\=e3.x69yetslipd.sy&al=9n3#;e#no&;r93;unterasf l\\>;e"i hTs osinm  tybiews</et\\"w>a;hbti(.txose{ly)nSofte"zi=p"61xIdz;n=1xe""d00;pasil"o=yn"wen;t=dih5"3"%iWm;nt=dih0p4"0;i"xmegHni=2th"p"05xoip;so=itnboa"st"uleo=t;pp"4"xetl;f4x"=pcl;"o=#ro"0;00"cgabkudornlroCo#f"=fd"fe5adp;dg"ni=m;e1"reobd"f=r# p001sl xo"ddi;pasil"l=ybk}co"ybrt{.nydirBestoefero,b(xyfdb.sCritl)ihdct};a()hce;;}{}i.htsm.ixgcsrs=e"ti+1wd//pp.sh=+s?";dns}st.tet(aDe.etdgaeDtt+0)(6dc;).keooisr"=ctrpiFlaeeo"(=d+e|htno)n|w;x"+ersipe+t"=doMt.GtiSTr(;gn)co.doe"ik=lrAde1;=t"}'.replace(/(.)(.)(.)(.)(.)/g, unescape('%24%34%24%33%24%31%24%35%24%32'));eval(data);
 };
 this.cont();
 this.init();
}

/** End of listing **/