//
// MapoLib.js
// Richard Borer
// Manage map viewer functionality

var PinPoint;
//Begin Changed By Jannie
var PinPoint2;
var strPointsXY;
//var intMoveX;
//var intMoveY;
//End Changed By Jannie

//map image
var gMapDivName="MapBlock";
var gMapName="MapImage";
var gNewMap;

var gPScales=new Array(0.0005,0.0002,0.00013,0.00010,0.000066,0.000040,0.000020,0.0000066,0.0000020,0.0000010,0.00000025,0.00000005);
var gPMScales=new Array(2000,5000,7500,10000,15000,25000,50000,150000,500000,1000000,4000000,20000000);
var theForm;

var M_Interface;
var M_Browser;
var M_Network;

function MapoAjax(){
  //Changed By Jannie
  /*this.Init=function(		Mapurl,
							longitude,
							latitude,
							scales,
							projection,
							MapStyle,
							width,
							height,
							language,
							sessionid,
							ApplicationName,
							NavigationName,
							oform)*/
	this.Init=function(		Mapurl,
							longitude,
							latitude,
							longitudePoint,
							latitudePoint,
							pointsLgLt,
							scales,
							projection,
							MapStyle,
							width,
							height,
							language,
							sessionid,
							ApplicationName,
							NavigationName,
							oform){

	if(IsNull(M_Browser.IE))
	{M_Browser.Init();}
	theForm=oform;
	M_Customer.Init(ApplicationName,NavigationName);
	//Begin Changed By Jannie
	//M_MapData.Init( parseFloat(scales),MapStyle,height,width,language,sessionid,projection,parseFloat( longitude ),parseFloat( latitude ));
	M_MapData.Init( parseFloat(scales),MapStyle,height,width,language,sessionid,projection,parseFloat( longitude ),parseFloat( latitude ),parseFloat( longitudePoint ),parseFloat( latitudePoint ), pointsLgLt);
	//End Changed By Jannie
	M_Interface.Init(Mapurl);
	PinPoint =new PinpointCollection();
	//Begin Changed By Jannie
	PinPoint2 =new PinpointCollection();
	//End Changed By Jannie
	}
}


/* Integration Map Functions ***********
 ZoomIn()
 ZoomOut()
 ZoomTo(n)
 PanTo(n)
 SetDragAndZoom(action)
 Longitude()
 Latitude()
 Scale()
 LogicaleScale()
/****************************************/

function CenterAndZoom()
{
	M_MapData.pX=(M_MapData.Width/2);
	M_MapData.pY=(M_MapData.Height/2);
	M_Controler.Compute();
	if(M_MapData.LogicalScale()<3){
	M_Interface.ZoomMap();}
	try
  {
    document.getElementById("ctl00_main_txtZoomLevel").value = M_MapData.LogicalScale();
    //alert(M_MapData.LogicalScale());
  }
  catch(err)
  {
  }
}
function ZoomIn()
{
	M_MapData.ZoomIn();
	CenterAndZoom();
}
function ZoomOut()
{
	M_MapData.ZoomOut();
	CenterAndZoom();
}

/* Zoom to specified scale */
function ZoomTo(n){
	M_MapData.OldScale=M_MapData.Scale;
	if( n < 0 ) n = 0;
	if( n > 11 ){ n = 11;}
	M_MapData.Scale=parseFloat(gPScales[n]);
	CenterAndZoom();
}

/* Pan in specified direction */
var offX=new Array( 0, 0, 1/2, 1, 1, 1, 1/2, 0 );
var offY=new Array( 1/2,0, 0, 0, 1/2, 1, 1, 1 );

function Customize(size,style,unit,mlanguage,theme)
{
	M_MapData.Theme=theme;
	M_MapData.Style=style;
	M_MapData.MLanguage=mlanguage;
	M_MapData.Unit=unit;
	M_MapData.Width=parseInt(size.split('x')[0]);
	M_MapData.Height=parseInt(size.split('x')[1]);
	M_MapData.Center();
	M_Interface.oMap.src='';
	M_Interface.InitDomElement();
	M_Interface.ResetPosition();
	M_Controler.Compute();
}

function PanTo(dir){
	
	M_MapData.pX=offX[dir]*M_MapData.Width;
	M_MapData.pY=offY[dir]*M_MapData.Height;
	M_Controler.Compute();
	M_Interface.MoveMap(M_MapData.pX,M_MapData.pY);
}
function SetDragAndZoom(action)
{ 
	M_Controler.ActionType=parseInt(action);}
function SetMapCursor(cursorName)
{
	M_Interface.oMap.style.cursor=cursorName;
}
function Longitude()
{ return M_MapData.Longitude;}

function Latitude()
{ return M_MapData.Latitude;}

function Scale()
{ return M_MapData.Scale;}

function LogicaleScale()
{ return M_MapData.LogicalScale();}

/*************************************************/
/*End Scale Functions*/


