var Ex = function(o) {
	for ( var k in o)
		this[k] = o[k];
	return this
}
var UI = function(id) {
	return document.getElementById(id)
}
var UIs = function(tag) {
	return Ex.call( [], this.getElementsByTagName(tag))
}
var Each = function(a, fn) {
	for ( var i = 0; i < a.length; i++)
		fn.call(a[i], i, a)
}
var dhooo = function(ini) {
	this.bind(ini, this);
	this.autoIndex = 0;
};
Ex.call(dhooo.prototype,{
					bind : function(ini, me) {
						var dir = ini.dir == 'top' ? 'scrollTop' : 'scrollLeft', pan = UI(ini.contentID);
						var start = function(o) {
							Each(ini.btns, function() {
								this.className = ''
							});
							
							//alert(" o = " +  o.innerHTML);
							//alert(" o.className = " +  o.className);
							//alert(" ini.className = " + ini.className);
							//在此修改了对应列表UL的类名        o.index 为第几个信息
							o.className = ini.className;
							me.autoIndex = o.index;
							var titleDiv = document.getElementById("homepage_cycle_dummy");
							titleDiv.innerHTML = __title[o.index];
							/*
							alert("o.index = " + o.index);
							alert("pan = " + pan.innerHTML);
							alert("ini.len = " + ini.len);
							alert("dir = " + dir);
							*/
							me.begin(o.index, pan, ini.len, dir);
						};
						pan.onmouseover = function() {
							me.stop = true
						};
						Each(ini.btns, function(i) {
							this.index = i;
							this.onmouseover = function() {
								me.stop = true;
								start(this)
							};
							pan.onmouseout = this.onmouseout = function() {
								me.stop = false
							}
						});
						var auto = function() {
							if (!me.stop) {
								// 设置轮转数 bannercount = 5;
								me.autoIndex = me.autoIndex == bannercount ? 0
										: ++me.autoIndex;
								start(ini.btns[me.autoIndex]);
							}
						};
						if (ini.auto)
							this.autoPlay = window.setInterval(auto, 5000);
					},
					begin : function(i, o, len, dir) {
						( function(me) {
							clearInterval(me.only);
							/*
							alert("me.only = " + me.only);
							alert("i = " + i);
							alert("o = " + o.innerHTML);
							alert("len = " + len);
							alert("dir = " + dir);
							*/
							me.only = setInterval( function() {
								var diff = (i * len - o[dir]) * 0.1;
								//alert(" diff = " + diff);
								o[dir] += Math[diff > 0 ? 'ceil' : 'floor']
										(diff);
								//alert(" o[dir] = " + o[dir]);
								if (diff == 0)
									clearInterval(me.only);
							}, 10)
						})(this)
					}
				})

if (!isIE_8()) {

	if (isIE_c()) {
		new dhooo( {
			btns :UIs.call(UI('myTab_btns2'), 'LI'),
			className :'nonce',
			contentID :'main2',
			len :240
			// ,len:202
			,
			dir :'top',
			auto :true
		});
	} else {
		new dhooo( {
			btns :UIs.call(UI('myTab_btns2'), 'LI'),
			className :'nonce',
			contentID :'main2',
			len :240,
			dir :'top',
			auto :true
		});
	}
} else {

	new dhooo( {
		btns :UIs.call(UI('myTab_btns2'), 'LI'),
		className :'nonce',
		contentID :'main2',
		len :240,
		dir :'top',
		auto :true
	});
}

function $(id) {
	return document.getElementById(id);
}
/*
 * var productDiv=new Array();
 * productDiv=[["showproduct1,imgproduct1","productlist1"],["showproduct2,imgproduct2","productlist2"],["showproduct3,imgproduct3","productlist3"],["showproduct4,imgproduct4","productlist4"]];
 * 
 * var playnum=1;
 * 
 * function showproductdiv(id){ if(id==0){id=playnum;} for(i=1;i<=4;i++){
 * 
 * if(i==id){ $("showproduct"+id).style.display="block";
 * $("imgproduct"+id).style.display="none"; $("__I"+id).style.display="block"; }
 * else{ $("showproduct"+i).style.display="none";
 * $("imgproduct"+i).style.display="block"; $("__I"+i).style.display="none"; }
 * 
 * 
 *  }
 * 
 * if(playnum==4){playnum=1}else{playnum++}
 *  } var myplay; function ProductDivPlay(id){ if(id==""){id=0}else{playnum=id}
 * 
 * myplay=setInterval("showproductdiv(0)",8000); }
 * 
 * function ProductDivStop(){
 * 
 * clearInterval(myplay); }
 */
