// JavaScript Document
var MemusAry=new Array();
var MemusPath=new Array();
var skipAry=new Array(1205,1212,1213);
var tripodAry=new Array();
function ShowItem(ID){
	var obj=document.getElementById("CoolMemu"+ID);
	if(obj!=null){
		//if(obj.style.display==""){
			//obj.style.display="none";
		//}else{
			obj.style.display="";
		//}
	}
}
function ShowMemus(ID,parten){
	var obj=document.getElementById("CoolMemu"+ID);
		if(HasChild(ID)){
			if(obj.style.display==""){
				obj.style.display="none";
			}else{
				obj.style.display="";
			}
		}else{
			if(CheckIsTripod(ID)){
				location.href="Series.asp?MId="+ID+"&Cla="+ID;
			}else{
				location.href="product.asp?MId="+ID+"&ClaId="+ID;
			}
		}
}
function sortMethod(a, b) {
    return b[1]-a[1];
}
function clearAllMemus(){
	for(i=0;i<MemusAry.length;i++){
		var obj=MemusAry.pop();
	}
}
function CheckIsTripod(ID){
	var tmp=SearchTheTopParent(ID);
	//alert("skip:"+skipAry.join(",")+" \n MemusPath:"+MemusPath.join(","));
	for(i=0;i<MemusPath.length;i++){
		for(j=0;j<skipAry.length;j++){
			if(MemusPath[i]==skipAry[j]){
				return true;
			}
		}
	}
	return false;
}
function FindthisCla(ID){
	for(i=0;i<MemusAry.length;i++){
		if(MemusAry[i][0]==ID){
			return MemusAry[i][1];
		}
	}
	return 0;
}
function SearchTheTopParent(Cla){
	//find the toppest item's classcode and return this classcode value
	//And bulding a golbal array MemusPath about the items path
	for(i=0;i<MemusAry.length;i++){
		if(MemusAry[i][0]==Cla){
			MemusPath.push(Cla);
			if(MemusAry[i][1]==0){
				return Cla;
			}else{
				return SearchTheTopParent(MemusAry[i][1]);
			}
		}
	}
	return 0;
}
function HasChild(ID){
	for(i=0;i<MemusAry.length;i++){
		if(MemusAry[i][1]==ID){
			return true;
		}
	}
	return false;
}
function bulidparentMemus(){

}
function BulidMemuItems(Par,Lev){
	//document.write("<table id='CoolMemu"+Par+"' style='display:none;' recordcount='+rstmp.recordcount+'><tr><td align='right'>");
	//while(){
		//document.write("<table width='"+MaxWidth-spdwidth*level+"' class='table-1'><tr><td class='childMemuText' witdh='100%'><a href='javascript:ShowMemus("+rstmp("classcode")+")'>"+rstmp("classname")+"</a></td></tr></table>");
		//BulidMemuItems(1,Lev+1);
	//}
	//document.write("</td></tr></table>");
}
function OutPutAry(TheAry){
	//while(TheAry.length>0){
		//var OnePro=TheAry.pop();
		//document.write('ID:'+OnePro[0]+'|ParCla:'+OnePro[1]+'|'+OnePro[2]+' \n <br>');
	//};
}
function findparent(Id){
	for(i=0;i<MemusAry.length;i++){
		if(MemusAry[i][1]==ID){
			return true;
		}
	}
}
function InitMemus(Id){
	var o = document.getElementById("CoolMemusItem"+Id);
	if(o!=null){
		o.style.backgroundColor="#636363";
		o.style.borderColor="#C2EFFF";
		//alert(o.style.color);
	}
	while(Id>0){
		//alert("show"+Id);
		ShowItem(Id);
		Id = FindthisCla(Id);
	}	
}