<!--
var fileLoaded = 1;
var SVGElem = null;
var hilite_elem = new Array();
var lastEvent = "";
var lastSelectedButton = "";
var ccHotspotLayer = null;
var ccRectLayer = null;
var outerWidth = 0;
var outerHeight = 0;
var innerWidth = 0;
var innerHeight = 0;
var originalScale = 1;
var originalTranslateX = 0;
var originalTranslateY = 0;

var UNI = 0;
var SUB = 1;
var NOSUB = 2;

var styleForPartsWoSub = new Array();
var styleForPartsWithSub = new Array();
var styleForClickedParts = new Array();
var styleForTextsWoSub = new Array();
var styleForTextsWithSub = new Array();
var styleForClickedTexts = new Array();

var currentToolBarFunction = null;
var originalViewbox = new Array(4);
var rootElement = null;
var zoomFactor = 2;
var startPoint;
var startX  = null; 
var startY  = null; 
var pathElement;

// executes on load of html page
function register2(doc)
{
	// add mouse events
	var element = doc.getElementById("CC_HOTSPOT");
	ccHotspotLayer = element;
	element.removeAttribute("id");

	// read hotspot styles
	if (document.styleSheets)   // IE
	{
		//alert(document.styleSheets[0].href);
		var rules;
		var rulesArr;
		var keyValuePair;
		for (i=0; i<document.styleSheets[0].rules.length; i++)
			if (document.styleSheets[0].rules.item(i).selectorText == ".part_wo_sub")
			{
				rules = document.styleSheets[0].rules.item(i).style.cssText;
				rulesArr = rules.split(";");
				for (j=0; j<rulesArr.length; j++)
				{
					keyValuePair = rulesArr[j].split(":");
					key = keyValuePair[0].replace(/\s+/g,"");
					value = keyValuePair[1].replace(/\s+/g,"");
					styleForPartsWoSub[j] = key + ":" + value;
				}
			}
			else if (document.styleSheets[0].rules.item(i).selectorText == ".part_with_sub")
			{
				rules = document.styleSheets[0].rules.item(i).style.cssText;
				rulesArr = rules.split(";");
				for (j=0; j<rulesArr.length; j++)
				{
					keyValuePair = rulesArr[j].split(":");
					key = keyValuePair[0].replace(/\s+/g,"");
					value = keyValuePair[1].replace(/\s+/g,"");
					styleForPartsWithSub[j] = key + ":" + value;
				}
			}
			else if (document.styleSheets[0].rules.item(i).selectorText == ".clicked_part")
			{
				rules = document.styleSheets[0].rules.item(i).style.cssText;
				rulesArr = rules.split(";");
				for (j=0; j<rulesArr.length; j++)
				{
					keyValuePair = rulesArr[j].split(":");
					key = keyValuePair[0].replace(/\s+/g,"");
					value = keyValuePair[1].replace(/\s+/g,"");
					styleForClickedParts[j] = key + ":" + value;
				}
			}
			else if (document.styleSheets[0].rules.item(i).selectorText == ".text_wo_sub")
			{
				rules = document.styleSheets[0].rules.item(i).style.cssText;
				rulesArr = rules.split(";");
				for (j=0; j<rulesArr.length; j++)
				{
					keyValuePair = rulesArr[j].split(":");
					key = keyValuePair[0].replace(/\s+/g,"");
					value = keyValuePair[1].replace(/\s+/g,"");
					styleForTextsWoSub[j] = key + ":" + value;
				}
			}
			else if (document.styleSheets[0].rules.item(i).selectorText == ".text_with_sub")
			{
				rules = document.styleSheets[0].rules.item(i).style.cssText;
				rulesArr = rules.split(";");
				for (j=0; j<rulesArr.length; j++)
				{
					keyValuePair = rulesArr[j].split(":");
					key = keyValuePair[0].replace(/\s+/g,"");
					value = keyValuePair[1].replace(/\s+/g,"");
					styleForTextsWithSub[j] = key + ":" + value;
				}
			}
			else if (document.styleSheets[0].rules.item(i).selectorText == ".clicked_text")
			{
				rules = document.styleSheets[0].rules.item(i).style.cssText;
				rulesArr = rules.split(";");
				for (j=0; j<rulesArr.length; j++)
				{
					keyValuePair = rulesArr[j].split(":");
					key = keyValuePair[0].replace(/\s+/g,"");
					value = keyValuePair[1].replace(/\s+/g,"");
					styleForClickedTexts[j] = key + ":" + value;
				}
			}
			else if (document.styleSheets[0].rules.item(i).selectorText == ".svgbutton_pressed")
			{
				styleForSvgButton = document.styleSheets[0].rules.item(i).style.cssText;
			}
	}
	else   // Netscape
	{
		// instead of using dashes write next letter in uppercase!
		i = 0;
		var repl;
		var ausdruck = /([A-Z])/
		var zeichen;
		for (var Eigenschaft in document.classes.part_wo_sub.all)
		{
			ausdruck.exec(Eigenschaft);
			zeichen = "-" + RegExp.$1.toLowerCase();
			repl = Eigenschaft.replace(/[A-Z]/, zeichen);
			styleForPartsWoSub[i] = repl + ":" + document.classes.part_wo_sub.all[Eigenschaft];
			i++;
		}
		i = 0;
		for (var Eigenschaft in document.classes.part_with_sub.all)
		{
			ausdruck.exec(Eigenschaft);
			zeichen = "-" + RegExp.$1.toLowerCase();
			repl = Eigenschaft.replace(/[A-Z]/, zeichen);
			styleForPartsWithSub[i] = repl + ":" + document.classes.part_with_sub.all[Eigenschaft];
			i++;
		}
		i = 0;
		for (var Eigenschaft in document.classes.clicked_part.all)
		{
			ausdruck.exec(Eigenschaft);
			zeichen = "-" + RegExp.$1.toLowerCase();
			repl = Eigenschaft.replace(/[A-Z]/, zeichen);
			styleForClickedParts[i] = repl + ":" + document.classes.clicked_part.all[Eigenschaft];
			i++;
		}
		i = 0;
		for (var Eigenschaft in document.classes.text_wo_sub.all)
		{
			ausdruck.exec(Eigenschaft);
			zeichen = "-" + RegExp.$1.toLowerCase();
			repl = Eigenschaft.replace(/[A-Z]/, zeichen);
			styleForTextsWoSub[i] = repl + ":" + document.classes.text_wo_sub.all[Eigenschaft];
			i++;
		}
		i = 0;
		for (var Eigenschaft in document.classes.text_with_sub.all)
		{
			ausdruck.exec(Eigenschaft);
			zeichen = "-" + RegExp.$1.toLowerCase();
			repl = Eigenschaft.replace(/[A-Z]/, zeichen);
			styleForTextsWithSub[i] = repl + ":" + document.classes.text_with_sub.all[Eigenschaft];
			i++;
		}
		i = 0;
		for (var Eigenschaft in document.classes.clicked_text.all)
		{
			ausdruck.exec(Eigenschaft);
			zeichen = "-" + RegExp.$1.toLowerCase();
			repl = Eigenschaft.replace(/[A-Z]/, zeichen);
			styleForClickedTexts[i] = repl + ":" + document.classes.clicked_text.all[Eigenschaft];
			i++;
		}
	}
	
	// initialize toolbar for zooming, panning, print
	initZoomAndPan();
}

