﻿function getGroupInfo()//获得group标签信息(即显示方式是2D还是3D)
{
	$.ajax(
		{
		 tyep: "GET",
		 url: "../phpCode/getProductInfo.php",
		 data: "nID=" + proID + "&typeInfo=showType" + "&ts=" + new Date().getTime(),
		 success: getProIDCallBack
		}
		);
}
function getProIDCallBack(msgBack)
{
	var types = eval("(" + msgBack + ")");
	
	for(var i in types)
	{
		vecGpInfo[i]= new gpInfo;
		vecGpInfo[i].showID = i;
		vecGpInfo[i].showType = types[i];
		//alert(vecGpInfo[i].showType);
	}
	productShow();
}
function gpInfo()
{
	this.showID = "";
	this.showType = "";
}
var vecGpInfo = new Array();
//设置4个视点功能
function setViewMode(type)
{	

	if(type==0)
	{
		ProductCtl.SetNavigationMode(1,0);
	}else if(type==1)
	{
		ProductCtl.SetNavigationMode(2,1);
	}else if(type==2)
	{
		ProductCtl.SetNavigationMode(3,3);
	}else if(type==3)
	{
		ProductCtl.RestoreScene();
		//ProductCtl.Restore();
	}
}
var curIndexGp = 0;//当前是第几个节点组
function getStepInfo(msgBack)
{
	var stepArray = eval("(" + msgBack + ")");
    var vargroup='<ul class= "cla_steps" >\n';
	for(var g in stepArray )
	{
		//alert(vecGroupsInfo[0].StepsQueue[g].StepName);
		vargroup += '<li><a class = "steps_li_2" title = '+ stepArray[g][1] +'  href = "#" id = "stepDefalut" onClick = "ShowContent('+stepArray[g][0]+')">' +                  stepArray[g][1] + '</a></li>\n';

	}	
	//vargroup+='</table>';	
	vargroup+='</ul>';
	$("#auto_height_5")[0].innerHTML=vargroup;
	document.getElementById('bgImg').className = 'cla_pro_lf_b';
	if(g >= 0)
	{	
		ShowContent(stepArray[0][0]);
	}

}
function ShowContent(index)
{
	$.ajax(
	{
	 tyep: "GET",
	 url: "../phpCode/getProductInfo.php",
	 data: "nID=" + proID + "&typeInfo=content" + "&contentID=" + index + "&ts=" + new Date().getTime(),
	 success: ShowContentList
	}
	);
}
function ShowContentList(msgBack)
{
	$("#showModel2D_text")[0].innerHTML = msgBack;
}
function productShow()//显示出产品说明的内容
{
	$("#cla1").attr("class", "cla_mm_li_1_1");
	$("#cla2").attr("class", "cla_mm_li_2_2");
	$("#cla3").attr("class", "cla_mm_li_3_2");
	$("#cla4").attr("class", "cla_mm_li_4_2");
	$("#cla5").attr("class", "cla_mm_li_5_2");
	$("#cla6").attr("class", "cla_mm_li_6_2");
	var sizeVcGpInfo = vecGpInfo.length;
	if(sizeVcGpInfo != 0 && vecGpInfo[1].showType == "2D")
	{
		$("#attentionCompany").hide();
		$("#attention3dIntroduce").hide();
		$("#attentionContactUs").hide();
		$("#attentionOnlineLeaveWord").hide();
		$("#showModel2D").show();
		$("#prgressBar").hide();
		$("#showModel3D").hide();
		$.ajax(
		{
		 tyep: "GET",
		 url: "../phpCode/getProductInfo.php",
		 data: "nID=" + proID + "&typeInfo=chapter" + "&typeID=" + vecGpInfo[1].showID + "&ts=" + new Date().getTime(),
		 success: getStepInfo
		}
		);
		
	}
	else 
	{
		$("#attentionCompany").hide();
		$("#attention3dIntroduce").hide();
		$("#attentionContactUs").hide();
		$("#attentionOnlineLeaveWord").hide();
		$("#showModel2D").hide();
		$("#showModel3D").show();
/*		curIndexGp = 0;
	    showGroup(0);
		onMouseMove(0);
		ShowStepList(0,0);*/
	}

}
function productStruct()//显示出产品结构的内容
{
    $("#cla1").attr("class", "cla_mm_li_1_2");
	$("#cla2").attr("class", "cla_mm_li_2_1");
	$("#cla3").attr("class", "cla_mm_li_3_2");
	$("#cla4").attr("class", "cla_mm_li_4_2");
	$("#cla5").attr("class", "cla_mm_li_5_2");
	$("#cla6").attr("class", "cla_mm_li_6_2");
	var sizeVcGpInfo = vecGpInfo.length;
	if(sizeVcGpInfo != 0 && vecGpInfo[2].showType == "2D")
	{
		$("#attentionCompany").hide();
		$("#attention3dIntroduce").hide();
		$("#attentionContactUs").hide();
		$("#attentionOnlineLeaveWord").hide();
		$("#showModel2D").show();
		$("#prgressBar").hide();
		$("#showModel3D").hide();
		$.ajax(
		{
		 tyep: "GET",
		 url: "../phpCode/getProductInfo.php",
		 data: "nID=" + proID + "&typeInfo=chapter" + "&typeID=" + vecGpInfo[2].showID + "&ts=" + new Date().getTime(),
		 success: getStepInfo
		}
		);
		
	}
	else
	{
		$("#attentionCompany").hide();
		$("#attention3dIntroduce").hide();
		$("#attentionContactUs").hide();
		$("#attentionOnlineLeaveWord").hide();
		$("#showModel2D").hide();
		$("#showModel3D").show();
		curIndexGp = 1;
	    showGroup(1);
		onMouseMove(0);
		ShowStepList(0,0);
	}

}
function productUse()
{
    $("#cla1").attr("class", "cla_mm_li_1_2");
	$("#cla2").attr("class", "cla_mm_li_2_2");
	$("#cla3").attr("class", "cla_mm_li_3_1");
	$("#cla4").attr("class", "cla_mm_li_4_2");
	$("#cla5").attr("class", "cla_mm_li_5_2");
	$("#cla6").attr("class", "cla_mm_li_6_2");
	var sizeVcGpInfo = vecGpInfo.length;
	if(sizeVcGpInfo != 0 && vecGpInfo[3].showType == "2D")
	{
		$("#attentionCompany").hide();
		$("#attention3dIntroduce").hide();
		$("#attentionContactUs").hide();
		$("#attentionOnlineLeaveWord").hide();
		$("#showModel2D").show();
		$("#prgressBar").hide();
		$("#showModel3D").hide();
		$.ajax(
		{
		 tyep: "GET",
		 url: "../phpCode/getProductInfo.php",
		 data: "nID=" + proID + "&typeInfo=chapter" + "&typeID=" + vecGpInfo[3].showID + "&ts=" + new Date().getTime(),
		 success: getStepInfo
		}
		);
		
	}
	else
	{
		$("#attentionCompany").hide();
		$("#attention3dIntroduce").hide();
		$("#attentionContactUs").hide();
		$("#attentionOnlineLeaveWord").hide();
		$("#showModel2D").hide();
		$("#showModel3D").show();
		curIndexGp = 2;
	    showGroup(2);
		onMouseMove(0);
		ShowStepList(0,0);
	}

}
function productPly()
{
	$("#cla1").attr("class", "cla_mm_li_1_2");
	$("#cla2").attr("class", "cla_mm_li_2_2");
	$("#cla3").attr("class", "cla_mm_li_3_2");
	$("#cla4").attr("class", "cla_mm_li_4_1");
	$("#cla5").attr("class", "cla_mm_li_5_2");
	$("#cla6").attr("class", "cla_mm_li_6_2");
	var sizeVcGpInfo = vecGpInfo.length;
	if(sizeVcGpInfo != 0 && vecGpInfo[4].showType == "2D")
	{
		$("#attentionCompany").hide();
		$("#attention3dIntroduce").hide();
		$("#attentionContactUs").hide();
		$("#attentionOnlineLeaveWord").hide();
		$("#showModel2D").show();
		$("#prgressBar").hide();
		$("#showModel3D").hide();
		$.ajax(
		{
		 tyep: "GET",
		 url: "../phpCode/getProductInfo.php",
		 data: "nID=" + proID + "&typeInfo=chapter" + "&typeID=" + vecGpInfo[4].showID + "&ts=" + new Date().getTime(),
		 success: getStepInfo
		}
		);
		
	}
	else
	{
		$("#attentionCompany").hide();
		$("#attention3dIntroduce").hide();
		$("#attentionContactUs").hide();
		$("#attentionOnlineLeaveWord").hide();
		$("#showModel2D").hide();
		$("#showModel3D").show();
		curIndexGp = 3;
	    showGroup(3);
		onMouseMove(0);
		ShowStepList(0,0);
	}

}
function productStick()
{
	$("#cla1").attr("class", "cla_mm_li_1_2");
	$("#cla2").attr("class", "cla_mm_li_2_2");
	$("#cla3").attr("class", "cla_mm_li_3_2");
	$("#cla4").attr("class", "cla_mm_li_4_2");
	$("#cla5").attr("class", "cla_mm_li_5_1");
	$("#cla6").attr("class", "cla_mm_li_6_2");
	var sizeVcGpInfo = vecGpInfo.length;
	if(sizeVcGpInfo != 0 && vecGpInfo[5].showType == "2D")
	{
		$("#attentionCompany").hide();
		$("#attention3dIntroduce").hide();
		$("#attentionContactUs").hide();
		$("#attentionOnlineLeaveWord").hide();
		$("#showModel2D").show();
		$("#prgressBar").hide();
		$("#showModel3D").hide();
		$.ajax(
		{
		 tyep: "GET",
		 url: "../phpCode/getProductInfo.php",
		 data: "nID=" + proID + "&typeInfo=chapter" + "&typeID=" + vecGpInfo[5].showID + "&ts=" + new Date().getTime(),
		 success: getStepInfo
		}
		);
		
	}
	else
	{
		$("#showModel3D").show();
		$("#attentionCompany").hide();
		$("#attention3dIntroduce").hide();
		$("#attentionContactUs").hide();
		$("#attentionOnlineLeaveWord").hide();
		$("#showModel2D").hide();
		curIndexGp = 4;
	    showGroup(4);
		onMouseMove(0);
		ShowStepList(0,0);
	}

}

