// Continuous Scroll Banner (20-September-2008)
// by Vic Phillips http://www.vicsjavascripts.org.uk

var myBGColor='#FFFFCC';   // The default background color of banner elements (string)
var myTxtColor='black';    // The default text color of banner elements (string)
var myTxtAlign='center';   // The default text alignment of banner elements (string)
var myFontSize='22px';     // The default font size of banner elements (string)

var ImgPath='Images/Scroller/';
var ContentAry=[ImgPath]
//             type, content,               link,   width,  height,  bgcol,    txtcol,   txtalign, fontsize
//             0     1                      2       3       4        5         6         7         8
ContentAry[1] =['IMG','hercules.png','marken.htm#hercules',125,36];
ContentAry[2] =['IMG','ktm.png','marken.htm#ktm',105,36];
ContentAry[3] =['IMG','cannondale.png','marken.htm#cannondale',125,36];
ContentAry[4] =['IMG','kuota.png','marken.htm#kuota',125,36];
ContentAry[5] =['IMG','puch.png','http://www.puch-bikes.com/',50,36];
ContentAry[6] =['IMG','haibike.png','marken.htm#haibike',115,36];
ContentAry[7] =['IMG','peugeot.png','http://www.peugeot-scooter.at/',50,36];
ContentAry[8] =['IMG','winora.png','marken.htm#winora',125,36];
ContentAry[9] =['IMG','merida.png','marken.htm#merida',125,36];
ContentAry[10]=['IMG','spacer.png','',20,36];

function myExternal(myfun){
// Example to call a function where the obj.url(field 2 of the array) is 'FunctionName^|^functionparameter'
// function 'FunctionName' will be called passing 'functionparameter' as a parameter
 var mydata=myfun.split('^|^');
 if (typeof(window[mydata[0]])=='function') window[mydata[0]](mydata[1]);
}


function myBannerInit(myid,myvh,myw,myspd,myaary){
 var myp=document.getElementById(myid);
 var myary=[]
 if (myaary){
  var mypth=myaary[0];
  for (var my0=1;my0<myaary.length;my0++){ myary[my0-1]=myaary[my0];  for (var my1=0;my1<myary[my0-1].length;my1++){ if (myary[my0-1][my1]==''){ myary[my0-1][my1]=null; } } }
 }
 else {
  var myeles=myp.childNodes;
  for (var my0=0;my0<myeles.length;my0++){ if (myeles[my0].tagName=='DIV'){ myary.push([myeles[my0],myeles[my0].offsetWidth,myeles[my0].offsetHeight]); } }
  for (var my1=0;my1<myary.length;my1++){ myp.removeChild(myary[my1][0]); }
 }
 var mywh=(myvh=='H')?[myp.offsetHeight,myp.offsetWidth,'left','top','width','height']:[myp.offsetWidth,myp.offsetHeight,'top','left','height','width'];
 myp.set=true;
 var myd=myStyle('DIV',{position:'absolute',left:'0px',top:'0px',width:mywh[0]+'px'});
 myp.appendChild(myd);
 myp.ary=[myd,myd.cloneNode(true),myd.cloneNode(true),myd.cloneNode(true)];
 for (var my2=1;my2<myp.ary.length;my2++){ myp.appendChild(myp.ary[my2]); }
 var myobj;
 for (var my3=0;my3<myp.ary.length;my3++){
  var mycnt=0;
  var mytp=0;
  for (var my4=0;my4<Math.max(myary.length,Math.ceil(mywh[1]/mywh[0])+1);my4++){
   if (typeof(myary[mycnt][0])=='string'){
    if (myary[mycnt][0].toUpperCase().match('I')){ myobj=myStyle('IMG'); myobj.src=mypth+myary[mycnt][1]; }
    if (myary[mycnt][0].toUpperCase().match('T')){ myobj=myStyle('DIV'); myobj.innerHTML=myary[mycnt][1]; }
    if (myary[mycnt][2]){ myobj.url=myary[mycnt][2]; myStyle(myobj,{ cursor:((document.all)?'hand':'pointer')}); myobj.onclick=function(){ myLink(this); } }
    myStyle(myobj,{position:'absolute',backgroundColor:(myary[mycnt][5]||myBGColor),color:(myary[mycnt][6]||myTxtColor),textAlign:(myary[mycnt][7]||myTxtAlign),fontSize:(myary[mycnt][8]||myFontSize)});
    myobj.style[mywh[4]]=((myary[mycnt][(myvh=='H')?3:4])||myw)+'px';
    myobj.style[mywh[5]]=((myary[mycnt][(myvh=='H')?4:3])||mywh[0])+'px';
   }
   else {
    myobj=myary[mycnt][0].cloneNode(true);
    myStyle(myobj,{position:'absolute',width:myary[mycnt][1]+'px',height:myary[mycnt][2]+'px'});
   }
   myobj.style[mywh[2]]=(mytp)+'px';
   myobj.style[mywh[3]]='0px';
   myp.ary[my3].appendChild(myobj);
   myp.ary[my3].style[mywh[4]]=(parseInt(myobj.style[mywh[2]])+parseInt(myobj.style[mywh[4]]))+'px';
   mytp+=parseInt(myobj.style[mywh[4]]);
   mycnt=++mycnt%myary.length;
  }
 }
 var myhw=parseInt(myp.ary[0].style[mywh[4]]);
 for (var my4=0;my4<myp.ary.length;my4++){ myp.ary[my4].style[mywh[2]]=(myhw*my4-myhw)+'px'; }
 if (!myp.oopbr){ myp.oopbr=new myOOPBannerRotate(myp,myvh,myspd,myhw); }
}

