////////////////////////////////////
// IMAGE MAP  FOR IE
///////////////////////////////////
function CImageMap(){
	this.container = null;
	this.containerWidth=0;
	this.containerHeight=0;
	this.image=null;
	this.upperDiv=null;
	this.imageWidth=0;
	this.imageHight=0;
	this.imagePah="";
	/* Init the Container for Map:
		id : id of the container
		width : width of the container
		height : height of the container
	*/
	this.init = function(container,width,height)
	{
		this.container = container;
		this.container.style.overflow="hidden";
		this.container.style.overflowX="hidden";
		this.container.style.overflowY="hidden";
		this.setSize(width,height);
		this.initImage(imageSrc,imageWidth,imageHeight);
	}
	/* Set size of the Map container
		w : width of the container
		h : height of the container
	*/
	this.setSize = function(w,h)
	{
		this.containerWidth = w;
		this.containerHeight = h;
		this.container.style.width=w+"px";
		this.container.style.height=h+"px";
		if (this.upperDiv)
		{
			this.setImagePosition(parseInt(this.upperDiv.style.left),parseInt(this.upperDiv.style.top));
			this.setCentered();
		}
	}
	/* Init the image inside the container
		path : path for the image
		width : width of the image
		height : height of the image
	*/
	this.initImage = function(path,width,height)
	{
		this.imagePath=path;
		this.imageWidth=width;
		this.imageHeight=height;
		this.upperDiv = document.createElement("DIV");
		this.upperDiv.id="transparentDiv";
		this.upperDiv.style.width=this.imageWidth+"px";
		this.upperDiv.style.height=this.imageHeight+"px";
		this.upperDiv.style.position="relative";
		this.upperDiv.style.background="url("+path+")";
		this.upperDiv.style.top="0px";
		this.upperDiv.style.left="0px";
		this.upperDiv.style.zIndex=101;
		this.upperDiv.style.padding=30;
		this.upperDiv = this.container.appendChild(this.upperDiv);
		this.upperDiv.imageMap=this;
		document.imageMap=this;
		this.upperDiv.onmousedown=function(e){this.imageMap.beginDrag(e);}
	}
	/*	Set image centered */
	this.setCentered = function()
	{
		if (this.imageWidth < this.containerWidth)
		{
			var left = Math.round((this.containerWidth-this.imageWidth)/2);
			this.upperDiv.style.left=left+"px";
		}

		if (this.imageHeight < this.containerHeight)
		{
			var top = Math.round((this.containerHeight-this.imageHeight)/2);
			this.upperDiv.style.top=top+"px";
		}
	}
	this.startX=0;
	this.startY=0;
	this.dragging = false;
	this.lastDocumentOnMouseUp=function(){};
	this.lastDocumentOnMouseMove=function(){};
	this.DEBUG="";
	this.beginDrag=function(e)
	{
		this.DEBUG+="Begin "+this.dragging+"\n";
		if (this.dragging) return;
		e = e || event;
		OImageMap.upperDiv.style.cursor="url(closedhand.cur), default;";
		
		this.lastDocumentOnMouseUp = document.body.onmouseup;
		this.lastDocumentOnMouseMove = document.body.onmousemove;
		document.onmousemove=function(e)
		{
			this.imageMap.onDragMove(e);
		}
		document.onmouseup=function(e)
		{
			this.imageMap.endDrag(e);
		}
		this.startX = e.clientX-parseInt(this.upperDiv.style.left);
		this.startY = e.clientY-parseInt(this.upperDiv.style.top);
		this.dragging=true;
	}
	this.endDrag=function(e)
	{
		OImageMap.upperDiv.style.cursor="url(openhand.cur), default;";
		this.DEBUG+="End "+this.dragging+"\n";
		document.onmouseup = this.lastDocumentOnMouseUp;
		document.onmousemove = this.lastDocumentOnMouseMove;
		this.dragging=false;
	}
	this.onDragMove=function(e)
	{
		e = e || event;
		if (!this.dragging) return;
		if ((document.all && e.button!=1)||(!document.all && e.button!=0))
		{
			this.endDrag();
			return;
		}
		var difX = e.clientX-this.startX;
		var difY = e.clientY-this.startY;
		this.setImagePosition(difX,difY);
		return false;
	}
	this.setImagePosition=function(difX,difY)
	{
		if (difX > 0) difX=0;
		if (difY > 0) difY=0;
		if (difX + this.imageWidth < this.containerWidth) difX=this.containerWidth-this.imageWidth;
		if (difY + this.imageHeight < this.containerHeight) difY=this.containerHeight-this.imageHeight;
		this.upperDiv.style.left=difX+"px";
		this.upperDiv.style.top=difY+"px";
		this.setCentered()
	}
	this.tempContainer = null;
	this.putSpotImage = function(x,y,src,title,href)
	{
		if (!this.tempContainer)
		{
			this.tempContainer = this.container.appendChild(document.createElement("DIV"));
			this.tempContainer.style.display="none";
		}
		var html = '<a style="position:absolute; z-index:10; top:'+y+'px; left:'+x+'px;" target="_blank" href="'+href+'"><img src="'+src+'" border="0" title="'+title+'" alt="'+title+'"></a>';
		this.tempContainer.innerHTML=html;
		this.upperDiv.appendChild(this.tempContainer.childNodes[0]);
	}
	this.getObject = function()
	{
		return this.upperDiv;
	}
	this.lines=[];
	this.addLine = function(line)
	{
		this.lines[this.lines.length]=line;
	}
	return this;
}