// ProductDivPlay(0);
/*
 * function showhidediv(){ for(i=0;i<arguments.length;i++){ if(i==0){
 * if(arguments[i]=="service"){$(arguments[i]).className="h2_other
 * nonce"}else{$(arguments[i]).className="nonce"}; } if(i==1){
 * $(arguments[i]).style.display=""; } if(i==2){
 * if(arguments[i]=="service"){$(arguments[i]).className="h2_other"}else{$(arguments[i]).className=""}; }
 * if(i==3){
 * if(arguments[i]=="service"){$(arguments[i]).className="h2_other"}else{$(arguments[i]).className=""}; }
 * if(i==4){ $(arguments[i]).style.display="none"; } if(i==5){
 * $(arguments[i]).style.display="none"; } } }
 * 
 * function showhide_divU(showdivid,hidedivid){ if($(showdivid)!=null){
 * $(showdivid).style.display=""; if(showdivid=='guanzhu')
 * $(showdivid+"_title").className="nonce"; else
 * $(showdivid+"_title").className="other nonce"; } if($(hidedivid)!=null){
 * $(hidedivid).style.display="none"; if(hidedivid=='huodong')
 * $(hidedivid+"_title").className="other"; else
 * $(hidedivid+"_title").className=""; } }
 * 
 */
function ScrollText(content, btnPrevious, btnNext, autoStart) {
	this.Delay = 10;
	this.LineHeight = 25;
	this.Amount = 1;
	this.Direction = "up";
	this.Timeout = 4000;

	this.ScrollContent = this.gid(content);
	this.ScrollContent.innerHTML += this.ScrollContent.innerHTML;
	// this.ScrollContent.scrollTop = 0;

	if (btnNext) {
		this.NextButton = this.gid(btnNext);
		this.NextButton.onclick = this.GetFunction(this, "Next");
		this.NextButton.onmouseover = this.GetFunction(this, "Stop");
		this.NextButton.onmouseout = this.GetFunction(this, "Start");
	}
	if (btnPrevious) {
		this.PreviousButton = this.gid(btnPrevious);
		this.PreviousButton.onclick = this.GetFunction(this, "Previous");
		this.PreviousButton.onmouseover = this.GetFunction(this, "Stop");
		this.PreviousButton.onmouseout = this.GetFunction(this, "Start");
	}
	this.ScrollContent.onmouseover = this.GetFunction(this, "Stop");
	this.ScrollContent.onmouseout = this.GetFunction(this, "Start");
	if (autoStart) {
		this.Start();
	}
}

ScrollText.prototype.gid = function(element) {
	return document.getElementById(element);
}

ScrollText.prototype.Previous = function() {
	clearTimeout(this.AutoScrollTimer);
	clearTimeout(this.ScrollTimer);
	this.Scroll("up");
}

ScrollText.prototype.Next = function() {
	clearTimeout(this.AutoScrollTimer);
	clearTimeout(this.ScrollTimer);
	this.Scroll("down");
}

ScrollText.prototype.Start = function() {
	clearTimeout(this.AutoScrollTimer);
	this.AutoScrollTimer = setTimeout(this.GetFunction(this, "AutoScroll"),
			this.Timeout);
}

ScrollText.prototype.Stop = function() {
	clearTimeout(this.ScrollTimer);
	clearTimeout(this.AutoScrollTimer);
}

ScrollText.prototype.AutoScroll = function() {
	if (this.Direction == "up") {
		if (parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2) {
			this.ScrollContent.scrollTop = 0;
			clearTimeout(this.AutoScrollTimer);
			this.AutoScrollTimer = setTimeout(this.GetFunction(this,
					"AutoScroll"), this.Timeout);
			return;
		}
		this.ScrollContent.scrollTop += this.Amount;
	} else {
		if (parseInt(this.ScrollContent.scrollTop) <= 0) {
			this.ScrollContent.scrollTop = parseInt(this.ScrollContent.scrollHeight) / 2;
		}
		this.ScrollContent.scrollTop -= this.Amount;
	}
	if (parseInt(this.ScrollContent.scrollTop) % this.LineHeight != 0) {
		this.ScrollTimer = setTimeout(this.GetFunction(this, "AutoScroll"),
				this.Delay);
	} else {
		this.AutoScrollTimer = setTimeout(this.GetFunction(this, "AutoScroll"),
				this.Timeout);
	}
}

ScrollText.prototype.Scroll = function(direction) {
	if (direction == "up") {
		if (this.ScrollContent.scrollTop == 0) {
			this.ScrollContent.scrollTop = parseInt(this.ScrollContent.scrollHeight) / 2;
		}
		this.ScrollContent.scrollTop -= this.Amount;
	} else {
		this.ScrollContent.scrollTop += this.Amount;
	}
	if (parseInt(this.ScrollContent.scrollTop) >= parseInt(this.ScrollContent.scrollHeight) / 2) {
		this.ScrollContent.scrollTop = 0;
	}
	if (parseInt(this.ScrollContent.scrollTop) % this.LineHeight != 0) {
		this.ScrollTimer = setTimeout(this.GetFunction(this, "Scroll",
				direction), this.Delay);
	}
}

ScrollText.prototype.GetFunction = function(variable, method, param) {
	return function() {
		variable[method](param);
	}
}
// ff兼容
function isIE_c() {
	if (window.navigator.userAgent.toLowerCase().indexOf("msie 8.0") > 1)
		return false;
	return window.navigator.userAgent.toLowerCase().indexOf("msie") >= 1 ? true
			: false;
}

