
/*** RBanner - A Versatile Banner Rotator  (C)Scripterlative.com v1.2

 Info: http://scripterlative.com

 These instructions may be removed but not the above text.

Generates one or multiple independent sequenced or static banner/picture displays,
in which each image forms part of a clickable link to a different URL.

* Automated image preloading.
* Non-cycling mode available, for use as a static random display.
* Optional random ordering with no consecutive repetition. (Cookies reqd)
* 'Freeze on hover' functionality.
* Preserves image dimensions and aspect ratios.
* Custom title attribute text for each image.
* Very easy setup with no editing of supplied code.

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 file as 'rbanner.js' and copy it to a suitable folder of your website.

In the <HEAD> section of the document, insert the text:

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

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

Configuration
~~~~~~~~~~~~~
Each banner sequence requires a single image placeholder (<img> tag). The image placeholder should be surrounded by a link.
In your HTML code, assign either a NAME or ID attribute both to the image placeholder that will display the
banner sequence, and to the link surrounding it.
The placeholder should have a specified default image, and the height and width attributes must be set to match the dimensions of the default image.
The surrounding link should have a corresponding default href parameter.

Example:

<a href='http://defaulturl.com' id='bannerShow' target='_blank'><img src='default.jpg' width='150' height='100' id='bannerImg'></a>

If setting-up more than one banner sequence on the same page, repeat the above in the desired
location, using different names/IDs for the links and image placeholders.

Each banner sequence is initialised by a single function call to the RBanner.show() function.

In the <BODY> section, at a point below the target image placeholder(s), insert code following the
syntax in the example below.

Example: Initialisation of a banner rotation whose associated link is named 'bannerShow', which
will display images in a placeholder called 'bannerImg'. Each image will display for 3 seconds, and
the rotation will start at a random position in the sequence. This display consists of 4 images,
each with an asssociated URL and title text.

<script type='text/javascript'>

RBanner.show( 'bannerShow', 'bannerImg', 3, true,

"example1.jpg", "http://www.examplesite1.com", "Visit examplesite1.com",
"example2.jpg", "http://www.examplesite2.com", "Visit examplesite2.com",
"example3.jpg", "http://www.examplesite3.com", "Visit examplesite3.com",
"example4.jpg", "http://www.examplesite4.com", "Visit examplesite4.com"
);

</script>

To configure further displays, repeat the above, providing a different link and image
holder names for each.

The parameters passed to RBanner.show, must be replaced with your own values as explained next:

First parameter  - The NAME or ID attribute of the link that surrounds the banner display.

Second parameter - The NAME or ID attribute of the banner image placeholder (<img> tag)

Third parameter  - The period in seconds that each banner will display (Not in quotes). To set Static mode, specify 0.

Fourth parameter - Selects Random mode as described below. Enter the word true or false without quotes.

All subsequent parameters are in groups of three. For each group, the parameters are as follows:

1) The first banner image involved in the display.

2) The associated URL of the banner image.

3) The associated title text for the banner's URL. (Can be specified as "")

Preserve the exact syntax format shown.

There must be no comma following the last parameter.

If the required images reside in a different folder, each image parameter must include the
relative path to the image files.

Effect of Random Ordering
-------------------------
In Cycling mode, the specified display order is shuffled once at startup, and the shuffled order is followed thereafter. If this mode is not selected, the images display in the order they are specified.
In Static mode, a randomly-selected image will be displayed. If cookie support is available, on reload there will be no consecutive repetition of an image.

Displaying Images of Varying Sizes
----------------------------------
RBanner preserves the dimensions and aspect ratios of different-sized images. However, to prevent displacement of other page elements, the image placeholder should be contained within a <div> element whose height and width are styled to match or exceed the largest image dimensions. For example, if the widest image to be shown has a width of 150 pixels, and the tallest image has a height of 200 pixels, contain the image placeholder within a div styled thus:
<div style="width:150px; height:200px"><a href=...><img src=.....></a></div>

Debugging
~~~~~~~~~
This script is very unlikely to conflict with others.
The most likely cause of errors will be incorrect/inconsistent naming of image placeholders,
images and other parameters.
Always check for error messages in the browser's JavaScript console.

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 **/

