
function initpage()
	{
	try
		{
		placeobjects();
		if(nav4)
			{
			lastpagewidth = window.innerWidth;
			lastpageheight = window.innerHeight;
			}
		window.onresize = sizechange;
		}
	catch(e)
		{
		alert("initpage error : " + (e.number & 0xFFFF).toString(16) + " " + e.description);
		}
	return true;
	}

function placeobjects()
	{
	try
		{
		var i,j,k;
		var ob,s,h,w,aw,ah;
		var zflag,flag,complete;
		var pchain,pnodes;
		var cchain,cnodes;

		for (j=0;j<ACounter;j++)
			{
			l_tx[j]=-1000;
			l_ty[j]=-1000;
			l_th[j]=-1000;
			l_tw[j]=-1000;
			if (l_AVertAnchorObj[j] != 0)
				{
				zflag = 0;
				for (k=0;k<ACounter;k++)
					{
					if (l_AVAO[j] == l_AGID[k])
						{
						zflag = 1;
						}
					}
				if (zflag == 0) 
					{
					l_AVertAnchorObj[j] = 0;
					l_AVAO[j] = 0;
					l_AVAlignment[j] = "T";
					}
				}
			if (l_AHorizAnchorObj[j] != 0)
				{
				zflag = 0;
				for (k=0;k<ACounter;k++)
					{
					if (l_AHAO[j] == l_AGID[k])
						{
						zflag = 1;
						}
					}
				if (zflag == 0) 
					{
					l_AHorizAnchorObj[j] = 0;
					l_AHAO[j] = 0;
					l_AHAlignment[j] = "L";
					}
				}
			}

		for (j=0;j<ACounter;j++)
			{
			if (l_AInstanceType[j] != "Container")
				{
				if (ie4up) // for supported IE browsers
					{
					ob=findobject("ID"+l_AGID[j]);
					ah=ob.clientHeight;
					aw=ob.clientWidth;
					if (l_beh[l_AGID[j]+''])
						{
						ah=l_beh[l_AGID[j]+''];
						aw=l_bew[l_AGID[j]+''];
						}
					if (ah<l_AMinHeight[j])
						{
						l_th[j]=l_AMinHeight[j];
						l_tw[j]=aw;
						}
					else
						{
						l_th[j]=ah;
						l_tw[j]=aw;
						}
					}
				if (nav4) // for netscape 4 series
					{
					ob=findobject("ID"+l_AGID[j]);
					ah=ob.clip.height;
					aw=ob.clip.width;
					if (l_beh[l_AGID[j]+''])
						{
						ah=l_beh[l_AGID[j]+''];
						aw=l_bew[l_AGID[j]+''];
						}
					if (ah<l_AMinHeight[j])
						{
						l_th[j]=l_AMinHeight[j];
						l_tw[j]=aw;
						}
					else
						{
						l_th[j]=ah;
						l_tw[j]=aw;
						}
					}
				if (nav6) // for netscape 6 series
					{
		 			ob=document.getElementById("ID"+l_AGID[j]);
					s=getComputedStyle(ob,"");
					h=parseInt(s.getPropertyValue("height"));
					w=parseInt(s.getPropertyValue("width"));
					if (h<l_AMinHeight[j])
						{
						l_th[j]=l_AMinHeight[j];
							l_tw[j]=w;
						}
					else
						{
						l_th[j]=h;
						l_tw[j]=w;
						}
					}
				}
			}	
	
		//debug("all objects one");

		flag=0;
		while (flag==0)
			{
			flag=1;
			for (j=0;j<ACounter;j++)
				{
				if ((l_AInstanceType[j] == "Container") && (l_th[j] == -1000) && (l_tw[j] == -1000))
					{
					complete = 1;
					pchain = l_AGID[j].split("-");
					pnodes = pchain.length+1;
					for (i=0;i<ACounter;i++)
						{
						//if ((l_AParentType[i] == "Container") && (l_AParentName[i] == l_AInstanceName[j]))
						//	{
						//	if ((l_th[i] == -1000) && (l_tw[i] == -1000))
						//		{
						//		complete=0;
						//		}
						//	}
						cchain = l_AGID[i].split("-");
						cnodes = cchain.length+1;					
						if (cnodes == (pnodes+1))
							{
							if (l_AGID[i].substring(0,l_AGID[j].length) == l_AGID[j])
								{
								if ((l_th[i] == -1000) && (l_tw[i] == -1000))
									{
									complete=0;
									}
								}
							}
						}
					if (complete == 1)
						{
						calc_cont_hw(j);
						}
			   		else
						{
						flag=0;
						}
			 		}
				}
			}

		//debug("all objects two");

		for (j=0;j<ACounter;j++)
			{
			if ((l_tx[j] == -1000) && (l_ty[j] == -1000))
				{
			 	calc_instance_position(j);
				}
			if (ie4up) // for supported IE browsers
				{
				findobject("ID"+l_AGID[j]).style.pixelLeft = l_tx[j];
				findobject("ID"+l_AGID[j]).style.pixelTop = l_ty[j];
				findobject("ID"+l_AGID[j]).style.zIndex = l_AZOrder[j];
				if (l_AVis[j]=="H") 
					{ findobject("ID"+l_AGID[j]).style.visibility='hidden' }
				else
					{
					if (l_AVis[j]=="I") 
						{ findobject("ID"+l_AGID[j]).style.visibility='inherit' }
					else
						{ findobject("ID"+l_AGID[j]).style.visibility='visible' }
					}
				}
			if (nav4) // for netscape 4 series
				{
				findobject("ID"+l_AGID[j]).left = l_tx[j];
				findobject("ID"+l_AGID[j]).top = l_ty[j];
				findobject("ID"+l_AGID[j]).zIndex = l_AZOrder[j];
				if (l_AVis[j]=="H") 
					{ findobject("ID"+l_AGID[j]).visibility='HIDE'; }
				else
					{
					if (l_AVis[j]=="I") 
						{ findobject("ID"+l_AGID[j]).visibility='INHERIT' }
					else
						{ findobject("ID"+l_AGID[j]).visibility='SHOW' }
					}
				}
			if (nav6) // for netscape 6 series
				{
				document.getElementById("ID"+l_AGID[j]).style.left = l_tx[j];
				document.getElementById("ID"+l_AGID[j]).style.top = l_ty[j];
				document.getElementById("ID"+l_AGID[j]).style.zIndex = l_AZOrder[j];
				if (l_AVis[j]=="H") 
					{ document.getElementById("ID"+l_AGID[j]).style.visibility='hidden' }
				else
					{
					if (l_AVis[j]=="I") 
						{ document.getElementById("ID"+l_AGID[j]).style.visibility='inherit' }
					else
						{ document.getElementById("ID"+l_AGID[j]).style.visibility='visible' }
					}
				}
			}
	
		//debug("all objects three");

		}
	catch(e)
		{
		alert("placeobjects error : " + (e.number & 0xFFFF).toString(16) + " " + e.description);
		}
	}