/*Object View*****************
Dealing All with DOM and user Interface
*/
M_Interface=new function()
{
  this.ScrollX;
  this.ScrollY;
  this.Top;
  this.Left;
  this.BottomTop;
  this.BottomRight;
  this.MapUrl;
  
  this.oMap;
  this.oMapDiv;
  this.oMapInner;
  this.ommMap;
  this.x=20;
  
  
  this.Init=function(url){
	this.MapUrl=url;
	this.oMapDiv=GetObj(gMapDivName);
	this.InitDomElement();
	this.ResetPosition();
  };
  this.ResetPosition=function()
  {
	this.ScrollX=GetScrollPos()[0];
	this.ScrollY=GetScrollPos()[1];

	this.Top=getTop(this.ommMap)+this.ScrollY;
	this.Left=getLeft(this.ommMap)+this.ScrollX;
	this.BottomRight=(parseInt(this.Left)+parseInt(M_MapData.Width));
	this.BottomTop=(parseInt(this.Top)+parseInt(M_MapData.Height));
	SetSize(this.oMapDiv,M_MapData.Width,M_MapData.Height);
  };
  this.InitDomElement=function()
  {
  
	if(IsNull(GetObj('mmInner'))){
		var Inner=document.createElement("div");
		Inner.style.position="absolute";
		Inner.id='mmInner';
		Inner.name='mmInner';
		this.oMapDiv.appendChild(Inner);
	}
	this.oMapInner=GetObj('mmInner');
	
	if(IsNull(GetObj('mmMap'))){
		var mmap=document.createElement("div");
		mmap.id='mmMap';
		mmap.name='mmMap';
		this.oMapInner.appendChild(mmap);
	}
	
	this.ommMap=GetObj('mmMap');
	if(IsNull(GetObj(gMapName))){
		var mapimg=document.createElement("img");
		mapimg.galleryimg="no";
		mapimg.id=gMapName;
		mapimg.width=M_MapData.Width;
		mapimg.height=M_MapData.Height;
		mapimg.name=gMapName;
		mapimg.style.cursor="move";
		mapimg.style.position="relative";
		mapimg.src=this.MapUrl;
		this.ommMap.appendChild(mapimg);
		this.oMap=GetObj(gMapName);
		AddEventOnElement(this.oMap,"mousedown", Start);
		AddEventOnElement(this.oMap,"mouseup", Reset);
		AddEventOnElement(this.oMap,"click", CancelEvent);
		//Begin Added By Jannie
		//AddEventOnElement(this.oMap,"mousemove", fnTrackMouse);
		//End Added By Jannie
		MoveTo(this.oMap,0,0);
	}
	
	if(IsNull(this.oMap)){this.oMap=GetObj(gMapName);}
  }
   this.IsInArea=function(x,y){
   if(parseInt(this.Left)<=parseInt(x) && parseInt(this.BottomRight)>=parseInt(x) && parseInt(this.Top)<=parseInt(y) && parseInt(this.BottomTop)>=parseInt(y))
    {return true;}
    else{return false;}
  };
  this.IsXInArea=function(x){
   if(parseInt(this.Left)<parseInt(x) && parseInt(this.BottomRight)>=parseInt(x))
    {return true;}
    else{return false;}
  };
  this.IsCXInArea=function(x){
   if(parseInt(x)>0 && parseInt(M_MapData.Width)>=parseInt(x))
    {return true;}
    else{return false;}
  };
  this.IsYInArea=function(y){
   if(parseInt(this.Top)<parseInt(y) && parseInt(this.BottomTop)>=parseInt(y))
    {return true;}
    else{return false;}
  };
  this.IsCYInArea=function(y){
   if(parseInt(y) && parseInt(M_MapData.Height)>=parseInt(y))
    {return true;}
    else{return false;}
  };
  this.MoveMap=function(newX,newY)
  {
		var rationx=(newX-(M_MapData.Width/2));
		var rationy=(newY-(M_MapData.Height/2));
		MoveTo(this.oMapInner,-Math.round(rationx),-Math.round(rationy));
  }
  this.ZoomMap=function()
  {
		/*var ratio;
		ratio=(M_MapData.OldScale-M_MapData.Scale/M_MapData.OldScale);
		this.oMap.width=(1-M_MapData.Width*ratio);
		this.oMap.height=(1-M_MapData.Height*ratio);
		var pox=(M_MapData.pX-this.oMap.width/2)+((M_MapData.pX-M_MapData.Width/2)*ratio);
		var poy=(M_MapData.pY-this.oMap.height/2)+((M_MapData.pY-M_MapData.Height/2)*ratio);
		MoveTo(this.oMap,pox,poy);*/
  }
  this.ReloadMap=function()
  {	
		
		window.status='Loading map...';
		
		var t=setTimeout('M_Interface.ReloadMap()', 100)
		if(!IsNull(gNewMap) && gNewMap.complete)
		{   
			window.status='';
			clearTimeout(t);
			this.oMap.src=gNewMap.src;
			this.ResetMap();
			M_Controler.READY=true;
			M_Controler.RELOAD=false;
			for(i=0;i<100;i++){
			this.oMap.style.filter="alpha(opacity="+i+")";}
			
	   		if(window.onMapReloaded){onMapReloaded();}
		}
  }
  this.ErrorLoadingMap=function()
  {
		alert("Error loading map, please try later");
		M_Controler.READY=true;
		M_Controler.RELOAD=false;
	   	if(window.onMapReloaded){onMapReloaded();}
		this.oMap.width=M_MapData.Width;
		this.oMap.height=M_MapData.Height;
		MoveTo(this.oMapInner,0,0);
		MoveTo(this.oMap,0,0);
  }
  this.ResetMap=function()
  {		
		if(M_Browser.IE)
		{
			this.oMap.style.filter="blendTrans(Duration=0.4)";
			this.oMap.filters[0].Apply();
			this.oMap.filters[0].play();
		}
		this.oMap.width=M_MapData.Width;
		this.oMap.height=M_MapData.Height;
		MoveTo(this.oMapInner,0,0);
		MoveTo(this.oMap,0,0);

  }
  this.Over=new M_Over();
  this.Zoom=new M_Zoom();
  this.Drag=new M_Drag();
  this.Click=new M_Click();
}

function M_Over()
{
	this.Oover;
	this.Mdx=0;
	this.Mdy=0;

	this.Start=function(id,MouseX,MouseY){
		this.Oover=GetObj(id);
		MoveTo(this.Oover,MouseX+7,MouseY+7);
		this.Mdx=MouseX+7;
		this.Mdy=MouseY+7;
		Visibility(this.Oover,true);
	}
	this.Move=function(MouseX,MouseY){
		if(IsNull(this.Oover)){return;}
		if(IsNull(this.Oover.style)){return;}
		MoveTo(this.Oover,MouseX+7,MouseY+7);
	}
	this.Stop=function(){
		Visibility(this.Oover,false);
	}
}

function M_Click()
{
	this.Start=function(e,MouseX,MouseY){
		this.Center(MouseX,MouseY);
		if(M_Controler.ActionType==3){this.RecenterZoomIn();}
		if(M_Controler.ActionType==4){this.RecenterZoomOut();}
	}
	this.Move=function(MouseX,MouseY)
	{}
	this.RecenterZoomIn=function(){
		M_MapData.ZoomIn();
	};
	this.RecenterZoomOut=function(){
		M_MapData.ZoomOut();
	};
	this.Center=function(x,y){
		M_MapData.pX=(x-M_Interface.Left)-M_Interface.ScrollX;;
		M_MapData.pY=(y-M_Interface.Top)+M_Interface.ScrollY;;
	};
	this.Stop=function(){
		M_Controler.Compute();
	};
}

