function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

var gSvgFigWinheight;

var gSvgFigWinwidth;

var gSvgFigObj;

var gViewWidth = 0, gViewHeight = 0;

var gSvgMin = 200;

var gSvgFigSizeIndex = new Array(0.5 , 0.75 , 1 , 1.25 , 1.5 , 1.75 , 2);

var gSvgFigSizeIndexNomal = 2;

var gSvgFigSizeIndexNow;

var gSvgChangColorTag = new Array();

var gSvgChangLcolorTag = new Array();

var gGBTtagColor = new Array();

var gGBTtagLColor = new Array();

var gGBTtagColorType = new Array();

var gChangCcolor = "#0FE70F";

var Blink;

var Blink_Count = 0;

var gObjKind = "";

var gList = ""

var gScrollFlag = 0;

var gSMDOfsetX;
var gSMDOfsetY;
var gSMDScLeft;
var gSMDScTop;
var gSMDMoving = false;

var gDisp_all = "clear";

var gDispInif = 0;

var gMax_x = 0;
var gMax_y = 0;
var gMin_x = 0;
var gMin_y = 0;

var gConsel = 0;

var gOffset_Top = 0;
var gOffset_Left = 0;

var gScrolldelaycnt = 0;
var gNulldelaycnt = 0;

var SVG_mode = "";//***SVG_CS2mode add 20070122***

var gPower_Supply = "y";//***for power supply fig 20070122***

function Figld()
{
	parent.gFigSvgLoadFlag = 1;
	parent.gFigSvgLoadFlag2 = 1;
	parent.gFigSvgLoadFlag3 = 1;
}


function SVG_FiginiSet()
{
	parent.gFigSvgLoadFlag = 1;
	parent.gFigSvgLoadFlag2 = 1;
	parent.gFigSvgLoadFlag3 = 1;
}


//*** 2 outline support 20070116***
function Figld2()
{
	parent.gFigSvgLoadFlag = 1;
	parent.gFigSvgLoadFlag4 = 1;
}
//*** 2 outline support 20070116***

function SVGSerch(para,Conlist,Lineid,Link,LiskClick)
{
	gScrollFlag = 0;

	if(LiskClick)
	{
		gList = "LiskClick";
		gObjKind = "";
	}

	if(para)
	{
		SVG_BoxResetColor();
	}

	var Cid = new Array();
	if(para == 'line')
	{
		SvgSerchLine(Lineid);
		Cid = Conlist;
	}
	else if(para == 'con')
	{
		if(Link == "list")
		{
			Cid[0] = Conlist;
		}
		else
		{
			Cid[0] = Conlist[0];
		}
	}
	else
	{
		;
	}

	//while(window.parent.work.FigSvg == null)//must
	//{
	//	;
	//}
	TM1 = setTimeout("Nulldelay()",10);

	SvgSerchCon(Cid);

	if(Link == "list" && gScrollFlag == 0)
	{
		SVG_Scroll();
	}

	Blink_Count = 0;
	SVGBlink();

	gConsel = 1;

}