function initZoomAndPan()
{
	if (!document.SVGEmbed)
		return;
	var doc = document.SVGEmbed.getSVGDocument();
	if (!doc) 
		return false;
	
	rootElement = doc.getDocumentElement();

	var viewbox = getViewBoxArray();
	var rectElement = doc.getElementById("CC_RECT");
	if (rectElement == null)
	{
        rectElement = doc.createElement("rect");
        rectElement.setAttribute("id", "CC_RECT");
        rectElement.setAttribute("x", viewbox.x - 1000);
        rectElement.setAttribute("y", viewbox.y - 1000);
        rectElement.setAttribute("width",  viewbox.width + 2000);
        rectElement.setAttribute("height", viewbox.height + 2000);
        rectElement.setAttribute("style", "stroke: black; stroke-width: 1pt; fill:white; opacity:0.0");
        if (ccHotspotLayer)
			ccHotspotLayer.parentNode.insertBefore(rectElement, ccHotspotLayer);
		else
			rootElement.appendChild(rectElement);
	}
	ccRectLayer = rectElement;
	rectElement.addEventListener("mousedown", mouseDownFunction, false);
	rectElement.addEventListener("mouseup", mouseUpFunction, false);
	rectElement.addEventListener("mousemove", mouseMoveFunction, false);
	
	originalViewbox.x = viewbox.x;
	originalViewbox.y = viewbox.y;
	originalViewbox.width = viewbox.width;
	originalViewbox.height = viewbox.height;
	
	originalScale = rootElement.getCurrentScale();
	originalTranslateX = rootElement.currentTranslate.x;
	originalTranslateY = rootElement.currentTranslate.y;

	outerWidth = document.SVGEmbed.offsetWidth;
	outerHeight = document.SVGEmbed.offsetHeight;
	innerWidth  = parseFloat(rootElement.getAttribute("width"));
	innerHeight = parseFloat(rootElement.getAttribute("height"));
}