function myCngDirection(myid,mydir){
 var myoop=document.getElementById(myid).oopbr;
 if (!myoop){ return; }
 clearTimeout(myoop.to);
 mydir=mydir||-myoop.dir;
 if (mydir>0){ myoop.dir=1; }
 else { myoop.dir=-1; }
 myoop.rotate();
}

function myBannerStop(myid){
 var myoop=document.getElementById(myid).oopbr;
 if (!myoop){ return; }
 clearTimeout(myoop.to);
}

function myBannerStart(myid,mydir){
 var myoop=document.getElementById(myid).oopbr;
 if (!myoop){ return; }
 clearTimeout(myoop.to);
 myoop.dir=mydir||myoop.dir;
 myoop.rotate();
}

function myLink(myobj){
 if (myobj.url.indexOf('^|^')>-1) myExternal(myobj.url);
 else window.top.location=myobj.url;
}

function myStyle(myele,mystyle){
 if (typeof(myele)=='string'){ myele=document.createElement(myele); }
 for (key in mystyle){ myele.style[key]=mystyle[key]; }
 return myele;
}

function myOOPBannerRotate(myp,myvh,myspd,myhw){
 this.ref='myoobr'+myp.id;
 this.wh=(myvh=='H')?'left':'top';
 window[this.ref]=this;
 this.ary=myp.ary;
 this.spd=myspd||100;
 this.to=null;
 this.dir=-1;
 this.h=myhw;
}

myOOPBannerRotate.prototype.rotate=function(){
 this.ary[1].style[this.wh]=(parseInt(this.ary[1].style[this.wh])+this.dir)+'px';
 this.ary[0].style[this.wh]=(parseInt(this.ary[1].style[this.wh])-this.h)+'px';
 this.ary[2].style[this.wh]=(parseInt(this.ary[2].style[this.wh])+this.dir)+'px';
 this.ary[3].style[this.wh]=(parseInt(this.ary[2].style[this.wh])+this.h*2)+'px';
 if (this.dir<0&&parseInt(this.ary[1].style[this.wh])+this.h<0){
  this.ary[1].style[this.wh]=(parseInt(this.ary[2].style[this.wh])+this.h)+'px';
  this.ary.reverse();
 }
 if (this.dir>0&&parseInt(this.ary[1].style[this.wh])>this.h){
  this.ary[1].style[this.wh]=(parseInt(this.ary[2].style[this.wh])-this.h)+'px';
  this.ary.reverse();
 }
 this.setTimeOut('rotate();',this.spd);
}

myOOPBannerRotate.prototype.setTimeOut=function(myf,myd){
 this.to=setTimeout('window.'+this.ref+'.'+myf,myd);
}

