﻿//copy from new eggs: http://www.newegg.com/Product/Product.aspx?Item=N82E16821103203
//swapProductImage:function(img,href,isAttach){$('productImagePreview').src=img;if(isAttach==1){$('productImagePreviewLink').href=href;};}

function swapProductImage(controlID, imgHref)
{
    var imagePreview = document.getElementById(controlID);
    imagePreview.src=imgHref;
}

//function shiftProductImage(controlID, href)
//{
//    var listImage = document.getElementById(controlID);
//    listImage.src = href;
//}

function OnMouseOver(control,styleName)
{
    control.className=styleName;
}

 

function scrollNews(selector,Entry,time,StartIndex, selectorImgUrl)
{
	var _self=this;
	this.Selector=selector;
	this.Entry=Entry;
	this.time = time;
	this.i=StartIndex||0;
	this.Count=$(this.Selector+" ul li").length;
	$(this.Selector+" ul li").hide();//全部隐藏
	$(this.Selector+" ul li").eq(this.i).show();//第i个显示
	$(this.Selector).bind("mouseenter",function(){
	    	if(_self.sI){clearInterval(_self.sI);}
	}).bind("mouseleave",function(){
			_self.showIndex(_self.i++);
	})
	/*生成激活OL项目*/
	for (var j = 0; j < this.Count; j++)
	    $(this.Selector + " .activeOL").append('<li><a onclick="' + this.Entry + '.showIndex(' + j + ');" href="#"><img src="'+selectorImgUrl+'"/></a></li>');
	$(this.Selector+" ol li a").eq(this.i).addClass("active");
	this.sI=setInterval(this.Entry+".showIndex(null)",this.time);
	
	this.GetSelector=function(){return this.Selector;}
	this.showIndex=function(index)
	{
		this.i++;//显示下一个
		if(this.sI){clearInterval(this.sI);}
		this.sI=setInterval(this.Entry+".showIndex()",this.time);
		if (index!=null)
		{
			this.i=index;
		}
		if(this.i==this.Count)
			this.i=0;
		$(this.Selector+" ul li").hide();
		$(this.Selector+" ul li").eq(this.i).slideDown();
		$(this.Selector+" ol li a").removeClass("active");
		$(this.Selector+" ol li a").eq(this.i).addClass("active");
	}
}
/**滚动新闻展示效果
code by CssRain--橘子.
转载请注明:http://www.cssrain.cn
// 参数1：ID    		
// 参数2：实例化对象的名称（跟var 后的相同）
// 参数3：间隔时间      
// 参数4：初始化时，默认哪个先显示
**/
