var recommendList;
function RecommendList(limitedHeight,boxName,imgsrow,instanceName)
{
    this.box = document.getElementById(boxName);
    
    this.imgsRow = imgsrow!=null?imgsrow:5;
    
    this.instanceName = instanceName;
    
    this.scrollHeight = 0;
    
    this.limitedHeight = limitedHeight;
    
    this.allScrollHeight = 0;
    
    this.rows = 0;
    
    this.rowHeight  = 0;
    
    this.offsetHeight = this.box.offsetHeight;
    
    
    this.init = function init()
                {
                    var node;
                    var nodesLength = this.box.childNodes.length;
                    for(var i = 0; i < nodesLength ; i++)
                    {
                        node = this.box.childNodes[i];
                        
                        if(node.nodeType == 1 && node.tagName.toLowerCase() == "div")
                        {
                            break;
                        }
                        else
                        {
                            node = null;
                        }
                    }
                    
                    if (node == null)
                    {
                        return null;
                    }
                    
                    var imgs = 0;
                    nodesLength = node.childNodes.length;
                    for( var j = 0; j < nodesLength;j++)
					{
						if(node.childNodes[j].nodeType ==1 && node.childNodes[j].tagName.toLowerCase() == "a")
						{
							imgs ++;
						}
					}
					
					this.rows =Math.ceil(imgs/this.imgsRow);
							
					this.rowHeight = this.offsetHeight /this.rows;
					
					this.box.innerHTML += this.box.innerHTML;
					
					this.box.style.position = "relative";
					
					this.box.style.top = "0px";
					
					
					
					this.doScrollUp();
                    
                };
                
                
                this.doScrollUp = function doScrollUp()
				{
					
					if(this.allScrollHeight == this.offsetHeight)
					{
						
						this.box.setAttribute("scroll", "stop");
						this.box.style.top = "0px";
						this.allScrollHeight = 0;
						this.scrollHeight = 0;
						setTimeout(this.instanceName+".doScrollUp();",1000*2);
					}
					else if( (this.allScrollHeight == 0 && this.box.getAttribute("scroll")!="do") ||(this.scrollHeight == 0 && this.box.getAttribute("scroll") != "do"))
					{
						
						this.box.setAttribute("scroll","do");
					
						setTimeout(this.instanceName+".doScrollUp();",1000*1);
						
					}
					else if(this.scrollHeight == this.rowHeight)
					{
						
						this.box.setAttribute("scroll", "stop");
						this.scrollHeight = 0;
						setTimeout(this.instanceName+".doScrollUp();",1000*1);
					}
					else
					{
						
						
						this.box.style.top = parseInt(this.box.style.top)-1+"px";
						this.allScrollHeight +=1;
						this.scrollHeight +=1;
						setTimeout(this.instanceName+".doScrollUp();",20);	
					}
					
				
					
					
				};

}

				
function Page_Load()
{

    recommendList = new RecommendList(90,"recommendProductsDiv",5,"recommendList");
  
    recommendList.init();
}


window.onload = Page_Load;