function ava_goshop(id){
	path="http://game.oncity.cc/ava";  //不用了.
	
	switch(id){
		case 1:
			window.location=path+"/avatar/";
			break;
		case 2:
			window.location=path+"/home/home.php?type=shop";
			break;

		case 3:
			window.location=path+"/photo.php";
			break;
		
		case 4:
			window.location=path+"/im_index.php";
			break;

		case 5:
			window.location=path+"/exchange/index.php";
			break;

		case 6:
			window.location=path+"/game/index.php";
			break;

		case 7:
			window.location=path+"/music/index.php";
			break;

		case 8:
			window.location=path+"/usercard/index.php";
			break;

		default:
			alert('error');
	
	}
}


function user_ava_flash_code(param) {

	var ava_list=new Array();
	var bg_flag='no';
	var border_flag='no';
	var output_flag='yes';
	var style_param='';
	var ava_id=random(1000000);
	var onclick_param='';
	var ava_name='';
	var head_flag='no';
	var menu_flag='yes';
	var icon_flag='no';
	var sex_flag='boy';
	var zoom=1;
	var i;
	
	w=0;h=0;
	w0=150;	h0=180;
	param1='';param2='';

	var p_array = param.split(";");
	
	for (i=0; i < p_array.length; i++) {
		var sl=p_array[i].split("=");
		if(sl.length==2) {
			switch(sl[0]) {
				case "head":
					if(sl[1]=='yes') {
						head_flag='yes';
						w0=60;
						h0=60;
					}
					break;
				case "code":
					code=sl[1];
					break;
				case 'sex':
					sex_flag=sl[1];
					break;
				case "icon":
					if(sl[1]=='yes') {
						icon_flag=sl[1];
						head_flag='yes';
					}
					break;
				case 'zoom':
					zoom=sl[1];
					break;
				case "name":
					ava_name=sl[1];
					break;
				case "bg":
					if(sl[1]=='yes') {
						bg_flag='yes';
					}
					break;
				case 'border':
					if(sl[1]=='yes') {
						color="solid Black";
					} else {
						color=sl[1];
					}
					border_flag='yes';
					style_param='border :1px '+color+';';
					break;
				case 'menu':
					if(sl[1]=='no') {
						menu_flag='no';
					}
					break;
				case 'w':
					w=sl[1];
					break;
				case 'h':
					h=sl[1];
				case 'write':
					if(sl[1]=='no') {
						output_flag='no';
					}
					break;
				case 'onclick':
					onclick_param=sl[1];
					break;
			}
		}
	}
	
	if(w && h) {
	} else {
		w=w0;
		h=h0;
	}

	if(icon_flag=='no') {
		s=CreateIMG(code,w,h);
	} else {
		s=CreateIcon(code);
	}

	if(output_flag=='yes') {
		document.write(s);
		obj=MM_findObj('ava_'+ava_id);
		obj.oncontextmenu =new Function('event.returnValue=false;');

		switch(onclick_param) {
			case 'no':
				obj.onclick =new Function('event.returnValue=false;');
				break;
			case '':
			    if(menu_flag=='yes') {
					obj.onclick=new Function("avatar_showmenu(event,'"+ava_name+"','"+code+"')");
					obj.onmouseout=new Function("delayavatar_hidemenu()");
				} else {
					obj.onclick =new Function("open_im('"+ava_name+"','')");
				}
				break;
			default:
				obj.onclick =new Function(onclick_param);
				break;
		}
		if(onclick_param!='no') obj.style.cursor ="hand";

	}

	return s;

	function CreateIcon(code) {

		var s='http://img3.oncity.cc/data/user/img1/'+(code%256)+"/"+(code%16)+"/"+ava_name+'_icon.gif';
		var ss='';
		if(zoom!=1) {
			ss="style='zoom: "+zoom+";filter:progid:DXImageTransform.Microsoft.Blur(PixelRadius=1, MakeShadow=false, ShadowOpacity=0.00);'";
		}
		s='<img src='+s+' border=0 id=ava_'+ava_id+' '+ss+' onError="this.src=\'http://img3.oncity.cc/images/'+sex_flag+'_icon.gif\';">';
		return s;

	}

	function CreateIMG(code,w,h){

		var i;

		w=parseInt(w);
		h=parseInt(h);
		w0=w;
		h0=h;

		if(border_flag=='yes') {
			w-=2;
			h-=2;
		}

		for(i=0;i<26;i++) ava_list[i]='';

		InitIMG(code);


		if(head_flag=='yes') {
			cy=(120-h)/2;
		} else {
			cy=(180-h)/2;
		}

		cx=(150-w)/2;
		ctop=cy;
		cright=cx+w;
		cbottom=cy+h;
		cleft=cx;
		ss='';

		s="<table cellspacing=0 cellpadding=0 width="+w0*zoom+" height="+h0*zoom+"><tbody><tr><td valign=top align=left><div id='ava_"+ava_id+"' style='position:absolute;width="+w0*zoom+";height="+h0*zoom+";"+style_param+"'>";

		if(zoom!=1) {
			ss="zoom: "+zoom+";filter:progid:DXImageTransform.Microsoft.Blur(PixelRadius=0.5, MakeShadow=false, ShadowOpacity=0.00);";
		}

		for(i=0;i<30;i++) {
			if(	ava_list[i]!='' && ava_list[i]!=null ) {
				s+="<img src="+ava_list[i]+" style='position:absolute;left:-"+cx*zoom+";top:-"+cy*zoom+";clip:rect("+ctop+" "+cright+" "+cbottom+" "+cleft+");"+ss+"'>";
			}
		}
		s+='</div></td></tr></tbody></table>';
		return s;
	}

	function TakeOnTog(IDArray,arrayLen,pID){
		//穿衣
		var nAct,nType,fileN,pID,i;
		for(i=0;i<arrayLen;i++)	{
			//循环显示每一幅图。
			nAct	=IDArray[i].charAt(0);
			nType	=IDArray[i].charAt(1);
			fileN	=IDArray[i].substr(2);
			
			//形成文件名
			fileN  	=FormatFileN(fileN,nAct,nType,'C');
			
			//根据不同的类型，执行不同的动作。
			switch(nAct){
				case 'C':			//表示当前类型的位置显示模板。
					//在当前位置显示模板。
					ShowStand(nType,true);
					break;
				case 'D':
					//关闭当前位置的模板。
					ShowStand(nType,false);
					break;
			}
			
			//在指定位置显示新的图形。
			SetIMG(nType,fileN,pID);
		}
	}
	//nType	:=要设置的部件对象的类型。
	//fileN	:=要设置的文件名。
	//pID	:=部件的动作+类型+ID。如果该值为空，表示返回类型所表示的对象。
	//设置单个部件的图像。
	function SetIMG(nType,fileN,pID){
		var t;
		switch(nType){
			case 'R': t=0; break;
			case 'S': t=1; break;
			case 'Z': t=2; break;
			case '+': t=3; break;
			case '-': t=4; break;
			case 'B': t=5; break;
			case 'N': t=6; break;
			case 'O': t=7; break;
			case 'Y': t=8; break;
			case 'P': t=9; break;
			case 'Q': t=10; break;
			case 'M': t=11; break;
			case 'D': t=12; break;
			case 'C': t=13; break;
			case 'T': t=14; break;
			case 'G': t=15; break;
			case 'H': t=16; break;
			case 'E': t=17; break;
			case 'F': t=18; break;
			case 'K': t=19; break;
			case 'L': t=20; break;
			case 'I': t=21; break;
			case 'J': t=22; break;
			case 'U': t=23; break;
			case 'V': t=24; break;
			case 'W': t=25; break;
			case 'X': t=26; break;
		}

		if(fileN!=-1) ava_list[t]=fileN;
	}
			
	//bIsShow:=true|false　。表示是否显示该模板。
	//显示或取消模板。
	function ShowStand(nType,bIsShow){
		var t;
		switch(nType){
			case 'B':	//脸型
			case 'M':	//鞋
			case 'N':	//眼睛
			case 'O':	//嘴
			case 'P':	//发型
				if(bIsShow){
					t=SetIMG(nType,FormatFileN(element.children[0].modelCode,null,nType,'M'),null);
				}
				return;
			case 'C':	//身体
				t=SetIMG('+',null,null);
				break;
			case 'D':	//腿
				t=SetIMG('-',null,null);
		}
		
	}
				
				
	function InitIMG(code){

		//可使用的字串
		var	strSrc ="BCDEFGHMNOPQS";

		var t,nPos,i;
		var nullFileN=FormatFileN(null);
		
		//初始化模板
		modelCode=code.substring(0,2);
		size=1;

		for(var i=0;i<size;i++){
			//初始化基本变量。
			t=SetIMG(strSrc.charAt(i),null,null);
			if (t!=undefined){
				t.prePID ="";
				t.src =nullFileN;
			}
		}

		//得到cookie的值。
		var myDress=code;
		

		if(myDress!=""){	
			//得到模板的结束位置。
			nPos=myDress.indexOf('.');

			if(nPos<0){
				//如果只有模板，没有其它任何的物品
				modelCode=myDress;
				myDress="";
			}else{
				//保存模板的值。
				modelCode=myDress.substring(0,nPos);
			}
		}
		
		if(modelCode=='') codelCode='F1';

		SetIMG(strSrc.charAt(0),FormatFileN(modelCode,null,strSrc.charAt(0),'M'),null);
		SetIMG('+',FormatFileN(modelCode,null,strSrc.charAt(1),'M'),null);
		SetIMG('-',FormatFileN(modelCode,null,strSrc.charAt(2),'M'),null);
		

		if(myDress!="")
		{		
			myDress =myDress.substr(nPos+1);
			var IDArray =myDress.split('.');
		}

		var up_n=1,up_o=1,up_p=1,up_m=1;
		if(!isNaN(IDArray)){
			for(i=0;i<IDArray.length;i++){
				nAct=IDArray[i].charAt(1);
				switch(nAct){
					case 'N':
						up_n=0;
						break;
					case 'O':
						up_o=0;
						break;
					case 'P':
						up_p=0;
						break;
					case 'M':
						up_m=0;
						break;
				}
			}
		}
		
		//显示眼睛的模板
		if(up_n==1){
			SetIMG('N',FormatFileN(modelCode,null,'N','M'),null);
		}
		
		//显示嘴的模板
		if(up_o==1){
			t =SetIMG('O',FormatFileN(modelCode,null,'O','M'),null);
		}

		//显示发型的模板
		if(up_p==1){
			t =SetIMG('P',FormatFileN(modelCode,null,'P','M'),null);
		}
		
		//显示鞋的模板
		if(up_m==1){
			t =SetIMG('M',FormatFileN(modelCode,null,'M','M'),null);
		}

		if(myDress=="") return;
		

		var nAct,subIDArray;
		
		for(i=0;i<IDArray.length;i++){
			nAct=IDArray[i].charAt(0);
			if(nAct=='A' || nAct=='B'){
				//如果是套装的ID。
				nPos =IDArray[i].indexOf('(');
				
				//得到子项的ID的数组。
				subIDArray =IDArray[i].substring(nPos+1,IDArray[i].length-1).split('_');
				
				//执行穿衣动作。
				TakeOnTog(subIDArray,subIDArray.length,IDArray[i]);
			}else{
				//如果不是套装，直接执行穿衣动作。
				subIDArray =IDArray[i].split('.');
				TakeOnTog(subIDArray,subIDArray.length,IDArray[i]);
			}
		}
	}
				
	function FormatFileN(fileN,nAct,nType,nFlag){
		//nFlag		-表示请求的类型，M表示模板，V表示浏览文件，C表示合成文件。

		var notReturn="";

		if(head_flag=='yes') {
			notReturn="IJKLDHMZ";
		}
		
		if(bg_flag=='no') {
			notReturn="JKLR";
			//IJKLRS
		}

		var loctions =notReturn.indexOf(nType);
		var IMGBasePath="http://img3.oncity.cc/face2/";

		if (loctions>=0){
			return -1;
		}

		if(fileN==null){
			//如果是空图。
			return -1;
		}

		//var	curPath=fileN%512;
		switch(nFlag){
			case 'M':
				//模板文件
				return IMGBasePath+"templates/"+nType+fileN+".gif";
			case 'V':
				//浏览文件
				return IMGBasePath+(fileN%256)+"/"+(fileN%16)+"/P"+fileN+".gif";
			case 'C':
				//合成文件
				return IMGBasePath+(fileN%256)+"/"+(fileN%16)+"/T"+fileN+".gif";
		}
	}
}