function SVG_Scroll()
{
	var Taglen = gSvgChangColorTag.length;
	var Tag;
	var Tag_X = new Number();
	var Tag_Y = new Number();
	var x = new Array();
	var y = new Array();

	var XPoint = new Array();
	var YPoint = new Array();

	//var Max_x = "";
	//var Min_x = "";
	//var Max_y = "";
	//var Min_y = "";

	var Max_x = 0;
	var Min_x = 9999;
	var Max_y = 0;
	var Min_y = 9999;

	var TagD;
	var TagP;

	var Tagx2 = 0;
	var Tagy2 = 0;
	var Tagw2 = 0;
	var Tagh2 = 0;

	var Tagx3 = 0;
	var Tagy3 = 0;

	var Tag_rect = "";

	var TagP_xy = "";
	var length0 = 0;
	var length1 = 0;
	var p0 = 0;
	var p1 = 0;

	gPower_Supply = "y";//***for power supply fig 20070122***

	for(var i = 0 ; i < Taglen ; i++)
	{
		gPower_Supply = "n";//***for power supply fig 20070122***

		Tag = gSvgChangColorTag[i];
		//TagD = Tag.getAttributeNode('d').value;

		Tag_rect = Tag.nodeName

		if(Tag_rect == "rect")//***SVG_CS2mode add 20070122***
		{
			Tagx2 = new Number(Tag.getAttributeNode('x').value);
			Tagy2 = new Number(Tag.getAttributeNode('y').value);
			Tagw2 = new Number(Tag.getAttributeNode('width').value);
			Tagh2 = new Number(Tag.getAttributeNode('height').value);

			if(Tagx2 < Min_x)
			{
				Min_x = Tagx2;
			}
			if(Tagy2 < Min_y)
			{
				Min_y = Tagy2;
			}
			if((Tagx2 + Tagw2) > Max_x)
			{
				Max_x = Tagx2 + Tagw2;
			}
			if((Tagy2 + Tagh2) > Max_y)
			{
				Max_y = Tagy2 + Tagh2;
			}
		}
		else if(Tag_rect == "polygon")//***SVG_CS2mode add 20070122***
		{
			TagP = Tag.getAttributeNode('points').value;
			length0 = TagP.length - 1;

			for(var j = 0; j < length0; j++)
			{
				p0 = TagP.indexOf(" ",j);
				TagP_xy = TagP.slice(j, p0);
				j = p0;

				if (TagP_xy != "")
				{
					length1 = TagP_xy.length;
					p1 = TagP_xy.indexOf(",",0);

					Tagx3 = new Number(TagP_xy.slice(0, p1));
					Tagy3 = new Number(TagP_xy.slice(p1 + 1, length1));

					if(Tagx3 < Min_x)
					{
						Min_x = Tagx3;
					}
					if(Tagy3 < Min_y)
					{
						Min_y = Tagy3;
					}
					if(Tagx3 > Max_x)
					{
						Max_x = Tagx3;
					}
					if(Tagy3  > Max_y)
					{
						Max_y = Tagy3;
					}
				}
			}
		}
		else if(Tag_rect == "path")
		{
			TagD = Tag.getAttributeNode('d').value;

			var Maha = /([A-Za-z][^A-Za-z]*)([A-Za-z][^A-Za-z]*)([A-Za-z][^A-Za-z]*)([A-Za-z][^A-Za-z]*)([A-Za-z][^A-Za-z]*)/;
			var Arr = new Array();
			Arr = Maha.exec(TagD);
			if(Arr)
			{
				var ComStr = /([A-Za-z])([^A-Za-z]*)/;
				var arr = new Array();

				var length = Arr.length - 1;

				for(var j = 1; j < length; j++)
				{
					arr = ComStr.exec(Arr[j]);
					var p1 = arr[2].indexOf(".",0);
					var p2 = arr[2].indexOf(",",0);

					//match case .,.
					var match_mode = 0;

					if((p1 == -1) && (p2 == -1))
					{//none
						match_mode = 1;
					}
					else if((p1 != -1) && (p2 == -1))
					{//,none->.only
						var p4 = arr[2].indexOf(".",p1 + 1);
						if(p4 == -1)
						{//.
							match_mode = 2;
						}
						else
						{//..
							match_mode = 3;
						}
					}
					else
					{//,exsist
						if(p1 > p2)
						{//,.
							match_mode = 6;
						}
						else
						{
							var p3 = arr[2].indexOf(".",p2 + 1);
							if(p3 != -1)
							{//.,.
								match_mode = 4;
							}
							else
							{//.,
								match_mode = 5;
							}
						}
					}

					switch(arr[1])
					{
						case "M":
							//NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*\,[^A-Za-z]*\.[^A-Za-z]*/));
							switch(match_mode)
							{
								case 1://
										NumStr = arr[2];
					   					break;
								case 2://.
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								case 3://..
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								case 4://.,.
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*\,[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								case 5://.,
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*\,[^A-Za-z]*/));
					   					break;
								case 6://,.
										NumStr = new String(arr[2].match(/[^A-Za-z]*\,[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								default:
					   				break;
							}

							var NumStr_Array = NumStr.split(",");
							XPoint[j] = new Number(NumStr_Array[0]);
							YPoint[j] = new Number(NumStr_Array[1]);
							break;
						case "H":
							//NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*/));
							switch(match_mode)
							{
								case 1://
										NumStr = arr[2];
					   					break;
								case 2://.
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								case 3://..
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								case 4://.,.
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*\,[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								case 5://.,
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*\,[^A-Za-z]*/));
					   					break;
								case 6://,.
										NumStr = new String(arr[2].match(/[^A-Za-z]*\,[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								default:
					   				break;
							}

							NumStr = new Number(NumStr);
							XPoint[j] = NumStr;
							YPoint[j] = YPoint[1];
					   		break;
				 		case "h":
							//NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*/));
							switch(match_mode)
							{
								case 1://
										NumStr = arr[2];
					   					break;
								case 2://.
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								case 3://..
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								case 4://.,.
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*\,[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								case 5://.,
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*\,[^A-Za-z]*/));
					   					break;
								case 6://,.
										NumStr = new String(arr[2].match(/[^A-Za-z]*\,[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								default:
					   				break;
							}

							NumStr = new Number(NumStr);
							XPoint[j] = XPoint[j-1] + NumStr;
							YPoint[j] = YPoint[j-1];
					   		break;
						case "V":
							//NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*/));
							switch(match_mode)
							{
								case 1://
										NumStr = arr[2];
					   					break;
								case 2://.
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								case 3://..
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								case 4://.,.
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*\,[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								case 5://.,
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*\,[^A-Za-z]*/));
					   					break;
								case 6://,.
										NumStr = new String(arr[2].match(/[^A-Za-z]*\,[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								default:
					   				break;
							}

							NumStr = new Number(NumStr);
							YPoint[j] = NumStr;
							XPoint[j] = XPoint[j-1];
					   		break;
				 		case "v":
							//NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*/));
							switch(match_mode)
							{
								case 1://
										NumStr = arr[2];
					   					break;
								case 2://.
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								case 3://..
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								case 4://.,.
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*\,[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								case 5://.,
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*\,[^A-Za-z]*/));
					   					break;
								case 6://,.
										NumStr = new String(arr[2].match(/[^A-Za-z]*\,[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								default:
					   			break;
							}

							NumStr = new Number(NumStr);
							YPoint[j] = YPoint[j-1] + NumStr;
							XPoint[j] = XPoint[j-1];
					   		break;
						case "L":
							//NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*\,[^A-Za-z]*\.[^A-Za-z]*/));
							switch(match_mode)
							{
								case 1://
										NumStr = arr[2];
					   					break;
								case 2://.
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								case 3://..
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								case 4://.,.
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*\,[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								case 5://.,
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*\,[^A-Za-z]*/));
					   					break;
								case 6://,.
										NumStr = new String(arr[2].match(/[^A-Za-z]*\,[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								default:
					   				break;
							}

							var NumStr_Array = NumStr.split(",");
							XPoint[j] = new Number(NumStr_Array[0]);
							YPoint[j] = new Number(NumStr_Array[1]);
					   		break;
						case "l":
							//NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*\.[^A-Za-z]*/));
							switch(match_mode)
							{
								case 1://
										NumStr = arr[2];
					   					break;
								case 2://.
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								case 3://..
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								case 4://.,.
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*\,[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								case 5://.,
										NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*\,[^A-Za-z]*/));
					   					break;
								case 6://,.
										NumStr = new String(arr[2].match(/[^A-Za-z]*\,[^A-Za-z]*\.[^A-Za-z]*/));
					   					break;
								default:
					   				break;
							}

							var NumStr_Array = new Array();

							if(NumStr.match(/\,/))
							{
								NumStr_Array = NumStr.split(",");
								NumStr_Array[0] = new Number(NumStr_Array[0]);
								NumStr_Array[1] = new Number(NumStr_Array[1]);
							}
							else
							{
								Ret = NumStr.match(/\-/);
								NumStr_Array[0] = new Number(RegExp.leftContext);
								NumStr_Array[1] = new Number('-' + RegExp.rightContext);
							}

							XPoint[j] = XPoint[j-1] + NumStr_Array[0];
							YPoint[j] = YPoint[j-1] + NumStr_Array[1];
					   		break;
						default:
					   		break;
					}

					if(!isNaN(XPoint[j]))
					{
						if(!Max_x)
						{
							Max_x = XPoint[j];
						}
						if(XPoint[j] > Max_x)
						{
							Max_x = XPoint[j];
						}
						if(!Min_x)
						{
							Min_x = XPoint[j];
						}
						if(XPoint[j] < Min_x)
						{
							Min_x = XPoint[j];
						}
					}

					if(!isNaN(YPoint[j]))
					{
						if(!Max_y)
						{
							Max_y = YPoint[j];
						}
						if(YPoint[j] > Max_y)
						{
							Max_y = YPoint[j];
						}
						if(!Min_y)
						{
							Min_y = YPoint[j];
						}
						if(YPoint[j] < Min_y)
						{
							Min_y = YPoint[j];
						}
					}

				}//for[j]
			}//if
		}
		else
		{
			;
		}
	}//for[i]

	if(gPower_Supply == "y")//***for power supply fig 20070122***
	{
	//case power supply->no scroll
		Max_x = 0;
		Max_y = 0;
		Min_x = 0;
		Min_y = 0;
	}
else
{

	gMax_x = Max_x;
	gMax_y = Max_y;
	gMin_x = Min_x;
	gMin_y = Min_y;

	SVG_FigObj();

	var Svg_Width  = (Max_x - Min_x) * gSvgFigObj.width / gViewWidth;
	var Svg_Height = (Max_y - Min_y) * gSvgFigObj.height / gViewHeight;
	var Win_Width  = gSvgFigWinwidth - 100;
	var Win_Height = gSvgFigWinheight - 100;

	if((Svg_Width > Win_Width) || (Svg_Height > Win_Height))
	{
		if(Svg_Height > Win_Height)
		{
			var SvgObjHeight = ( Win_Height * gSvgFigObj.height) / Svg_Height;

			if(SvgObjHeight < gSvgMin)
			{
				SvgObjHeight = gSvgMin;
			}

			var SvgObjWidth = SvgObjHeight * gViewWidth / gViewHeight;
			
			Svg_Width  = (Max_x - Min_x) * SvgObjWidth / gViewWidth;
			
			if(Svg_Width > Win_Width)
			{
				SvgObjWidth  = ( Win_Width * SvgObjWidth ) / Svg_Width;
				SvgObjHeight =	SvgObjWidth * gViewHeight / gViewWidth;
			}
		}
		else
		{
			SvgObjWidth  = ( Win_Width * gSvgFigObj.width ) / Svg_Width;

			if(SvgObjWidth < gSvgMin)
			{
				SvgObjWidth = gSvgMin;
			}
			
			SvgObjHeight = SvgObjWidth * gViewHeight / gViewWidth;
		}

		gSvgFigObj.height = SvgObjHeight;
		gSvgFigObj.width  = SvgObjWidth;

		if(gViewWidth > gViewHeight)
		{
			magni = gSvgFigObj.height / gSvgFigWinheight + 0.005;//
		}
		else
		{
			magni = gSvgFigObj.width / gSvgFigWinwidth + 0.005;//
		}
		gSvgFigSizeIndexNow = Cal_Mag(magni);

		parent.navi.SVG_SetTransform(gSvgFigWinheight,gSvgFigWinwidth,gSvgFigObj,gViewWidth,gViewHeight,gSvgFigSizeIndexNow);

	}

	Tag_X = (Max_x + Min_x) / 2;
	Tag_Y = (Max_y + Min_y) / 2;

	var Scroll_X = (gSvgFigObj.width  * Tag_X) / gViewWidth - gSvgFigWinwidth / 2;
 	var Scroll_Y = (gSvgFigObj.height * Tag_Y) / gViewHeight- gSvgFigWinheight / 2;

	var scrollHeight = window.parent.work.document.body.scrollTop;
	var scrollWidth = window.parent.work.document.body.scrollLeft;

	if(Scroll_X <= 0)
	{
		Scroll_X = 1;
	}
	if(Scroll_Y <= 0)
	{
		Scroll_Y = 1;
	}

	//if((Scroll_X > 0) || (Scroll_Y > 0))
	//{
		TM6 = setTimeout("Scrolldelay('"+Scroll_X+"','"+Scroll_Y+"','"+scrollWidth+"','"+scrollHeight+"')",100);
	//}
}
}


function Scrolldelay(Scroll_X , Scroll_Y , scrollWidth , scrollHeight)
{
	var Width_temp = window.parent.work.document.body.scrollLeft;

	window.scrollTo(Scroll_X , Scroll_Y);

	//if((Scroll_X + 2 > Width_temp) && (Scroll_X - 2 < Width_temp))
	if(Width_temp > 0)
	{
		gScrolldelaycnt = 0;
		gScrollFlag = 1;
		clearTimeout(TM6);
	}
	else
	{
		gScrolldelaycnt++;

		//if(gScrolldelaycnt > 50)
		if(gScrolldelaycnt > 80)//20080912
		{
			gScrolldelaycnt = 0;
			clearTimeout(TM6);
			return;
		}
		TM6 = setTimeout("Scrolldelay('"+Scroll_X+"','"+Scroll_Y+"','"+scrollWidth+"','"+scrollHeight+"')",100);
	}
}


function SvgSerchLine(id)
{
	var type = 'line';
	var matchId = new RegExp("^(.*:)?"+id,"");
	var SvgDoc = window.parent.work.FigSvg.getSVGDocument();
	var RootNode = SvgDoc.documentElement;

	var length = RootNode.childNodes.length;
	for(var i = 0 ; i < length ; i++)
	{
		var Target = RootNode.childNodes.item(i);

		if(Target.nodeName == 'g')//no change
		{
			if(Target.getAttributeNode('id').value == "ILLUST")
			{
				if(Target.getAttributeNode('id').value.match(matchId))
				{
					if(Target.nodeName == 'path')//no change
					{
						SVGChangColor_Regist(Target,type);
					}
					else
					{
						SVGSrechPath(Target,type);
					}
				}
				else
				{
					SvgSrechChildId(Target,id,type);
				}
			}
			else
			{
				SvgSrechChildId(Target,id,type);
			}
		}
	}

}


function SvgSerchCon(Clist)
{
	var type = 'con';
	var id = Clist;
	var Conleng = id.length;

	var SvgDoc = window.parent.work.FigSvg.getSVGDocument();

	var RootNode = SvgDoc.documentElement;

	var length = RootNode.childNodes.length;

	for(var j = 0; j < Conleng; j++)
	{
		var matchId = new RegExp("^(.*:)?"+id[j] + ':',"");

		for(var i = 0; i < length; i++)
		{
			var Target = RootNode.childNodes.item(i);

			if(Target.nodeName == 'g')//no change
			{
				if(Target.getAttributeNode('id').value == "ILLUST")
				{
					if(Target.getAttributeNode('id').value.match(matchId))
					{
						if(Target.nodeName == 'path')//no change
						{
							SVGChangColor_Regist(Target,type)
						}
						else
						{
							SVGSrechPath(Target,type);
						}
					}
					else
					{
						SvgSrechChildId(Target,id[j],type);
					}
				}
				else
				{
					SvgSrechChildId(Target,id[j],type);
				}
			}
		}
	}

}


function SVGSrechPath(Tag,type)
{
	var Target = "";

	if(Tag.childNodes)
	{
		var Tagleng = Tag.childNodes.length
		
		for(var i = 0; i < Tagleng; i++)
		{
			Target = Tag.childNodes.item(i);

			//***SVG_CS2mode add 20070122***
			if((Target.nodeName == 'line')
			|| (Target.nodeName == 'path')
	    	|| (Target.nodeName == 'rect')
			|| (Target.nodeName == 'circle')
			|| (Target.nodeName == 'ellipse')
			|| (Target.nodeName == 'polyline')
			|| (Target.nodeName == 'polygon'))
			{
				if(Target.nodeName != 'path')
				{
					SVG_mode = "cs";
				}
				else
				{
					SVG_mode = "10";
				}
				//if(Target.nodeName == 'path')
				//{
			//***SVG_CS2mode add 20070122***

				SVGChangColor_Regist(Target,type);
			}
			else
			{
				SVGSrechPath(Target,type);
			}
		}
	}

}


function SvgSrechChildId(Tag,id,type)
{
	var Target = "";

	if(type == 'line')
	{
		var matchId = new RegExp("^(.*:)?"+id,"");
	}
	else
	{
		var matchId = new RegExp("^(.*:)?"+id + ':',"");
	}

	if(Tag.childNodes)
	{
		var Tagleng = Tag.childNodes.length;

		for(var i = 0; i < Tagleng; i++)
		{
			Target = Tag.childNodes.item(i);

			//***SVG_CS2mode add 20070122***
			if(Target.nodeName == 'g' || Target.nodeName == 'path' || Target.nodeName == 'a' || Target.nodeName == 'line' || Target.nodeName == 'polyline')
			//***SVG_CS2mode add 20070122***
			{
				if(Target.getAttributeNode('id'))
				{
					if(Target.getAttributeNode('id').value.match(matchId))
					{
						//***SVG_CS2mode add 20070122***
						//if(Target.nodeName == 'path')
						if((Target.nodeName == 'path') || (Target.nodeName == 'line') || (Target.nodeName == 'polyline'))
						{
							if((Target.nodeName == 'line') || (Target.nodeName == 'polyline'))
							{
								SVG_mode = "cs";
							}
							else
							{
								SVG_mode = "10";
							}

							//***SVG_CS2mode add 20070122***
							SVGChangColor_Regist(Target,type)
						}
						else
						{
							SVGSrechPath(Target,type);
						}
					}
					else
					{
						SvgSrechChildId(Target,id,type);
					}
				}
				else
				{
					SvgSrechChildId(Target,id,type);
				}
			}
		}
	}

}


function SVGChangColor_Regist(Tag,type)
{
	gChangCcolor = "#0FE70F";

	//***SVG_CS2mode add 20070122***
	//var TagPatDval = Tag.getAttributeNode('d').value;
	//***SVG_CS2mode add 20070122***

	var TagPatStrokeval = Tag.getAttribute("stroke");

	var TagPatfillval = Tag.getAttribute("fill");

	var TagnodeName = Tag.nodeName;

	//겓cream color,orange color with Range 20070605
	var nTagPatfillval = 0;
	var nTagPatfillval_R = 0;
	var nTagPatfillval_G = 0;
	var nTagPatfillval_B = 0;
	var TagStrtemp;
	//겒cream color,orange color with Range 20070605

	//***SVG_CS2mode add 20070122***

	if(SVG_mode == "cs")
	{
		//겓cream color,orange color with Range 20070605
		TagStrtemp = TagPatfillval.substring(1,7);//reject #

		nTagPatfillval = Number("0x"+TagStrtemp);
		nTagPatfillval_R = nTagPatfillval & 0xFF0000;
		nTagPatfillval_G = nTagPatfillval & 0xFF00;
		nTagPatfillval_B = nTagPatfillval & 0xFF;
		//겒cream color,orange color with Range 20070605

		if(type == 'line')
		{
			gSvgChangColorTag.push(Tag);
			gGBTtagColor.push(Tag.getAttribute("stroke"));
			gGBTtagColorType.push("stroke");

			if((TagnodeName == 'circle') || (TagnodeName == 'polygon'))
			{
				gSvgChangColorTag.push(Tag);
				gGBTtagColor.push(Tag.getAttribute("fill"));
				gGBTtagColorType.push("fill");
			}
		}

		//else if((TagPatfillval != 'none') && (TagPatfillval != '#000000'))
		//else if((TagPatfillval == '#FFFCD1') || (TagPatfillval == '#F9CFBA'))//cream color,orange color
		//else if((TagPatfillval == '#FFFFBF') || (TagPatfillval == '#FCC0A7'))//cream color,orange color 20070131

		else if(((nTagPatfillval_R >= 0xF50000) && (nTagPatfillval_R <= 0xFF0000) &&
			   (nTagPatfillval_G >= 0xF800) && (nTagPatfillval_G <= 0xFF00) &&
			   (nTagPatfillval_B >= 0xBE) && (nTagPatfillval_B <= 0xD1)) ||
			   ((nTagPatfillval_R >= 0xF40000) && (nTagPatfillval_R <= 0xFC0000) &&
			   (nTagPatfillval_G >= 0xBF00) && (nTagPatfillval_G <= 0xCF00) &&
			   (nTagPatfillval_B >= 0xA7) && (nTagPatfillval_B <= 0xBB)))	//cream color,orange color with Range 20070605
		{
			if(Tag.getAttributeNode('fill'))
			{
				var TagPatFillval = Tag.getAttributeNode('fill').value;
			}
			gSvgChangColorTag.push(Tag);
			gGBTtagColor.push(Tag.getAttribute("fill"));
			gGBTtagColorType.push("fill");
		}

	}
	else
	{//SVG_mode 10
		var TagPatDval = Tag.getAttributeNode('d').value;

		//***SVG_CS2mode add 20070122***
		if(type == 'line')
		{
			if(TagPatStrokeval && ( TagPatfillval && (TagPatfillval == 'none' )))
			{
				gSvgChangColorTag.push(Tag);
				gGBTtagColor.push(Tag.getAttribute("stroke"));
				gGBTtagColorType.push("stroke");
			}
			else if(TagPatStrokeval && !TagPatfillval && (TagPatDval && !TagPatDval.match('c')))
			{
				gSvgChangColorTag.push(Tag);
				gGBTtagColor.push(Tag.getAttribute("stroke"));
				gGBTtagColorType.push("stroke");

				gSvgChangColorTag.push(Tag);
				gGBTtagColor.push(Tag.getAttribute("fill"));
				gGBTtagColorType.push("fill");
			}
			else if(TagPatStrokeval && !TagPatfillval && (TagPatDval && TagPatDval.match('c')))
			{
				gSvgChangColorTag.push(Tag);
				gGBTtagColor.push(Tag.getAttribute("stroke"));
				gGBTtagColorType.push("stfi");

				gSvgChangColorTag.push(Tag);
				gGBTtagColor.push(Tag.getAttribute("stroke"));
				gGBTtagColorType.push("stroke");
			}
			else if(TagPatStrokeval && ( TagPatfillval && (TagPatfillval != 'none' )) && (TagPatDval && TagPatDval.match('c')))
			{
				gSvgChangColorTag.push(Tag);
				gGBTtagColor.push(Tag.getAttribute("fill"));
				gGBTtagColorType.push("fill");

				gSvgChangColorTag.push(Tag);
				gGBTtagColor.push(Tag.getAttribute("stroke"));
				gGBTtagColorType.push("stroke");
			}

		}
		else
		{
			if(Tag.getAttributeNode('fill'))
			{
				var TagPatFillval = Tag.getAttributeNode('fill').value;
			}

			if(!(TagPatDval.match(/[c]/ && (TagPatFillval) && (TagPatFillval == "none"))) && (TagPatFillval && !(TagPatFillval == "none")))
			{
				gSvgChangColorTag.push(Tag);
				gGBTtagColor.push(Tag.getAttribute("fill"));
				gGBTtagColorType.push("fill");
			}
		}
	}//***SVG_CS2mode add 20070122***

	SVG_mode = "10";//***SVG_CS2mode add 20070122***
}


function SVGBlink()
{
	if(gSvgChangColorTag[0])
	{
		Blink_Count++;

		if((Blink_Count == 1) || (Blink_Count == 3) || (Blink_Count == 5) || (Blink_Count == 7) || (Blink_Count == 9))
		{
			SVGChangColor();
		}
		else
		{
			SVGResetColor();
		}

		if(Blink_Count <= 8)
		{
			Blink = setTimeout("SVGBlink()",350);
		}
		else
		{
			clearTimeout(Blink);
			Blink_Count = 0;
			//clearTimeout(TM6);//svg scroll
		}
		
	}
	else
	{
		;
	}

}


function SVGChangColor()
{
	var Taglength = gSvgChangColorTag.length;
	var FillType;
	var Target;

	for(var i = 0; i < Taglength; i++)
	{
		Target   = gSvgChangColorTag[i];
		FillType = gGBTtagColorType[i];

		if(FillType == "stfi")
		{
			Target.setAttribute("fill",gChangCcolor);
		}
		
		Target.setAttribute(FillType,gChangCcolor);
	}

}


function SVGResetColor()
{
	var Tagleng = gSvgChangColorTag.length;

	for(var i = 0; i < Tagleng; i++)
	{
		if(gSvgChangColorTag[i])
		{
			if(gGBTtagColorType[i] == "stroke")
			{
				gSvgChangColorTag[i].setAttribute("stroke", gGBTtagColor[i]);
			}
			else if(gGBTtagColorType[i] == "fill")
			{
				gSvgChangColorTag[i].setAttribute("fill", gGBTtagColor[i]);
			}
			else if(gGBTtagColorType[i] == "stfi")
			{
				gSvgChangColorTag[i].setAttribute("fill", gGBTtagColor[i]);
			}
		}
	}
}


function SVG_Ope(EventNode,id,para,sCons)
{
	var conlist = sCons.split('\t');
	var conlistleng = sCons.length;
	var Conlist = new Array();

	for(var i = 0; i < conlistleng; i++)
	{
		if(conlist[i])
		{
			Conlist.push(conlist[i])
		}
	}

	SVGSerch(para,Conlist,id,"","");

}


function SVG_OnClick(evt)
{
	gList = "";
	var EventNode = evt.getTarget();
	var id = "";

	for(var i = 0; i < 10; i++)
	{
		if(EventNode.getAttributeNode('id'))
		{
			id = EventNode.getAttributeNode('id').value;
			i = 10;

			if((id != "")
			&& (id != "EXTERIOR")
			&& (id != "RANGE")
			&& (id != "ID")
			&& (id != "ILLUST")
			&& (id != "NUMBER"))
			{
				if(id.substr(4,1) == "h")
				{//For HarnessLayout
					var nwin = window.open("fig.html?j="+gXmlFigGrpHarness+"&f="+id,"winfiggrp"+gXmlFigGrpHarness);
					nwin.focus();
				}
				else
				{
					//뾴멹뙚랊귉
					SVG_Dist(EventNode,id);
				}
			}
		}
		else
		{
			EventNode = EventNode.parentNode;
		}
	}

	if((id != "")
	&& (id != "EXTERIOR")
	&& (id != "RANGE")
	&& (id != "ID")
	&& (id != "ILLUST")
	&& (id != "NUMBER"))
	{
		SVG_Scroll_Figsel();//

		parent.work.gDisp_all = "sel";
		gConsel = 0;
	}

}


function SVG_BoxResetColor()
{
	clearTimeout(Blink);

	var Tagleng = gSvgChangColorTag.length;

	for(var i = 0; i < Tagleng; i++)
	{
		if(gSvgChangColorTag[i])
		{
			if(gGBTtagColorType[i] == "stroke")
			{
				gSvgChangColorTag[i].setAttribute("stroke", gGBTtagColor[i]);
			}
			else if(gGBTtagColorType[i] == "fill")
			{
				gSvgChangColorTag[i].setAttribute("fill", gGBTtagColor[i]);
			}
			else if(gGBTtagColorType[i] == "stfi")
			{
				gSvgChangColorTag[i].setAttribute("fill", gGBTtagColor[i]);
			}
		}
	}

	for(var l = 0; l < Tagleng; l++)
	{
		gSvgChangColorTag.shift();
		gGBTtagColor.shift();
		gGBTtagColorType.shift();
	}
	
}


function SVG_FiginiSet999 (navi)
{
	SVG_FigObj(navi);

	if(gViewWidth > gViewHeight)
	{
		if(gSvgFigWinheight < gSvgMin)
		{
			gSvgFigWinheight = gSvgMin;
		}

		gSvgFigObj.height = gSvgFigWinheight;
		gSvgFigObj.width  = gSvgFigWinheight * gViewWidth / gViewHeight;

	}
	else
	{
		if(gSvgFigWinwidth < gSvgMin)
		{
			gSvgFigWinwidth = gSvgMin;
		}
		gSvgFigObj.width = gSvgFigWinwidth;
		gSvgFigObj.height = gSvgFigWinwidth * gViewHeight / gViewWidth;
		
	}

	if(gDispInif == 0)
	{
		gDispInif = 1;
		temp_width = gSvgFigObj.width;
		temp_height = gSvgFigObj.height;
		temp_width2 = gSvgFigWinwidth;
		temp_height2 = gSvgFigWinheight;
	}

	window.parent.work.scrollTo(0,0);

	gSvgFigSizeIndexNow = gSvgFigSizeIndexNomal;

	parent.work.gDisp_all = "clear";//

	if(!location.href.match('navi.html') && location.href.match('base_figinfo.html'))
	{
		parent.navi.SVG_SetTransform(gSvgFigWinheight,gSvgFigWinwidth,gSvgFigObj,gViewWidth,gViewHeight,gSvgFigSizeIndexNow);
	}

}

function SVG_FiginiSet2 (navi)
{
	SVG_FigObj(navi);

	if(gViewWidth > gViewHeight)
	{
		if(gSvgFigWinheight < gSvgMin)
		{
			gSvgFigWinheight = gSvgMin;
		}

		gSvgFigObj.height = gSvgFigWinheight;
		gSvgFigObj.width  = gSvgFigWinheight * gViewWidth / gViewHeight;

	}
	else
	{
		if(gSvgFigWinwidth < gSvgMin)
		{
			gSvgFigWinwidth = gSvgMin;
		}
		gSvgFigObj.width = gSvgFigWinwidth;
		gSvgFigObj.height = gSvgFigWinwidth * gViewHeight / gViewWidth;
		
	}

	if(gDispInif == 0)
	{
		gDispInif = 1;
		temp_width = gSvgFigObj.width;
		temp_height = gSvgFigObj.height;
		temp_width2 = gSvgFigWinwidth;
		temp_height2 = gSvgFigWinheight;
	}

	window.parent.work.scrollTo(0,0);

	gSvgFigSizeIndexNow = gSvgFigSizeIndexNomal;

	parent.work.gDisp_all = "clear";//

	if(!location.href.match('navi.html') && location.href.match('base_figinfo.html'))
	{
		parent.navi.SVG_SetTransform(gSvgFigWinheight,gSvgFigWinwidth,gSvgFigObj,gViewWidth,gViewHeight,gSvgFigSizeIndexNow);
	}

}

function SVG_SetTransform(FH,FW,SO,SVW,SVH,SI)
{
	gSvgFigWinheight    = FH;
	gSvgFigWinwidth     = FW;
	gSvgFigObj          = SO;
	gViewWidth          = SVW;
	gViewHeight         = SVH;
	gSvgFigSizeIndexNow = SI;

}


function SVG_FigObj(navi)
{
	if(navi)
	{
		gSvgFigWinheight = window.parent.work.document.body.clientHeight - 30;
		gSvgFigWinwidth  = window.parent.work.document.body.clientWidth;
		gSvgFigObj = window.parent.work.document.getElementsByTagName('embed').item(0);
	}
	else
	{
		gSvgFigWinheight = window.document.body.clientHeight - 30;
		gSvgFigWinwidth  = window.document.body.clientWidth;
		gSvgFigObj = window.document.getElementsByTagName('embed').item(0);
	}

	var svgFigObjRootElem = gSvgFigObj.getSVGDocument().rootElement;

	var svgFigViewBox = svgFigObjRootElem.getAttribute('viewBox');

	var views = svgFigViewBox.split(/ /);

	gViewWidth  = new Number(views[2]);
	gViewHeight = new Number(views[3]);

}


function SVG_Dist(EventNode,id)
{

	var Id = id;
	var Para;
	var sUrl = "";

	var nJob = GetUrlQueryParam("j");
	var sFig = GetUrlQueryParam("f");
	var sFigGrp= gXmlFigGrpName[nJob];

	var sCons = "";
	var sLink = "";
	var sTop = "";
	var sCircuit = "";

	if(!id.match(/K$/))
	{
		var ids = id.split(":");
	}
	else
	{
		var ids = new Array(id);
	}

	var length = ids.length;
	for(var i = 0; i < length; i++)
	{
		if(ids[i] != "")
		{
			Para = GetParaFromId(sFigGrp,sFig,ids[i]);

			if(Para[0] == "line") sCons = Para[2];
			if(Para[0] == "con") sCons = sCons + Para[2] + "\t";
			if(Para[0] == "link") sLink = Para[2];
			if(Para[0] == "top") sTop = Para[2];
			if(Para[0] == "circuit") sCircuit = Para[2];

			gObjKind = Para[0];
		}
	}

	if(sCons != "")
	{
		SVG_Ope(EventNode,id,Para[0],sCons);

		parent.info.gConSvgLoadFlag2 = 0;

		parent.info.document.all("data").innerHTML = FigData_LoadConnInfoData(2,sCons,"info");

		TM2 = setTimeout("Condelay2()",10);

	}

	if(sLink != "")
	{
		sUrl = "fig.html?j=" + nJob + "&f=" + sLink;
		//var nwin = window.open(sUrl,"_top","");
		var nwin = window.open(sUrl,"_parent","");
		nwin.focus();
	}

	if(sTop != "")
	{
		var vCate = GetCategoryInfoFromSubcategory(sTop);

		var from_text = "&";
		var to_text = "DELIMITAamp";
		sTop = sTop.split(from_text);
		sTop = sTop.join(to_text);

		sUrl = "category.html?j=" + gXmlFigGrpCircuit + "&tc=" + escape(sTop);

		//var nwin = window.open(sUrl,"_top","");
		var nwin = window.open(sUrl,"_parent","");
		nwin.focus();
	}

	if(sCircuit != "")
	{
		sUrl = "fig.html?j=" + nJob + "&f=" + sCircuit;
		//var nwin = window.open(sUrl,"_top","");
		var nwin = window.open(sUrl,"_parent","");
		nwin.focus();
	}

}


function Condelay2()
{
	if(parent.info.gConSvgLoadFlag2 == 0)
	{
		gCondelay2cnt++;

		if(gCondelay2cnt > 1000)
		{
			gCondelay2cnt = 0;
			//alert(gTimeout_Error);
			clearTimeout(TM2);
			return;
		}

		TM2 = setTimeout("Condelay2()",10);
	}
	else
	{
		parent.info.gConSvgLoadFlag2 = 0;
    	parent.info.SVG_ConiniSet('list');
		clearTimeout(TM2);
	}
}


function Nulldelay()
{
	if(window.parent.work.FigSvg == null)
	{
		gNulldelaycnt++;

		if(gNulldelaycnt > 1000)
		{
			gNulldelaycnt = 0;
			//alert(gTimeout_Error);
			clearTimeout(TM1);
			return;
		}

		TM1 = setTimeout("Nulldelay()",10);
	}
	else
	{
		clearTimeout(TM1);
	}
}


function SVG_Scroll_Listsel()
{
	var Tag_X = new Number();
	var Tag_Y = new Number();

	var Svg_Width  = (parent.work.gMax_x - parent.work.gMin_x) * gSvgFigObj.width / gViewWidth;
	var Svg_Height = (parent.work.gMax_y - parent.work.gMin_y) * gSvgFigObj.height / gViewHeight;
	var Win_Width  = gSvgFigWinwidth - 100;
	var Win_Height = gSvgFigWinheight - 100;

	if((Svg_Width > Win_Width) || (Svg_Height > Win_Height))
	{
		if(Svg_Height > Win_Height)
		{
			var SvgObjHeight = ( Win_Height * gSvgFigObj.height) / Svg_Height;

			if(SvgObjHeight < gSvgMin)
			{
				SvgObjHeight = gSvgMin;
			}

			var SvgObjWidth = SvgObjHeight * gViewWidth / gViewHeight;
			
			Svg_Width  = (parent.work.gMax_x - parent.work.gMin_x) * SvgObjWidth / gViewWidth;
			
			if(Svg_Width > Win_Width)
			{
				SvgObjWidth  = ( Win_Width * SvgObjWidth ) / Svg_Width;
				SvgObjHeight =	SvgObjWidth * gViewHeight / gViewWidth;
			}
		}
		else
		{
			var SvgObjWidth  = ( Win_Width * gSvgFigObj.width ) / Svg_Width;

//add
			if(SvgObjWidth<gSvgFigObj.width)
			{
				SvgObjWidth = gSvgFigObj.width;
			}


			if(SvgObjWidth < gSvgMin)
			{
				SvgObjWidth = gSvgMin;
			}
			
			SvgObjHeight = SvgObjWidth * gViewHeight / gViewWidth;
		}

		gSvgFigObj.height = SvgObjHeight;
		gSvgFigObj.width  = SvgObjWidth;

//////////gSvgFigSizeIndexNow = gSvgFigSizeIndex[gSvgFigSizeIndexNow];

		parent.navi.SVG_SetTransform(gSvgFigWinheight,gSvgFigWinwidth,gSvgFigObj,gViewWidth,gViewHeight,gSvgFigSizeIndexNow);

	}

	Tag_X = (parent.work.gMax_x + parent.work.gMin_x) / 2;
	Tag_Y = (parent.work.gMax_y + parent.work.gMin_y) / 2;

	var Scroll_X = (gSvgFigObj.width  * Tag_X) / gViewWidth;
 	var Scroll_Y = (gSvgFigObj.height * Tag_Y) / gViewHeight;

	window.parent.work.scrollTo(Scroll_X - gSvgFigWinwidth / 2 + 10 , Scroll_Y - gSvgFigWinheight / 2);

}


function SVG_Scroll_Figsel()
{
	var Taglen = gSvgChangColorTag.length;
	var Tag;

	var XPoint = new Array();
	var YPoint = new Array();

	//var Max_x = "";
	//var Min_x = "";
	//var Max_y = "";
	//var Min_y = "";

	var Max_x = 0;
	var Min_x = 9999;
	var Max_y = 0;
	var Min_y = 9999;

	var TagD;
	var TagP;

	var Tagx2 = 0;
	var Tagy2 = 0;
	var Tagw2 = 0;
	var Tagh2 = 0;

	var Tagx3 = 0;
	var Tagy3 = 0;

	var Tag_rect = "";

	var TagP_xy = "";
	var length0 = 0;
	var length1 = 0;
	var p0 = 0;
	var p1 = 0;

	gPower_Supply = "y";//***for power supply fig 20070122***

	for(var i = 0 ; i < Taglen ; i++)
	{
		gPower_Supply = "n";//***for power supply fig 20070122***

		Tag = gSvgChangColorTag[i];
		//var TagD = Tag.getAttributeNode('d').value;

		Tag_rect = Tag.nodeName

		if(Tag_rect == "rect")//***SVG_CS2mode add 20070122***
		{
			Tagx2 = new Number(Tag.getAttributeNode('x').value);
			Tagy2 = new Number(Tag.getAttributeNode('y').value);
			Tagw2 = new Number(Tag.getAttributeNode('width').value);
			Tagh2 = new Number(Tag.getAttributeNode('height').value);

			if(Tagx2 < Min_x)
			{
				Min_x = Tagx2;
			}
			if(Tagy2 < Min_y)
			{
				Min_y = Tagy2;
			}
			if((Tagx2 + Tagw2) > Max_x)
			{
				Max_x = Tagx2 + Tagw2;
			}
			if((Tagy2 + Tagh2) > Max_y)
			{
				Max_y = Tagy2 + Tagh2;
			}
		}
		else if(Tag_rect == "polygon")//***SVG_CS2mode add 20070122***
		{
			TagP = Tag.getAttributeNode('points').value;
			length0 = TagP.length - 1;

			for(var j = 0; j < length0; j++)
			{
				p0 = TagP.indexOf(" ",j);
				TagP_xy = TagP.slice(j, p0);
				j = p0;

				if (TagP_xy != "")
				{
					length1 = TagP_xy.length;
					p1 = TagP_xy.indexOf(",",0);

					Tagx3 = new Number(TagP_xy.slice(0, p1));
					Tagy3 = new Number(TagP_xy.slice(p1 + 1, length1));

					if(Tagx3 < Min_x)
					{
						Min_x = Tagx3;
					}
					if(Tagy3 < Min_y)
					{
						Min_y = Tagy3;
					}
					if(Tagx3 > Max_x)
					{
						Max_x = Tagx3;
					}
					if(Tagy3  > Max_y)
					{
						Max_y = Tagy3;
					}
				}
			}
		}
		else if(Tag_rect == "path")
		{
			TagD = Tag.getAttributeNode('d').value;

			var Maha = /([A-Za-z][^A-Za-z]*)([A-Za-z][^A-Za-z]*)([A-Za-z][^A-Za-z]*)([A-Za-z][^A-Za-z]*)([A-Za-z][^A-Za-z]*)/;
			var Arr = new Array();
			Arr = Maha.exec(TagD);

			if(Arr)
			{
				var ComStr = /([A-Za-z])([^A-Za-z]*)/;
				var arr = new Array();

				var length = Arr.length - 1;
				for(var j = 1; j < length; j++)
				{
					arr = ComStr.exec(Arr[j]);
					switch(arr[1])
					{
						case "M":
							NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*\,[^A-Za-z]*\.[^A-Za-z]*/));
							var NumStr_Array = NumStr.split(",");
							XPoint[j] = new Number(NumStr_Array[0]);
							YPoint[j] = new Number(NumStr_Array[1]);
							break;
						case "H":
							NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*/));
							NumStr = new Number(NumStr);
							XPoint[j] = NumStr;
							YPoint[j] = YPoint[1];
					   		break;
				 		case "h":
							NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*/));
							NumStr = new Number(NumStr);
							XPoint[j] = XPoint[j-1] + NumStr;
							YPoint[j] = YPoint[j-1];
					   		break;
						case "V":
							NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*/));
							NumStr = new Number(NumStr);
							YPoint[j] = NumStr;
							XPoint[j] = XPoint[j-1];
					   		break;
				 		case "v":
							NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*/));
							NumStr = new Number(NumStr);
							YPoint[j] = YPoint[j-1] + NumStr;
							XPoint[j] = XPoint[j-1];
					   		break;
						case "L":
							NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*\,[^A-Za-z]*\.[^A-Za-z]*/));
							var NumStr_Array = NumStr.split(",");
							XPoint[j] = new Number(NumStr_Array[0]);
							YPoint[j] = new Number(NumStr_Array[1]);
					   		break;
						case "l":
							NumStr = new String(arr[2].match(/[^A-Za-z]*\.[^A-Za-z]*\.[^A-Za-z]*/));
							var NumStr_Array = new Array();

							if(NumStr.match(/\,/)){
								NumStr_Array = NumStr.split(",");
								NumStr_Array[0] = new Number(NumStr_Array[0]);
								NumStr_Array[1] = new Number(NumStr_Array[1]);
							}else{
								Ret = NumStr.match(/\-/);
								NumStr_Array[0] = new Number(RegExp.leftContext);
								NumStr_Array[1] = new Number('-' + RegExp.rightContext);
							}

							XPoint[j] = XPoint[j-1] + NumStr_Array[0];
							YPoint[j] = YPoint[j-1] + NumStr_Array[1];
					   		break;
						default:
					   		break;
					}

					if(!Max_x){ Max_x = XPoint[j]; }
					if(!Max_y){ Max_y = YPoint[j]; }

					if(XPoint[j] > Max_x){Max_x = XPoint[j];}
					if(YPoint[j] > Max_y){Max_y = YPoint[j];}

					if(!Min_x){ Min_x = XPoint[j]; }
					if(!Min_y){ Min_y = YPoint[j]; }

					if(XPoint[j] < Min_x){Min_x = XPoint[j];}
					if(YPoint[j] < Min_y){Min_y = YPoint[j];}

				}//for
			}//if
		}
		else
		{
			;
		}
	}//for

	if(gPower_Supply == "y")//***for power supply fig 20070122***
	{
	//case power supply->no scroll
		Max_x = 0;
		Max_y = 0;
		Min_x = 0;
		Min_y = 0;
	}
	else
	{
		gMax_x = Max_x;
		gMax_y = Max_y;
		gMin_x = Min_x;
		gMin_y = Min_y;
	}
}


