var Ajax=function(url,resultFunc,par){
			var obj={};
			obj.method = "GET";
			obj.parameters = par;
     var httpRequest;
      if (window.ActiveXObject)try{httpRequest = new ActiveXObject("Microsoft.XMLHTTP");}catch (e){try{httpRequest = new ActiveXObject("Msxml2.XMLHTTP");}catch (e){}}
      if (!httpRequest){alert('不能创建XMLHTTP实例');resultFunc();}
      httpRequest.onreadystatechange = function(){if (httpRequest.readyState == 4){resultFunc(httpRequest);}}
      if(url.indexOf('machineDate')==-1) url+=(url.indexOf('?')==-1?"?":"&")+("machineDate="+new Date().getTime());
      url+=(url.indexOf('?')==-1?"?":"&")+obj.parameters;
      if(obj.asynchronous==true) httpRequest.open(obj.method, url); else httpRequest.open(obj.method, url,false);
      httpRequest.send(null);
      return httpRequest;
  };

var g_sub1Id='';

function SubmitSearch()
{
	if(form1.searchStr.value=="")return false;
	form1.submit();
}

function Sub1Click(cid)
{
	if(g_sub1Id!=cid)
	{
		var eleOld =document.getElementById("div_sub1_body_"+g_sub1Id);
		if(eleOld!=null)eleOld.style.display = "none";

		var eleNew = document.getElementById("div_sub1_body_"+cid);
		if(eleNew!=null)eleNew.style.display = "block";
		g_sub1Id = cid;
	}
	else
	{
		var eleOld =document.getElementById("div_sub1_body_"+g_sub1Id);
		if(eleOld!=null)eleOld.style.display = "none";
		g_sub1Id = 0;
	}
	document.documentElement.scrollTop=0;
}


function Sub2Click(cid)
{
	var ele2 = document.getElementById("div_sub2_head_"+cid);
	var ele1 = document.getElementById("div_sub2_body_"+cid);
	if(ele1==null || ele2==null) return;
	var flag;
	if(ele1.style.display=="none")
	{
		ele1.style.display="block";
		ele2.style.background ="url(/images/arrowS.gif) 8px 11px no-repeat";
	}
	else
	{
		ele1.style.display="none";
		ele2.style.background ="url(/images/arrowA.gif) 8px 11px no-repeat";
	}

}


function ShopCar(id)
{
		var sUrl = "/index.php?cmd=shopcar&action=add&itemId="+id;
//		var frm = document.frmHide;
//		if(frm==null)return;
//		frm.location.href=sUrl;
		newWin = window.open(sUrl,"","scrollbars=yes,menubar=no,toolbar=no,resizable=no,alwaysRaised=yes,width=600,height=400,left=100,top=160");
//		alert("test="+id);
}


function OpenItem(sUrl)
{
	ducument.location.href=sUrl;
}


function ShowItemImage(imgEleId)
{
	var maxWidth=640;
  var flag=false;
  var ImgD=document.getElementById(imgEleId);
  var image=new Image();

  image.src=ImgD.src;
  if(image.width>maxWidth)
  {
       ImgD.width=maxWidth;
  }

  ImgD.style="display:block";
}



function Bottom_hid()
{
	var ele=document.getElementById("bo"+"tto"+"m_h"+"id");
	if(ele!=null)
	{
		ele.style.display="none";
	}
}



///////////////////////////////////////////////////////////
var ClassItem = function(classId,className,level,isSub,sub1,sub2,sUrl)
{
	this.classId = classId;
	this.className = className;
	this.level = level;
	this.isSub = isSub;
	this.sub1 = sub1;
	this.sub2 = sub2;
	this.sUrl = sUrl;
};


var ClassList = function(){
	this.classList = new Array();
	this.activeSub1="";
};

ClassList.prototype={
	Add:function(classId,className,level,isSub,sub1,sub2,sUrl)
	{
		this.classList.push(new ClassItem(classId,className,level,isSub,sub1,sub2,sUrl));
	},

	DrawAll:function()
	{
		var arr = {};
		if(g_sub1Id!=null)this.actSub1 = g_sub1Id;
		if(g_sub2Id!=null)this.actSub2 = g_sub2Id;
		if(g_classId!=null)this.actClassId = g_classId;

		var open=0;
		for(var i=0;i<this.classList.length;i++)
		{
			var str="";
			var row = this.classList[i];
			if(row.sub1==this.activeSub1 && this.activeSub1!="")continue;
			switch(row.level)
			{
				case "2":
					str+=this.GetSub2(row);
					break;
				case "3":
					str+=this.GetItem3(row);
					break;
				case "4":
					str+=this.GetSub2End(row);
			}

			if(arr[row.sub1]==null)arr[row.sub1]="";
			arr[row.sub1]+=str;
		}

		for(var key in arr)
		{
			var val = arr[key];
			var ele = document.getElementById("div_sub1_body_"+key);
			if(ele==null)continue;
			ele.innerHTML = val;
		}
	},


	GetSub1:function(row)
	{
		var str="";
		str+="<div class=category_sub1 onclick=Sub1Click('"+row.classId+"')>";
		str+=row.className;
		str+="</div>";

		if(row.classId==this.actSub1)
			str+="<div id=div_sub1_body_"+row.classId+" style='display:block;border:0px solid #ff0000'>";
		else
			str+="<div id=div_sub1_body_"+row.classId+" style='display:none;border:0px solid #ff0000'>";

		return str;
	},

	GetSub2:function(row)
	{
		var cn="";
		cn+=(row.classId==this.actSub2)?"a":"c";
		cn+=(row.isSub==1)?"1":"2";

		var str="";
		str+="<div id='div_sub2_head_"+row.classId+"' class='c_sub2 c_sub2_"+cn+" subline' onclick=Sub2Click('"+row.classId+"')>";
		if(row.classId==this.actSub2)
		{
			str+=row.className;
		}
		else
		{
			str+="<a href='"+row.sUrl+"'>"+row.className+"</a>";
		}
		str+="</div>";

		if(row.isSub=="1")
		{
			if(row.classId==this.actSub2)
				str+="<div id=div_sub2_body_"+row.classId+">";
			else
				str+="<div id=div_sub2_body_"+row.classId+" style='display:none;'>";
		}
		return str;
	},




	GetItem3:function(row)
	{
		var str="";
		if(row.classId==this.actClassId)
		{
			str+="<div class='c_sub3 c_sub3_act subline'>";
			str+=row.className;
		}
		else
		{
			str+="<div class='c_sub3 subline'>";
			str+="<a href='"+row.sUrl+"'>"+row.className+"</a>";
		}
		str+="</div>";

		return str;
	},

	GetSub2End:function(row)
	{
		return "</div>";
	}
}

////////////////////////////////////////
var g_obj=null;
function OnDrawCategories()
{
	if(g_obj==null)return;
	g_obj.DrawAll();
}


function RunEnding()
{
	HiedEle("godblessme");
	HiedEle("category_infomations");
}

function HiedEle(eleId)
{
	var ele = document.getElementById(eleId);
	if(ele!=null) ele.style.display = "none";
}