function GroupInfo() 
{
	this.Groupid="";
	this.GroupDescribe = "";
	this.GroupName = "";
	this.StepsQueue = new Array();
}
var vecGroupsInfo = new Array();
function StepsInfo()
{
	this.nStepId = "";	
	this.StepName="";
	this.StepDescribe = "";
	this.SubStepsQueue = new Array();	
}
function getStepsInfo(Gi)
{
 	var vecStepsInfo = new Array();
	nStepsNum = ProductCtl.GetCountOfStep(Gi);
	for(var Si=0; Si<nStepsNum; Si++)
	{
		tmpStepsInfo = ProductCtl.GetStepInfo(Gi, Si).toArray();
		vecStepsInfo[Si] = new StepsInfo;
		vecStepsInfo[Si].StepName = tmpStepsInfo[0];
		vecStepsInfo[Si].StepDescribe = tmpStepsInfo[1];
		vecStepsInfo[Si].nStepId = tmpStepsInfo[2];		
		//vecStepsInfo[Si].SubStepsQueue = getSubStepsInfo(Gi, Si);		
	}
	return vecStepsInfo;
}
function SubStepsInfo()
{
	this.nSubStepId = "";
	this.SubStepName="";
	this.SubStepDescribe = "";	
	this.nPos="";
}
function getSubStepsInfo(Gi,Si)
{
	var vecSubStepsInfo = new Array();
	nSubStepsNum = ProductCtl.GetCountOfSubStep(Gi, Si);
	for(var SSi=0; SSi<nSubStepsNum; SSi++)
	{
		tmpSubStepsInfo = ProductCtl.GetSubStepInfo(Gi, Si, SSi).toArray();
		vecSubStepsInfo[SSi] = new SubStepsInfo;
		vecSubStepsInfo[SSi].SubStepName = tmpSubStepsInfo[0];
		vecSubStepsInfo[SSi].SubStepDescribe = tmpSubStepsInfo[1];
		vecSubStepsInfo[SSi].nSubStepId = tmpSubStepsInfo[2];
		vecSubStepsInfo[SSi].nPos = tmpSubStepsInfo[3];					
	}
	return vecSubStepsInfo;	
}