function SVG_Figfitness (navi)
{
	gSvgFigSizeIndexNow = gSvgFigSizeIndexNomal;

	SVG_FigSizeChange(navi,"b");

}
function SVG_FigExpansion(navi)
{
	if(gSvgFigSizeIndex.length - 1 > gSvgFigSizeIndexNow)
	{
		if(parent.work.gDisp_all == "clear")
		{
			gSvgFigSizeIndexNow ++;
		}

		SVG_FigSizeChange(navi,"b");
	}
}


function SVG_FigReduction(navi)
{
	if(0 < gSvgFigSizeIndexNow)
	{
		gSvgFigSizeIndexNow --;
		SVG_FigSizeChange(navi,"s");
	}
}


function SVG_FigSizeChange(navi,Disp_size)
{
	var magni = 0;

	var Offset_Top = 0;
	var Offset_Left = 0;

	var Y = 0;
	var X = 0;

	var nY = 0;
	var nX = 0;

	var Xoff = 0;

	var Y1 = 0;
	var X1 = 0;
	var Y2 = 0;
	var X2 = 0;

	if(parent.work.gConsel == 0)
	{//normal
		;
	}
	else if(parent.work.gConsel == 1)
	{//con sel 1st
		;
	}
	else
	{//con sel 2nd,3rd...
		if((gOffset_Top != window.parent.work.document.body.scrollTop) || (gOffset_Left != window.parent.work.document.body.scrollLeft))
		{//user scroll

			if (parent.work.gDisp_all != "all")
			{
				parent.work.gConsel = 0;
			}
		}
		else
		{
			;
		}
	}

	if(parent.work.gDisp_all == "all")
	{
		gSvgFigObj.width = parent.work.temp_width;
		gSvgFigObj.height = parent.work.temp_height;

		gSvgFigWinwidth = parent.work.temp_width2;
		gSvgFigWinheight = parent.work.temp_height2;
	}
	else if(parent.work.gDisp_all == "sel")
	{
		if(gViewWidth > gViewHeight)
		{
			magni = gSvgFigObj.height / gSvgFigWinheight + 0.005;//
		}
		else
		{
			magni = gSvgFigObj.width / gSvgFigWinwidth + 0.005;//
		}

		if(gSvgFigSizeIndexNow > Cal_Mag(magni))
		{
			gSvgFigSizeIndexNow = Cal_Mag(magni);
		}
		else if(gSvgFigSizeIndexNow <= Cal_Mag(magni))
		{
			gSvgFigSizeIndexNow++;
		}
	}
	else
	{
		;
	}
	parent.work.gDisp_all = "clear";

	if(gViewWidth > gViewHeight)
	{//Case Width>Height
		nY = gSvgFigWinheight * gSvgFigSizeIndex[gSvgFigSizeIndexNow];
		nX = nY * gViewWidth / gViewHeight;

		Offset_Top = window.parent.work.document.body.scrollTop;
		Offset_Left = window.parent.work.document.body.scrollLeft;

		Xoff = ((Offset_Left + (gSvgFigWinwidth / 2)) / (gSvgFigObj.width / 2) - 1) * ((nX - gSvgFigObj.width) / 2);
		X = ((nX / 2) - (gSvgFigObj.width / 2)) + Xoff;

		Yoff = ((Offset_Top + (gSvgFigWinheight / 2)) / (gSvgFigObj.height / 2) - 1) * ((nY - gSvgFigObj.height) / 2);
		Y = ((nY / 2) - (gSvgFigObj.height / 2)) + Yoff;

		gSvgFigObj.height = gSvgFigWinheight * gSvgFigSizeIndex[gSvgFigSizeIndexNow];
		gSvgFigObj.width  = gSvgFigObj.height * gViewWidth / gViewHeight;
	}
	else
	{//Case Height >= Width
		nX = gSvgFigWinwidth * gSvgFigSizeIndex[gSvgFigSizeIndexNow];
		nY = nX * gViewHeight / gViewWidth;

		Offset_Top = window.parent.work.document.body.scrollTop;
		Offset_Left = window.parent.work.document.body.scrollLeft;

		Xoff = ((Offset_Left + (gSvgFigWinwidth / 2)) / (gSvgFigObj.width / 2) - 1) * ((nX - gSvgFigObj.width) / 2);
		X = ((nX / 2) - (gSvgFigObj.width / 2)) + Xoff;

		Yoff = ((Offset_Top + (gSvgFigWinheight / 2)) / (gSvgFigObj.height / 2) - 1) * ((nY - gSvgFigObj.height) / 2);
		Y = ((nY / 2) - (gSvgFigObj.height / 2)) + Yoff;

		gSvgFigObj.width = gSvgFigWinwidth * gSvgFigSizeIndex[gSvgFigSizeIndexNow];
		gSvgFigObj.height = gSvgFigObj.width * gViewHeight / gViewWidth;
	}

	//if(parent.work.gConsel == 0)
	if((parent.work.gConsel == 0) || (gPower_Supply == "y"))//***for power supply fig 20070122***
	{
		window.parent.work.scrollBy(X,Y);//normal
	}
	else
	{
		if(parent.work.gConsel < 10000)
		{
			parent.work.gConsel = parent.work.gConsel + 1;
		}
		if(gPower_Supply == "n")//***for power supply fig 20070122***
		{
			SVG_Scroll_Listsel();//connector select
		}
	}

	gPower_Supply = "y";//***for power supply fig 20070122***

	gOffset_Top = window.parent.work.document.body.scrollTop;
	gOffset_Left = window.parent.work.document.body.scrollLeft;

}