function getObj(mouseEvent) 
{
	SVGElem = mouseEvent.getTarget()
	var thisType = SVGElem.getTagName()
	// make sure we've parsed up to the text element level
	while (SVGElem.getAttribute('id') == "") {
		if (thisType == "svg")
		{
			SVGElem = null;
			return;
		}
		
		SVGElem = SVGElem.getParentNode()
		thisType = SVGElem.getTagName()
	}
}


// executes on mouseover of hotspot in svg
function showHs(mouseEvent)
{
	getObj(mouseEvent)
	if (SVGElem == null)
		return;
	var hotspot = SVGElem.getAttribute('id');
	if (SVGElem.getAttribute("clicked") == "1")
		return;
	
	var elemArr = new Array();
	elemArr = findAllElements("id", hotspot);

	var found = false;
	for (i=0; i<PartsName.length; i++)
		if ( (PartsHs[i] == hotspot) && (PartsRef[i] != '') )
		{
			for (part=0; part<elemArr.length; part++)
				tree_walk(elemArr[part], SUB, "set", elemArr[part].getTagName());
			found = true;
			break;
		}
	if (!found)
		for (part=0; part<elemArr.length; part++)
			tree_walk(elemArr[part], NOSUB, "set", elemArr[part].getTagName());
	lastEvent = "mouseover";
}



// executes on mouseout of hotspot in svg
function hideHs(mouseEvent)
{
	getObj(mouseEvent)
	if (SVGElem == null)
		return;

	var hotspot = SVGElem.getAttribute('id');
	if (SVGElem.getAttribute("clicked") == "1")
		return;
	var elemArr = new Array();
	elemArr = findAllElements("id", hotspot);
	if (lastEvent == "click")
		return;
	for (part=0; part<elemArr.length; part++)
		tree_walk(elemArr[part], SUB, "reset", "");
	lastEvent = "mouseout";
}




// executes on mouse-click in svg
function showPart(mouseEvent)
{
	getObj(mouseEvent)
	if (SVGElem == null)
		return;
	var id = SVGElem.getAttribute('id')

	if (hilite_elem.length > 0)
	{
		resetAllElementsStyle(hilite_elem);
		hilite_elem = new Array();
	}

	hilite_elem = findAllElements("id", id);
	setAllElementsStyle(hilite_elem);


	// on double-click open sub-assembly
	if (mouseEvent.detail == 2)
	{
		for (i=1; i<=PartsHs.length; i++)
			if (PartsHs[i] == id)
			{
				if (PartsRef[i] != '')
					goToAssembly(i);
				break;
			}
	}
	else
	{
		writeFstLine(id);
		if (!hiliteAndScrollRow(id))
		{
			// work-around for Illustrator10
			var idLen = id.length;
			if ( (id.substr(idLen-1,1) == '_') && (id.substr(idLen-3,1) == '_') )
			{
				newId = id.substr(0, idLen-3);
				hiliteAndScrollRow(newId)
			}
		}
	}
	lastEvent = "click";
}


// executes when user clicks on radio button in parts table
function ShowObject(id)
{
	if (hilite_elem.length > 0)
	{
		resetAllElementsStyle(hilite_elem);
		hilite_elem = new Array();
	}
	doc = document.SVGEmbed.getSVGDocument();
	hilite_elem = findAllElements("id", id);
	setAllElementsStyle(hilite_elem);

	writeFstLine(id);
	hiliteAndScrollRow(id);
	lastEvent = "click";
}