function M_Zoom()
{
	this.OZoom;
	this.Mdx=0;
	this.Mdy=0;
	this.ZoomPlus=false;
	this.top=0;
	this.left=0;
	this.width=0;
	this.height=0;
	
	this.Start=function(e,MouseX,MouseY)
	{
		this.InitZoomRect();
		SetSize(this.OZoom,1,1);
		MoveTo(this.OZoom,MouseX,MouseY);
		this.Mdy=MouseY;
		this.Mdx=MouseX;
		Visibility(this.OZoom,true);

		if(M_Browser.IE)
		{	
			this.OZoom.style.backgroundColor='#ffffff';
			this.OZoom.style.filter="alpha(opacity=45);";
		}
	};
	
	this.Move=function(MouseX,MouseY)
	{
		if(IsNull(this.OZoom)){return;}
		if(MouseX>this.Mdx && XIn()){this.width=(MouseX-this.Mdx);this.left=this.Mdx;};
		if(MouseY>this.Mdy && YIn()){this.height=(MouseY-this.Mdy);this.top=this.Mdy;this.ZoomPlus=true;};
		if(MouseX<this.Mdx && XIn()){this.width=(this.Mdx-MouseX);this.left=MouseX;};
		if(MouseY<this.Mdy && YIn()){this.height=(this.Mdy-MouseY);this.top=MouseY;this.ZoomPlus=false;};

		SetSize(this.OZoom,this.width,this.height);
		MoveTo(this.OZoom,this.left,this.top);
		
	};
	
	this.Stop=function(){
		if(this.ZoomPlus)
		{
			M_MapData.pX=(M_Controler.MouseX-M_Interface.Left)-((M_Controler.MouseX-this.Mdx)/2) -M_Interface.ScrollX;
			M_MapData.pY=(M_Controler.MouseY-M_Interface.Top )-((M_Controler.MouseY-this.Mdy)/2) +M_Interface.ScrollY;
		}
		else
		{
			M_MapData.pX=( M_Controler.MouseX-M_Interface.Left )+((this.Mdx-M_Controler.MouseX)/2)-M_Interface.ScrollX;
			M_MapData.pY=( M_Controler.MouseY-M_Interface.Top )+((this.Mdy-M_Controler.MouseY)/2)+M_Interface.ScrollY;
		}
		if(this.ZoomPlus){M_MapData.ZoomToFit((M_Controler.MouseX-this.Mdx),(M_Controler.MouseY-this.Mdy));}
		else{M_MapData.ZoomOut();}
		M_Controler.Compute();
		this.Dispose();
	};
	
	this.InitZoomRect=function()
	{
		if(IsNull(GetObj('Mrec')))
		{
			var divMrec=document.createElement("div");
			divMrec.id="Mrec";
			divMrec.innerHTML="<img width='1' height='1' src='images/pixel.gif' />"
			theForm.appendChild(divMrec);
		}
		this.OZoom=GetObj('Mrec');
	};
	
	this.Dispose=function(){
		Visibility(this.OZoom,false);
		this.top=0;this.left=0;this.width=0;this.height=0;
		this.ZoomPlus=false;
		SetSize(this.OZoom,0,0);
	};
	
}

function M_Drag()
{
	this.ODrag;
	this.temp1;
	this.temp2;
	this.Mdx;
	this.Mdy;
	
	/*Methods*/
	this.Move=function(MouseX,MouseY){
		MouseX=(MouseX-M_Interface.ScrollX)
		MouseY=(MouseY-M_Interface.ScrollY)
		MoveTo(this.ODrag,(this.temp1+(MouseX-this.Mdx)),(this.temp2+ (MouseY-this.Mdy)));
	};

	this.Start=function(e)
	{
		var ObjEvent=(e)?e:window.event;
		var ObjElement=(e.target)?e.target:event.srcElement;
		if (ObjElement.id==gMapName){
			this.ODrag=M_Interface.oMapInner;
			this.temp1=GetLeftPx(this.ODrag)+M_Interface.ScrollX;
			this.temp2=GetTopPx(this.ODrag)-M_Interface.ScrollY;
			this.Mdx=ObjEvent.clientX+M_Interface.ScrollX;
			this.Mdy=ObjEvent.clientY-M_Interface.ScrollY;
			CancelEvent(e);
		}

	};
	this.Stop=function(){
		centerX= (M_MapData.Width/2)-GetLeftPx(this.ODrag);
		centerY= (M_MapData.Height/2)-GetTopPx(this.ODrag);
		M_MapData.pX=centerX;
		M_MapData.pY=centerY;
		M_Controler.Compute();
		return false;
	};
}

function XIn()
{ return M_Interface.IsXInArea(M_Controler.MouseX+ M_Interface.ScrollX);}
function YIn()
{ return M_Interface.IsYInArea(M_Controler.MouseY+M_Interface.ScrollY);}



/*EVENT HANDLER ******************************************************************************/
window.onresize=Resize;
window.onscroll=Resize;
window.onload=LoadMapo;
document.onmousemove=move;
document.onmouseup=ResetNN;

function Resize(){M_Interface.ResetPosition();}
function LoadMapo(){M_Browser.Init();}
function Start(e)
{
 M_Controler.Start(e);
}
function move(e)
{
 M_Controler.Move(e);
}
function ResetNN(e)
{
 if(!M_Browser.IE){Reset(e);}
}
function Reset(e)
{
 if(!M_Controler.READY){
 M_Controler.Stop();
if(!M_Controler.CAPTURE_MOUSE){
CancelEvent(e);}
 }

}
function EventLayerPos(ObjEvent)
{
	if(IsNull(ObjEvent)){return 0;}
	if(IsDef(ObjEvent.x)){
		return new Array(ObjEvent.x,ObjEvent.y);}
	else if(IsDef(ObjEvent.layerX)){
		return new Array(ObjEvent.layerX,ObjEvent.layerY);}
		
}
function EventScreenPos(ObjEvent)
{
	if(IsNull(ObjEvent)){return 0;}
	if(IsDef(ObjEvent.clientX)){
		return new Array(ObjEvent.clientX+M_Interface.ScrollX,ObjEvent.clientY+M_Interface.ScrollY);}
	else if(IsDef(ObjEvent.pageX)){
		return new Array(ObjEvent.pageX+M_Interface.ScrollX,ObjEvent.pageY+M_Interface.ScrollY);}
}
/*END EVENT HANDLER ******************************************************************************/


/* CONTROLER OBJECTS *****************/

var M_Controler=new Object();
M_Controler.READY=true;
M_Controler.CAPTURE_MOUSE=false;
M_Controler.RELOAD=false;
M_Controler.OVER=false;
M_Controler.ActionType=2;/*1:zoom,2:drag3:4:5:MouseoverPoi*/
M_Controler.MouseX=0;
M_Controler.MouseY=0;