function SVG_FigSizeAll(navi)
{
	var magni;

	SVG_FigObj(navi);

	if(gViewWidth > gViewHeight)
	{
		gSvgFigObj.width = gSvgFigWinwidth;
		gSvgFigObj.height = gSvgFigObj.width * gViewHeight / gViewWidth;

		magni = gSvgFigObj.height / gSvgFigWinheight + 0.005;//
	}
	else
	{
		gSvgFigObj.height = gSvgFigWinheight;
		gSvgFigObj.width = gSvgFigObj.height * gViewWidth / gViewHeight;

		magni = gSvgFigObj.width / gSvgFigWinwidth + 0.005;//
	}

	gSvgFigSizeIndexNow = Cal_Mag(magni);

	gSvgFigWinwidth = gSvgFigObj.width;
	gSvgFigWinheight = gSvgFigObj.height;

	parent.work.gDisp_all = "all";

	window.parent.work.scrollTo(0,0);

}


function SVG_ShowAltCon(evt)
{
	var nJob = GetUrlQueryParam("j");
	var sFig =  GetUrlQueryParam("f");
	var sFigGrp = gXmlFigGrpName[nJob];
	var EventNode = evt.getTarget();
	
	for(var i = 0; i < 10; i++)
	{
		if(EventNode.getAttributeNode('id'))
		{
			id = EventNode.getAttributeNode('id').value;
			break;
		}
		else
		{
			EventNode = EventNode.parentNode;
		}
	}

	var Para;
	var sName = "";
	var nCount = 0;
	var ids = id.split(":");

	var length = ids.length;
	var length2 = 0;
	var j = 0;
	var fLine_Num = false;

	for(var i = 0; i < length; i++)
	{
		if((ids[i] != "")
		&& (ids[i] != "EXTERIOR")
		&& (ids[i] != "RANGE")
		&& (ids[i] != "ID")
		&& (ids[i] != "ILLUST")
		&& (ids[i] != "NUMBER")
		&& (ids[i] != "K")
		&& (ids[i] != "AAA"))
		{
			//***L+Num(Line id) case is break***
			length2 = ids[i].length;
			fLine_Num = true;
			if(ids[i].substr(0,1) == "L")
			{
				for(var j = 1; j < length2; j++)
				{
					if(isNaN(ids[i].substr(j,1)) == true)
					{//Not Num
						fLine_Num = false;
						break;
					}
					else
					{//Num
						;
					}
				}
				if(fLine_Num == true)
				{//Num
					break;
				}
				else
				{//Not Num
					;
				}
			}
			else
			{//Not Line
				;
			}

			Para = GetParaFromId(sFigGrp,sFig,ids[i]);
			if(Para[0] == "con")
			{
				sName = sName + "<tr><td nowrap>[ " + Para[2] + " ]</td><td nowrap>" + Para[1] + "</td></tr>";
			}
			if(Para[0] == "circuit") sName = sName + "<tr><td nowrap>" + Para[1] + "</td></tr>";
			if(Para[0] == "link")    sName = sName + "<tr><td nowrap>" + Para[1] + "</td></tr>";
			if(Para[0] == "top")     sName = sName + "<tr><td nowrap>" + Para[1] + "</td></tr>";
			nCount = nCount + 1;
		}
		else
		{
			break;
		}
	}

	if(nCount != 0)
	{
		if(window.parent.work.document.all("divalt"))
		{
			sName = "<table>" + sName + "</table>";
			window.parent.work.document.all("divalt").innerHTML = sName;

			var mouseX = evt.clientX;
			var mouseY = evt.clientY;

			var bodyWidth = window.parent.work.document.body.clientWidth;
			var bodyHeight = window.parent.work.document.body.clientHeight;

			var bodyScrollX = window.parent.work.document.body.scrollLeft;
			var bodyScrollY = window.parent.work.document.body.scrollTop;

			var divWidth = window.parent.work.document.all("divalt").offsetWidth;
			var divHeight = window.parent.work.document.all("divalt").offsetHeight;

			var posX = mouseX + 20;
			var posY = mouseY - 20;

			var divCenterX = posX + (divWidth / 2);
			var divCenterY = posY - (divHeight / 2)

			if(mouseX <= divCenterX)
			{
				posX = mouseX + 20;
				if((posX+divWidth) >= bodyScrollX + bodyWidth )
				{
					posX = mouseX - 20 - divWidth;
				}
			}
			else
			{
				posX = mouseX - 20 - divWidth;
				if(posX < bodyScrollX)
				{
					posX = mouseX + 20;
				}
			}
			if(mouseY >= divCenterY)
			{
				posY = mouseY + 20;
				if(( posY + divHeight ) >= bodyScrollY + bodyHeight )
				{
					posY = mouseY - 20 - divHeight;
				}
			}
			else
			{
				posY = mouseY - 20 - divHeight;
				if( posY  <= bodyScrollY)
				{
					posY = mouseY + 20;
				}
			}

			window.parent.work.document.all("divalt").style.posLeft = posX;
			window.parent.work.document.all("divalt").style.posTop = posY;
			window.parent.work.document.all("divalt").style.visibility = 'visible';
		}
	}

}