// style functions
function setElementStyle(elem, type, nodeType)
{
	if (elem.getAttribute("cc_old_style").length == 0)
	{
		// attribute is not yet set
		var style = elem.getAttribute("style");
		if (style == "")
			style = "stroke-color:inherit";
		elem.setAttribute("cc_old_style", style);
	}

	style = elem.getStyle();
	var key;
	var value;
	if (type == NOSUB)
	{
		if (nodeType == "text")
			for (i=0; i<styleForTextsWoSub.length; i++)
			{
				pair = styleForTextsWoSub[i].split(":");
				style.setProperty(pair[0],pair[1]);
			}
		else
			for (i=0; i<styleForPartsWoSub.length; i++)
			{
				pair = styleForPartsWoSub[i].split(":");
				style.setProperty(pair[0],pair[1]);
			}
	}
	else if (type == SUB)
	{
		if (nodeType == "text")
			for (i=0; i<styleForTextsWithSub.length; i++)
			{
				pair = styleForTextsWithSub[i].split(":");
				style.setProperty(pair[0],pair[1]);
			}
		else
			for (i=0; i<styleForPartsWithSub.length; i++)
			{
				pair = styleForPartsWithSub[i].split(":");
				style.setProperty(pair[0],pair[1]);
			}
	}
	else
	{
		if (nodeType == "text")
			for (i=0; i<styleForClickedTexts.length; i++)
			{
				pair = styleForClickedTexts[i].split(":");
				style.setProperty(pair[0],pair[1]);
			}
		else
			for (i=0; i<styleForClickedParts.length; i++)
			{
				pair = styleForClickedParts[i].split(":");
				style.setProperty(pair[0],pair[1]);
			}
	}
}


function resetElementStyle(elem)
{
	var style = elem.getAttribute("cc_old_style");
	if (style)
	{
		elem.removeAttribute("cc_old_style");
		elem.setAttribute("style", style);
	}
}


function setAllElementsStyle(elemArr)
{
	for (ii=0; ii<elemArr.length; ii++)
	{
		elemArr[ii].setAttribute("clicked", "1");
		tree_walk(elemArr[ii], UNI, "set", elemArr[ii].getTagName());
	}
}


function resetAllElementsStyle(elemArr)
{
	for (i=0; i<elemArr.length; i++)
	{
		if (elemArr[i].getAttribute("clicked") != "")
			elemArr[i].removeAttribute("clicked");
		tree_walk(elemArr[i], 0, "reset", "");
	}
}


function setButtonStyle(id)
{
	if (document.getElementById)
	{
		resetLastButtonStyle();
		var button;
		button = document.getElementById(id);
		button.className = "svgbutton_pressed";
		lastSelectedButton = id;
	}
}

function resetButtonStyle(id)
{
	if (document.getElementById)
	{
		var button = document.getElementById(id);
		button.className = "svgbutton";
		lastSelectedButton = "";
	}
}

function resetLastButtonStyle()
{
	if (lastSelectedButton != "")
	{
		var button = document.getElementById(lastSelectedButton);
		button.className = "svgbutton";
		lastSelectedButton = "";
	}
}

function removeAttr(attr, value)
{
	var elemArr = findAllElements(attr, value);
	for (i=0; i<elemArr.length; i++)
		elemArr[i].removeAttribute(attr);
}


// find selected element when more than one element with the same id exists
function findElement(document, attr)
{
	var elem = document.getElementById(attr);
	var part;
	var found = 0;
	if ( (elem.getAttribute("cc_hotspot_id") != "1") && (ccHotspotLayer) )
	{
		var list = ccHotspotLayer.getChildNodes();
		for (i=0; i<list.length; i++)
		{
			part = list.item(i);
			if ( (part.getNodeType() == 1) && (part.getAttribute("id") == attr) && (part.getAttribute('cc_hotspot_id') == "1") )
			{
				elem = part;
				found = 1;
				break;
			}
		}
		// work-around for Illustrator 10
		if (!found)
		{
			list = ccHotspotLayer.getElementsByTagName("text")
			for (i=0; i<list.length; i++)
			{
				part = list.item(i);
				if ( (part.getNodeType() == 1) && (part.getAttribute("id") == attr) && (part.getAttribute('cc_hotspot_id') == "1") )
				{
					elem = part;
					break;
				}
			}
		}
	}
	return elem;
}

