/*
	ChromoViz's Javascript

	Creator : Hee Joon Chung
	Implement : 2003. 8. 19
	Modify  : 2003. 8. 21

	Current Version : v0.02
*/
	
	var curr_x;
	var flag = 0;
	function MovetoZero(svgName, checkobj)
	{
		var svgobj;
		var svgstyle;
		var x;
		var y;
		var info;
		var target_y;
		var dest_y = 158;
		var svgstyle;
		var animate;

		var svgdoc = eval("document."+svgName+".getSVGDocument()");
		var svgroot = svgdoc.getDocumentElement();
		svgobj = svgdoc.getElementById(checkobj.name);

		
		x = parseInt(svgobj.getAttribute("x"));
		y = parseInt(svgobj.getAttribute("y"));
		info = parseInt(svgobj.getAttribute("info"));

		target_y = dest_y - info;

		if (checkobj.checked)
		{
			svgobj.setAttribute("x", "0");
			svgobj.setAttribute("y", "0");
			svgstyle = svgobj.getStyle();
			svgobj.setAttribute("visibility", "visible");
			svgobj.setAttribute("y", target_y);

			if (flag == 0)
				svgstyle.setProperty("stroke", "yellow");

			else if (flag == 1)
				svgstyle.setProperty("stroke","blue");

			else if (flag == 2)
				svgstyle.setProperty("stroke", "green");
			flag++;
		}
		else
			svgobj.setAttribute("visibility", "hidden");
	}

	function FindAccNum(svgName)
	{
		var search_AccNum = document.FindData.accNum.value;

		var svgdoc = eval("document."+svgName+".getSVGDocument()");
		var svgroot = svgdoc.getDocumentElement();

		svgobj = svgdoc.getElementById(search_AccNum);

		if (svgobj == null)
			alert("No matche AccNum");
		else
		{
			svgstyle = svgobj.getStyle();

			var temp_x = parseFloat(svgobj.getAttribute("x"));
			var temp_y = parseFloat(svgobj.getAttribute("y"));
			var width = parseFloat(svgobj.getAttribute("width"));
			var height = parseFloat(svgobj.getAttribute("height"));
			var data,text,style;

			var circle, animate;

			var target_x = temp_x + (width/2.0);
			var target_y = temp_y + height;

			data = svgdoc.createTextNode(search_AccNum);
			text = svgdoc.createElement("text");

			text.setAttribute("x", target_x);
			text.setAttribute("y", target_y);
			style = text.getStyle();
			style.setProperty("fill","black");
			style.setProperty("fill-opacity", ".4");
			style.setProperty("text-anchor","middle");
			style.setProperty("font-size", "2pt");
			text.appendChild(data);
		
			svgroot.appendChild(text);

			circle = svgdoc.createElement("circle");
			circle.setAttribute("cx", target_x);
			circle.setAttribute("cy", target_y);
			circle.setAttribute("r", 5);
			
			style = circle.getStyle();
			style.setProperty("fill", "blue");
			style.setProperty("fill-opacity", ".4");

// Addtition Function
// Function : Animate keyword
			animate = svgdoc.createElement("animate");
			animate.setAttribute("attributeName", "r");
			animate.setAttribute("attributeType", "auto");
			animate.setAttribute("from", "20");
			animate.setAttribute("to", "3");
			animate.setAttribute("dur", "6s");
			animate.setAttribute("begin", "1s");
			animate.setAttribute("repeatCount", "indefinite");

			circle.appendChild(animate);
//Addition Function
			svgroot.appendChild(circle);
		}
	}
