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";
	}
}
/**
* column_15_267
*/
function switchTab4(number,obj){
	
	var tr=obj.parentNode.parentNode;
	var tds = tr.childNodes;
	for(var i=0;i<tds.length;i++){
		var a=tds[i].childNodes;
		for(var j=0;j<a.length;j++){
			if(a[j].className=="btbody_bt_a"){
				a[j].className="btbody_bt";
				break;
			}
		}
		
	}
	obj.className="btbody_bt_a";
	
	var divs=document.getElementById("rootdiv").childNodes;
	var div=document.getElementById("column_"+number);
	for(var i=0;i<divs.length;i++){
		if(divs[i].tagName=="DIV"){
			divs[i].style.display="none";
		}
	}
	div.style.display="block";
}
function showInfo(column_,content_){
	var div=document.getElementById("column_"+column_);
	var divs=div.childNodes;
	for(var i=0;i<divs.length;i++){
		if(divs[i].tagName=="DIV" && divs[i].id!=""){
			divs[i].style.display="none";
		}
	}
	var showDiv=document.getElementById("column_"+column_+"_content_"+content_);
	showDiv.style.display="block";
}
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";
	}
}
/**
 * /include/new/column_1_6_3_3.jsp
 * @param {Object} currentCount
 * @param {Object} count
 */
function showContentDiv(currentCount,count){
	for(var i = 0;i<count;i++){
		var temp= i+1;
		if((temp)==currentCount){
			document.getElementById("title"+temp).className="btbody_bt_a";
			document.getElementById("contentDiv"+temp).style.display = "block";
		}
		else{
			document.getElementById("title"+temp).className="btbody_bt";
			document.getElementById("contentDiv"+temp).style.display = "none";
		}
	}
}
/**
 * /include/new/column_1_20_8_3.jsp
 * @param {Object} currentIndex
 * @param {Object} count
 */
function showCurrentColumn(startIdName,currentIndex,count){
	
	for(var i = 0;i<count;i++){
		if(i==currentIndex){
			document.getElementById("title"+startIdName+i).className="btbody_bt_a";
			document.getElementById("column"+startIdName+i).style.display = "block";
		}
		else{
			document.getElementById("title"+startIdName+i).className="btbody_bt";
			document.getElementById("column"+startIdName+i).style.display = "none";
		}
	}
}
/**
 * /include/new/column_1_20_8_3.jsp
 * @param {Object} columnId
 * @param {Object} currentIndex
 * @param {Object} count
 */
function showPro2(columnId,currentIndex,count) {
	for(var i = 0;i<count;i++){
		if(i==currentIndex){
			document.getElementById("pro1_"+columnId+"_"+i).style.display = "none";
			document.getElementById("pro2_"+columnId+"_"+i).style.display = "block";
		}
		else{
			document.getElementById("pro1_"+columnId+"_"+i).style.display = "block";
			document.getElementById("pro2_"+columnId+"_"+i).style.display = "none";
		}
	}
}

/**
 * 初始化top样式
 */
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");
	} 
}


/**
 * 改变top的显示样式
 */
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="";
    var tbottom7 = document.getElementById("tbottom7");
    tbottom7.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; 

}

function showCategoryDiv(id) {
	var category1 = document.getElementById("category1") ;
	var category2 = document.getElementById("category2") ;
	if(category1.id==id){
		category1.style.display = "block";
		category2.style.display = "none";
	}
	else{
		category1.style.display = "none";
		category2.style.display = "block";
	}
		
}