// find all elements when more than one element with the same id exists
function findAllElements(attr, value)
{
	var elemList = new Array();
	if (value=="")
		return elemList;
	var cnt = 0;
	var part;
	if (ccHotspotLayer)
	{
		//var list = ccHotspotLayer.getElementsByTagName("text")
		var list = ccHotspotLayer.getChildNodes();
		for (i=0; i<list.length; i++)
		{
			part = list.item(i);
			if (part.getNodeType() == 1)
			{
				var val = part.getAttribute(attr);
				if (val != "")
				{
					if ((value == "NULL") || (part.getAttribute(attr) == value))
					{
						elemList[cnt] = part;
						cnt = cnt + 1;
					}
				}
			}
		}
		// work-around for Illustrator 10
		if (!cnt)
		{
			list = ccHotspotLayer.getElementsByTagName("text")
			for (i=0; i<list.length; i++)
			{
				part = list.item(i);
				if ( (part.getNodeType() == 1) && ((value == "NULL") || (part.getAttribute(attr) == value)) )
				{
					elemList[cnt] = part;
					cnt = cnt + 1;
				}
			}
		}
	}
	return elemList;
}


//recursion-tracking variables
var depth=0;
var depthList = new Array();
var nodeTypeList = new Array();

function tree_walk(node, type, fct, nodeType)
{
	nodeTypeList[depth]=nodeType;
	if (fct == "set")
		setElementStyle(node, type, nodeType)
	if (fct == "reset")
		resetElementStyle(node);
	for (current=0; current<node.childNodes.length; current++)
	{
  		child = node.childNodes.item(current);
		if (child.nodeType == 1)
		{
  			nodeType = child.getTagName();
			if (nodeTypeList[depth] == "text")
				nodeTypeList[depth+1]="text";
			else
				nodeTypeList[depth+1]=nodeType;
			if (fct == "set")
				setElementStyle(child, type, nodeTypeList[depth+1])
			if (fct == "reset")
				resetElementStyle(child);
			if (child.hasChildNodes) 
			{
				depthList[depth]=current;
				depth=depth+1;
				tree_walk(child, type, fct, nodeTypeList[depth]);
				depth=depth-1;
				current=depthList[depth];
			}	
		}
	}
}

var neuesFenster=null;
// executes when user clicks on toolbar button
function toolBar(mode)
{
	if (document.SVGEmbed == null)
		return;
		
	startX = null; 
	startY = null; 

	if( mode == "zoomIn")
	{
		if(currentToolBarFunction == "zoomIn")
		{
			currentToolBarFunction = null;
			resetButtonStyle("zoomin");
			return;
		}
		currentToolBarFunction = "zoomIn";
		setButtonStyle("zoomin");
	}
	else if (mode == "zoomOutA")
	{
		currentToolBarFunction = null;
		setButtonStyle("zoomout");
		var viewboxArray = getViewBoxArray();
		viewboxArray.x = viewboxArray.x + viewboxArray.width*(1-zoomFactor) / 2;
   		viewboxArray.y = viewboxArray.y + viewboxArray.height*(1-zoomFactor) / 2;
		viewboxArray.width *= zoomFactor;
		viewboxArray.height *= zoomFactor;
		setViewBox(viewboxArray);
	}
	else if (mode == "zoomOutE")
	{
		currentToolBarFunction = null;
		resetLastButtonStyle();
	}
	else if (mode == "zoomInWindow")
	{
		if (currentToolBarFunction == "zoomInWindow")
		{
			currentToolBarFunction = null;
			resetButtonStyle("zoominwindow");
			return;
		}
		currentToolBarFunction = "zoomInWindow";
		setButtonStyle("zoominwindow");
	}
	else if (mode == "homeViewA")
	{
		currentToolBarFunction = null;
		setButtonStyle("homeview");
		rootElement.setCurrentScale(originalScale);
		rootElement.currentTranslate.x = originalTranslateX;
		rootElement.currentTranslate.y = originalTranslateY;
		setViewBox(originalViewbox);
	}
	else if (mode == "homeViewE")
	{
		currentToolBarFunction = null;
		resetLastButtonStyle();
	}
	else if (mode == "pan")
	{
		if (currentToolBarFunction == "pan")
		{
			currentToolBarFunction = null;
			resetButtonStyle("pan");
			return;
		}
		currentToolBarFunction = "pan";
		setButtonStyle("pan");
	}
	else if (mode == "showAllHotspots")
	{
		currentToolBarFunction = null;
		setButtonStyle("showall");
		var elemArr = new Array();
		elemArr = findAllElements("id", "NULL");

		for (iElem=0; iElem<elemArr.length; iElem++)
		{
			for (part=1; part<PartsName.length; part++)
				if (elemArr[iElem].id == PartsHs[part])
				{
					if (PartsRef[part] != '')
						tree_walk(elemArr[iElem], SUB, "set", elemArr[iElem].getTagName());
					else
						tree_walk(elemArr[iElem], NOSUB, "set", elemArr[iElem].getTagName());
				}
		}
	}
	else if (mode == "hideAllHotspots")
	{
		currentToolBarFunction = null;
		resetButtonStyle("showall");
		var elemArr = new Array();
		elemArr = findAllElements("id", "NULL");
		for (part=0; part<elemArr.length; part++)
			tree_walk(elemArr[part], SUB, "reset", "");
	}
}