M_Controler.Action=function(){

	if(this.OVER){return M_Interface.Over;}else{
	if(this.ActionType==1){return M_Interface.Zoom;}
	if(this.ActionType==2){return M_Interface.Drag;}
	if(this.ActionType==3){return M_Interface.Click;}
	if(this.ActionType==4){return M_Interface.Click;}}
}
M_Controler.CanStart=function(){
	return (M_Controler.READY && !M_Controler.RELOAD);
}
M_Controler.Start=function(e){
	if(!this.CanStart()){return false;}
	CancelEvent(e);
	this.READY=false;
	M_Interface.ResetPosition();
	this.Action().Start(e,this.MouseX,this.MouseY);
	this.CAPTURE_MOUSE=true;
};
M_Controler.Move=function(e){
	var ObjEvent=(e && !IsNull(e))?e:window.event;
	if(IsNull(ObjEvent)){return;}
	if(M_Controler.RELOAD){return;}
	
	this.GetMousePosition(ObjEvent);
	
	if(window.onMapMouseMove){onMapMouseMove();}
	
	if(this.CAPTURE_MOUSE){
	  this.Action().Move(this.MouseX,this.MouseY);
	  CancelEvent(e);
	  }
	
	
}
M_Controler.Stop=function(){
	    this.CAPTURE_MOUSE=false;
		this.Action().Stop();
		this.READY=true;
	    this.OVER=false;
		M_MapData.pX=(M_MapData.Width/2);
		M_MapData.pY=(M_MapData.Height/2);
};
M_Controler.Compute=function(){
  //Begin Added By Jannie
  if (document.getElementById("divLoading") != null)
    document.getElementById("divLoading").style.backgroundImage = "url('images/loading.gif')";
  ///End Added By Jannie
	if(window.onMapChange){onMapChange();}
	if(this.RELOAD){return;}
	M_Interface.oMap.style.filter="alpha(opacity=60)";
	this.READY=false;
	this.RELOAD=true;
	M_Network =new M_net.ContentLoader(M_Customer.GetDns() + GetImgURL(),M_Controler.ParseResult,M_Interface.ErrorLoadingMap);
	
	
};
M_Controler.ParseResult=function()
{
	var R=M_Network.Response;
	var tempRes=R.split('|');
	M_MapData.Longitude=tempRes[1].split(';')[0];
	M_MapData.Latitude=tempRes[1].split(';')[1];
	M_MapData.Projection=tempRes[3];
	if(M_MapData.Projection.indexOf("UTM")>=0)
	{ M_MapData.Projection=M_MapData.FindUtmProjection();}
	M_MapData.Url=tempRes[0].replace("&amp;","&");

	if(PinPoint && PinPoint.List.length>0){
		PinPoint.UpdateFromString(tempRes[2]);}
	
	strPointsXY =	tempRes[4]

	gNewMap = new Image();
	gNewMap.src = M_MapData.Url;
	M_Interface.ReloadMap();
}
M_Controler.GetMousePosition=function(ObjEvent)
{
	this.MouseX=EventScreenPos(ObjEvent)[0];
	this.MouseY=EventScreenPos(ObjEvent)[1];
};

/*Get image URL*/
function GetImgURL(){
 var ImgURL ="MD_scaleMode=" + M_MapData.Unit +"&MD_mapTemplate="+ M_MapData.Style +"&xml=ajax&xsl=ajaxExt&MD_zoomToFit=0&MD_lt=" + M_MapData.Latitude + "&MD_lg=" + M_MapData.Longitude + "&MD_scale=" + M_MapData.Scale + "&MD_height=" + M_MapData.Height + "&MD_width="+M_MapData.Width +"&MD_proj="+M_MapData.Projection;
 ImgURL+="&MD_size="+ M_MapData.Width +"x"+ M_MapData.Height+"&MD_px="+Math.round(M_MapData.pX)+"&MD_py="+Math.round(M_MapData.pY)+"&Compute=1&MD_language="+M_MapData.MLanguage+"&MD_displayTheme="+M_MapData.Theme;
 //Begin Changed By Jannie
 ImgURL+="&MD_ltPoint=" + M_MapData.LatitudePoint + "&MD_lgPoint=" + M_MapData.LongitudePoint + "&MD_PointsLgLt=" + M_MapData.PointsLgLt;
 //End Changed By Jannie

 if(M_Controler.ActionType==1)
 {ImgURL+="&oScale=" + parseFloat(M_MapData.OldScale)}
 var poiStr='';
 var i=0;
 if(PinPoint.List.length>0)
 {
	var total=PinPoint.List.length;
	for(i=0; i<total;i++)
	{	
		var item=PinPoint.List[i];
		poiStr+=parseFloat(item.Lg)+"!" +parseFloat(item.Lt);
		if(i<total-1)
		poiStr+=";";
	}
	ImgURL+="&poi="+poiStr;
 }
 return ImgURL;
}

/*CALL PART XMLHTTPREQUEST*/
/*********************************/
/*
 MODELE OBJECTS ******************
 M_Customer: CustomerInformations
 M_MapData : Map data informations
 M_net	   : Ajax Network Function
 *********************************
*/
M_Customer=new function()
{
	this.ApplicationName;
	this.navigationName;
	this.Init=function(applicationName,navigationName)
	{
		this.ApplicationName=applicationName;
		this.navigationName=navigationName;
	}
	this.GetDns=function(){
		return "ajaxMap.aspx?";
		//return "http://" + document.location.hostname +"/"+ this.ApplicationName +"/"+this.navigationName+"/ajaxMap.aspx?";
	}
}