function ShowStepList(obj,type)//播放动画
{
	//vecGroupsInfo[curIndexGp].
	//ProductCtl.PlayAll();
	ProductCtl.PlayStep(curIndexGp, type);
	//ProductCtl.PlayAll();
	if(!vecGroupsInfo[curIndexGp] && !vecGroupsInfo[curIndexGp].StepsQueue[type]){
		varExplain = vecGroupsInfo[curIndexGp].StepsQueue[type].StepDescribe;
		//alert(varExplain);
		$("#stepExplain")[0].innerHTML = varExplain;
	}
}
function onMouseMove(type)
{
	if(!vecGroupsInfo[curIndexGp] && !vecGroupsInfo[curIndexGp].StepsQueue[type]){
		varExplain = vecGroupsInfo[curIndexGp].StepsQueue[type].StepDescribe;
		$("#stepExplain")[0].innerHTML = varExplain;
	}
}
function onMouseOut(type)
{
	$("#stepExplain")[0].innerHTML = "";
}
function showGroup(type)
{
	curIndexGp = type;
	var vargroup='<ul class= "cla_steps" >\n';
	for(var g = 0; g < ProductCtl.GetCountOfStep(type); g++ )
	{
		//alert(vecGroupsInfo[0].StepsQueue[g].StepName);
/*		vargroup += '<li onmousemove="onMouseMove('+g+')" onmouseout="onMouseOut('+g+')"><a class = "steps_li_2" title = "'+ vecGroupsInfo[type].StepsQueue[g].StepName +'"  href = "#" id = "stepDefalut" onClick = "ShowStepList(this,'+g+')">' + vecGroupsInfo[type].StepsQueue[g].StepName + '</a></li>\n';*/
		vargroup += '<li onclick="onMouseMove('+g+')"><a class = "steps_li_2" title = "'+ vecGroupsInfo[type].StepsQueue[g].StepName +'"  href = "#" id = "stepDefalut" onClick = "ShowStepList(this,'+g+')">' + vecGroupsInfo[type].StepsQueue[g].StepName + '</a></li>\n';
	}	
	//alert(vargroup);
	//vargroup+='</table>';	
	vargroup+='</ul>';
	$("#auto_height_5")[0].innerHTML=vargroup;
	document.getElementById('bgImg').className = 'cla_pro_lf_b';
	//ShowStepList(0);
	//ShowStepList(0);
}
function OnSceneFinish(nIndex)
{
	//alert(nIndex);
    var totalnum = ProductCtl.GetCountOfGroup();	
	if(totalnum==0)return;		
	//alert(totalnum);
	for(var Gi=0; Gi<totalnum; Gi++)
	{		
		var tmpGroupsInfo = ProductCtl.GetGroupInfo(Gi).toArray();
		vecGroupsInfo[Gi] = new GroupInfo;
		vecGroupsInfo[Gi].GroupName = tmpGroupsInfo[0];			
		vecGroupsInfo[Gi].GroupDescribe = tmpGroupsInfo[1];
		vecGroupsInfo[Gi].Groupid = tmpGroupsInfo[2];		
		vecGroupsInfo[Gi].StepsQueue = getStepsInfo(Gi);
	}	
	curIndexGp = 0;
	showGroup(curIndexGp);
	onMouseMove(0);
	ShowStepList(0,0);
	//alert(vecGroupsInfo[0].StepsQueue[0].SubStepsQueue[0].SubStepName);
}
function CreateControl(DivID, CLSID, ObjectID,WIDTH, HEIGHT, parName1, parValue1, parName2, parValue2)//动态创建控件
{

  var d = document.getElementById(DivID);
  d.innerHTML =  '<object classid=' + CLSID + ' id=' + ObjectID + ' width=' + WIDTH + ' height=' + HEIGHT +'><param name='+ parName1 +'   value=' + parValue1 + '><param name='+ parName2 +'  value=' + parValue2 + '></object>';

}