// functions connected with mouse events (for zooming, panning, ...)
function mouseDownFunction(mouseEvent)
{
	if ((currentToolBarFunction == null) || (rootElement == null))
		return;
	if (mouseEvent.button != 0)	// continue when lmb
		return;
	var doc = document.SVGEmbed.getSVGDocument();
	if (doc == null)
		return;

	if (currentToolBarFunction == "zoomIn")
	{
		var viewboxArray = getViewBoxArray();
		viewboxArray.x = viewboxArray.x + (mouseEvent.clientX-rootElement.currentTranslate.x) * (viewboxArray.width)/(outerWidth*rootElement.currentScale) - (viewboxArray.width / zoomFactor)/ 2; 
		viewboxArray.y = viewboxArray.y + (mouseEvent.clientY-rootElement.currentTranslate.y) * (viewboxArray.height)/(outerHeight*rootElement.currentScale) -  (viewboxArray.height / zoomFactor)/ 2; 
		viewboxArray.width /= zoomFactor;
		viewboxArray.height /= zoomFactor;
		setViewBox(viewboxArray);
	}
	else if (currentToolBarFunction == "pan")
	{
		if (ccRectLayer)
			rootElement.appendChild(ccRectLayer);

		startX = mouseEvent.clientX;
		startY = mouseEvent.clientY;
	}
	else if (currentToolBarFunction == "zoomInWindow")
	{
		if (ccRectLayer)
			rootElement.appendChild(ccRectLayer);
		
		var viewbox = getViewBoxArray();
		startX =  mouseEvent.clientX; 
		startY =  mouseEvent.clientY;
		var scaleX = viewbox.width / outerWidth;  
		var scaleY = viewbox.height / outerHeight; 
		
		// create a rectangle to show selected window
		if (pathElement != null)
		{
        	rootElement.removeChild(pathElement);
			pathElement = null;
			startX = null;
			startY = null;
			return;
		}

		// create the rectangle
		var doc = document.SVGEmbed.getSVGDocument();
        pathElement = doc.createElement("path");
		if (scaleX >= scaleY)
		{
            x = (startX - rootElement.currentTranslate.x) * scaleX / rootElement.currentScale + viewbox.x;
            y = (startY - rootElement.currentTranslate.y) * scaleX / rootElement.currentScale + viewbox.y + (viewbox.height - outerHeight * scaleX) / 2;
		}
		else 
		{
            x = (startX - rootElement.currentTranslate.x) * scaleY / rootElement.currentScale + viewbox.x + (viewbox.width - outerWidth * scaleY) / 2;
            y = (startY - rootElement.currentTranslate.y) * scaleY / rootElement.currentScale + viewbox.y;
		}
        startPoint = "M" + x + " " + y;
        pathElement.setAttribute("d", startPoint + "h1v1h-1z");
		var style = "stroke: black; stroke-width:" + (viewbox.width / outerWidth) + "; fill:none";
        pathElement.setAttribute("style", style);
        rootElement.appendChild(pathElement);
		pathElement.addEventListener("mouseup", mouseUpFunction, false);
		pathElement.addEventListener("mousemove", mouseMoveFunction, false);
	}
}