function  SVG_ShowAltCon_mov()
{
    var mouseX = document.body.scrollLeft + event.clientX;
    var mouseY = document.body.scrollTop + event.clientY;

	var bodyWidth = window.parent.work.document.body.clientWidth;
	var bodyHeight = window.parent.work.document.body.clientHeight;

	var bodyScrollX = window.parent.work.document.body.scrollLeft;
	var bodyScrollY = window.parent.work.document.body.scrollTop;

	var posX = window.parent.work.document.all("divalt").style.posLeft;
	var posY = window.parent.work.document.all("divalt").style.posTop;

	var divWidth = window.parent.work.document.all("divalt").offsetWidth;
	var divHeight = window.parent.work.document.all("divalt").offsetHeight;

	var divCenterX = posX + (divWidth / 2);
	var divCenterY = posY - (divHeight / 2);

	if(mouseX <= divCenterX)
	{
		posX = mouseX + 20;
		if((posX+divWidth) >= bodyScrollX + bodyWidth )
		{
			posX = mouseX - 20 - divWidth;
		}
	}
	else
	{
		posX = mouseX - 20 - divWidth;
		if(posX < bodyScrollX)
		{
			posX = mouseX + 20;
		}
	}
	if(mouseY >= divCenterY)
	{
		posY = mouseY + 20;
		if(( posY + divHeight ) >= bodyScrollY + bodyHeight )
		{
			posY = mouseY - 20 - divHeight;
		}
	}
	else
	{
		posY = mouseY - 20 - divHeight;
		if( posY  <= bodyScrollY)
		{
			posY = mouseY + 20;
		}
	}

	window.parent.work.document.all("divalt").style.posLeft = posX;
	window.parent.work.document.all("divalt").style.posTop = posY;
	window.parent.work.document.all("divalt").style.visibility = 'visible';

}