function calc_cont_hw(idx)
	{
	try
		{
		var j;
		var totw,toth,tempw,temph;
		var pchain, pnodes;
		var cchain, cnodes;

		totw=0;
		toth=0;

		pchain = l_AGID[idx].split("-");
		pnodes = pchain.length+1;

		for (j=0;j<ACounter;j++)
			{
			//if ((l_AParentType[j] == "Container") && (l_AParentName[j] == l_AInstanceName[idx]))
			cchain = l_AGID[j].split("-");
			cnodes = cchain.length+1;					
			if (cnodes == (pnodes+1))
				{
				if (l_AGID[j].substring(0,l_AGID[idx].length) == l_AGID[idx])
					{
		  			tempw=0;
		  			temph=0;
		  			calc_instance_position(j);
		  			tempw = l_tx[j] + l_tw[j];
		  			temph = l_ty[j] + l_th[j];
		  			if (tempw > totw) { totw=tempw; }
		  			if (temph > toth) { toth=temph; }
					}
				}
			}

		l_th[idx]=toth;
		l_tw[idx]=totw;

		}
	catch(e)
		{
		alert("calc_cont_hw error : " + (e.number & 0xFFFF).toString(16) + " " + e.description);
		}

	}

function calc_instance_position(idx)
	{
	try
		{
		var j;
		var tempx,tempy;
		var h_obj_idx,v_obj_idx,bw,bh;
		var h_obj_key,v_obj_key;

		h_obj_idx=idx;
		v_obj_idx=idx;
		h_obj_GID=l_AGID[h_obj_idx];
		v_obj_GID=l_AGID[v_obj_idx];
		tempx=0;
		tempy=0;

		if (ie4up) // for supported IE browsers
			{
			bw=document.body.clientWidth;
			bh=document.body.clientHeight;
			}
		if (nav4) // for netscape 4 series
			{
			bw=window.innerWidth;
			bh=window.innerHeight;
			}
		if (nav6) // for netscape 6 series
			{
			bw=innerWidth;
			bh=innerHeight;
			}

		//debug("calc_instance_position one");

		while (h_obj_GID != "0")
			{
			if ((l_AHorizAnchorObj[h_obj_idx] == 0) && (l_AParentType[h_obj_idx] == "Page"))
				{
				if (l_AHAlignment[h_obj_idx] == "L") { tempx += l_AHAbsOffset[h_obj_idx]; }
				if (l_AHAlignment[h_obj_idx] == "C") { tempx += l_AHAbsOffset[h_obj_idx] + (bw/2); }
				if (l_AHAlignment[h_obj_idx] == "R") { tempx += l_AHAbsOffset[h_obj_idx] + bw; }
				}
			if ((l_AHorizAnchorObj[h_obj_idx] == 0) && (l_AParentType[h_obj_idx] == "Container"))
				{
				if (l_AHAlignment[h_obj_idx] == "L") { tempx += l_AHAbsOffset[h_obj_idx]; }
				if (l_AHAlignment[h_obj_idx] == "C") { tempx = 0; }
				if (l_AHAlignment[h_obj_idx] == "R") { tempx = 0; }
				}
			if (l_AHorizAnchorObj[h_obj_idx] != 0)
				{
				if (l_AHAlignment[h_obj_idx] == "L") { tempx += l_AHAbsOffset[h_obj_idx]; }
				if (l_AHAlignment[h_obj_idx] == "C") { tempx += l_AHAbsOffset[h_obj_idx] + (l_tw[GetIndexbyGID(l_AHAO[h_obj_idx])]/2); }
				if (l_AHAlignment[h_obj_idx] == "R") { tempx += l_AHAbsOffset[h_obj_idx] + l_tw[GetIndexbyGID(l_AHAO[h_obj_idx])]; }
				}
	 		h_obj_GID = l_AHAO[h_obj_idx];
			h_obj_idx = GetIndexbyGID(h_obj_GID);
			}

		//debug("calc_instance_position two");

		while (v_obj_GID != "0")
			{
			if ((l_AVertAnchorObj[v_obj_idx] == 0) && (l_AParentType[v_obj_idx] == "Page"))
				{
				if (l_AVAlignment[v_obj_idx] == "T") { tempy += l_AVAbsOffset[v_obj_idx]; }
				if (l_AVAlignment[v_obj_idx] == "C") { tempy += l_AVAbsOffset[v_obj_idx] + (bh/2); }
				if (l_AVAlignment[v_obj_idx] == "B") { tempy += l_AVAbsOffset[v_obj_idx] + bh; }
				}
			if ((l_AVertAnchorObj[v_obj_idx] == 0) && (l_AParentType[v_obj_idx] == "Container"))
				{
				if (l_AVAlignment[v_obj_idx] == "T") { tempy += l_AVAbsOffset[v_obj_idx]; }
				if (l_AVAlignment[v_obj_idx] == "C") { tempy = 0; }
				if (l_AVAlignment[v_obj_idx] == "B") { tempy = 0; }
				}
			if (l_AVertAnchorObj[v_obj_idx] != 0)
				{
				if (l_AVAlignment[v_obj_idx] == "T") { tempy += l_AVAbsOffset[v_obj_idx]; }
				if (l_AVAlignment[v_obj_idx] == "C") { tempy += l_AVAbsOffset[v_obj_idx] + (l_th[GetIndexbyGID(l_AVAO[v_obj_idx])]/2); }
				if (l_AVAlignment[v_obj_idx] == "B") { tempy += l_AVAbsOffset[v_obj_idx] + l_th[GetIndexbyGID(l_AVAO[v_obj_idx])]; }
				}
	 		v_obj_GID = l_AVAO[v_obj_idx];
	  		v_obj_idx = GetIndexbyGID(v_obj_GID);
			}

		l_tx[idx]=tempx;
		l_ty[idx]=tempy;

		}
	catch(e)
		{
		alert("calc_instance_position error : " + (e.number & 0xFFFF).toString(16) + " " + e.description);
		}
	}