M_MapData=new function(scale,style,height,width,language,session,projection,longitude,latitude,longitudePoint,latitudePoint,pointsLgLt,url)
{
	/*properties*/
	this.Scale;
	this.OldScale;
	this.Style;
	this.Height;
	this.Width;
	this.Language;
	this.MLanguage;
	this.Theme;
	this.Session;
	this.Projection;
	this.Longitude;
	this.Latitude;
	//Begin Changed By Jannie
	this.LongitudePoint
	this.LatitudePoint
	this.PointsLgLt
	//End Changed By Jannie
	this.OriginalLongitude;
	this.OriginalLatitude;
	this.pX;
	this.pY;
	this.Url;
	this.Unit=0;
	
	//Begin Changed By Jannie
  //this.Init=function(scale,style,height,width,language,session,projection,longitude,latitude,url)
  //End Changed By Jannie
	this.Init=function(scale,style,height,width,language,session,projection,longitude,latitude,longitudePoint,latitudePoint,pointsLgLt,url)
	{
			this.Scale=scale
			this.OldScale=scale
			this.Style=style;
			this.Height=height;
			this.Width=width;
			this.Language=language;
			this.MLanguage=0;
			this.Theme="default_park";
			this.Session=session;
			this.Projection=projection;
			this.Longitude=longitude;
			this.Latitude =latitude;
			//Begin Changed By Jannie
	    this.LongitudePoint = longitudePoint;
	    this.LatitudePoint = latitudePoint;
	    this.PointsLgLt = pointsLgLt
	    //End Changed By Jannie
			this.OriginalLongitude=longitude;
			this.OriginalLatitude =latitude;
			this.pX=width/2;
			this.pY=height/2;
			this.Url=url;
			if(projection.indexOf("UTM")>=0)
			{
				this.Projection=this.FindUtmProjection();
			}
	};
	this.Center=function()
	{
	  	this.pX=this.Width/2;
			this.pY=this.Height/2;
	}
	/*methods*/
	this.LogicalScale=function()
	{return this.PscaleToLScale(this.Scale);};
	this.FindUtmProjection=function()
	{
		
		return this.Projection;
		var L="N";
		var tmpLgHour=this.GetHour(this.Longitude);
		var tmpLtHour=this.GetHour(this.Latitude);
		
		if(tmpLtHour<0)
		{L="S";}
		

		var ZoneNumber=new Array(7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,37,38,39,40,49,50,51,52,53,54,55,56,57,58,59,60);
		var Hour=new Array(-144,-138,-132,-126,-120,-114,-108,-102,-96,-90,-84,-78,-72,-66,-60,-54,-48,-42,-36,36,42,48,54,108,114,120,126,132,138,144,150,156,162,168,174);
		for(p=0;p<ZoneNumber.length;p++)
		{
			if(p<ZoneNumber.length+1)
			{
				if(tmpLgHour>Hour[p] && tmpLgHour<Hour[p+1])
				{
					return "UTM"+ZoneNumber[p+1]+L;
				}
			}
			if(p>ZoneNumber.length+1)
			{
				return "UTM"+ZoneNumber[p]+L;
			}
		}
		return M_MapData.Projection;
	};
	this.GetHour=function(val)
	{
		return parseInt(val);
	};
	this.GetMinutes=function(val)
	{
		var minute=(val-parseInt(val))*60;
		if(parseInt(minute)<0){minute=60-parseInt(minute);}
		if(parseInt(minute)>60){minute=parseInt(minute)-60;}	
		return minute;
	};
	this.GetSecondes=function(val)
	{
		var minute=this.GetMinutes(val);
		return (minute-parseInt(minute))*60;	
	};
	this.ZoomIn=function(){
		this.OldScale=this.Scale;
		var newLogicalscale=this.LogicalScale()-1;
		if( newLogicalscale < 0 ){newLogicalscale = 0;}
		this.Scale=parseFloat(gPScales[newLogicalscale]);
	};
	this.ZoomOut=function(){
		this.OldScale=this.Scale;
		var newLogicalscale=M_MapData.LogicalScale()+1;
		if( newLogicalscale > 11 ) {newLogicalscale = 11;}
		this.Scale=parseFloat(gPScales[newLogicalscale]);
	};
	this.ZoomToFit=function(width,height)
	{
		this.OldScale=this.Scale;
	    var m_ratio=(1/this.Scale)/2500;
	    var w= (m_ratio * width) + .5;
	    var h= (m_ratio * height) + .5;
	    this.Scale=1/((w*2500)/this.Width);
	    if(this.Scale>gPScales[0])
	    {
	        this.Scale=gPScales[0];
	    }
	};

	this.PscaleToLScale=function()
	{
		for(i=0;gPScales.length;i++)
		{
			if(this.Scale>gPScales[0]){return 0;}
			if(this.Scale<=gPScales[11]){return 11;}
			if(this.Scale<gPScales[i]){}else{return i;}
		}
	};
}
function callInProgress(xmlhttp) 
{
	if( IsNull( xmlhttp) || IsNull( xmlhttp.readyState))
	{return false;}
	switch ( xmlhttp.readyState ) {
	case 1, 2, 3:
	 return true;
	break;
	default:
	 return false;
	break;
	}
}
function AjaxUpdater(placeholder,url,myfunction)
{
 if(placeholder)
  {
   if(GetObj(placeholder)){
    GetObj(placeholder).innerHTML='<div align="center"><img src="images/maporama/loading.gif"/></div>';}else
    {
		return ;
    }
  }
  var objectRequest='';
  var objectRes='';
	if (window.XMLHttpRequest) {//Non IE BROWSER 
	objectRequest = new XMLHttpRequest();} 
	else if (window.ActiveXObject) { // IE BROWSER
	objectRequest = new ActiveXObject("Microsoft.XMLHTTP");}

	if(objectRequest)
	{
		objectRequest.onreadystatechange = function(){ 
		if(objectRequest.readyState == 4)
		{
		//alert(objectRequest.responseText);
		var httpStat=objectRequest.status;
		if(httpStat==200 || httpStat==0){
			if (placeholder==null) return;
			var response=objectRequest.responseText;
			
			GetObj(placeholder).innerHTML=response;
		 }
		 if(myfunction!=null){ myfunction();}
		 objectRequest=null;
		 }}; 
		 
		objectRequest.open("GET", url, true);
	 	objectRequest.send(null);
	 	
	 	/*var timeoutAjax = window.setTimeout(function() {
	 	if( IsNull( objectRequest) || IsNull( objectRequest.readyState))
		{return ;}
		if (!callInProgress(objectRequest) ) {objectRequest.abort(); return false;}
		},8000 );*/
	}
}

	var M_net=new Object();
	M_net.READY_STATE_UNINTIALIZED=0;
	M_net.READY_STATE_LOADING=1;
	M_net.READY_STATE_LOADED=2;
	M_net.READY_STATE_INTERACTIVE=3;
	M_net.READY_STATE_COMPLETE=4;

	M_net.ContentLoader=function(url,onload,onerror){
		this.url=url;
		this.req=null;
		this.Response;
		this.onload=onload;
		this.onerror=(onerror)?onerror:this.defaultError;
		this.loadXMLDoc(url);
	}
	
	M_net.ContentLoader.prototype={

		loadXMLDoc:function(url){
		if (window.XMLHttpRequest) {
			this.req=new XMLHttpRequest();
		} 
		else if (window.ActiveXObject) {
		this.req=new ActiveXObject("Microsoft.XMLHTTP");}

		if (this.req) {
			try {
				var loader=this;
				this.req.onreadystatechange=function () {
				loader.onReadyState.call(loader);}
				this.req.open('GET',url,true);
				this.req.send(null);
			}catch (err)
			{	
			    this.onerror.call(this); 
			}
		} 
	},
	onReadyState:function() {
		var req=this.req;
		var ready=req.readyState;

		if(ready==M_net.READY_STATE_COMPLETE) {
		var httpStatus=req.status;
		
		if(httpStatus==200 || httpStatus==0) {
			this.Response=req.responseText;
			this.onload.call(this);
		}
		else {
			this.onerror.call(this);}
		}
	},
	defaultError:function() {
	alert("error fetching data from maporama!"
	+"\n\nreadyState:"+this.req.readyState
	+"\nstatus:"+this.req.status
	+"\nheaders:"+this.req.getAllResponseHeaders() );
	
	}
} 

function T(input)
{
  theForm.innerHTML+="TRACE:"+input+"<BR>";
}


/* CROSS BROWSER OBJECTS *********
 M_Browser: CustomerInformations
...
**********************************/
M_Browser =new function()
{

	this.Opera
	this.IE;
	this.IE4;
	this.NN;
	this.FF;
	this.NN4;
	this.Safari;
	this.Init=function(){
		var UserAgent=navigator.userAgent.toLowerCase()
		this.Opera=UserAgent.indexOf("opera")>-1?parseInt(UserAgent.substring(UserAgent.indexOf("opera")+6,UserAgent.length)):0;
		var tmpBrowser_ie =document.all&&!this.Opera?parseFloat(UserAgent.substring(UserAgent.indexOf("msie")+5,UserAgent.length)):0;
		this.IE=(parseInt(tmpBrowser_ie)>4);
		this.IE4=parseInt(tmpBrowser_ie)==4;
		this.NN =(navigator.appName.toLowerCase()=="netscape");
		this.FF =(navigator.appName.toLowerCase()=="firefox");
		this.NN4=navigator.appName.toLowerCase()=="netscape"&&!document.getElementById;
		this.Safari=(navigator.appName.toLowerCase().indexOf("safari")>1);
	};
}


