var DOM = (document.getElementById)?true:false;
var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 4 && !DOM);
var IE4 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) >= 4);
var layerType = NS4?'layer':'div';
var windowWidth, bannerTop, bannerLeft, imgReady=false;
var layerText, styleText, leftText, topText, appVer=navigator.appVersion; 

if(navigator.appName == "Netscape")
{
  layerText="document.layers";
  styleText="";
  leftText='.left';
  topText='.top';
  windowWidth = window.innerWidth - 16;
}
else
{
  layerText="document.all";
  styleText=".style";
  leftText='.pixelLeft';
  topText='.pixelTop';
  windowWidth = document.body.clientWidth;
  if(parseFloat(appVer.substr(appVer.indexOf("MSIE ")+5, 5))>=5)
    windowWidth = windowWidth-16;
}

function getImg() 
{
  if(document.images)
    {
      if(bannercount>=1)
	{
          img = new Array(); 
          img[0] = new Image();
          img[0].src = image0;
        }
      if(bannercount>=2)
	{	
      	  img[1] = new Image();
          img[1].src = image1;
	}
      if(bannercount>=3)
        {
      	  img[2] = new Image();
          img[2].src = image2;
	}	

      imgReady = true;
    }
}



var curProduct=0, curStage=0, curX=0, curY=0, k1=255, k=255, k3=255, xStep=0;
var bannerImg = new Array(), bannerTitle = new Array(), titleFont = new Array(), bannerDesc = new Array(), descFont = new Array(), bannerPrice = new Array(), bannerLine = new Array(), price = new Array(), nameLen = new Array();
var promoFont, bannerPromo;
function BannerAnimate()
{
  if(imgReady)
    {
      if(curStage==0)
	{
          if(curX==0)
            {
              if(DOM)
                {
                  bannerPromo.style.visibility='hidden';
		  bannerImg[curProduct].style.left=bannerLeft+100;
                  bannerImg[curProduct].style.top=bannerTop;
	          bannerImg[curProduct].style.visibility='visible';
                  document.getElementById('bgLink').href=urlBase+eval('url'+curProduct);
                }
	      else
                { 
		  for(j=0; j<bannercount; j++)
		    eval(layerText+'["bannerBg'+j+'"]'+styleText+'.visibility="hidden"');
                  eval(layerText+'["bannerBg'+curProduct+'"]'+styleText+'.visibility="visible"');
		  eval(layerText+'["bannerPromo"]'+styleText+'.visibility="hidden"');
                  eval(layerText+'["bannerImg'+curProduct+'"]'+styleText+leftText+'='+bannerLeft);
		  eval(layerText+'["bannerImg'+curProduct+'"]'+styleText+topText+'='+bannerTop);
                  eval(layerText+'["bannerImg'+curProduct+'"]'+styleText+'.visibility="visible"');
                }
              curX=100;
	    }
          else if(curX<380)
	    {
	      curX=curX+2;
              if(DOM)
	    	bannerImg[curProduct].style.left=curX+bannerLeft;
	      else
	        eval(layerText+'["bannerImg'+curProduct+'"]'+styleText+leftText+'='+(curX+bannerLeft));
	    }
	  else
	    {
              curStage++;
	      curX=10000;
	    }

	  setTimeout("BannerAnimate()", 10);
	}
      else if(curStage==1)
        {
	  if(curX==10000)
            {
              k1=255;
              k=255;
              k2=255;
	      curY=50;
	      xStep=(380.0-Math.min((nameLen[curProduct]*(nameLen[curProduct]>50?6.1:(nameLen[curProduct]>40?6.9:7.0))), 370))/100;
              curX=0.0-(xStep*50.0);

	      if(DOM)
                {
	          if(nameLen[curProduct]>50)
                    titleFont[curProduct].style.fontSize='8pt';
	          else if(nameLen[curProduct]>40)
                    titleFont[curProduct].style.fontSize='9pt';

                  bannerTitle[curProduct].style.left=curX+bannerLeft;
                  bannerTitle[curProduct].style.top=curY+bannerTop;
                  titleFont[curProduct].style.color='#FFFFFF';
	          bannerTitle[curProduct].style.visibility='visible';
                }
	      else
		{                  
		  eval(layerText+'["bannerTitle'+curProduct+'"]'+styleText+leftText+'='+(curX+bannerLeft));
		  eval(layerText+'["bannerTitle'+curProduct+'"]'+styleText+topText+'='+(curY+bannerTop));
                  eval(layerText+'["bannerTitle'+curProduct+'"]'+styleText+'.visibility="visible"');
		}
	    }
          else if(k>=5)
	    {
              k1=k1-3;
	      k=k-5;
	      k2=k2-2;
              curX=curX+xStep;
	      if(curY>1)
		curY=curY-1;
		
	      if(DOM)
                {
	    	  bannerTitle[curProduct].style.left=Math.round(curX)+bannerLeft;
                  bannerTitle[curProduct].style.top=curY+bannerTop;
                  if(k>15) titleFont[curProduct].style.color=('#'+k1.toString(16)+k.toString(16)+k2.toString(16));
                }
	      else
		{
	    	  eval(layerText+'["bannerTitle'+curProduct+'"]'+styleText+leftText+'='+(Math.round(curX)+bannerLeft));
		  eval(layerText+'["bannerTitle'+curProduct+'"]'+styleText+topText+'='+(curY+bannerTop));
		}
	    }
	  else
	    {	           
	      curStage++;
	      curX=0;
	    }
          
          setTimeout("BannerAnimate()", 30);
	}
      else if(curStage==2)
        {
	  if(curX==0)
            {
              curX=10;
	      if(DOM)
                {
                  descFont[curProduct].style.fontSize='8pt';
                  bannerDesc[curProduct].style.visibility='visible';
                }
	      else
                eval(layerText+'["bannerDesc'+curProduct+'"]'+styleText+'.visibility="visible"');
              
              setTimeout("BannerAnimate()", 8000);
	    }
	  else if(curX>=2)
            {
              if(DOM)
		{
                  descFont[curProduct].style.fontSize=curX.toString(10)+'pt';     
		  curX--;
              	  setTimeout("BannerAnimate()", 50);
		}
	      else
		{     
		  curX=1;
              	  setTimeout("BannerAnimate()", 5);
		}
	    }
	  else if(curX==1)
	    {             
              if(DOM)
                bannerDesc[curProduct].style.visibility='hidden';
	      else
		eval(layerText+'["bannerDesc'+curProduct+'"]'+styleText+'.visibility="hidden"');

	      curStage++;
	      curX=0;

              setTimeout("BannerAnimate()", 50);
	    }
	}
      else if(curStage==3)
        {
	  if(curX==0 && price[curProduct].length>0)
            {
	      if(DOM)
	        bannerPrice[curProduct].style.visibility='visible';
	      else
	        eval(layerText+'["bannerPrice'+curProduct+'"]'+styleText+'.visibility="visible"');
              
              curX=1;
              setTimeout("BannerAnimate()", 5000); 
	    }
	  else if(curX==1 || (curX!=2 && price[curProduct].length==0))
            {
              if(DOM)
                {
                  bannerPrice[curProduct].style.visibility='hidden';
		  bannerLine[curProduct].style.visibility='visible';
                }
	      else
		{
		  eval(layerText+'["bannerPrice'+curProduct+'"]'+styleText+'.visibility="hidden"');
		  eval(layerText+'["bannerLine'+curProduct+'"]'+styleText+'.visibility="visible"');
                }

              curX=2;
              setTimeout("BannerAnimate()", 8000);
	    }
	  else if(curX==2)
	    {             
	      curStage++;
	      curX=10000;
              setTimeout("BannerAnimate()", 50);  
	    }
	}      
      else if(curStage==4)
        {
           if(curX==10000)
            {
	      curX=bannerTop;
	    }
          else if(curX>-60)
	    {
              if(DOM)
	    	bannerImg[curProduct].style.top=curX--;
	      else	      
	        eval(layerText+'["bannerImg'+curProduct+'"]'+styleText+topText+'='+(curX--));
	    }
	  else
	    {
              if(DOM)
                {
                  bannerLine[curProduct].style.visibility='hidden';
	          bannerImg[curProduct].style.visibility='hidden';
                  bannerTitle[curProduct].style.visibility='hidden';
                }
	      else
		{
		  eval(layerText+'["bannerLine'+curProduct+'"]'+styleText+'.visibility="hidden"'); 
		  eval(layerText+'["bannerImg'+curProduct+'"]'+styleText+'.visibility="hidden"'); 
		  eval(layerText+'["bannerTitle'+curProduct+'"]'+styleText+'.visibility="hidden"'); 		  
		}

              curProduct=(++curProduct)%bannercount;
	      curStage++;
	      curX=10000;
	    }

	  setTimeout("BannerAnimate()", 15);
	}
      else if(curStage==5)
        {
           if(curX==10000)
            {
	      if(promo1.length==0 && promo2.length==0)
                {
                  curStage=0;
                  curX=0;
                }
              else
                {
		  if(DOM)
		    {
                      promoFont.style.color='#FFFFFF';
                      bannerPromo.style.visibility='visible';
		    }
		  else
		    eval(layerText+'["bannerPromo"]'+styleText+'.visibility="visible"');  	
                  curX=255;
                }
              setTimeout("BannerAnimate()", 100);
	    }
          else if(curX>=23)
	    {
              curX=curX-7;
              if(DOM)
	    	promoFont.style.color='#FF'+curX.toString(16)+curX.toString(16);
	      else
	        curX=0;

              setTimeout("BannerAnimate()", 100);
	    }
	  else
	    {
	      curStage=0;
	      curX=0;
              setTimeout("BannerAnimate()", 10000);  
	    }
	}
    }
  else
    setTimeout("BannerAnimate()", 500);
}