function isIE_8() {
	if (window.navigator.userAgent.toLowerCase().indexOf("msie 8.0") > 1)
		return true;
	else
		return false;
}
// 图片滚动列表
var Speed_1 = 10; // 速度(毫秒)
var Space_1 = 10; // 每次移动(px)
var PageWidth_1 = 151 * 1; // 翻页宽度
var interval_1 = 7000; // 翻页间隔
var fill_1 = 0; // 整体移位
var MoveLock_1 = false;
var MoveTimeObj_1;
var MoveWay_1 = "right";
var Comp_1 = 0;
var AutoPlayObj_1 = null;
function GetObj(objName) {
	if (document.getElementById) {
		return eval('document.getElementById("' + objName + '")')
	} else {
		return eval('document.all.' + objName)
	}
}
function AutoPlay_1() {
	clearInterval(AutoPlayObj_1);
	AutoPlayObj_1 = setInterval('ISL_GoDown_1();ISL_StopDown_1();', interval_1)
}
function ISL_GoUp_1() {
	if (MoveLock_1)
		return;
	clearInterval(AutoPlayObj_1);
	MoveLock_1 = true;
	MoveWay_1 = "left";
	MoveTimeObj_1 = setInterval('ISL_ScrUp_1();', Speed_1);
}
function ISL_StopUp_1() {
	if (MoveWay_1 == "right") {
		return
	}
	;
	clearInterval(MoveTimeObj_1);
	if ((GetObj('ISL_Cont_1').scrollLeft - fill_1) % PageWidth_1 != 0) {
		Comp_1 = fill_1 - (GetObj('ISL_Cont_1').scrollLeft % PageWidth_1);
		CompScr_1()
	} else {
		MoveLock_1 = false
	}
	AutoPlay_1()
}
function ISL_ScrUp_1() {
	if (GetObj('ISL_Cont_1').scrollLeft <= 0) {
		GetObj('ISL_Cont_1').scrollLeft = GetObj('ISL_Cont_1').scrollLeft
				+ GetObj('List1_1').offsetWidth
	}
	GetObj('ISL_Cont_1').scrollLeft -= Space_1
}
function ISL_GoDown_1() {
	clearInterval(MoveTimeObj_1);
	if (MoveLock_1)
		return;
	clearInterval(AutoPlayObj_1);
	MoveLock_1 = true;
	MoveWay_1 = "right";
	ISL_ScrDown_1();
	MoveTimeObj_1 = setInterval('ISL_ScrDown_1()', Speed_1)
}
function ISL_StopDown_1() {
	if (MoveWay_1 == "left") {
		return
	}
	;
	clearInterval(MoveTimeObj_1);
	if (GetObj('ISL_Cont_1').scrollLeft % PageWidth_1
			- (fill_1 >= 0 ? fill_1 : fill_1 + 1) != 0) {
		Comp_1 = PageWidth_1 - GetObj('ISL_Cont_1').scrollLeft % PageWidth_1
				+ fill_1;
		CompScr_1()
	} else {
		MoveLock_1 = false
	}
	AutoPlay_1()
}
function ISL_ScrDown_1() {
	if (GetObj('ISL_Cont_1').scrollLeft >= GetObj('List1_1').scrollWidth) {
		GetObj('ISL_Cont_1').scrollLeft = GetObj('ISL_Cont_1').scrollLeft
				- GetObj('List1_1').scrollWidth
	}
	GetObj('ISL_Cont_1').scrollLeft += Space_1
}
function CompScr_1() {
	if (Comp_1 == 0) {
		MoveLock_1 = false;
		return
	}
	var num, TempSpeed = Speed_1, TempSpace = Space_1;
	if (Math.abs(Comp_1) < PageWidth_1 / 2) {
		TempSpace = Math.round(Math.abs(Comp_1 / Space_1));
		if (TempSpace < 1) {
			TempSpace = 1
		}
	}
	if (Comp_1 < 0) {
		if (Comp_1 < -TempSpace) {
			Comp_1 += TempSpace;
			num = TempSpace
		} else {
			num = -Comp_1;
			Comp_1 = 0
		}
		GetObj('ISL_Cont_1').scrollLeft -= num;
		setTimeout('CompScr_1()', TempSpeed)
	} else {
		if (Comp_1 > TempSpace) {
			Comp_1 -= TempSpace;
			num = TempSpace
		} else {
			num = Comp_1;
			Comp_1 = 0
		}
		GetObj('ISL_Cont_1').scrollLeft += num;
		setTimeout('CompScr_1()', TempSpeed)
	}
}
function picrun_ini() {
	GetObj("List2_1").innerHTML = GetObj("List1_1").innerHTML;
	GetObj('ISL_Cont_1').scrollLeft = fill_1 >= 0 ? fill_1
			: GetObj('List1_1').scrollWidth - Math.abs(fill_1);
	GetObj("ISL_Cont_1").onmouseover = function() {
		clearInterval(AutoPlayObj_1)
	}
	GetObj("ISL_Cont_1").onmouseout = function() {
		AutoPlay_1()
	}
	AutoPlay_1();
}

// picrun_ini();
// 产品展示滚动图片结束

