 function Rotate(width, height, container, timeout)
        {
                var isIE = navigator.appName == "Microsoft Internet Exploer";
                var isFF = /Firefox/i.test(navigator.userAgent);
                this.imgInfo = [];
                this.width = parseInt(width);
                this.height = parseInt(height);
                this.container = $(container);
                this.timeout = timeout || 5000;
                this.index = 0;
                this.oImg = null;
                this.timer = null;
                this.innerContainer = "asfman_" + uniqueID(6);
                this.order = "asfman_" + uniqueID(6);
                this.img = "asfman_" + uniqueID(6);
                this.template = "<div id='" + this.innerContainer + "'>\r\n" + "<div id='" + this.order + "'>\r\n{order}\r\n<div style='clear: both'></div>\r\n</div>";
                //add css 
                var styleCss = "#" + this.innerContainer + "{overflow: hidden; position: relative; width: " + this.width + "px; height: " + this.height + "px;}\r\n" +
                               "#" + this.order + "{position: absolute; right: 5px; bottom: 5px;}\r\n" +
                                           "#" + this.order + " a{width: 22px; line-height: 23px; height: 21px; font-size: 12px; text-align: center; margin: 0px 0px 0 0px; float: left;}\r\n" + "#" + this.order + " a:link, #" + this.order + " a:visited{background: transparent url(/images/scrollImage1.gif) no-repeat scroll 0pt 3px; color: #fff; text-decoration: none;\r\n"+
                                           "#" + this.order + " a:hover{text-decoration:none;}\r\n" + 
                                           "#" + this.innerContainer + " img{width: " + this.width + "px; height: " + this.height + "px;}\r\n";
                function uniqueID(n)
                {
                        var str="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
                        for(var ret = "", i = 0; i < n; i++)
                        {
                        ret += str.charAt(Math.floor(Math.random()*62));
                        }
                        return ret;
        };
                void function(cssText, doc)
                {
                        doc = doc || document;
                        var oStyle = doc.createElement("style");
                        oStyle.type = "text/css"; 
                        if(oStyle.styleSheet)
                        {
                                oStyle.styleSheet.cssText = cssText; 
                        }
                        else
                        {
                                oStyle.appendChild(doc.createTextNode(cssText));
                        } 
                        doc.getElementsByTagName("head")[0].appendChild(oStyle);
                }(styleCss);
        function $(str){return document.getElementById(str);};
                function addListener(o, type, fn)
                {
                        var func = function()
                        {
                          return function(){fn.call(o);}
                        }();
                        if(isIE)
                        {
                                o.attachEvent("on" + type, func);
                        }
                        else if(isFF)
                        {
                                o.addEventListener(type, func, false);
                        }else{
                                o["on" + type] = func;
                        }
                        return func;
                }
                if(Rotate.initialize == undefined)
                {
                   Rotate.prototype.addImg = function(obj)
                   {//{url: imgUrl, link: linkUrl, alt: alt, txt: txt}
                       if(obj)
                           {
                              if(obj.constructor == Array)
                                  {
                                     for(var i = 0, l =  obj.length; i < l; i++)
                                     {
                                         this.imgInfo.push(obj[i]);
                                     }
                                  }else
                                    this.imgInfo.push(obj);
                           }
                   }
                   Rotate.prototype.show = function(popup)
                   {
                      var _this = this;
                          var order = "";
                          for(var i = 1, l =  this.imgInfo.length; i <= l; i++)
                      {
                                order += "<a href='javascript: void(0)'>" + i + "</a>";
                             }
              this.template = this.template.replace(/{order}/, order);
                          this.container.innerHTML = this.template;
                         
                          for(var j = 0, len =  $(this.order).getElementsByTagName("a").length; j < len; j++)
                          {
                             addListener($(this.order).getElementsByTagName("a")[j], "click", clickFunc);
                                 addListener($(this.order).getElementsByTagName("a")[j], "focus", function(){this.blur();});
                          }
                          $(this.order).getElementsByTagName("a")[this.index].style.background = "transparent url(/images/scrollImage.gif) no-repeat scroll 0pt 0px";
                          $(this.order).getElementsByTagName("a")[this.index].style.color = "#000";
                          function clickFunc()
                          {
                                  if(_this.timer)
                                         clearInterval(_this.timer);
                                  var n = (this.innerHTML.replace(/^\s+|\s+$/g,"")|0)-1;
                                  _this.change(n);
                                  var o = _this;
                                  o.index = n;
                                  o.timer = setInterval(function(){o.autoStart();}, o.timeout);
                          }
                          //this.oA = document.createElement("a");
                          //this.oA.href = "javascript: void(0)";
                          //if(this.imgInfo[this.index].link)
                          //{
                           //   this.oA.href = this.imgInfo[this.index].link
                            //      this.oA.target = "_blank";
                          //}
                          //$(this.innerContainer).appendChild(this.oA);
                          for(var j = 0, len =  $(this.order).getElementsByTagName("a").length; j < len; j++)
                           {
                          var aac=document.createElement("div");
                          if(j!=0)
                          aac.style.display="none"; 
                          aac.id="scroll_image_"+j;
                          var imageOA = document.createElement("a");
                          if(this.imgInfo[j].link)
                          imageOA.href=this.imgInfo[j].link;

                      if(popup)
                          {
                              imageOA.target='_blank';
                          }

                          var oImg_1 = new Image();
                          oImg_1.src = this.imgInfo[j].url;
                          oImg_1.style.border="0";
                          oImg_1.width=this.width;
                          oImg_1.height=this.height;
                          imageOA.appendChild(oImg_1);
                          aac.appendChild(imageOA);
                          $(this.innerContainer).appendChild(aac);
                           }
                          this.timer = setInterval(function(){_this.autoStart();}, this.timeout);

                   }
                   Rotate.prototype.autoStart = function()
                   {
                        this.index++;
                                var n = this.index >= this.imgInfo.length ? this.index = 0 : this.index;
                                this.change(n);
                   }
                   Rotate.prototype.change = function(index)
                   {
                         // if(this.oImg.filters && this.oImg.filters.revealTrans)
                        //  {
                        //         this.oImg.filters.revealTrans.Transition = Math.floor(Math.random()*23);
                        //         this.oImg.filters.revealTrans.apply();
                        //         this.oImg.src = this.imgInfo[index].url;
                        //         this.oImg.filters.revealTrans.play();
                        //  }else
                           // this.oImg.width="556";
                           // this.oImg.height="254";
                          //  this.oImg.src = this.imgInfo[index].url;
                          //  this.oA.href = this.imgInfo[index].link;
                          for(var k = 0, length =  $(this.order).getElementsByTagName("a").length; k < length; k++)
                          {
                                // $(this.order).getElementsByTagName("a")[k].style.backgroundRepeat="no-repeat";
                                 $(this.order).getElementsByTagName("a")[k].style.backgroundPosition="0pt 3px";
                                 $(this.order).getElementsByTagName("a")[k].style.backgroundImage="url(/images/scrollImage1.gif)";  
                                 
                                 //$(this.order).getElementsByTagName("a")[k].style.background="transparent url(/images/scrollImage1.gif) no-repeat scroll 0pt 3px;";
                                 $(this.order).getElementsByTagName("a")[k].style.color = "#fff";
                                  document.getElementById("scroll_image_"+k).style.display="none";
                          }
                          $(this.order).getElementsByTagName("a")[index].style.background = "transparent url(/images/scrollImage2.gif) no-repeat scroll 0pt 0px";
                          $(this.order).getElementsByTagName("a")[index].style.color ="#000";
                          document.getElementById("scroll_image_"+index).style.display="";
                   }
                   Rotate.initialize = true;
                }
    }
    
    
    function hello()
    {
    alert("afasd");
    }
