var currId1 = 'NewProduct_0';
var currId2 = 'NewProduct2_0_0';
var currId3 = 'NewProduct3_0_0';

function changTop(newId){
	if( currId1!=null){
	  document.getElementById(currId1).style.display="none";
	  document.getElementById(currId1+'_t').style.display="block";
	}
	document.getElementById(newId).style.display="block";
	document.getElementById(newId+'_t').style.display="none";
	currId1 = newId;
}

//column_1_20_7_3.jsp 
function switchTab2(id,td){
	var tr = td.parentNode;
	tds = tr.childNodes;
	var tab = document.getElementById("content_"+id);
	var tabs = document.getElementById("mytab").getElementsByTagName("span");
	for(var i=0;i<tabs.length;i++){
		if(i==id){
			tabs[i].style.display="block";
		}else{
			tabs[i].style.display="none";
		}
		for(var j=0;j<tds.length;j++){
			if(j%2==0)
				tds[j].className="r_b1";
		}
		td.className="r_b2";
	}
}

function changTop2(newId){
	if( currId2!=null){
	  document.getElementById(currId2).style.display="none";
	  document.getElementById(currId2+'_t').style.display="block";
	}
	document.getElementById(newId).style.display="block";
	document.getElementById(newId+'_t').style.display="none";
	currId2 = newId;
}

//column_1_32_8_3.jsp
function switchTab3(id,td){
	var tr = td.parentNode;
	tds = tr.childNodes;
	var tab = document.getElementById("content3_"+id);
	var tabs = document.getElementById("mytab3").getElementsByTagName("span");
	for(var i=0;i<tabs.length;i++){
		if(i==id){
			tabs[i].style.display="block";
		}else{
			tabs[i].style.display="none";
		}
		for(var j=0;j<tds.length;j++){
			if(j%2==0)
				tds[j].className="r_b1";
		}
		td.className="r_b2";
	}
}

function changTop3(newId){
	if( currId3!=null){
	  document.getElementById(currId3).style.display="none";
	  document.getElementById(currId3+'_t').style.display="block";
	}
	document.getElementById(newId).style.display="block";
	document.getElementById(newId+'_t').style.display="none";
	currId3 = newId;
}

function showDiv(id){
	if(id=="a"){
		document.getElementById("a").className="l_b02";
		document.getElementById("b").className="l_b01";
		document.getElementById("c").className="l_b01";
		document.getElementById("one").style.display = "block";
		document.getElementById("two").style.display = "none";
		document.getElementById("three").style.display = "none";
	}
	if(id=="b"){
		document.getElementById("a").className="l_b01";
		document.getElementById("b").className="l_b02";
		document.getElementById("c").className="l_b01";
		document.getElementById("one").style.display = "none";
		document.getElementById("two").style.display = "block";
		document.getElementById("three").style.display = "none";
	}
	if(id=="c"){
		document.getElementById("a").className="l_b01";
		document.getElementById("b").className="l_b01";
		document.getElementById("c").className="l_b02";
		document.getElementById("one").style.display = "none";
		document.getElementById("two").style.display = "none";
		document.getElementById("three").style.display = "block";
	}
}


function initTopCss(pathname) {
	if(pathname.indexOf("/book/browse.jsp")!=-1) {
		var tbottom = document.getElementById("tbottom5");
		tbottom.setAttribute("class","top_botton");
		tbottom.setAttribute("className","top_botton");
	} else if(pathname.indexOf("/book")!=-1||pathname.indexOf("/book/index.jsp")!=-1) {
		var tbottom = document.getElementById("tbottom2");
		tbottom.setAttribute("class","top_botton");
		tbottom.setAttribute("className","top_botton");
	} else if(pathname.indexOf("/cd")!=-1||pathname.indexOf("/cd/index.jsp")!=-1) {
		var tbottom = document.getElementById("tbottom3");
		tbottom.setAttribute("class","top_botton");
		tbottom.setAttribute("className","top_botton");
	} else if(pathname.indexOf("/subject/")!=-1||pathname.indexOf("/subject/index.jsp")!=-1) {
		var tbottom = document.getElementById("tbottom4");
		tbottom.setAttribute("class","top_botton");
		tbottom.setAttribute("className","top_botton");
	} else if(pathname.indexOf("/help/")!=-1||pathname.indexOf("/help/index.jsp")!=-1) {
		var tbottom = document.getElementById("tbottom6");
		tbottom.setAttribute("class","top_botton");
		tbottom.setAttribute("className","top_botton");
	} else if(pathname.indexOf("/")!=-1||pathname.indexOf("/index.jsp")!=-1) {
		var tbottom = document.getElementById("tbottom1");
		tbottom.setAttribute("class","top_botton");
		tbottom.setAttribute("className","top_botton");
	} 
}



