/**
 * 案例效果首页
 */
var Sound=new Array();
Sound[1]="/Resources/swf/sound4";
Sound[2]="/Resources/swf/sound6";
Sound[3]="/Resources/swf/sound11";
Sound[4]="/Resources/swf/sound14";
function SystemCasesIndex()
{
	var _SystemCasesIndex=this;//this 的上下文
	this.RenderObjs=new SystemClassIndexRender();//遮罩层
	this.RenderObjs.Parent=this;
	this.AjaxServer=new CasesServer();
	var _SystemCasesIndexRender=this.RenderObjs;//遮罩层上下文
	/**
	 * prototype
	 */
	this.Types=new Array();
	this.MenuDiv=new Array();
	this.AreaDiv=new Array();
	/**
	 * 初始化
	 */
	this.Init=function()
	{
		_SystemCasesIndex.InitTypes();
		_SystemCasesIndex.InitData();
		_SystemCasesIndex.InitAllEventObjs();
		_SystemCasesIndex.InitMeunEvent();
		
	}
	this.InitData=function()
	{
		_SystemCasesIndex.AjaxServer.GetMenu(null,_SystemCasesIndex.OnInitDataCallBack);
	}	
	this.OnInitDataCallBack=function(Data)
	{
		_SystemCasesIndexRender.Data=Data;
	}
	/**
	 * 初始化类别
	 */
	this.InitTypes=function()
	{
		_SystemCasesIndex.Types[0]="HouseOrnamental";
		_SystemCasesIndex.Types[1]="OfficeOrnamental";
		_SystemCasesIndex.Types[2]="HotelOrnamental";
		
		return true;
	}
	/**
	 * 初始化按钮事件
	 */
	this.InitMeunEvent=function()
	{
		for (i=0; i<_SystemCasesIndex.MenuDiv.length; i++)
		{
			//路过事件
			_SystemCasesIndex.SetMenuMouseOver(_SystemCasesIndex.MenuDiv[i], _SystemCasesIndex.Types[i] + '_Menu_Div',_SystemCasesIndex.AreaDiv[i],_SystemCasesIndex.Types[i]+'_Div');
			_SystemCasesIndexRender.SetDefDivCreates(_SystemCasesIndex.Types[i]+'_Div');
		}
	}
	/**
	 * 鼠标路过执行动作
	 * @param {Object} EventObj
	 * @param {Object} ObjId
	 */
	this.OnMenuMouseOver=function(EventObj,ObjId,AreaObj,AreaId)
	{
		if (_SystemCasesIndexRender.RenderDivs[AreaId]==false)
		{
			_SystemCasesIndexRender.Go(EventObj,ObjId,AreaObj,AreaId);
		}
	}
	/**
	 * 鼠标移开执行动作
	 * @param {Object} EventObj
	 * @param {Object} ObjId
	 */
	this.OnMenuMouseOut=function(EventObj,ObjId,AreaObj,AreaId)
	{
		_SystemCasesIndexRender.Cancel(EventObj,ObjId,AreaObj,AreaId);
		_SystemCasesIndexRender.RenderDivs[AreaId]=false;
	    _SystemCasesIndex.SetMenuMouseOver(EventObj,ObjId,AreaObj,AreaId);
	}
	/**
	 * 初始化所有的区域，以及菜单的 obj
	 */
	this.InitAllEventObjs=function()
	{
		for (var i=0; i< _SystemCasesIndex.Types.length ;i++)
		{
			_SystemCasesIndex.MenuDiv[i]=$("#"+ _SystemCasesIndex.Types[i]+'_Menu_Div')[0];
			_SystemCasesIndex.AreaDiv[i]=$("#"+ _SystemCasesIndex.Types[i]+'_Div')[0];
		}
	}
	/**
	 * 设置鼠标路过事件
	 * @param {Object} EventObj
	 * @param {Object} ObjId
	 */
	this.SetMenuMouseOver=function(EventObj,ObjId,AreaObj,AreaId)
	{
		_SystemCasesIndexRender.RenderDivs[AreaId]=false;
			EventObj.onmouseover = function()
			{
				
				_SystemCasesIndex.OnMenuMouseOver(EventObj, ObjId, AreaObj, AreaId);
			}
	}
	/**
	 * 调试
	 * @param {Object} Msg
	 */
	this.Debug=function(Msg)
	{
		return;
		var DebugMsg=$("#DebugDiv")[0];
		if (DebugMsg)
		{
			DebugMsg.value=DebugMsg.value+Msg+"\r\n";
		}
	}
}
window.onload=function()
{
	var SysCases=new SystemCasesIndex();
	SysCases.Init();
	var RNum=Math.floor(Math.random()*4+1); //1-10
	Site.playSound(Sound[RNum]);
}