if(framenum==5)
{
 bannerTop=3;
 bannerLeft=Math.max(((windowWidth*.80-420)/2), 10);
}
else if(framenum==7)
{
 bannerTop=Math.max(10, (lHeight-60)/2+6);
 bannerLeft=Math.max(lWidth+20, windowWidth*.25)+Math.max((windowWidth-Math.max(lWidth+20, windowWidth*.25)-420)/2, 0);
}
else if(framenum==9)
{
 bannerTop=Math.max(105, lHeight+37);
 if(IE4) bannerTop=bannerTop+6;
 bannerLeft=Math.max(windowWidth*.25, 160);
 bannerLeft=bannerLeft+(Math.max(windowWidth*.70, 420)-420)/2;
}
else
{
 bannerTop=Math.max(4, (lHeight-60)/2);
 bannerLeft=Math.max(lWidth+20, windowWidth*.25)+Math.max((windowWidth-Math.max(lWidth+20, windowWidth*.25)-420)/2, 0);
}

getImg();

if(bannercount>0)
{
  var desc, heading, priceLine, imageheight;

  if(NS4)
    {
      document.writeln('<layer id=bannerPromo Z-INDEX=4 width=420 height=60 top='+bannerTop+' left='+bannerLeft+' VISIBILITY=hidden><br><font size=2 color=red face=Verdana><b> &nbsp; &nbsp; '+promo1+'<br> &nbsp; &nbsp; '+promo2+'</b></font></'+layerType+'>');
    }
  else
    {
      document.writeln('<div id=bannerBg style="position: absolute; Z-INDEX: 1; width: 420; height: 60; top:'+bannerTop+'; left: '+bannerLeft+';"><table cellpadding=0 cellspacing=0 border=0 bgcolor=white width=420 height=60><tr><td><a id=bgLink href=""><img src=/ac/b.gif width=420 height=60 border=0></a></td></tr></table></'+layerType+'>');
      document.writeln('<div id=bannerPromo style="position: absolute; Z-INDEX: 4; width:420; height:60; top:'+bannerTop+'; left:'+bannerLeft+'; VISIBILITY: hidden;"><img src=/ac/b.gif width=1 height=12><br><font name=promoFont id=promoFont style="color: #FFFFFF; font: Bold 10pt Verdana;">'+promo1+'<br>'+promo2+'</font></'+layerType+'>');
      promoFont=document.getElementById('promoFont');
      bannerPromo=document.getElementById('bannerPromo');
    }

  for(i=0; i<bannercount; i++)
    { 
      nameLen[i]=eval('name'+i).length;
      desc=eval('desc'+i);
      imageheight=eval('imageheight'+i);
      price[i]=eval('price'+i);
      heading=eval('heading'+i);
      if(price[i].length>0)
        {
	  if(heading.length>1)
	    priceLine=heading+' Only '+sitecurrency+price[i];
          else
            priceLine='Our Price '+sitecurrency+price[i];
        }
      else
        priceLine='';

      if(NS4)
        {
	  document.writeln('<layer id=bannerTitle'+i+' Z-INDEX=8 width=380 height=10 top='+bannerTop+' left='+bannerLeft+' VISIBILITY=hidden><center><a class=bannerT href='+urlBase+eval('url'+i)+'>'+eval('name'+i)+'</a></center></'+layerType+'>');
          document.writeln('<layer id=bannerDesc'+i+' Z-INDEX=6 width=360 height=10 top='+(bannerTop+20)+' left='+(bannerLeft+10)+' VISIBILITY=hidden><a class=bannerD href='+urlBase+eval('url'+i)+'><p align='+((desc.length<70)?'center':'justify')+'>'+desc+'</p></a></'+layerType+'>');
          document.writeln('<layer id=bannerPrice'+i+' Z-INDEX=4 width=380 height=10 top='+(bannerTop+30)+' left='+bannerLeft+' VISIBILITY=hidden><center><a class=bannerP href='+urlBase+eval('url'+i)+'>'+priceLine+'</a></center></'+layerType+'>');
          document.writeln('<layer id=bannerLine'+i+' Z-INDEX=4 width=380 height=10 top='+(bannerTop+30)+' left='+bannerLeft+' VISIBILITY=hidden><center><a class=bannerL href='+urlBase+eval('url'+i)+'>Click here for more details about this product!</a></center></'+layerType+'>');
        }
      else
        { 
    	  document.writeln('<div id=bannerImg'+i+' style="position: absolute; Z-INDEX: 10; height: 60; width: 40; top:'+bannerTop+'; left: '+bannerLeft+'; VISIBILITY: hidden;"><table cellpadding=0 cellspacing=0 border=0 height=60 width=40 bgcolor=white><tr><td valign=center><a href='+urlBase+eval('url'+i)+'><img src='+img[i].src+((imageheight>60 || imageheight==0)?' height=60':' ')+' align=absmiddle border=0></a></td></tr></table></'+layerType+'>');
    	  document.writeln('<div id=bannerTitle'+i+' style="position: absolute; Z-INDEX: 8; width:380; height:5; top:'+bannerTop+'; left: '+bannerLeft+'; VISIBILITY: hidden;"><center><a name=titleFont'+i+' id=titleFont'+i+' style="color: #FFFFFF; font: Bold 10pt Arial; text-decoration:none;" href='+urlBase+eval('url'+i)+'>'+eval('name'+i)+'</a></center></'+layerType+'>'); 
          document.writeln('<div id=bannerDesc'+i+' style="position: absolute; Z-INDEX: 6; width:360; height:5; top:'+(bannerTop+(IE4?19:8))+'; left: '+(bannerLeft+10)+'; VISIBILITY: hidden;"><a name=descFont'+i+' id=descFont'+i+' style="color: #787878; font: 8pt Arial; text-decoration:none;" href='+urlBase+eval('url'+i)+'><p name=descText'+i+' id=descText'+i+' align='+((desc.length<70)?'center':'justify')+'>'+desc+'</p></a></'+layerType+'>');
          document.writeln('<div id=bannerPrice'+i+' style="position: absolute; Z-INDEX: 4; width:380; height:5; top:'+(bannerTop+30)+'; left: '+bannerLeft+'; VISIBILITY: hidden;"><center><a style="color: #18AD18; font: Bold 11pt Arial; text-decoration:none;" href='+urlBase+eval('url'+i)+'>'+priceLine+'</a></center></'+layerType+'>');
          document.writeln('<div id=bannerLine'+i+' style="position: absolute; Z-INDEX: 4; width:380; height:5; top:'+(bannerTop+30)+'; left: '+bannerLeft+'; VISIBILITY: hidden;"><center><a style="color: #CC33CC; font: Bold 11pt Arial; text-decoration:none;" href='+urlBase+eval('url'+i)+'>Click here for more details about this product!</a></center></'+layerType+'>');

          bannerImg[i] = document.getElementById('bannerImg'+i);
          bannerTitle[i] = document.getElementById('bannerTitle'+i);
          titleFont[i] = document.getElementById('titleFont'+i);
          bannerDesc[i] = document.getElementById('bannerDesc'+i);
          descFont[i] = document.getElementById('descFont'+i);
          bannerPrice[i] = document.getElementById('bannerPrice'+i);
          bannerLine[i] = document.getElementById('bannerLine'+i);;
        }
    }

  if(NS4)
    {	
      for(i=0; i<bannercount; i++)
	{
	  imageheight=eval('imageheight'+i);
	  document.writeln('<layer id=bannerImg'+i+' Z-INDEX=10 width=40 height=60 top='+bannerTop+' left='+bannerLeft+' VISIBILITY=hidden><table cellpadding=0 cellspacing=0 border=0 height=60 width=40 bgcolor=white><tr><td valign=middle><a href='+urlBase+eval('url'+i)+'><img src='+img[i].src+((imageheight>60 || imageheight==0)?' height=60':' ')+' align=absmiddle border=0></a></td></tr></table></'+layerType+'>');
  	  document.writeln('<layer id=bannerBg'+i+' Z-INDEX=1 width=420 height=60 top='+bannerTop+' left='+bannerLeft+'><table cellpadding=0 cellspacing=0 border=0 bgcolor=white width=420 height=60><tr><td><a href='+urlBase+eval('url'+i)+'><img src=/ac/b.gif width=420 height=60 border=0></a></td></tr></table></'+layerType+'>');	}
    }
  setTimeout("BannerAnimate()", 1500);
}