var ie5=document.all && !window.opera
var ns6=document.getElementById

if (ie5||ns6) document.write('<div id="popitmenu" onMouseover="avatar_clearavatar_hidemenu();" onMouseout="dynamichide(event)" X=0 Y=0></div>')

function iecompattest(){
return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement : document.body
}

function avatar_showmenu(e, u_name, code){
if (!document.all&&!document.getElementById)
return
var defaultMenuWidth="130px"

which='<a href=javascript:open_im(\''+u_name+'\');><img src=http://m.oncity.cc/ava/a_m1.gif align=absmiddle width=16 height=16 border=0>  '+u_name+'</a>'
which+='<img src=http://m.oncity.cc/ava/a_m00.gif width=126 height=7><br>' //Optional Separator
which+='<a href=javascript:open_im(\''+u_name+'\');><img src=http://m.oncity.cc/ava/a_m2.gif align=absmiddle width=16 height=16 border=0> 我的Hompy</a>'
which+='<a href=javascript:send(\'op=add&name='+u_name+'\');><img src=http://m.oncity.cc/ava/a_m4.gif align=absmiddle width=16 height=16 border=0> 发送留言</a>'
which+='<a href=javascript:flist(\'name='+u_name+'\');><img src=http://m.oncity.cc/ava/a_m5.gif align=absmiddle width=16 height=16 border=0> 加为好友</a>'
which+='<a href=javascript:show_avatar_box(\''+code+'\');><img src=http://m.oncity.cc/ava/a_m3.gif align=absmiddle width=16 height=16 border=0> 查看衣柜</a>'

avatar_clearavatar_hidemenu()
menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu")
menuobj.innerHTML=which
menuobj.style.width=defaultMenuWidth
menuobj.contentwidth=menuobj.offsetWidth
menuobj.contentheight=menuobj.offsetHeight
menuobj.style.visibility="visible"
menuobj.X=ie5? event.clientX : e.clientX
menuobj.Y=ie5? event.clientY : e.clientY
avatar_movemenu(e)

}

