﻿function SetImg()
{
    var obj=document.getElementsByTagName("img");
    for(i=0;i<obj.length;i++)
    {
	    var ImgID=obj[i].id.substring(0,11);
	    if(ImgID=="ProductImgA" || ImgID=="ProductImgB")
	    {
	        var ImgWidth=obj[i].width;
	        var ImgHeight=obj[i].height;
	        if(ImgWidth>=100&&ImgWidth>=ImgHeight)
	        {
		        obj[i].style.width="100px";
	        }
	        else
	        {
	            obj[i].style.width="auto";
	        }
	        if(ImgHeight>=100&&ImgHeight>ImgWidth)
	        {
		        obj[i].style.height="100px";
	        }
	        else
	        {
	            obj[i].style.height="auto";
	        }
	    }
	    else if(ImgID=="ProductImgC")
	    {
	        var ImgWidth=obj[i].width;
	        var ImgHeight=obj[i].height;
	        if(ImgWidth>=80&&ImgWidth>=ImgHeight)
	        {
		        obj[i].style.width="80px";
	        }
	        else
	        {
	            obj[i].style.width="auto";
	        }
	        if(ImgHeight>=80&&ImgHeight>ImgWidth)
	        {
		        obj[i].style.height="80px";
	        }
	        else
	        {
	            obj[i].style.height="auto";
	        }
	    }
    }
    
    var demo=document.getElementById("BrandList");
	var demo1=document.getElementById("Scroll1");
	var demo2=document.getElementById("Scroll2");
	var speed=30;//速度数值越大速度越慢
	demo2.innerHTML=demo1.innerHTML;
	function Marquee()
	{
		if(demo2.offsetWidth-demo.scrollLeft<=0)//offsetWidth是对象的可见宽度，scrollLeft是位于对象左边界和窗口中目前可见内容的最左端之间的距离
		demo.scrollLeft-=demo1.offsetWidth;
		else
		demo.scrollLeft++;
	}
	var MyMar=setInterval(Marquee,speed);
	demo.onmouseover=function() {clearInterval(MyMar);}
	demo.onmouseout=function() {MyMar=setInterval(Marquee,speed);}
}