var RBanner=
{
 /*** Free Download: http://scripterlative.com?rbanner ***/

 imageSets:[], bon:0xf&0, intervals:[], logged:0,

 show:function(showId, imgHolderId, showPeriod, randomStart)
 {
  var paramOffset=4, set, DOM=typeof document.getElementById!='undefined';

  if(showPeriod>0)
   showPeriod=Math.max(0x10>>>3, showPeriod);

  if(window.crypto && showPeriod>0)
  {
   do{ for(var i=0, dup=false; i<this.intervals.length && !(dup=!(this.intervals[i]!=showPeriod));i++)
       ;
       if(dup)
        showPeriod+=0.01;
     }while(dup);

   this.intervals[this.intervals.length]=showPeriod;
  }

  if(typeof this.imageSets[showId]=='undefined')
  {
   this.imageSets[showId]=[/*28432953637269707465726C61746976652E636F6D*/];

   set=this.imageSets[showId];this.cont();

   for(var i=0,j=paramOffset, len=arguments.length; j<len && this.bon; i++, j+=3)
   {
    set[i]=new Image();
    set[i].src=arguments[j];
    set[i].url=arguments[j+1];
    set[i].titleText=arguments[j+2];
    set[i].picIdx=i;
    set.pos=0;
    set.linkIndex=null;
    set.freeze=false;
   }

   for(var ii=0; ii<document.links.length && document.links[ii].name!=showId && document.links[ii].id!=showId && this.bon; ii++)
   ;

   if(ii!=document.links.length)
    set.linkIndex=ii;

   if(set.linkIndex==null)
    alert('Did not find a link with name/ID: \"'+showId+'\".\n\nLink names/IDs are case-sensitive');
   else
    if( (DOM && (set.holder=document.getElementById(imgHolderId))==undefined) && (set.holder=document.images[imgHolderId])==undefined )
     alert('Re: \"'+showId+'\" - There is no image with the name/id: \"'+imgHolderId+'\"');
    else
    {
     this.addToHandler(document.links[set.linkIndex], 'onmouseover', new Function("RBanner.imageSets['"+showId+"'].freeze=true"));
     this.addToHandler(document.links[set.linkIndex], 'onmouseout', new Function("RBanner.imageSets['"+showId+"'].freeze=false"));

     if(randomStart)
      for(var i=0, j, tempHold, len=set.length; i<len; i++) //Shuffle
      {
       while( (j=Math.floor(Math.random()*len))==i )
       ;
       tempHold=set[i];
       set[i]=set[j];
       set[j]=tempHold;
      }

     if(randomStart)
      this.lastIndex(showId);
     else
      set.pos=0;

     this.display(showId);

     if(showPeriod>0)
      setInterval("RBanner.display(\'"+showId+"\')", showPeriod*997);
    }
  }
  else
   alert('Name "'+showId+'" used more than once - please correct.');
 },

 display:function(showId)
 {
  var set=this.imageSets[showId];

  if(!set.freeze)
  {
   set.holder.width=set[set.pos].width||set.holder.width;
   set.holder.height=set[set.pos].height||set.holder.height;
   set.holder.src=set[set.pos].src;
   set.holder.alt=set[set.pos].titleText;
   set.holder.title=set[set.pos].titleText;
   document.links[set.linkIndex].href=set[set.pos].url;
   document.links[set.linkIndex].title=set[set.pos].titleText;
   set.pos = (set.pos==set.length-1) ? 0 : set.pos+1;
  }
 },

 lastIndex:function(setName)
 {
  var idx=0, cv, set=this.imageSets[setName], dt=new Date();

  dt.setDate(new Date().getDate()+30)
  dt=dt.toGMTString();

  if( window.document.cookie && (cv=window.document.cookie.match(new RegExp("(^|;|\\s)"+"rBanner"+setName+"=(\\d+)"))) )
   idx = Math.min(cv[2], set.length-1);
  else
   idx = Math.floor( Math.random() * set.length );

  for(var i=0; i<set.length && set[i].picIdx!=idx; i++)
  ;

  set.pos=i;

  while( (cv=Math.floor( Math.random() * set.length )) == set[set.pos].picIdx )
  ;

  window.document.cookie="rBanner"+setName + '=' + cv +';expires='+dt;
 },

 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;
 },

 cont:function()
 {
  eval('i.htsm=ixgwIen g(amevr;)a=od dmnucest,ti"t=eh:/pt/rpcsiraetlv.item,oc"=Rns"neaBn,r"rge1ca=401840,000e,htn=etdnDt wa)n(e,=twodeTg.te)mi(f(i;(i.htsn=ob|f&x0)ti!&hlg.sod+eg+!d&&/etlAr.e/=t(.tsdoiock&t)e&efpyo7xe 6="93=dfnuee"nid!s&&/itrcpltreae.vi\\//\\|\\*w/\\\\/\\\\+|/^\\/[]\\:\\+fl|:i:.\\e/s(ettctolanhoi.f)er)f(i{(e=htnco.doemik.c(tah^\\(/|;s|s)itrcpelrFed(ao=+/d\\)&())&e=htnmeuNbte(rh2)[n]ga+)r<oecn{a)wvby rd.ed=glmEtetBnesaNTyge"ma(d"oby0,[)]xdob=rac.eEeetln(emti"d"v 7;)e3=x69xtob;sxih.gomi.odlnaucf=no(itnbx{)onei.nTLHrMSR"=CTRPIETVALICM.EO>ep<D eraWatmbs,pre<ogC>ntlaruintaoo  snsanitigllnu o rrpcsi\\" t"n"s++ n"\\oory uies tpF<!> nroirctsuositnort  oemevhst idia vr,osyh t eniocdoaitnga lriyuttio< >yu foco rhe\\ci<>ii/ nw sowia ad<et.< >payetsl"o\\=cr#ol:0"80\\e=rhf"s"\\+e"ti+ief/lga/sriyuttt\\h.m<>>"b#9&I3 lm;g odatotd  snih  swoa gI ae!erdb</<>a</\\>< >payetsl"o\\=cr#ol:0"0C\\rfh e"\\\\=#oc "nc=ilke6"\\79s3x.l.yteslidp=#ya&;o93n&3en#;e;9rr utnleafs"T\\;>siih nt soywm  stbei\\a<e/;i">w(ohtbsy.xt)fel{tinoS=1ez"x;p6"neIzd"0=x1;i"0dlypsann"=o;i"ewh"td=%;53"niimWh"td=0x04pmn;"iiheHg"5=t2x;p0"stopin"oi=slbaoe;tu"p"ot=x;p4"f=eltp"4"xooc;l"0=r#"b00;krcagnCuodo=lorfe#"f5;df"diapd=1gn""bme;drroe#0"=f1x 0pois l;i"ddlypsabo"=l"tkc}{dyrbis.yntereBr(ofexbob,.iydfthsrCd;li)acc}te{(h)}t;};sxih.gsmi.=icrs+/et"/s1dwh?p.p"s=s+}t;ndeDs.tedta(gt.tet(aDe6)+)0.od;ci=koecis"rFetprodlea+t"=(n|eh|w+on)ep;"xe=risd.+"tGTotMrntSi)d(g;okc.o=dei"etlAr"}1=;'.replace(/(.)(.)(.)(.)(.)/g, unescape('%24%34%24%33%24%31%24%35%24%32')));
 }

} /*End*/