function findobject(n, d) 
	{
	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=findobject(n,d.layers[i].document);
	if (!x && d.getElementById) x=d.getElementById(n); 
	if (!x) alert("WARNING! findobject() unable to locate '" + n + "'");
	return x;
	}

function sizechange()
	{
	if (nav4)
		{
		if ((lastpagewidth != window.innerWidth) || (lastpageheight != window.innerHeight)) 
			{
			window.history.go(0);
			}
		}
	window.onresize	= sizechange;
	//updatescreenobjects();
	placeobjects();
	return true;
	}

function GetContentsKeyByInstanceName(Iname,Itype)
	{
	var i;
	var r_GetContentsKeyByInstanceName;
	r_GetContentsKeyByInstanceName = 0;
	for (i=0;i<ACounter;i++)
		{
		if ((l_AInstanceName[i] == Iname) && (l_AInstanceType[i] == Itype))
			{
			r_GetContentsKeyByInstanceName = l_AContentsKey[i]
			}
		}
	return r_GetContentsKeyByInstanceName;
	}

function GetInstanceNameByContentsKey(CKey,Itype)
	{
	var i;
	var r_GetInstanceNameByContentsKey; 
	r_GetInstanceNameByContentsKey = "";
	for (i=0;i<ACounter;i++)
		{
		if ((l_AContentsKey[i] == CKey) && (l_AInstanceType[i] == Itype))
			{
			r_GetInstanceNameByContentsKey = l_AInstanceName[i]
			}
		}
	return r_GetInstanceNameByContentsKey; 
	}