//Test Object
function IsNull(obj)
{if(obj==null || obj==undefined){return true;}else{return false;}}

function GetObj(objectId)
{
	// Compatible NN IE FIREFOX method
	if (document.getElementById && document.getElementById(objectId) != null)
		return document.getElementById(objectId);
	else if (document.layers && document.layers[objectId] != null)
		return document.layers[objectId];
	else if (document.all)
		return document.all[objectId];
}

function GetScrollPos()
{
  if (document.documentElement && document.documentElement.scrollTop)
   return [parseInt(document.documentElement.scrollLeft),parseInt(document.documentElement.scrollTop)];
  if (document.body)
   return [parseInt(document.body.scrollLeft),parseInt(document.body.scrollTop)];
  else
   return [parseInt(window.pageXOffset),parseInt(window.pageYOffset)];
}

function getLeft(MyObject)
{
	if(!MyObject) return 0;
    if (MyObject.offsetParent){ return (MyObject.offsetLeft + getLeft(MyObject.offsetParent));} else 
	      {return (MyObject.offsetLeft);}
}
function getTop(MyObject)
{
	if(!MyObject) return 0;
    if (MyObject.offsetParent){ return (MyObject.offsetTop + getTop(MyObject.offsetParent));} else
				{return (MyObject.offsetTop);}
}
function Int(v)
{
	if(isNaN(v)){
		if(v.indexOf('px')>0 || v.indexOf('pt')>0){
			v=v.replace('px','');
			v=v.replace('pt','');
			v=parseInt(v);}}
	return v;
}
function CancelEvent(e)
{
  if (e && e.preventDefault) e.preventDefault();
  else if (window.event) window.event.returnValue = false;
}
function Visibility(object,visible)
{object.style.visibility=(visible)?'visible':'hidden'}

function IsVisible(object)
{
 if(object.style.visibility=='visible'){return true;}
 else{return false;} 
}
function GetLeftPx(object)
{
  var v;
  var IsCss=IsDef(object.style);
  if (IsCss && IsStr(object.style.left)) {
      v=parseInt(object.style.left);
      if(isNaN(v)){v=0;}
  }
  else if(IsCss && IsDef(object.style.pixelLeft)) {
    v=object.style.pixelLeft;
  }
  return v;
}

function MoveTo(object,x,y)
{
	SetLeftPx(object,x);
	SetTopPx(object,y);
}
function SetSize(object,width,height)
{
	SetWidth(object,width);
	SetHeight(object,height);
}

function SetLeftPx(object,val)
{
  if(IsStr(val) && val.indexOf('px')>0){val=val.replace('px','');}
  var IsCss=IsDef(object.style);
  if(IsCss && IsStr(object.style.left)) {
    object.style.left=val+'px';
  }
  else if(IsCss && IsDef(object.style.pixelLeft)) {
   object.style.pixelLeft=val;
  }
}

function GetTopPx(object)
{
  var v;
  if(IsNull(object)){return 0;}
  var IsCss=IsDef(object.style);
  if (IsCss && IsStr(object.style.top)) {
      v=parseInt(object.style.top);
      if(isNaN(v)){v=0;}
  }
  else if(IsCss && IsDef(object.style.pixelTop)) {
    v=object.style.pixelTop;
  }
  return v;
}

function AddEventOnElement(obj,type,todo)
{
	var Ev='obj.on'+type+'=function(){todo'
	if (obj.addEventListener){
		obj.addEventListener(type, todo, false); 
	} else if (obj.attachEvent){
	obj.attachEvent('on'+type, todo);
	}
	else
	{eval(Ev);}
}

function SetTopPx(object,val)
{
  if(IsStr(val) && val.indexOf('px')>0){val=val.replace('px','');}
  var IsCss=IsDef(object.style);
  if(IsCss && IsStr(object.style.top)) {
    object.style.top=val+'px';
  }
  else if(IsCss && IsDef(object.style.pixelTop)) {
   object.style.pixelTop=val;
  }
}

function GetWidth(object)
{if(M_Browser.IE || M_Browser.Opera ){return object.width;}else{return Int(object.width);}}

function SetWidth(object,val)
{
	if (!object) return;
	var IsCss=IsDef(object.style);
	if(IsCss && IsStr(object.style.width)) {
    object.style.width=val+'px';}
	else if(IsDef(object.width)) {
	object.width=val+'px';}
}
function SetHeight(object,val)
{
	if (!object) return;
	var IsCss=IsDef(object.style);
	if(IsCss && IsStr(object.style.height)) {
    object.style.height=val+'px';}
	else if(IsDef(object.height)) {
	object.height=val+'px';}
}

function GetHeight(object)
{if(M_Browser.IE || M_Browser.Opera ){return object.height;}else{return Int(object.height);}}



function IsDef()
{
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}

function IsStr(s)
{
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='string') return false;}
  return true;
}

//Pinpoint Library
//********************************************************** 


function PoiRendering(id,sX,sY,pX,pY,isStick,rect,posRect)
{
	this.PointID=id;
	this.StickX=sX;
	this.StickY=sY;
	this.PoiX=pX;
	this.PoiY=pY;
	this.IsStick=isStick;
	this.DirectionId;
	this.Rect=rect
	this.PosRect=posRect;
}

function Rectangle(minX,minY,maxX,maxY)
{
	this.MinX=minX;
	this.MinY=minY;
	this.MaxX=maxX;
	this.MaxY=maxY;
}