function avatar_movemenu(e) {

	menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu")
	eventX=ie5? event.clientX : e.clientX
	eventY=ie5? event.clientY : e.clientY
	if( menuobj.X>=eventX && menuobj.Y>=eventY) {
	
		//Find out how close the mouse is to the corner of the window
		var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX
		var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY
		//if the horizontal distance isn't enough to accomodate the width of the context menu
		if (rightedge<menuobj.contentwidth)
		//move the horizontal position of the menu to the left by it's width
		menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px"
		else
		//position the horizontal position of the menu where the mouse was clicked
		menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px"
		//same concept with the vertical position
		if (bottomedge<menuobj.contentheight)
		menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+"px" : window.pageYOffset+eventY-menuobj.contentheight+"px"
		else
		menuobj.style.top=ie5? iecompattest().scrollTop+event.clientY+"px" : window.pageYOffset+eventY+"px"
	}
	menuobj.X=eventX;
	menuobj.Y=eventY;

	return false
}

function contains_ns6(a, b) {
//Determines if 1 element in contained in another- by Brainjar.com
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function avatar_hidemenu(){
if (window.menuobj)
menuobj.style.visibility="hidden"
}

function dynamichide(e){
if (ie5&&!menuobj.contains(e.toElement))
avatar_hidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
avatar_hidemenu()
}

function delayavatar_hidemenu(){
delayhide=setTimeout("avatar_hidemenu()",1000)
}

function avatar_clearavatar_hidemenu(){
if (window.delayhide)
clearTimeout(delayhide)
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}