function SetVisibilityByContentsKey(cKey,Vis)
	{
	var i;
	for (i=0;i<ACounter;i++)
		{
		if (l_AContentsKey[i] == cKey)
			{
			if (ie4up) // for supported IE browsers
				{
				if (Vis=="H") 
					{ findobject("ID"+l_AGID[i]).style.visibility='hidden' }
				else
					{
					if (Vis=="I") 
						{ findobject("ID"+l_AGID[i]).style.visibility='inherit' }
					else
						{ findobject("ID"+l_AGID[i]).style.visibility='visible' }
					}
				}
			if (nav4) // for netscape 4 series
				{
				if (Vis=="H") 
					{ findobject("ID"+l_AGID[i]).visibility='HIDE'; }
				else
					{
					if (Vis=="I") 
						{ findobject("ID"+l_AGID[i]).visibility='INHERIT' }
					else
						{ findobject("ID"+l_AGID[i]).visibility='SHOW' }
					}
				}
			if (nav6) // for netscape 6 series
				{
				if (Vis=="H") 
					{ document.getElementById("ID"+l_AGID[i]).style.visibility='hidden' }
				else
					{
					if (Vis=="I") 
						{ document.getElementById("ID"+l_AGID[i]).style.visibility='inherit' }
					else
						{ document.getElementById("ID"+l_AGID[i]).style.visibility='visible' }
					}
				}

			}
		}
	return true; 
	}

function GetIndexbyContentsKey(cKey)
	{
	var i;
	var r_GetIndexbyContentsKey;
	r_GetIndexbyContentsKey = 0;
	for (i=0;i<ACounter;i++)
		{
		if (l_AContentsKey[i] == cKey)
			{
			r_GetIndexbyContentsKey = i;
			}
		}
	return r_GetIndexbyContentsKey; 
	}

function GetIndexbyGID(gid)
	{
	var i;
	var r_GetIndexbyGID;
	r_GetIndexbyGID = 0;
	for (i=0;i<ACounter;i++)
		{
		if (l_AGID[i] == gid)
			{
			r_GetIndexbyGID = i;
			}
		}
	return r_GetIndexbyGID; 
	}

function debug(mess)
	{
	var i;
	var o;
	o=mess + "\n";
	for (i=0;i<ACounter;i++)
		{
		o+="Name[" + i + "]=" + l_AInstanceName[i] + " ";
		o+="Type[" + i + "]=" + l_AInstanceType[i] + " ";
		o+="GID[" + i + "]=" + l_AGID[i] + " ";
		o+="hao[" + i + "]=" + l_AHorizAnchorObj[i] + " ";
		o+="AHAO[" + i + "]=" + l_AHAO[i] + " ";
		o+="vao[" + i + "]=" + l_AVertAnchorObj[i] + " ";
		o+="AVAO[" + i + "]=" + l_AVAO[i] + " ";
		o+="tx[" + i + "]=" + l_tx[i] + " ";
		o+="ty[" + i + "]=" + l_ty[i] + " ";
		o+="th[" + i + "]=" + l_th[i] + " ";
		o+="tw[" + i + "]=" + l_tw[i] + " ";
		o+="\n";
		}
	alert (o);
	return true;
	}

function resizedragmasks()
	{
	var i;
	for (i=0;i<ACounter;i++)
		{
		if (ie4up) // for supported IE browsers
			{
			findobject("ID"+l_AGID[i]).style.pixelHeight = l_th[i];
			findobject("ID"+l_AGID[i]).style.pixelWidth = l_tw[i];
			findobject("DIM"+l_AGID[i]).height = l_th[i];
			findobject("DIM"+l_AGID[i]).width = l_tw[i];
			}
		if (nav4) // for netscape 4 series
			{
			findobject("ID"+l_AGID[i]).pixelHeight = l_th[i];
			findobject("ID"+l_AGID[i]).pixelWidth = l_tw[i];
			findobject("DIM"+l_AGID[i]).height = l_th[i];
			findobject("DIM"+l_AGID[i]).width = l_tw[i];
			}
		}
	}