function mouseMoveFunction(mouseEvent)
{
	if ((currentToolBarFunction == null) || (rootElement == null))
		return;
	if (startX == null || startY == null)
		return;
		
	var viewboxArray = getViewBoxArray();
	var scaleX = viewboxArray.width / outerWidth;  
	var scaleY = viewboxArray.height / outerHeight;  
		
	if (currentToolBarFunction == "pan") 
	{
		var diffX = startX - mouseEvent.clientX;
		var diffY = startY - mouseEvent.clientY;
		startX = mouseEvent.clientX; 
		startY = mouseEvent.clientY; 
		viewboxArray.x = viewboxArray.x + (diffX * scaleX * rootElement.currentScale); 
		viewboxArray.y = viewboxArray.y + (diffY * scaleY * rootElement.currentScale); 
		setViewBox(viewboxArray);
	}
	else if (currentToolBarFunction == "zoomInWindow") 
	{
		if (pathElement != null)
		{
			var width, height;
			if (scaleX >= scaleY)
			{
				width  = (mouseEvent.clientX - startX) * scaleX;
				height = (mouseEvent.clientY - startY) * scaleX;
			}
			else
			{
				width  = (mouseEvent.clientX - startX) * scaleY;
				height = (mouseEvent.clientY - startY) * scaleY;
			}
			pathElement.setAttribute("d", startPoint + "h" + width + "v" + height + "h" + (width * -1) + "z");
        }
	}
}

function mouseUpFunction(mouseEvent)
{
	if ((currentToolBarFunction == null) || (rootElement == null))
		return;
	if (currentToolBarFunction == "pan" || startX == null || startY == null)
	{
        if (ccRectLayer && ccHotspotLayer)
			ccHotspotLayer.parentNode.insertBefore(ccRectLayer, ccHotspotLayer);

		startX = null; 
		startY = null; 
	}
	else if  (currentToolBarFunction == "zoomInWindow")
	{
        if (ccRectLayer && ccHotspotLayer)
			ccHotspotLayer.parentNode.insertBefore(ccRectLayer, ccHotspotLayer);

		var X = mouseEvent.clientX;
		var Y = mouseEvent.clientY;

		var viewbox = getViewBoxArray();
		var scaleX = viewbox.width / outerWidth;  
		var scaleY = viewbox.height / outerHeight;  
		rootElement.removeChild(pathElement);
		pathElement = null;

		// determine scale and displacement
		var zoomX = Math.abs((startX - X) / outerWidth); 
		var zoomY = Math.abs((startY - Y) / outerHeight);
		var zoom = Math.max(zoomX, zoomY);
		// do not zoom if array is too small
		if ((zoom*scaleX) < 0.005)
		{
			startX = null; 
			startY = null; 
			return;
		}
		xp = Math.abs(startX + (X - startX)/2);
		yp = Math.abs(startY + (Y - startY)/2);
		if (scaleX > scaleY)
		{ 			
			viewbox.x = viewbox.x + (xp - rootElement.currentTranslate.x) * scaleX / rootElement.currentScale -  (viewbox.width * zoom) / 2; 
			viewbox.y = viewbox.y + (yp - rootElement.currentTranslate.y) * scaleX / rootElement.currentScale -  (viewbox.height * zoom) / 2 + (viewbox.height - outerHeight * scaleX)/2; 
		}
		else
		{
			viewbox.x = viewbox.x + (xp - rootElement.currentTranslate.x) * scaleY / rootElement.currentScale -  (viewbox.width * zoom) / 2 + (viewbox.width - outerWidth * scaleY)/2; 
			viewbox.y = viewbox.y + (yp - rootElement.currentTranslate.y) * scaleY / rootElement.currentScale -  (viewbox.height * zoom) / 2; 
		}
		viewbox.width *= zoom;
		viewbox.height *= zoom;
		setViewBox(viewbox);
		startX = null; 
		startY = null; 
	}
}

function getViewBoxArray()
{
	if (rootElement)
	{
		var viewbox = rootElement.getAttribute("viewBox");
		var viewBoxArray = new Array(4);
		if (viewbox != "") {
			var params = viewbox.split(/\s*,\s*|\s+/);
			viewBoxArray.x      = parseFloat(params[0]);
			viewBoxArray.y      = parseFloat(params[1]);
			viewBoxArray.width  = parseFloat(params[2]);
			viewBoxArray.height = parseFloat(params[3]);
		}
		else
		{
			viewBoxArray.x      = 0;
			viewBoxArray.y      = 0;
			viewBoxArray.width  = innerWidth;
			viewBoxArray.height = innerHeight;
		}
		return viewBoxArray;
	}
}

function setViewBox(viewBoxArray)
{
	if (rootElement)
		rootElement.setAttribute("viewBox", viewBoxArray.x + " " + viewBoxArray.y + " " + viewBoxArray.width + " " + viewBoxArray.height);
}

//-->