////////////////////////////////////
//Image MAP FOR SVG
///////////////////////////////////
var dragging = false;
var offset = null;
function Grab(evt){
	if (dragging) {
		Drop(evt);
		return;
	}	
	if (!offset)
		offset = SVGRoot.createSVGPoint();
	if (evt.target.tagName!='image') return;
	var matrix = SVGContainer.getCTM();
	var mouse = getMouse(evt);
	offset.x = matrix.e - mouse.x;
	offset.y = matrix.f - mouse.y;
	SVGContainer.style.cursor="url(closedhand.cur), default;";
	
	window.frames.SVGMap.window.onmouseup=function(){
		parent.Drop(evt);
		return;
	}
	window.onmouseup=function(){
		parent.Drop(evt);
		return;
	}
	dragging=true;
}
function Drag(evt){
	var mouse = getMouse(evt);
	var matrix = SVGContainer.getCTM();
	parent.TrackMouseCursorFF(mouse.x - matrix.e, mouse.y - matrix.f);
	
	
	if (!SVGRoot || !dragging) return;
	if (evt.button!=0) {
		Drop(evt);
		return;
	}
	
	

	var x = mouse.x + offset.x;
	var y = mouse.y + offset.y;
	x = x>0?0:x;
	y = y>0?0:y;
	x = x<window.frames.SVGMap.window.innerWidth-parseInt(SVGBg.getAttribute("width"))?window.frames.SVGMap.window.innerWidth-parseInt(SVGBg.getAttribute("width")):x;
	y = y<window.frames.SVGMap.window.innerHeight-parseInt(SVGBg.getAttribute("height"))?window.frames.SVGMap.window.innerHeight-parseInt(SVGBg.getAttribute("height")):y;
	SVGContainer.setAttribute('transform', 'translate(' + x + ',' + y + ')');
	setCentered();
}
function Drop(evt){
	dragging=false;
	SVGContainer.style.cursor="url(openhand.cur), default;";
}
function getMouse (evt) {
	var position = SVGRoot.createSVGPoint();
	position.x = evt.clientX;
	position.y = evt.clientY;
	return position;
}