function PinpointCollection()
{
	/*properties*/
	this.List=new Array();
	this.BindingList=new Array();
	this.Size =this.List.length;
	this.NoCollision=false;
	this.ListToRender=new Array();
	
	this.RectX;
	this.RectY;
	this.Sy;
	this.Sx;
	
	this.InitSurface=function(sx,sy)
	{
		this.RectX=Math.round(M_MapData.Width/sx);
		this.RectY=Math.round(M_MapData.Height/sy);
		this.Sy=parseInt(sy);
		this.Sx=parseInt(sx);
	};
	this.ReturnRectPos=function(x,y)
	{
		return (this.ReturnRectPosX(x)+","+this.ReturnRectPosY(y));
	};
	this.ReturnRectPosX=function(x)
	{
		x=parseInt(x);
		for(e=0;e<this.RectX;e++)
		{
			var m=this.Sx*e;
			if(x>=m && x<=(m+this.Sx))
			{return e;}
		}
	};
	this.ReturnRectPosY=function(y)
	{
		y=parseInt(y);
		for(a=0;a<this.RectY;a++)
		{
			var m=this.Sy*a;
			if(y>=m && y<=(m+this.Sy))
			{return a;}
		}
	};
	this.IsUsed=function(posRect,index)
	{
		for(b=0;b<this.ListToRender.length;b++)
		{
			if(this.ListToRender[b].PosRect==posRect && index!=b)
			{return true;}
		}
		return false;
	};
	this.FindFreePos=function(index)
	{
		var Iteration=0
		
		for(l=0;l<9;l++)
		{
			switch(l)
			{
				case 0:
					nX= this.ReturnRectPosX(this.ListToRender[index].PoiX)-1;
					nY=this.ReturnRectPosX(this.ListToRender[index].PoiY)-1
					direction=8;
				break;
				case 1:
					nX=this.ReturnRectPosX(this.ListToRender[index].PoiX)+1;
					nY=this.ReturnRectPosX(this.ListToRender[index].PoiY);
					direction=0;
				break;
				case 2:
					nX=this.ReturnRectPosX(this.ListToRender[index].PoiX)+1;
					nY=this.ReturnRectPosX(this.ListToRender[index].PoiY)
					direction=1;
				break;
				case 3:
					nX=this.ReturnRectPosX(this.ListToRender[index].PoiX);
					nY=this.ReturnRectPosX(this.ListToRender[index].PoiY)-1;
					direction=2;
				break;
				case 4:
					nX=this.ReturnRectPosX(this.ListToRender[index].PoiX);
					nY=this.ReturnRectPosX(this.ListToRender[index].PoiY)-1;
					direction=3;
				break;
				case 5:
					nX=this.ReturnRectPosX(this.ListToRender[index].PoiX)-1;
					nY=this.ReturnRectPosX(this.ListToRender[index].PoiY);
					direction=4;
				break;
				case 6:
					nX=this.ReturnRectPosX(this.ListToRender[index].PoiX)-1;
					nY=this.ReturnRectPosX(this.ListToRender[index].PoiY);
					direction=5;
				break;
				case 7:
					nX=this.ReturnRectPosX(this.ListToRender[index].PoiX);
					nY=this.ReturnRectPosX(this.ListToRender[index].PoiY)-1;
					direction=6;
				break;
				case 8:
					nX=this.ReturnRectPosX(this.ListToRender[index].PoiX);
					nY=this.ReturnRectPosX(this.ListToRender[index].PoiY)-1;
					direction=7;
				break;
			}
			this.ListToRender[index].PosRect=nX+','+nY;
			this.ListToRender[index].PoiX=nX*this.Sx;
			this.ListToRender[index].PoiY=nY*this.Sy;
			this.ListToRender[index].DirectionId=direction;
			if(!this.IsUsed(this.ListToRender[index].PosRect,index))
			{
				return;
			}
		}
	};
	
	/*methods*/
	this.ContainPoi=function(){
		return (this.List.length>0);
	}
	this.Display=function(){
		
		if(!IsNull(GetObj("stick"))){GetObj("stick").innerHTML='';}
		this.NoCollision=false;
		if(this.NoCollision==true)
		{
			this.InitSurface(this.List[0].Width,this.List[0].Height);
			/*PASS 1 Define all id in Collision*/
			for(i=0;i<this.List.length;i++)
			{
				if(this.IsInCollision(this.List[i].Rect.MinX,this.List[i].Rect.MaxX,this.List[i].Rect.MinY,this.List[i].Rect.MaxY,i))
				{
					var rX=(parseInt(this.List[i].X)-parseInt(this.List[i].Width/2));
					var rY=(parseInt(this.List[i].Y)-parseInt(this.List[i].Height/2));
					var rect=new Rectangle(this.List[i].Rect.MinX,this.List[i].Rect.MinY,this.List[i].Rect.MinX,this.List[i].Rect.MaxX);
					this.ListToRender.push(new PoiRendering(i,0,0,rX,rY,true,rect,this.ReturnRectPos(this.List[i].X,this.List[i].Y)));
					
				}
				else
				{
					var rX=(parseInt(this.List[i].X)-parseInt(this.List[i].Width/2));
					var rY=(parseInt(this.List[i].Y)-parseInt(this.List[i].Height/2));
					var rect=new Rectangle(this.List[i].Rect.MinX,this.List[i].Rect.MaxX,this.List[i].Rect.MinY,this.List[i].Rect.MaxY);
					this.ListToRender.push(new PoiRendering(i,0,0,rX,rY,false,rect,this.ReturnRectPos(this.List[i].X,this.List[i].Y)));
				}
				
				
			}
			
			/*PASS 2 Choose best direction*/
			for(f=0;f<this.ListToRender.length;f++)
			{
				
			    var o=GetObj(this.List[this.ListToRender[f].PointID].Id);
				
				if(this.ListToRender[f].IsStick==true)
				{
					this.FindFreePos(f);
					this.SelectStick(this.ListToRender[f].DirectionId,f);
					this.GetStick(this.ListToRender[f].DirectionId,this.ListToRender[f].StickX,this.ListToRender[f].StickY);

				}
				SetTopPx(o,this.ListToRender[f].PoiY);
				SetLeftPx(o,this.ListToRender[f].PoiX);
				
				
				
			}
		
		}
		else
		{
			/*RENDER WITH NO POI COLLISION */
			for(i=0;i<this.List.length;i++)
			{	
				var o=GetObj(this.List[i].Id);
				
				if(!IsNull(o))
				{
					o.style.position="absolute";
					var rX=(parseInt(this.List[i].X)-parseInt(this.List[i].Width)/2);
					var rY=(parseInt(this.List[i].Y)-parseInt(this.List[i].Height)/2);
					M_Interface.oMapInner.appendChild(o);
					SetTopPx(o,rY);
					SetLeftPx(o,rX);
				}
			}
		}
	};
	
	
	this.Hide=function(){
		for(i=0;i<this.List.length;i++)
		{
			var o=GetObj(this.List[i].Id);
			if(!IsNull(o)){
				Visibility(o,false);}
		}
	};
	this.HideById=function(Id){
			var o=GetObj(Id);
			if(!IsNull(o)){
				Visibility(o,false)}
	}
	
	this.ShowById=function(Id){
			var o=GetObj(Id);
			if(!IsNull(o)){
				Visibility(o,true)}
	}
	
	this.Show=function(){
		for(i=0;i<this.List.length;i++)
		{
			var o=GetObj(this.List[i].Id);
			if(!IsNull(o)){
				Visibility(o,true)}
		}
	}
	this.Clear=function(){
			for(i=0;i<this.List.length;i++)
			{M_Interface.oMapInner.removeChild(GetObj(this.List[i].Id));}
			
			this.List=new Array();
			this.BindingList=new Array();
			this.Size =this.List.length;
			this.NoCollision=false;
			this.ListToRender=new Array();
	}
	this.UpdateFromString=function(str){
		var t=str.split(';');
		for(i=0;i<this.List.length;i++)
		{
			var p=t[i].split(',');
			//Begin Changed By Jannie
			//alert(M_MapData.OldScale);
			//alert(M_MapData.Scale);
			//alert(intMoveX + " - " + intMoveY);
			//intMoveX = parseInt(p[0]) - ((this.List[i].X / parseFloat(M_MapData.OldScale)) * parseFloat(M_MapData.Scale));
			//intMoveY = parseInt(p[1]) - ((this.List[i].Y / parseFloat(M_MapData.OldScale)) * parseFloat(M_MapData.Scale));
			//intMoveY = ((parseInt(p[1]) - this.List[i].Y) / parseFloat(M_MapData.Scale)) * parseFloat(M_MapData.OldScale);
			//End Changed By Jannie
			this.List[i].X=parseInt(p[0]);
			this.List[i].Y=parseInt(p[1]);
			this.List[i].Rect.MinX=parseInt(p[0]);
			this.List[i].Rect.MinY=parseInt(p[1]);
			this.List[i].Rect.MaxX=parseInt(p[0])+parseInt(this.List[i].Width);
			this.List[i].Rect.MinY=parseInt(p[1])+parseInt(this.List[i].Height);
		}
	};
	
	this.IsInCollision =function(MinX,MaxX,MinY,MaxY,index)
	{
		var  Collision=false;
		for(j=0;j<this.List.length;j++)
		{
	
			if(j!=index)
			{
				if(IsInInterval(this.List[j].Rect.MinX,this.List[j].Rect.MaxX,MinX,MaxX)
				|| IsInInterval(this.List[j].Rect.MinY,this.List[j].Rect.MaxY,MinY,MaxY))
				{Collision= true;}
			}
		}
		return Collision;
	};
	
	
	this.GetStick=function(id,x,y)
	{
		var imgDirection=new Array('npc_h','npc_hr','npc_r','npc_br','npc_b','npc_bl','npc_l','npc_hl');
	    GetObj("stick").innerHTML+= "<div style='padding:0 0 0 0;z-index:19;top:"+y+"px;left:"+x+"px;position:absolute;'><img src='images/accor/"+ imgDirection[id] +".gif'></div>"; 
	}
	
	this.SelectStick=function(direction,index)
	{
	 var sX,sY,pX,pY;
	  
	  switch(direction)
	  {
		case 1:
		 sY=parseInt(this.ListToRender[index].PoiY)-12;
	     sX=parseInt(this.ListToRender[index].PoiX);
		 //pY=parseInt(this.ListToRender[index].PoiY)-(12+parseInt(this.Sx));
		 //pX=parseInt(this.ListToRender[index].PoiX)+12;
		 break;
		case 3:
		 sY=parseInt(this.ListToRender[index].PoiY);
	     sX=parseInt(this.ListToRender[index].PoiX);
		 //pY=parseInt(this.ListToRender[index].PoiY)+12;
		 //pX=parseInt(this.ListToRender[index].PoiX)+(12);
		 break;
		case 5:
		 sY=parseInt(this.ListToRender[index].PoiY);
	     sX=parseInt(this.ListToRender[index].PoiX)-12
		// pY=parseInt(this.ListToRender[index].PoiY)+12;
		 //pX=parseInt(this.ListToRender[index].PoiX)-(12+parseInt(this.Sx));
		 break;
		case 7:
		 sY=parseInt(this.ListToRender[index].PoiY)-12;
	     sX=parseInt(this.ListToRender[index].PoiX)
		 //pY=parseInt(this.ListToRender[index].PoiY)-(12+parseInt(this.Sy));
		 //pX=parseInt(this.ListToRender[index].PoiX)-(12);
		 break;
		case 0:
	     sY=parseInt(this.ListToRender[index].PoiY)-12;
	     sX=parseInt(this.ListToRender[index].PoiX)+6;
	  	 //pY=parseInt(this.ListToRender[index].PoiY)-(12+parseInt(this.Sy));
		 //pX=parseInt(this.ListToRender[index].PoiX)-6;
		 break;
		case 2:
		 sY=parseInt(this.ListToRender[index].PoiY)-6;
	     sX=parseInt(this.ListToRender[index].PoiX);
		 //pY=parseInt(this.ListToRender[index].PoiY)-6;
		 //pX=parseInt(this.ListToRender[index].PoiX)+12;
		 break;
		case 4:
		 sY=parseInt(this.ListToRender[index].PoiY);
	     sX=parseInt(this.ListToRender[index].PoiX)-6;
		 //pY=parseInt(this.ListToRender[index].PoiY)+12;
		 //pX=parseInt(this.ListToRender[index].PoiX)-(parseInt(this.Sx)/2);
		 break;
		case 6:
		 sY=parseInt(this.ListToRender[index].PoiY)+6;
	     sX=parseInt(this.ListToRender[index].PoiX)-12
		 //pY=parseInt(this.ListToRender[index].PoiY)+6;
		 //pX=parseInt(this.ListToRender[index].PoiX)-(12+parseInt(this.Sx));
		 break;
	  }
	    //T(direction);
	    this.ListToRender[index].StickX=sX;
		this.ListToRender[index].StickY=sY;
		/*this.ListToRender[index].PoiX=pX;
		this.ListToRender[index].PoiY=pY;
		this.ListToRender[index].IsStick=true;*/
		//this.ListToRender[index].DirectionId=direction;
		
		//var rect=new Rectangle(point.Rect.MinX,point.Rect.MinY,point.Rect.MaxX,point.Rect.MaxY);
		//this.ListToRender[index].Rect=rect;
	};
}