function changeTopCss(td) {
	var tbottom1 = document.getElementById("tbottom1");
	tbottom1.className="";
	var tbottom2 = document.getElementById("tbottom2");
	tbottom2.className="";
	var tbottom3 = document.getElementById("tbottom3");
	tbottom3.className="";
	var tbottom4 = document.getElementById("tbottom4");
	tbottom4.className="";
	var tbottom5 = document.getElementById("tbottom5");
	tbottom5.className="";
	var tbottom6 = document.getElementById("tbottom6");
	tbottom6.className="";
	td.className="top_botton";
}

function changeMusic(dom,id) {
	var parent = dom.parentNode;
	var childrens = parent.childNodes;
	for(var i = 0;i<childrens.length;i++) {
		childrens[i].className = "music_kb3";
		if(childrens[i].firstChild) {
			childrens[i].className = "font5";
		}
	}
	dom.className = "music_kb2";
	dom.firstChild.className = "";
	var table = document.getElementById("table"+id);
	parent = table.parentNode;
	childrens = parent.childNodes;
	for(var i = 0;i<childrens.length;i++) {
		if(childrens[i].style) {
			childrens[i].style.display = "none";
		}
	}
	table.style.display="";
}

function changeVideo(dom,id) {
	var parent = dom.parentNode;
	var childrens = parent.childNodes;
	for(var i = 0;i<childrens.length;i++) {
		childrens[i].className = "music_kb5";
		if(childrens[i].firstChild) {
			childrens[i].firstChild.className = "font5";
		}
	}
	dom.className = "music_kb4";
	dom.firstChild.className = "";
	var table = document.getElementById("table"+id);
	parent = table.parentNode;
	childrens = parent.childNodes;
	for(var i = 0;i<childrens.length;i++) {
		if(childrens[i].style) {
			childrens[i].style.display = "none";
		}
	}
	table.style.display="";
}

function subPropose() {
	document.getElementById("propose").value="";
	alert("感谢你的建议和意见");
}


var showIndex = 0;
var commoditys = [];
var IntervalID;
function beginChangePic() {
	commoditys = document.getElementsByName("advance_pic_content");
	IntervalID = setInterval('autoChangePic()',3000);
}

function stopChangePic() {
	clearInterval(IntervalID);
}
function stopChangePicByInfo(infoTable) {
	var inputInfoTableId = infoTable.id;
	for(var i = 0;i<commoditys.length;i++) {
		var commodity = commoditys[i];
			var commodityId = commodity.value;
			var picTableId = "pic_"+commodityId;
			var infoTableid = "info_"+commodityId;
			var picTable = document.getElementById(picTableId);
			var infoTable = document.getElementById(infoTableid);
		if(infoTableid == inputInfoTableId) {
			picTable.style.display = "block";
			infoTable.style.display = "none";
		}
		else {
			picTable.style.display = "none";
			infoTable.style.display = "block";
		}
	}

	stopChangePic();
}

var autoChangePic = function (){
	for(var i = 0;i<commoditys.length;i++) {
		var commodity = commoditys[i];
			var commodityId = commodity.value;
			var picTableId = "pic_"+commodityId;
			var infoTableid = "info_"+commodityId;
			var picTable = document.getElementById(picTableId);
			var infoTable = document.getElementById(infoTableid);
		if(i == showIndex) {
			picTable.style.display = "block";
			infoTable.style.display = "none";
		}
		else {
			picTable.style.display = "none";
			infoTable.style.display = "block";
		}
	}
	showIndex++;
	if(showIndex == commoditys.length)showIndex =0; 

}