function setCentered(isResize){
	if (!isResize) return;
	var matrix = SVGContainer.getCTM();
	var left=matrix.e?matrix.e:0;
	var top=matrix.f?matrix.f:0;
	if (imageWidth < window.frames.SVGMap.window.innerWidth){
		left = Math.round((window.frames.SVGMap.window.innerWidth-imageWidth)/2);

	}
	if (imageHeight < window.frames.SVGMap.window.innerHeight){
		top = Math.round((window.frames.SVGMap.window.innerHeight-imageHeight)/2);
	}

	if (-left > imageWidth - window.frames.SVGMap.window.innerWidth)
		left = -(imageWidth - window.frames.SVGMap.window.innerWidth);
	if (-top > imageHeight - window.frames.SVGMap.window.innerHeight)
		top = -(imageHeight - window.frames.SVGMap.window.innerHeight);

	SVGContainer.setAttribute('transform', 'translate(' + left + ',' + top + ')');
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
var OImageMap = null;
var isIE = document.all?true:false;
if (isIE) try { document.execCommand("BackgroundImageCache", false, true); } catch (e){}
function initMAP()
{
	//imageWidth = document.getElementById("container").firstChild.scrollWidth;
	//imageHeight = document.getElementById("container").firstChild.scrollHeight;
	if (isIE)
	{
		// IE
		OImageMap = new CImageMap();
		OImageMap.init(document.getElementById("container"),document.body.offsetWidth,document.body.offsetHeight);
		OImageMap.setImagePosition(-imageStartX,-imageStartY);
		document.getElementById("container").style.visibility="visible";
		OImageMap.upperDiv.appendChild(document.getElementById("subcontainer"))
		document.getElementById("subcontainer").style.display="block";
		OImageMap.upperDiv.style.cursor="url(openhand.cur), default;";
		//document.getElementById("container").removeChild(document.getElementById("container").firstChild);
	}
	else
	{
		//FF
		document.getElementById("container").style.display="none";
		document.getElementById("subcontainer").style.display="none";
		document.getElementById("subcontainer_svg").style.display="block";
		document.getElementById("subcontainer_svg").style.width=document.body.offsetWidth+"px";
		document.getElementById("subcontainer_svg").style.height=document.body.offsetHeight + "px";
		var elem = SVGDocument.createElementNS(SVGNS,'image');
		elem.setAttribute("x",0);
		elem.setAttribute("y",0);
		elem.setAttribute("width",imageWidth);
		elem.setAttribute("height",imageHeight);
		elem.setAttribute("pointer-events","all");
		elem.setAttributeNS(XLINKNS,"xlink:href",imageSrc);
		SVGBg=SVGContainer.appendChild(elem);
		SVGContainer.appendChild(SVGDocument.getElementById("subcontainer"));
		SVGContainer.setAttribute('transform', 'translate(' + -imageStartX + ',' + -imageStartY + ')');
		SVGContainer.style.cursor="url(openhand.cur), default;";
		//document.getElementById("container").removeChild(document.getElementById("container").firstChild);
		setCentered();
	}
	resize();
}
function resize(evt){
	if (isIE)
		var height = document.body.offsetHeight-getFullHeight(document.getElementById("container"))-FooterMargin;
	else
		var height = document.body.offsetHeight-getFullHeight(document.getElementById("subcontainer_svg"))-FooterMargin;
	if (height<0) height=0;
	if (isIE){
		OImageMap.setSize(document.body.offsetWidth,height);
	}else{
		var width = document.body.offsetWidth - FFMargin;
		document.getElementById("subcontainer_svg").style.width=width+"px";
		document.getElementById("subcontainer_svg").style.height=height + "px";
		SVGRoot.setAttribute("width",width+"px");
		SVGRoot.setAttribute("height",height+"px");
		setCentered(true);
	}
}
function getFullHeight(node){
	var result = 0;
	while(node && node!=document.body){
		result+=node.offsetTop;
		node=node.parentNode;
	}
	return result;
}
function TrackMouseCursor(e){
	e = e || window.event;
	if (e.srcElement && e.srcElement.id=='transparentDiv')
	  TrackMouseCursorFF(e.offsetX,e.offsetY);
	else
	 	TrackMouseCursorFF("empty");
}
function TrackMouseCursorFF(x,y){
  if (x!="empty")
	  document.getElementById("coordSite").innerHTML = x + ":" + y + " ";
  else
   	 document.getElementById("coordSite").innerHTML="&nbsp;";
}

function setStatusTag(obj, msg)
{
  if (document.getElementById(obj).innerText)
  {
    document.getElementById(obj).innerText = msg;
  }
  else
  {
    if (document.getElementById(obj).textContent)
    {
      document.getElementById(obj).textContent = msg;
    }
    else
    {
      alert("Error: This application does not support your browser. Try again using IE or Firefox.");
    }
  }
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var SVGNS = "http://www.w3.org/2000/svg";
var XLINKNS = "http://www.w3.org/1999/xlink";
var SVGDocument = null;
var SVGRoot = null;
var SVGBg = null;
var SVGContainer = null;
var VMLContainer = null;
var LinesObjects = {
  Lines : {},
  addLineToDocument:function(arPoints,id,deviceNumber,interfaceNumber,ipAddress,deviceName,interfaceDesc,color,size){
	   if (isIE){
			var l = document.createElement("v:polyline");
			l.points=arPoints.join(",");
			l.filled="false";
			l.id = id;
			l.href="javascript:void(0);";
			l.className="vml_line",
			l.opacity=1;
			l.strokecolor=color;
			l.strokeweight=size;
			this.Lines[id] = {object:VMLContainer.appendChild(l),line:0,lineLast:0,deviceNumber:deviceNumber,interfaceNumber:interfaceNumber,ipAddress:ipAddress,deviceName:deviceName,interfaceDesc:interfaceDesc};
	   }else{
			var l = SVGDocument.createElementNS(SVGNS,'polyline');
			l.setAttribute("points",arPoints.join(","));
			l.setAttribute("fill","none");
			l.setAttribute("cursor","pointer");
			l.setAttribute("id",id);
			l.setAttribute("stroke",color);
			l.setAttribute("stroke-width",size);
			l.setAttribute("pointer-events","all");
			this.Lines[id] = {object:SVGContainer.appendChild(l),line:0,lineLast:0,deviceNumber:deviceNumber,interfaceNumber:interfaceNumber,ipAddress:ipAddress,deviceName:deviceName,interfaceDesc:interfaceDesc};
	   }
	    this.Lines[id].object.onclick=function(e)
	    {
			var id = this.id||this.getAttribute("id");
			var l = LinesObjects.Lines[id];
			if (!l.MessageBox)
			{
				l.MessageBox =new MessageBox();
				l.MessageBox.init();
			}
			else
			{
				l.MessageBox.goToTop();
			}

	   		l.MessageBox.show(e,l.deviceNumber,l.interfaceNumber,l.ipAddress,l.deviceName,l.interfaceDesc);
		};
	},
	i:0,
	fetchValues_ajax:function(){
		setStatusTag("statustag", "Fetching data");
		var ajax = new AJAX(LinesObjects.fetchValues_ajax_callback,LinesObjects.fetchValues_ajax,AJAXUpdateTime);
		ajax.load(AJAXUpdateScript);
	},
	fetchValues_ajax_callback:function(obj){
		var result = eval(obj.xmlDoc.responseText);
		for (var id_part in result){
			var id = "line"+id_part;
			LinesObjects.Lines[id].lineLast=LinesObjects.Lines[id].line;
			LinesObjects.Lines[id].line=parseInt(result[id_part]);
			if (isIE)
				LinesObjects.Lines[id].object.title=LinesObjects.Lines[id].line + "%";
			else
				LinesObjects.Lines[id].object.setAttribute("title",LinesObjects.Lines[id].line + "%");
		}
		LinesObjects.i=1;
		LinesObjects.UpdateLines();
		setTimeout("LinesObjects.fetchValues_ajax()", AJAXUpdateTime);
	},
	fetchValues:function(){
		for (var id in this.Lines){
			this.Lines[id].lineLast=this.Lines[id].line;
			this.Lines[id].line=Math.floor(Math.random()*99);
			
			if (isIE)
				this.Lines[id].object.title=this.Lines[id].line + "%";
			else
				this.Lines[id].object.setAttribute("title",this.Lines[id].line + "%");
		}
		this.i=1;
		this.UpdateLines();
		setTimeout("LinesObjects.fetchValues()", AJAXUpdateTime);
	},
	UpdateLines:function(){
		for (var id in this.Lines){
			this.changeLine(this.Lines[id].line, this.Lines[id].lineLast, this.Lines[id].object);
		}
		this.i++;
		if(this.i < 7){
			setTimeout("LinesObjects.UpdateLines()", 150);
		}
		setStatusTag("statustag", ".");
	},
	getLineColor:function(Util){
		var HexColor;
		if (Util == -1){
			return "#333333";
		}else if (Util == -2){
			return "#FFFFFF";
		}else if (Util < 4){
			HexColor=Math.round(Util*255/50);
			return "#0" + HexColor.toString(16).toUpperCase() + "FF00";
		}else if (Util < 50){
			HexColor=Math.round(Util*255/50);
			return "#" + HexColor.toString(16).toUpperCase() + "FF00";
		}else if (Util < 97){
			HexColor=Math.round(255-((Util-50)*255/50));
			return "#FF" + HexColor.toString(16).toUpperCase() + "00";
		}else{
	    	HexColor=Math.round(255-((Util-50)*255/50));
			return "#FF0" + HexColor.toString(16).toUpperCase() + "00";
		}
	},
	getLineSize:function(Util){
		if (Util < 20)  { return 2; }
		if (Util < 50)  { return 3; }
		if (Util < 80)  { return 4; }
		return 5;
	},
	changeLine:function(Line, LineLast, LineObject){
		var LineCurr=LineLast;
		if (Line > LineLast){
			LineCurr = ((Line-LineLast)/6*this.i) + LineLast;
		}else{
			LineCurr = LineLast - ((LineLast-Line)/6*this.i);
		}
		if (isIE){
			LineObject.strokeweight=this.getLineSize(LineCurr);
			LineObject.strokecolor=this.getLineColor(LineCurr);
		} else {
			LineObject.setAttribute("stroke",this.getLineColor(LineCurr));
			LineObject.setAttribute("stroke-width",this.getLineSize(LineCurr));
		}
		return;
	}
}

function initContainers(){
	if (isIE){
		VMLContainer = document.getElementById("subcontainer");
	}else{
		SVGDocument = window.frames.SVGMap.document.getElementById("SVGDoc").ownerDocument;
		SVGRoot = window.frames.SVGMap.document.getElementById("SVGDoc");
		SVGContainer = SVGRoot.appendChild(SVGDocument.createElementNS(SVGNS,'g'));
	}
	window.onresize = resize;
}

function afterLoad(){
	//define the main JS variables
	initContainers();
	//create the movable map
	initMAP();
	//create the Libes on the map
	initLines();
	//start dynamic update of the lines
	if (DemoMode)
		LinesObjects.fetchValues();
	else	
		LinesObjects.fetchValues_ajax();
}

function MessageBox(){
	this.container=null;
	this.container_sh=null;
	this.container_data=null;
	this.init=function(){
		var container_sh = document.createElement("DIV");
		container_sh.style.position="absolute";
		container_sh.style.zIndex=1000;
		container_sh.className="shadow";
		this.container_sh = document.body.appendChild(container_sh);
		
		
		this.container = document.body.appendChild(document.getElementById("customMessageBox").cloneNode(true));
		this.container.id="";
		this.container.style.position="absolute";
		this.container.style.zIndex=1000;
		this.container_data = this.container.getElementsByTagName("TABLE")[1];
	};
	this.goToTop=function(){
		this.container_sh = document.body.appendChild(this.container_sh);
		this.container = document.body.appendChild(this.container);
		this.container_data = this.container.getElementsByTagName("TABLE")[1];
	}
	this.hide=function(){
		if (!this.container) return;
		this.container_sh.style.display="none";
		this.container.style.display="none";
	};
	this.show=function(e,deviceNumber,interfaceNumber,ipAddress,deviceName,interfaceDesc){
		e=e||window.event;
		var c = document.getElementById("subcontainer_svg");
		var extX = 0;
		var extY = 0;
		if (c.style.display!='none'){
			extX = c.offsetLeft;
			extY = getFullHeight(c);
		}
		this.container.style.visibility="hidden";
		this.container.style.display="block";
		var x = e.clientX+extX-Math.round(this.container.offsetWidth/2);
		var y = e.clientY+extY-Math.round(this.container.offsetHeight/2);
		if (x+this.container.offsetWidth > document.body.offsetWidth)
			x=document.body.offsetWidth-this.container.offsetWidth;
		x=x>0?x:0;
		if (y+this.container.offsetHeight > document.body.offsetHeight)
			y=document.body.offsetHeight-this.container.offsetHeight;
		y=y>0?y:0;
		this.fill(deviceNumber,interfaceNumber,ipAddress,deviceName,interfaceDesc);
		this.container.style.top=y+"px";
		this.container.style.left=x+"px";
		this.container.style.visibility="visible";
		this.container_sh.style.width = (this.container.offsetWidth)+"px";
		this.container_sh.style.height = (this.container.offsetHeight)+"px";
		this.container_sh.style.top=(y+10)+"px";
		this.container_sh.style.left=(x+10)+"px";
		this.container_sh.style.display="block";

	};
	var self = this;
	this.fill=function(deviceNumber,interfaceNumber,ipAddress,deviceName,interfaceDesc){
		this.container_data.rows[0].cells[3].firstChild.API = this;
//		this.container_data.rows[0].cells[1].firstChild.href = "telnet:"+ipAddress;
//		this.container_data.rows[0].cells[1].firstChild.innerHTML=ipAddress;
		this.container_data.rows[0].cells[1].innerHTML=ipAddress;
		this.container_data.rows[0].cells[2].firstChild.href="SwMonInt"+deviceNumber+"-"+interfaceNumber+"D.htm";
		this.container_data.rows[0].cells[2].firstChild.innerHTML=deviceName;
		this.container_data.rows[1].cells[1].firstChild.href="SwMonInt"+deviceNumber+"-"+interfaceNumber+"D.htm";
		this.container_data.rows[1].cells[1].firstChild.innerHTML="Int #"+interfaceNumber;
		this.container_data.rows[1].cells[2].innerHTML=interfaceDesc;
		
		var src = "Graphics/SwMonMapInt"+deviceNumber+"-"+interfaceNumber+".png?id="+(new Date()).valueOf();
		setTimeout(function(){
			self.container_data.rows[2].cells[0].innerHTML='<img src="'+src+'"/>';
		},1);
	};
}



///////////////////////////////////////////////////////////
///////////////// AJAX //////////////////////////////////
////////////////////////////////////////////////////////
function AJAX(funcObject,funcOnfail,timeout){
	this.xmlDoc=null;
	this.async = true;
	this.onloadAction=funcObject||null;
	this.funcOnfail=funcOnfail||null;
	this.timeout=timeout||1000;
	this.waitCall=null;
	return this;
};
AJAX.prototype.waitLoadFunction=function(dhtmlObject)
{
	this.check=function()
	{
		if(dhtmlObject.onloadAction!=null)
		{
			if((!dhtmlObject.xmlDoc.readyState)||(dhtmlObject.xmlDoc.readyState == 4))
			{
				if(dhtmlObject.xmlDoc.status == 200)
				{
					setStatusTag("statustag", ".");

					dhtmlObject.onloadAction(dhtmlObject);
					if(dhtmlObject.waitCall)
					{
						dhtmlObject.waitCall();dhtmlObject.waitCall=null;
					}
					dhtmlObject=null;
				}
				else
				{
					setStatusTag("statustag", "Error: Could not communicate with webserver (" + dhtmlObject.xmlDoc.status + " " + dhtmlObject.xmlDoc.statusText + ")");
					if(dhtmlObject.funcOnfail!=null) setTimeout(dhtmlObject.funcOnfail,dhtmlObject.timeout);
				}
			}
		}
	};
	return this.check;
};
AJAX.prototype.load=function(filePath){
	var postVars = "";
	var postMode = false;
	filePath+=((filePath.indexOf("?")!=-1)?"&":"?")+"uid="+(new Date()).valueOf();
	this.filePath=filePath;
	if(window.XMLHttpRequest){
		this.xmlDoc = new XMLHttpRequest();
		this.xmlDoc.open(postMode?"POST":"GET",filePath,this.async);
		if(postMode)
			this.xmlDoc.setRequestHeader('Content-type','application/x-www-form-urlencoded');
		this.xmlDoc.onreadystatechange=new this.waitLoadFunction(this);
		this.xmlDoc.send(null||postVars);
	}else{
		if(document.implementation && document.implementation.createDocument){
			this.xmlDoc = document.implementation.createDocument("","",null);
			this.xmlDoc.onload = new this.waitLoadFunction(this);
			this.xmlDoc.load(filePath);
		}else{
			this.xmlDoc = new ActiveXObject("Microsoft.XMLHTTP");
			this.xmlDoc.open(postMode?"POST":"GET",filePath,this.async);
			if(postMode)this.xmlDoc.setRequestHeader('Content-type','application/x-www-form-urlencoded');
			this.xmlDoc.onreadystatechange=new this.waitLoadFunction(this);
			this.xmlDoc.send(null||postVars);
		}
	}
};