function SVG_HideAltCon()
{
	if(window.parent.work.document.all("divalt"))
	{
		window.parent.work.document.all("divalt").style.visibility = 'hidden';
	}
}


function SVG_ScrollbyMouseDragOnMD()
{
	if((document.body.clientWidth) >= event.clientX && (document.body.clientHeight >= event.clientY))
	{
		gSMDOfsetX = event.clientX;
		gSMDOfsetY = event.clientY;
		gSMDScLeft = document.body.scrollLeft;
		gSMDScTop = document.body.scrollTop;
		gSMDMoving = true;
		event.returnValue = false;
		event.cancelBubble = true;
		document.body.style.cursor = "move";
		return false;
	}

}


function SVG_ScrollbyMouseDragOnMM()
{
	if(gSMDMoving)
	{
		var nScLeft = gSMDScLeft - (event.clientX - gSMDOfsetX);
		var nScTop = gSMDScTop  - (event.clientY - gSMDOfsetY);
		document.body.scrollLeft = nScLeft;
		document.body.scrollTop = nScTop;
		document.body.style.cursor = "move";
	}
	else
	{
		document.body.style.cursor = "default";
	}

}


function SVG_ScrollbyMouseDragOnMU()
{
	if(gSMDMoving)
	{
		gSMDMoving = false;
		event.returnValue = false;
		event.cancelBubble = true;
		document.body.style.cursor = "default";

		return false;
	}

}