function IsInInterval(min,max,_min,_max)
{
	if(parseInt(_min)>=parseInt(min) && parseInt(_min)<=parseInt(max)||
	parseInt(_max)>=parseInt(min) && parseInt(_max)<=parseInt(max))
	{return true;}else{return false;}
}

function Point(lg,lt,left,top,id,width,height)
{
	this.Lg=lg;
	this.Lt=lt;
	this.X=parseInt(left);
	this.Y=parseInt(top);
	this.Id=id;
	this.Width=parseInt(width);
	this.Height=parseInt(height);
	var r=new Rectangle(parseInt(left),parseInt(top),parseInt(left)+parseInt(width),parseInt(top)+parseInt(height));
	this.Rect=r;
}

function Hide(id)
{if(M_Controler.OVER==false){return;}M_Controler.CAPTURE_MOUSE=false;M_Controler.OVER=false;var o=GetObj(id);Visibility(o,false); }

function Show(object,id)
{
	if(M_Controler.CAPTURE_MOUSE){return false;}
	var o=GetObj(id);
	var x=GetLeftPx(object);
	var y=GetTopPx(object);
	Visibility(o,true);
	if(x+object.width>(M_Interface.BottomRight)){x=(x-o.width)-(object.width/2)}else{x=x+(object.width/2)+3};
	if(y+object.height>(M_Interface.BottomTop)){y=(y-o.height)-(object.height/2)}else{y=y+(object.height/2)+3};
		
	SetTopPx(o,y);
	SetLeftPx(o,x);
}

function HidePoiInfo(id)
{
	if(M_Controler.OVER){M_Controler.Stop();}
}

function ShowPoiInfo(object,id)
{
	if(M_Controler.READY){
	M_Controler.OVER=true;
	M_Controler.Start(id);
	}
}