function SVG_ScrollbyMouseDragOnMO()
{
	gSMDMoving = false;

}


function SVG_ScrollbyMoseDragOnCM()
{
	return false;
}

function SVG_ScrollbyMoseDragOnSS()
{
	return false;
}

function Cal_Mag(magni)
{
	var FigSizeIndex = 0;


	if(magni < 0.45)
	{
		FigSizeIndex = -1;
	}
	else if((magni == 0.45) || ((magni > 0.45) && (magni < 0.5)))
	{
		FigSizeIndex = 0;
	}
	else if((magni == 0.5) || ((magni > 0.5) && (magni < 0.75)))
	{
		FigSizeIndex = 1;
	}
	else if((magni == 0.75) || ((magni > 0.75) && (magni < 1.0)))
	{
		FigSizeIndex = 2;
	}
	else if((magni == 1.0) || ((magni > 1.0) && (magni < 1.25)))
	{
		FigSizeIndex = 3;
	}
	else if((magni == 1.25) || ((magni > 1.25) && (magni < 1.5)))
	{
		FigSizeIndex = 4;
	}
	else if((magni == 1.5) || ((magni > 1.5) && (magni < 1.75)))
	{
		FigSizeIndex = 5;
	}
	else if(magni >= 1.75)
	{
		FigSizeIndex = 6;
	}

	return FigSizeIndex;

}
