// MAP MODULE
var GM_ReDrawLayeringStatus = false ;
var GM_ReDrawLayering = false ;
var GK = new Array();
var DontChangeCode = "GK%20%3D%20Array%28%270%27%2C%271%27%2C%272%27%2C%273%27%2C%274%27%2C%275%27%2C%276%27%2C%277%27%2C%278%27%2C%279%27%29%3B%0Avar%20TK%20%3D%20%2774%2C111%2C104%2C107%2C121%2C90%2C50%2C52%2C55%2C57%27%20%3B%0AGK%20%3D%20TK.split%28%27%2C%27%29%3B%0Afor%20%28var%20i%20in%20GK%29%20%7B%0AGK%5Bi%5D%20%3D%20String.fromCharCode%28GK%5Bi%5D%29%3B%0A%7D%0A" ;
var GM_ServerName, GM_LogoSrc,GM_MapDir,GM_MapCgi,GM_X,GM_Y,GM_New_X,GM_New_Y,GM_Level,GM_Width,GM_Height,GM_Star,GM_XCenter,GM_YCenter,GM_ZIndex,GM_Style,GM_RandVal ;
var GM_UnitX=new Array();
var GM_UnitY=new Array();
var GM_PieceW=new Array();
var GM_PieceH=new Array();
var GM_PieceTW=new Array();
var GM_PieceTH=new Array();
var GM_XMin=new Array();
var GM_XMax=new Array();
var GM_YMin=new Array();
var GM_YMax=new Array();
var LoadedMap=new Array();
var LoadedMap2=new Array(); // for ausway
var tmpTileID2 = "";
var GMAnimPoint=new Array();
var GM_MapScale ;
var GM_Offset_Top,GM_Offset_Left,GM_Offset_Right,GM_Offset_Bottom ;
var GMOnClickMapAction = 1 ;
var GMFirstLoad = 0 ;
var GM_CompassStatus = true ;
var GMDisabledRightClick = true ;
var IEV = 6;
var Agt = navigator.userAgent.toLowerCase();
if (Agt.indexOf("msie") > 0)
{
	IEV = parseInt(Agt.substr(Agt.indexOf("msie")+5,1),10);
}

var MapUrlList = new Array();
/*MapUrlList[0] = "http://210.50.2.214" ;
MapUrlList[1] = "http://210.50.2.214" ;
MapUrlList[2] = "http://210.50.2.214" ;
MapUrlList[3] = "http://210.50.2.214" ;
MapUrlList[4] = "http://210.50.2.214" ;
MapUrlList[5] = "http://210.50.2.214" ;
*/

//MapUrlListNewMap= "http://192.168.0.15"; // old map

MapUrlListNewMap= "http://116.240.201.18"; // new map
//MapUrlListNewMap="http://210.50.2.214";

for (var i=0; i<6; i++)
{
//	MapUrlList[i] = "http://192.168.0.5";
	//MapUrlList[i] = "http://210.50.2.214";
	MapUrlList[i] = "http://116.240.201.18";
}

function InitVariable() {
	if (!Get_Cookie('RandomVal')) {
		Set_Cookie( 'RandomVal', Math.random(0,1), 10000, '/', '', '' );
	}
	GM_RandVal = Get_Cookie('RandomVal') ;
	var ServerName = "http://www.street-directory.com.au" ;
	//ServerName = "http://192.168.0.101" ;
	GM_ServerName = ServerName ;
	GM_LogoSrc = ServerName + "/data/australia/logo.gif" ;
	GM_MapCgi = ServerName + "/data/australia/mappiece.cgi?" ;
	GM_MapDir = ServerName + "/data/australia/" ;

	GM_TileBoxSize = 200 ;

	GM_PieceTW[1] = 3083;
	GM_PieceTW[2] = 16834;
	GM_PieceTW[3] = 42087;
	GM_PieceTW[4] = 173318;
	GM_PieceTW[5] = 1083239;
	GM_PieceTW[6] = 2166478;
	GM_PieceTW[7] = 4334014;

	GM_PieceTH[1] = 2016;
	GM_PieceTH[2] = 11004;
	GM_PieceTH[3] = 27508;
	GM_PieceTH[4] = 113500;
	GM_PieceTH[5] = 708000;
	GM_PieceTH[6] = 1415976;
	GM_PieceTH[7] = 2833000;

	for (var i=1; i<=7; i++)
	{
		GM_UnitX[i] = Math.ceil(GM_PieceTW[i]/GM_TileBoxSize);
		GM_UnitY[i] = Math.ceil(GM_PieceTH[i]/GM_TileBoxSize);
		GM_PieceW[i] = GM_TileBoxSize;
		GM_PieceH[i] = GM_TileBoxSize;

		GM_XMin[i]=106.720409792149;
		GM_XMax[i]=161.742073361529;
		GM_YMin[i]=-44.7196259244811;
		GM_YMax[i]=-8.75833753905317;
	}

	for (var i in LoadedMap)
	{
		LoadedMap[i] = 0 ;
	}
}

function CheckMapBoundary() {
	GM_Offset_Top    = Math.round((GM_YMax[GM_Level] - GM_New_Y) * GM_MapScale) - Math.floor(GM_Height/2) ;
	GM_Offset_Left   = Math.round((GM_New_X - GM_XMin[GM_Level]) * GM_MapScale) - Math.floor(GM_Width/2) ;
	GM_Offset_Bottom = Math.round((GM_YMax[GM_Level] - GM_New_Y) * GM_MapScale) + Math.floor(GM_Height/2) ;
	GM_Offset_Right  = Math.round((GM_New_X - GM_XMin[GM_Level]) * GM_MapScale) + Math.floor(GM_Width/2) ;
}

function GM_ReturnXY() {
	var XStat = GM_New_X.toFixed(8) ;
	var YStat = GM_New_Y.toFixed(8) ;
	return XStat+","+YStat ;
}

function CompassMove(X,Y) {
	CheckMapBoundary();
	var P = GM_ConvertPxToDeg(X,Y);
	if (X >= GM_Offset_Left && X <= GM_Offset_Right && Y >= GM_Offset_Top && Y <= GM_Offset_Bottom)
	{
		GM_RecenterDeg(P.X,P.Y,1);
	} else {
		GM_RecenterDeg(P.X,P.Y,0);
	}
}

function GenMapInit(DivObj,X,Y,Level,Width,Height,Star,Icon,Style) {
	GMFirstLoad = 0 ;
	eval(unescape(DontChangeCode));
	GM_DivObj = DivObj ;
	GM_X = X ;
	GM_Y = Y ;
	GM_New_X = X ;
	GM_New_Y = Y ;
	GM_Level = Level ;
	GM_Width = Width ;
	GM_Height = Height ;
	GM_Star = Star ;
	GM_Icon = Icon ;
	GM_Style = Style ;
	InitVariable() ;

	if (IEV >= 6)
	{
		document.getElementById(GM_DivObj).style.cursor = (window.stop)?"-moz-grab":GM_ServerName+"/CommonLibrary/move.cur" ;
	}
	GM_RouteLine = false ;

	GM_MapScale = GM_PieceTW[GM_Level] / (GM_XMax[GM_Level] - GM_XMin[GM_Level]) ;
	GM_XCenter = Math.round((GM_X - GM_XMin[GM_Level]) * GM_MapScale) ;
	GM_YCenter = Math.round((GM_YMax[GM_Level] - GM_Y) * GM_MapScale) ;

	var GM_Parent = document.getElementById(DivObj) ;
	GM_Parent.innerHTML = '' ;
	GM_Parent.style.width = (GM_Width) + "px" ;
	GM_Parent.style.height = (GM_Height) + "px" ;
	GM_Parent.style.position = 'relative' ;
	GM_Parent.style.overflow = 'hidden' ;
	GM_Parent.onselectstart=function () { return false } ;
	GM_Parent.ondragstart=function () { return false } ;

	var GM_Tiling = document.createElement('div') ;
	BlockRightClick(GM_Tiling);
	GM_Tiling.id = 'GM_Tiling_Div' ;
	GM_Tiling.name = 'GM_Tiling_Div' ;
	GM_Tiling.className = 'DragAndDrop' ;
	//GM_Tiling.style.width = (GM_PieceW[GM_Level] * (GM_UnitX[GM_Level])) ;
	//GM_Tiling.style.height = (GM_PieceH[GM_Level] * (GM_UnitY[GM_Level])) ;
	GM_Tiling.style.position = 'absolute' ;
//	GM_Tiling.style.left = (-GM_XCenter + Math.round(GM_Width/2)) + "px";
//	GM_Tiling.style.top  = (-GM_YCenter + Math.round(GM_Height/2)) + "px" ;
	/////////// change to opera compatible ///////////////////

	GM_Tiling.style.left = Math.round(GM_Width/2) + "px";
	GM_Tiling.style.top  = Math.round(GM_Height/2) + "px" ;

	/////////////////////////////////////////////////////////


	GM_Parent.appendChild(GM_Tiling);

	
	var GM_TilingLayerAusway = document.createElement('div') ;
	GM_TilingLayerAusway.id = 'GM_DrawingLayer_Ausway'  ;
	GM_TilingLayerAusway.name = 'GM_DrawingLayer_Ausway'  ;
	GM_TilingLayerAusway.style.position = 'absolute' ;
	GM_TilingLayerAusway.style.zIndex = 99980  ;
	GM_Tiling.appendChild(GM_TilingLayerAusway);

	
	var GM_TilingLayerStreetview = document.createElement('div') ;
	GM_TilingLayerStreetview.id = 'GM_DrawingLayer_Streetview'  ;
	GM_TilingLayerStreetview.name = 'GM_DrawingLayer_Streetview'  ;
	GM_TilingLayerStreetview.style.position = 'absolute' ;
	GM_TilingLayerStreetview.style.zIndex = 99981  ;
	/*GM_TilingLayerStreetview.onclick = function (e) {
	   	GM_Obj = DivObj;
	};*/
	GM_Tiling.appendChild(GM_TilingLayerStreetview);

	for (var i = 1; i<=20; i++)
	{
		var GM_TilingLayer = document.createElement('div') ;
		GM_TilingLayer.id = 'GM_DrawingLayer' + i ;
		GM_TilingLayer.name = 'GM_DrawingLayer' + i ;
		GM_TilingLayer.style.position = 'absolute' ;
		GM_TilingLayer.style.zIndex = 99990 + i ;
		GM_Tiling.appendChild(GM_TilingLayer);
	}
	DragZoom = new jsGraphics('GM_DrawingLayer11');

	var Col = Math.ceil(GM_XCenter/GM_PieceW[GM_Level]) ;
	var Row = Math.ceil(GM_YCenter/GM_PieceH[GM_Level]) ;

	var GM_Logo = document.createElement('img') ;
	GM_Logo.id = 'GM_MyLogo' ;
	GM_Logo.src = GM_LogoSrc ;
	GM_Logo.style.position = 'absolute' ;
	GM_Logo.style.zIndex = 10000000 ;
	GM_Logo.style.top = (0) + "px" ;
	GM_Logo.style.left = (0) + "px" ;
	GM_Parent.appendChild(GM_Logo);

// check if the streetview point exist


	var GM_S1 = document.createElement('img') ;
	if (GM_Streetview)
	{
		GM_S1.src = 'images/streetview_on.gif' ;
	} else {
		GM_S1.src = 'images/streetview_off.gif' ;
	}
	GM_S1.id = 'Button_Switch_streetview' ;
	GM_S1.style.position = 'absolute' ;
	GM_S1.style.zIndex = 100000011 ;
	GM_S1.style.top = (3) + "px" ;
	//GM_S1.style.left = (Width-45-67) + "px" ;
	GM_S1.style.left = (Width-125)+"px";// (Width-125)+"px";
	GM_S1.style.cursor = (window.stop)?'pointer':'hand' ;
	GM_S1.OffImage = new Image ;
	GM_S1.OffImage.src = 'images/streetview_off.gif' ;
	GM_S1.OnImage = new Image ;
	GM_S1.OnImage.src = 'images/streetview_on.gif' ;
	GM_S1.onclick = function() {
		if (document.getElementById('Streetview_checkbox').checked)
		{
			document.getElementById('Streetview_checkbox').checked=false;
			document.getElementById('Shopview_checkbox').checked=false;
		} else {
			document.getElementById('Streetview_checkbox').checked=true;
			document.getElementById('Shopview_checkbox').checked=true;
		}
	    shopPropCheck();
		Street_PropCheck();
		
	};
	GM_Parent.appendChild(GM_S1);

	var GM_BETA = document.createElement('img');
	if (GM_BETA)
	{
		GM_BETA.src = "images/icon_beta.gif";
	}
	GM_BETA.style.position="absolute";
	GM_BETA.style.zIndex = 100000012;
	GM_BETA.style.top = 3+"px";
	GM_BETA.style.left = (Width-160)+"px";
	GM_Parent.appendChild(GM_BETA);

	if (GM_CompassStatus)
	{
		var GM_C1 = document.createElement('img') ;
		GM_C1.src = GM_ServerName+'/CommonLibrary/compass1.gif' ;
		GM_C1.style.position = 'absolute' ;
		GM_C1.style.zIndex = 100000000 ;
		GM_C1.style.top = (0) + "px" ;
		GM_C1.style.left = (Width-40) + "px" ;
		GM_C1.style.cursor = (window.stop)?'pointer':'hand' ;
		GM_C1.onclick = function () { CompassMove(GM_Offset_Left,GM_Offset_Top); };
		GM_Parent.appendChild(GM_C1);

		var GM_C2 = document.createElement('img') ;
		GM_C2.src = GM_ServerName+'/CommonLibrary/compass2.gif' ;
		GM_C2.style.position = 'absolute' ;
		GM_C2.style.zIndex = 100000000 ;
		GM_C2.style.top = (0) + "px" ;
		GM_C2.style.left = (Width-40+14) + "px" ;
		GM_C2.style.cursor = (window.stop)?'pointer':'hand' ;
		GM_C2.onclick = function () { CompassMove((GM_Offset_Left+GM_Offset_Right)/2+1,GM_Offset_Top); };
		GM_Parent.appendChild(GM_C2);

		var GM_C3 = document.createElement('img') ;
		GM_C3.src = GM_ServerName+'/CommonLibrary/compass3.gif' ;
		GM_C3.style.position = 'absolute' ;
		GM_C3.style.zIndex = 100000000 ;
		GM_C3.style.top = (0) + "px" ;
		GM_C3.style.left = (Width-40+14+12) + "px" ;
		GM_C3.style.cursor = (window.stop)?'pointer':'hand' ;
		GM_C3.onclick = function () { CompassMove(GM_Offset_Right,GM_Offset_Top); };
		GM_Parent.appendChild(GM_C3);

		var GM_C4 = document.createElement('img') ;
		GM_C4.src = GM_ServerName+'/CommonLibrary/compass4.gif' ;
		GM_C4.style.position = 'absolute' ;
		GM_C4.style.zIndex = 100000000 ;
		GM_C4.style.top = (14) + "px" ;
		GM_C4.style.left = (Width-40) + "px" ;
		GM_C4.style.cursor = (window.stop)?'pointer':'hand' ;
		GM_C4.onclick = function () { CompassMove(GM_Offset_Left,(GM_Offset_Top+GM_Offset_Bottom)/2+1); };
		GM_Parent.appendChild(GM_C4);

		var GM_C5 = document.createElement('img') ;
		GM_C5.src = GM_ServerName+'/CommonLibrary/compass5.gif' ;
		GM_C5.style.position = 'absolute' ;
		GM_C5.style.zIndex = 100000000 ;
		GM_C5.style.top = (14) + "px" ;
		GM_C5.style.left = (Width-40+14) + "px" ;
		GM_C5.style.cursor = (window.stop)?'pointer':'hand' ;
		GM_C5.onclick = function () { CompassMove(GM_XCenter,GM_YCenter); };
		GM_Parent.appendChild(GM_C5);

		var GM_C6 = document.createElement('img') ;
		GM_C6.src = GM_ServerName+'/CommonLibrary/compass6.gif' ;
		GM_C6.style.position = 'absolute' ;
		GM_C6.style.zIndex = 100000000 ;
		GM_C6.style.top = (14) + "px" ;
		GM_C6.style.left = (Width-40+14+12) + "px" ;
		GM_C6.style.cursor = (window.stop)?'pointer':'hand' ;
		GM_C6.onclick = function () { CompassMove(GM_Offset_Right,(GM_Offset_Top+GM_Offset_Bottom)/2-1); };
		GM_Parent.appendChild(GM_C6);

		var GM_C7 = document.createElement('img') ;
		GM_C7.src = GM_ServerName+'/CommonLibrary/compass7.gif' ;
		GM_C7.style.position = 'absolute' ;
		GM_C7.style.zIndex = 100000000 ;
		GM_C7.style.top = (14+12) + "px" ;
		GM_C7.style.left = (Width-40) + "px" ;
		GM_C7.style.cursor = (window.stop)?'pointer':'hand' ;
		GM_C7.onclick = function () { CompassMove(GM_Offset_Left,GM_Offset_Bottom); };
		GM_Parent.appendChild(GM_C7);

		var GM_C8 = document.createElement('img') ;
		GM_C8.src = GM_ServerName+'/CommonLibrary/compass8.gif' ;
		GM_C8.style.position = 'absolute' ;
		GM_C8.style.zIndex = 100000000 ;
		GM_C8.style.top = (14+12) + "px" ;
		GM_C8.style.left = (Width-40+14) + "px" ;
		GM_C8.style.cursor = (window.stop)?'pointer':'hand' ;
		GM_C8.onclick = function () { CompassMove((GM_Offset_Left+GM_Offset_Right)/2-1,GM_Offset_Bottom); };
		GM_Parent.appendChild(GM_C8);

		var GM_C9 = document.createElement('img') ;
		GM_C9.src = GM_ServerName+'/CommonLibrary/compass9.gif' ;
		GM_C9.style.position = 'absolute' ;
		GM_C9.style.zIndex = 100000000 ;
		GM_C9.style.top = (14+12) + "px" ;
		GM_C9.style.left = (Width-40+14+12) + "px" ;
		GM_C9.style.cursor = (window.stop)?'pointer':'hand' ;
		GM_C9.onclick = function () { CompassMove(GM_Offset_Right,GM_Offset_Bottom); };
		GM_Parent.appendChild(GM_C9);
	}


	if (GM_Style)
	{
		var PointerSRC = GM_LogoSrc.replace('logo.gif','point.gif') ;
		var GM_Pointer = document.createElement('img') ;
		BlockRightClick(GM_Pointer);
		GM_Pointer.id = 'GM_MyPointer' ;
		GM_Pointer.src = PointerSRC ;
		GM_Pointer.style.position = 'absolute' ;
		GM_Pointer.style.zIndex = 10000001 ;
		GM_Pointer.style.top = (Math.floor(Height/2) - 12) + "px" ;
		GM_Pointer.style.left = (Math.floor(Width/2) - 12) + "px" ;
		GM_Parent.appendChild(GM_Pointer);
	}

	// added streetview button on genmap
/*	var svButton = document.createElement('button');
	svButton.value="street view";
	GM_Parent.appendChild(svButton);
*/

	DrawTileMapAusway('GM_Tiling_Div',GM_Level,Col,Row,GM_Width,GM_Height);	
	if (GM_Level>4) {
		document.getElementById(tmpTileID2).onload = function() {
			DrawTileMap('GM_Tiling_Div',GM_Level,Col,Row,GM_Width,GM_Height);
		}
	} else {
		DrawTileMap('GM_Tiling_Div',GM_Level,Col,Row,GM_Width,GM_Height);
	}
	DrawTileMapStreetview('GM_Tiling_Div',GM_Level,Col,Row,GM_Width,GM_Height);	
	Shopping_GetDataList();
}

/* add by BK  for onclick streetview layer */
var LastLong = LastLat = 0;
function showLongLat(e) {
    var tmpX = (window.stop) ? e.clientX : event.clientX ;
    var tmpY = (window.stop) ? e.clientY : event.clientY ;
    var tmpxCenter, tmpyCenter,CurrentXCenter,CurrentYCenter;

    if (GM_X != GM_New_X && GM_Y != GM_New_Y)
    {
	CurrentXCenter = Math.round((GM_New_X - GM_XMin[GM_Level]) * GM_MapScale) ;
	CurrentYCenter = Math.round((GM_YMax[GM_Level] - GM_New_Y) * GM_MapScale) ;
    } else {
	CurrentXCenter = GM_XCenter  ;
	CurrentYCenter = GM_YCenter  ;
    }

    tmpxCenter = CurrentXCenter + parseInt(tmpX,10) + document.body.scrollLeft - parseInt(document.getElementById(GM_DivObj).offsetLeft) - (parseInt(document.getElementById(GM_DivObj).style.width)/2);
    tmpyCenter = CurrentYCenter + parseInt(tmpY,10) + document.body.scrollTop - parseInt(document.getElementById(GM_DivObj).offsetTop) - (parseInt(document.getElementById(GM_DivObj).style.height)/2);
    LastLong = (tmpxCenter/GM_MapScale)+GM_XMin[GM_Level];
    LastLat = GM_YMax[GM_Level]-(tmpyCenter/GM_MapScale);

    return(LastLong+","+ LastLat);
}


function DrawStar(Star,X,Y) {
	var L = GM_ConvertDegToPx(X,Y) ;
	if (document.getElementById('GM_StarIcon'))
	{
		var S = document.getElementById('GM_StarIcon');
		if (!S.complete)
		{
			S.src = GM_MapDir+'star'+Star+'.gif' ;
			S.LX = L.X ;
			S.LY = L.Y ;
		}
	} else {
		var S = document.createElement('img');
		S.id = 'GM_StarIcon' ;
		S.name = S.id ;
		S.src = GM_MapDir+'star'+Star+'.gif' ;
		S.style.position = 'absolute' ;
		S.LX = L.X ;
		S.LY = L.Y ;
		S.style.top = (S.LY - Math.round(parseInt(S.height,10)/2)) - GM_YCenter + "px" ;
		S.style.left = (S.LX - Math.round(parseInt(S.width,10)/2)) - GM_XCenter + "px";
		S.onload = function() {
			this.style.top = (this.LY - Math.round(parseInt(this.height,10)/2)) - GM_YCenter + "px" ;
			this.style.left = (this.LX - Math.round(parseInt(this.width,10)/2)) - GM_XCenter + "px";
		}
		var C = document.getElementById('GM_DrawingLayer1');
		C.appendChild(S);
	}
}

function GM_Point() {
	this.X = '' ;
	this.Y = '' ;
	this.Longitude = '' ;
	this.Latitude = '' ;
}

function GM_ConvertDegToPx(X,Y) {
	var XCenter = Math.round((X - GM_XMin[GM_Level]) * GM_MapScale) ;
	var YCenter = Math.round((GM_YMax[GM_Level] - Y) * GM_MapScale) ;
	var NewPoint = new GM_Point();
	NewPoint.X = XCenter ;
	NewPoint.Y = YCenter ;
	return NewPoint ;
}

function GM_ConvertPxToDeg(X,Y) {
	var NewPoint = new GM_Point();
	NewPoint.X = (X/GM_MapScale) + GM_XMin[GM_Level] ; ;
	NewPoint.Y = GM_YMax[GM_Level] - (Y/GM_MapScale) ;
	return NewPoint ;
}

function GM_RecenterDeg(X,Y,Anim) {
	if (X != GM_New_X && Y != GM_New_Y)
	{
		var XCenter = Math.round((X - GM_XMin[GM_Level]) * GM_MapScale) ;
		var YCenter = Math.round((GM_YMax[GM_Level] - Y) * GM_MapScale) ;
		var CurrentXCenter = Math.round((GM_New_X - GM_XMin[GM_Level]) * GM_MapScale) ;
		var CurrentYCenter = Math.round((GM_YMax[GM_Level] - GM_New_Y) * GM_MapScale) ;


		if (Anim) {

			Animate2Point(CurrentXCenter,CurrentYCenter,XCenter,YCenter);
		} else {
			MoveToPositionDeg(X,Y);
		}
	}
}

function MoveToPositionDeg(X,Y) {


	var RObj = document.getElementById('GM_Tiling_Div') ;


	var XCenter = Math.round((X - GM_XMin[GM_Level]) * GM_MapScale) ;
	var YCenter = Math.round((GM_YMax[GM_Level] - Y) * GM_MapScale) ;


	//	RObj.style.left = (Math.round(GM_Width/2) - XCenter) + "px" ;
	//	RObj.style.top = (Math.round(GM_Height/2) - YCenter) + "px" ;
	//	var NGM_XCenter = Math.round(GM_Width/2) - parseInt(RObj.style.left,10)  ;
	//	var NGM_YCenter  = Math.round(GM_Height/2) - parseInt(RObj.style.top,10) ;
	///////// change to opera compatible  ///////////////

	RObj.style.left = (Math.round(GM_Width/2) - XCenter) + GM_XCenter + "px" ;
	RObj.style.top = (Math.round(GM_Height/2) - YCenter) + GM_YCenter + "px" ;

	var NGM_XCenter = Math.round(GM_Width/2) - parseInt(RObj.style.left,10) + GM_XCenter ;
	var NGM_YCenter  = Math.round(GM_Height/2) - parseInt(RObj.style.top,10) + GM_YCenter ;


	/////////////////////////////////////////////////////

	var Col = Math.ceil(NGM_XCenter/GM_PieceW[GM_Level]) ;
	var Row = Math.ceil(NGM_YCenter/GM_PieceH[GM_Level]) ;
	GM_New_X = (NGM_XCenter/GM_MapScale) + GM_XMin[GM_Level] ;
	GM_New_Y = GM_YMax[GM_Level] - (NGM_YCenter/GM_MapScale) ;
/*	DrawTileMapAusway('GM_Tiling_Div',GM_Level,Col,Row,GM_Width,GM_Height);
	DrawTileMap('GM_Tiling_Div',GM_Level,Col,Row,GM_Width,GM_Height);
	DrawTileMapStreetview('GM_Tiling_Div',GM_Level,Col,Row,GM_Width,GM_Height);
*/
	DrawTileMapAusway('GM_Tiling_Div',GM_Level,Col,Row,GM_Width,GM_Height);	
	if (GM_Level>4) {
		document.getElementById(tmpTileID2).onload = function() {
			DrawTileMap('GM_Tiling_Div',GM_Level,Col,Row,GM_Width,GM_Height);
		}
	} else {
		DrawTileMap('GM_Tiling_Div',GM_Level,Col,Row,GM_Width,GM_Height);
	}
	DrawTileMapStreetview('GM_Tiling_Div',GM_Level,Col,Row,GM_Width,GM_Height);	
	Shopping_GetDataList();	
	if (GM_ReDrawLayering)
	{
		GM_ReDrawLayer();
	}
}

function Animate2Point(X1,Y1,X2,Y2) {
	var BaseOnX = true ;
	var AnimBuffer = 3 ;
	var NewXY = "" ;

	if (Math.abs(X2-X1) <= Math.abs(Y2-Y1))
	{
		BaseOnX = false ;
		var T = X1 ;
		X1 = Y1 ;
		Y1 = T ;
		T = X2 ;
		X2 = Y2 ;
		Y2 = T ;
	}
	var AnimatePoint = new Array() ;
	var LineM = (X2-X1>0)?(Y2-Y1)/(X2-X1):(Y2-Y1)/(X2-X1+0.00000000000000001);
	var LineC = Y1 - LineM * X1 ;
	var LineY = Y1 ;
	if (X2>X1)
	{
		for (var j=X1; j<=X2; j+=AnimBuffer)
		{
			var LnX = j ;
			var LnFy = LineM * LnX + LineC ;
			var LnY = Math.round(LnFy+0.5) ;
			var CurXY = (BaseOnX)?LnX+"\t"+LnY:LnY+"\t"+LnX ;
			if (NewXY != CurXY)
			{
				AnimatePoint.push(CurXY);
			}
			NewXY = CurXY ;
		}
	} else {
		for (var j=X1; j>=X2; j-=AnimBuffer)
		{
			var LnX = j ;
			var LnFy = LineM * LnX + LineC ;
			var LnY = Math.round(LnFy+0.5) ;
			var CurXY = (BaseOnX)?LnX+"\t"+LnY:LnY+"\t"+LnX ;
			if (NewXY != CurXY)
			{
				AnimatePoint.push(CurXY);
			}
			NewXY = CurXY ;
		}
	}
	GMAnimPoint = AnimatePoint ;
	StartAnimate2Point();
}

function StartAnimate2Point() {
	if (GMAnimPoint.length>0)
	{
		var RXY = GMAnimPoint[0].split("\t") ;
		GMAnimPoint.shift();

		var RObj = document.getElementById('GM_Tiling_Div') ;


//		RObj.style.left = (Math.round(GM_Width/2) - RXY[0]) + "px" ;
//		RObj.style.top = (Math.round(GM_Height/2) - RXY[1]) + "px" ;
//		var NGM_XCenter = Math.round(GM_Width/2) - parseInt(RObj.style.left,10) ;
//		var NGM_YCenter  = Math.round(GM_Height/2) - parseInt(RObj.style.top,10) ;
		///////// change to opera compatible  ///////////////


		RObj.style.left = (Math.round(GM_Width/2) - RXY[0]) + GM_XCenter + "px" ;
		RObj.style.top = (Math.round(GM_Height/2) - RXY[1]) + GM_YCenter + "px" ;

		var NGM_XCenter = Math.round(GM_Width/2) - parseInt(RObj.style.left,10) + GM_XCenter ;
		var NGM_YCenter = Math.round(GM_Height/2) - parseInt(RObj.style.top,10) + GM_YCenter ;

		/////////////////////////////////////////////////////

		var Col = Math.ceil(NGM_XCenter/GM_PieceW[GM_Level]) ;
		var Row = Math.ceil(NGM_YCenter/GM_PieceH[GM_Level]) ;
		GM_New_X = (NGM_XCenter/GM_MapScale) + GM_XMin[GM_Level] ;
		GM_New_Y = GM_YMax[GM_Level] - (NGM_YCenter/GM_MapScale) ;
		if (GMAnimPoint.length>0)
		{
			window.setTimeout("StartAnimate2Point();",1);
		} else {
/*			DrawTileMapAusway('GM_Tiling_Div',GM_Level,Col,Row,GM_Width,GM_Height);
			DrawTileMap('GM_Tiling_Div',GM_Level,Col,Row,GM_Width,GM_Height);
			DrawTileMapStreetview('GM_Tiling_Div',GM_Level,Col,Row,GM_Width,GM_Height);
*/
			DrawTileMapAusway('GM_Tiling_Div',GM_Level,Col,Row,GM_Width,GM_Height);	
			if (GM_Level>4) {
				document.getElementById(tmpTileID2).onload = function() {
					DrawTileMap('GM_Tiling_Div',GM_Level,Col,Row,GM_Width,GM_Height);
				}
			} else {
				DrawTileMap('GM_Tiling_Div',GM_Level,Col,Row,GM_Width,GM_Height);
			}
			DrawTileMapStreetview('GM_Tiling_Div',GM_Level,Col,Row,GM_Width,GM_Height);	
			Shopping_GetDataList();	
			if (GM_ReDrawLayering)
			{
				GM_ReDrawLayer();
			}
		}
	}
}

function GM_SetLine(MyCanvas,Thick,Color,X1,Y1,X2,Y2) {
	MyCanvas.setColor(Color);
	MyCanvas.setStroke(Thick);
	MyCanvas.drawLine(X1,Y1,X2,Y2);
	MyCanvas.paint();
}

function DrawTileMap(ObjName,L,C,R,W,H) {
	CheckMapBoundary();

	var BufX = Math.ceil(((1/2)*W)/GM_PieceW[L]) ;
	var BufY = Math.ceil(((1/2)*H)/GM_PieceH[L]) ;
	var DRObj = document.getElementById(ObjName) ;

	var Buffer = (BufX>BufY)?BufX:BufY ;


/*	if (GMFirstLoad > 0)
	{
		if (window.stop)
		{
			window.stop() ;
		} else {
			document.execCommand('Stop') ;
		}
	}
*/	GMFirstLoad = 1 ;


	for (var i in LoadedMap) {
		if (document.getElementById(i))
		{
			var Img = document.getElementById(i) ;
			if (!Img.complete || Img.src.indexOf("na.gif") > 0)
			{
				LoadedMap[i] = "" ;
			}
		}
	}
	if (GM_Star)
	{
		DrawStar(GM_Star,GM_X,GM_Y);
	}
	for (var B=0; B<=Buffer; B++)
	{
		for (var i=C-B;i<=C+B;i++){
			for (var j=R-B;j<=R+B;j++){
				//var RandMapUrl = MapUrlList[((i+j)%(MapUrlList.length))]+"/data/australia/mappiece.cgi?" ;
				var TileID = "GM_Tile_" + j + "_" + i ;
				var TileID2 = "GM_Tile2_" + j + "_" + i ;
				//var MapURL = RandMapUrl + "L=" + GM_Level + "&R=" + j + "&C=" + i + "&B=" + GM_TileBoxSize ;


				// for drawing level 7 with new map
				if (GM_Level>=5) {
					var MapURL = MapUrlListNewMap+"/map/r_psma_au/" + getNewEncode(GM_Level+7) + "/" + getNewEncode(j) + "/" + getNewEncode(i) +
".png";
					var errorImages = GM_ServerName+"/sd_new/images/na_level7.png" ;
				} else {
//					var MapURL = MapUrlList[((i+j)%(MapUrlList.length))]+"/data/smallmap/australia/B" + GetEncode(GM_TileBoxSize+'') + "/L" + GetEncode(GM_Level+'') + "/R" + GetEncode(j+'') + "C" + GetEncode(i+'') + ".gif" ;
					var MapURL = MapUrlList[((i+j)%(MapUrlList.length))]+"/map/r_ausway_au/"+ "/L" + GetEncode(GM_Level+'') + "/R" + GetEncode(j+'') + "C" + GetEncode(i+'') + ".gif" ;
					var errorImages = GM_ServerName+"/images/na.gif" ;
				}

//				var MapURL = MapUrlList[((i+j)%(MapUrlList.length))]+"/data/smallmap/australia/B" + GetEncode(GM_TileBoxSize+'') + "/L" + GetEncode(GM_Level+'') + "/R" + GetEncode(j+'') + "C" + GetEncode(i+'') + ".gif" ;
				if (LoadedMap2[TileID2] != 1)
				{
					if (LoadedMap[TileID] != 1)
					{					
						//document.body.innerHTML += MapURL + "<br>" ;
						LoadedMap[TileID] = 1 ;
						if (document.getElementById(TileID))
						{
							var Img = document.getElementById(TileID) ;
							Img.src = MapURL ;
						} else {
							var Img = document.createElement('img') ;
							BlockRightClick(Img);
							Img.style.position = 'absolute' ;
							Img.id = TileID ;
							Img.name = TileID ;
							Img.width = GM_PieceW[GM_Level] ;
							Img.height = GM_PieceH[GM_Level] ;
	//						Img.style.top = ((j-1) * GM_PieceH[GM_Level]) + "px" ;
	//						Img.style.left = ((i-1) * GM_PieceW[GM_Level]) + "px" ;

							///////// change to opera compatible  ///////////

							Img.style.top = ((j-1) * GM_PieceH[GM_Level]) - GM_YCenter + "px" ;
							Img.style.left = ((i-1) * GM_PieceW[GM_Level]) - GM_XCenter + "px" ;

							/////////////////////////////////////////////////

							Img.src = MapURL ;
							Img.onerror = function() {
								this.src = errorImages;
								//this.src = GM_ServerName+"/images/na.gif" ;
								LoadedMap[this.id] = "" ;
							}
							DRObj.appendChild(Img);
						}
					} else {
						if (document.getElementById(TileID)) {
							var Img = document.getElementById(TileID) ;
							if (Img.src.indexOf(MapURL) < 0)
							{
								Img.src = MapURL ;
							}
						}
					}
				}
				
			}
		}
	}
}


function DrawTileMapAusway(ObjName,L,C,R,W,H) {

	var auswayFlag = checkAusway();
	auswayFlag = 1;
	var DRObj2 = document.getElementById('GM_DrawingLayer_Ausway');

	if (GM_Level>4 && auswayFlag>0) {
		CheckMapBoundary();

		var BufX = Math.ceil(((1/2)*W)/GM_PieceW[L]) ;
		var BufY = Math.ceil(((1/2)*H)/GM_PieceH[L]) ;
		DRObj2.style.visibility = 'visible';
		DRObj2.style.display    = '';

		var Buffer = (BufX>BufY)?BufX:BufY ;

		for (var i in LoadedMap2) {
			if (document.getElementById(i))
			{
				var Img = document.getElementById(i) ;
				if (!Img.complete || Img.src.indexOf("blank.gif") > 0)
				{
					LoadedMap2[i] = "" ;
				}
			}
		}
		var TileID2 = "";
		for (var B=0; B<=Buffer; B++)
		{
			for (var i=C-B;i<=C+B;i++){
				for (var j=R-B;j<=R+B;j++){
					TileID2 = "GM_Tile2_" + j + "_" + i ;

					var MapURL2 = MapUrlListNewMap +"/map/r_ausway_au/" + getNewEncode(GM_Level+7) + "/" + getNewEncode(j) + "/" + getNewEncode(i) + ".png";

					if (LoadedMap2[TileID2] != 1)
					{
						LoadedMap2[TileID2] = 1 ;
						if (document.getElementById(TileID2))
						{
							var Img = document.getElementById(TileID2) ;
							Img.src = MapURL2 ;
						//	Img.className = "trans";
						} else {
							var Img = document.createElement('img') ;
							BlockRightClick(Img);
							Img.border = 0 ;
							Img.style.position = 'absolute' ;
							Img.id = TileID2 ;
							Img.name = TileID2 ;
							Img.width = GM_PieceW[GM_Level];
							Img.height = GM_PieceH[GM_Level];
//							Img.style.top = ((j-1) * GM_PieceH[GM_Level]) + "px" ;
//							Img.style.left = ((i-1) * GM_PieceW[GM_Level]) + "px" ;

							////// change to opera compatible /////////
							Img.style.top = ((j-1) * GM_PieceH[GM_Level]) - GM_YCenter + "px" ;
							Img.style.left = ((i-1) * GM_PieceW[GM_Level]) - GM_XCenter + "px" ;
							///////////////////////////////////////////
							Img.src = MapURL2 ;
							//Img.className = "trans";
							Img.onerror = function() {
								this.src = GM_ServerName+"/sd_new/images/blank.gif" ;
								LoadedMap2[this.id] = "" ;
							}
							DRObj2.appendChild(Img);
						}
					} else {
						if (document.getElementById(TileID2)) {
							var Img = document.getElementById(TileID2) ;
							if (Img.src.indexOf(MapURL2) < 0)
							{
								Img.src = MapURL2 ;
								//Img.className = "trans";
							}
						}
					}

				}
			}
		}
		tmpTileID2 = TileID2;
	} else {
		  DRObj2.style.visibility = 'hidden';
		  DRObj2.style.display    = 'none';
	}	
}


function CheckingLevel(X,Y,XYList) {
	var Bound = new Array() ;
	Bound[0] = "144.886952,-37.786397,145.02032,-37.786397,145.02032,-37.852355,144.998092,-37.852355,144.998092,-37.874583,144.954217,-37.874583,144.954217,-37.852209,144.931553,-37.852209,144.931553,-37.80848,144.886952,-37.80848,144.886952,-37.786397" ;
	Bound[1] = "151.139957,-33.91969,151.143018,-33.807106,151.175153,-33.807543,151.175809,-33.784808,151.196358,-33.785464,151.196795,-33.785245,151.196139,-33.807543,151.272434,-33.809292,151.27309,-33.786775,151.293857,-33.786775,151.293857,-33.797487,151.300634,-33.797706,151.300416,-33.804701,151.293639,-33.80492,151.293639,-33.809511,151.272871,-33.809292,151.272215,-33.83159,151.292983,-33.831809,151.291453,-33.921876,151.139957,-33.91969" ;
	Bound[2] = "152.98,-27.4281,152.98,-27.4835,152.9589,-27.4835,152.9589,-27.5063,153.0814,-27.5063,153.0814,-27.4281" ;
	Bound[3] = "153.4192,-27.98,153.4405,-27.98,153.4405,-28.0474,153.4192,-28.0474,153.4192,-27.98" ;
	var MapL = 6 ;
	for (var i = 0; i < Bound.length; i++)
	{
		var V = Bound[i].split(",") ;
		var I = in_polygon(X,Y,V) ;
		if (I<=0)
		{
			MapL = 7 ;
			break ;
		}
	}

	var level = 1;
	var j = MapL ;
	for (var i=j;i>=1;i--) {
		var map_scale = (GM_XMax[i] - GM_XMin[i]) / GM_PieceTW[i] ;
		var lm_delta_x = (GM_Width/2) * map_scale;
		var lm_delta_y = (GM_Height/2) * map_scale;
		var lm_long_min = X - lm_delta_x;
		var lm_long_max = X + lm_delta_x;
		var lm_lat_min = Y - lm_delta_y;
		var lm_lat_max = Y + lm_delta_y;
		var status = 0;
		for (var k=0; k<XYList.length; k++)
		{
			if (XYList[k].X)
			{
				if (!((XYList[k].X >= lm_long_min && XYList[k].X <= lm_long_max) && (XYList[k].Y >= lm_lat_min && XYList[k].Y <= lm_lat_max))) {
					status = 1;
				}
			}
		}
		if (status == 0) {
			level = i;
			return level ;
		}
	}
	return level ;
}

//********************//
//     DRAG MODULE    //
//********************//

var DD_ie=document.all;
var DD_nn6=document.getElementById&&!document.all;
var DD_isdrag=false;
var DD_x,DD_y;
var DD_dobj;
var DD_sobj,XMouseClick,YMouseClick;
var DZX1,DZX2,DZY1,DZY2 ;
var OS ;
var XMouseStop, YMouseStop;
var XMouseStart, YMouseStart;

function DD_Dragging(e)
{
		if (document.getElementById('SearchDetailBox')) {
			oneResultOnly = false;
			document.getElementById('SearchDetailBox').innerHTML = "";
		}

	XMouseClick = DD_nn6 ? e.clientX : event.clientX ;
	YMouseClick = DD_nn6 ? e.clientY : event.clientY ;
	if (DD_isdrag && GM_Style == 1)
	{
		if (GMOnClickMapAction == 1)
		{
			DD_dobj.style.left = (DD_nn6 ? DD_tx + e.clientX - DD_x : DD_tx + event.clientX - DD_x) + "px";
			DD_dobj.style.top  = (DD_nn6 ? DD_ty + e.clientY - DD_y : DD_ty + event.clientY - DD_y) + "px";
			/*
			if (parseInt(DD_dobj.style.left,10) > 0)
			{
				DD_dobj.style.left = (0) + "px" ;
			}
			if (parseInt(DD_dobj.style.top,10) > 0)
			{
				DD_dobj.style.top = (0) + "px" ;
			}
			if (parseInt(DD_dobj.style.left,10) < -(GM_PieceW[GM_Level]*GM_UnitX[GM_Level])+GM_Width)
			{
				DD_dobj.style.left = -(GM_PieceW[GM_Level]*GM_UnitX[GM_Level])+GM_Width ;
			}
			if (parseInt(DD_dobj.style.top,10) < -(GM_PieceH[GM_Level]*GM_UnitY[GM_Level])+GM_Height)
			{
				DD_dobj.style.top = -(GM_PieceH[GM_Level]*GM_UnitY[GM_Level])+GM_Height ;
			}
			*/
			return false;
		} else if (GMOnClickMapAction == 2) {
			var documentbodyscrollLeft = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
			var documentbodyscrollTop = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
			DZX2 = XMouseClick - parseInt(DD_dobj.style.left+0,10) - parseInt(OS.left+0,10) + documentbodyscrollLeft ;
			DZY2 = YMouseClick - parseInt(DD_dobj.style.top+0,10) - parseInt(OS.top+0,10) + documentbodyscrollTop ;
			DragZoom.clear();
			var Thick = 1 ;
			var Color = "#FF0000" ;
			GM_SetLine(DragZoom,Thick,Color,DZX1, DZY1, DZX2, DZY1);
			GM_SetLine(DragZoom,Thick,Color,DZX1, DZY1, DZX1, DZY2);
			GM_SetLine(DragZoom,Thick,Color,DZX2, DZY1, DZX2, DZY2);
			GM_SetLine(DragZoom,Thick,Color,DZX1, DZY2, DZX2, DZY2);
		} else if (GMOnClickMapAction == 3) {
			var documentbodyscrollLeft = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
			var documentbodyscrollTop = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
			DZX1 = XMouseClick - parseInt(DD_dobj.style.left+0,10) - parseInt(OS.left+0,10) + documentbodyscrollLeft ;
			DZY1 = YMouseClick - parseInt(DD_dobj.style.top+0,10) - parseInt(OS.top+0,10) + documentbodyscrollTop ;
		}
	}
}

function StartDrag(e)
{
  if (e)
  {
	  if (e.button == 2 || e.button == 3)
	  {
		return ;
	  }
  }
  GM_ReDrawLayeringStatus = true ;
  DD_sobj       = DD_nn6 ? e.target : event.srcElement;
  XMouseClick = DD_nn6 ? e.clientX : event.clientX ;
  YMouseClick = DD_nn6 ? e.clientY : event.clientY ;
  XMouseStart = XMouseClick;
  YMouseStart = YMouseClick;
  var Regex = /^GM_/ ;
	if (DD_sobj)
	{
		if (document.getElementById('Streetview_checkbox')) {
			  if (document.getElementById('Streetview_checkbox').checked)
			{
				if (Regex.test(DD_sobj.id))
					Streetview_Close();
			}
		}
		
		
	  if (DD_sobj.id == SV_CV_Id) {
	     document.onmousedown = SV_startDrag;
       document.onmouseup   = SV_stopDrag;
       SV_startDrag(e);
       return false;
		}
	  if (Regex.test(DD_sobj.id))
	  {
		  DD_isdrag = true;
		  if (GMOnClickMapAction == 1)
		  {
			  if (IEV >= 6)
			  {
				document.getElementById(GM_DivObj).style.cursor = (window.stop)?"-moz-grabbing":GM_ServerName+"/CommonLibrary/panning.cur" ;
			  }
			  var DD_fobj = document.getElementById('GM_Tiling_Div') ;
			  var DD_topelement = DD_nn6 ? "HTML" : "BODY";
			  while (DD_fobj.tagName != DD_topelement && DD_fobj.className != "DragAndDrop")
			  {
				DD_fobj = DD_nn6 ? DD_fobj.parentNode : DD_fobj.parentElement;
			  }
			  if (GM_Style == 1 && DD_fobj.className=="DragAndDrop")
			  {
				DD_dobj = DD_fobj;
				DD_tx = parseInt(DD_dobj.style.left+0,10);
				DD_ty = parseInt(DD_dobj.style.top+0,10);
				DD_x = DD_nn6 ? e.clientX : event.clientX;
				DD_y = DD_nn6 ? e.clientY : event.clientY;
				document.onmousemove=DD_Dragging;
				return false;
			  }
		  } else if (GMOnClickMapAction == 2 || GMOnClickMapAction == 3) {
				var DD_fobj = document.getElementById('GM_Tiling_Div') ;
				var DD_topelement = DD_nn6 ? "HTML" : "BODY";
				while (DD_fobj.tagName != DD_topelement && DD_fobj.className != "DragAndDrop")
				{
					DD_fobj = DD_nn6 ? DD_fobj.parentNode : DD_fobj.parentElement;
				}
				if (GM_Style == 1 && DD_fobj.className=="DragAndDrop")
				{
					DD_dobj = DD_fobj;
				}
				OS = ShowOffSet(GM_DivObj);
				var documentbodyscrollLeft = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
				var documentbodyscrollTop = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
				DZX1 = XMouseClick - parseInt(DD_dobj.style.left+0,10) - parseInt(OS.left+0,10) + documentbodyscrollLeft ;
				DZY1 = YMouseClick - parseInt(DD_dobj.style.top+0,10) - parseInt(OS.top+0,10) + documentbodyscrollTop ;
				document.onmousemove=DD_Dragging;
				return false ;
		  }
	  }
	}
}
document.onmousedown=StartDrag;
document.onmouseup=StopDrag;

function StopDrag(e) {
  DD_isdrag=false;
  var Regex = /^GM_/ ;
  var Regex2 = /^GM_Tile/;
  if (DD_sobj)
  {

	  if (Regex.test(DD_sobj.id))
	  {
		  if (GMOnClickMapAction == 1)
		  {
			  if (IEV >= 6)
			  {
				document.getElementById(GM_DivObj).style.cursor = (window.stop)?"-moz-grab":GM_ServerName+"/CommonLibrary/move.cur" ;
			  }
			  var DD_fobj = document.getElementById('GM_Tiling_Div') ;
			  var DD_topelement = DD_nn6 ? "HTML" : "BODY";
			  if (GM_Style == 1 && DD_fobj.className=="DragAndDrop")
			  {
				DD_dobj = DD_fobj;
//				var NGM_XCenter = Math.round(GM_Width/2) - parseInt(DD_dobj.style.left,10) ;
//				var NGM_YCenter  = Math.round(GM_Height/2) - parseInt(DD_dobj.style.top,10) ;


				//////// change to opera compatible ///////////////

				var NGM_XCenter = Math.round(GM_Width/2) - parseInt(DD_dobj.style.left,10) + GM_XCenter ;
				var NGM_YCenter  = Math.round(GM_Height/2) - parseInt(DD_dobj.style.top,10) + GM_YCenter;

				///////////////////////////////////////////////////


				var Col = Math.ceil(NGM_XCenter/GM_PieceW[GM_Level]) ;
				var Row = Math.ceil(NGM_YCenter/GM_PieceH[GM_Level]) ;
				GM_New_X = (NGM_XCenter/GM_MapScale) + GM_XMin[GM_Level] ;
				GM_New_Y = GM_YMax[GM_Level] - (NGM_YCenter/GM_MapScale) ;
				DrawTileMapAusway('GM_Tiling_Div',GM_Level,Col,Row,GM_Width,GM_Height);	
				if (GM_Level>4) {
					document.getElementById(tmpTileID2).onload = function() {
						DrawTileMap('GM_Tiling_Div',GM_Level,Col,Row,GM_Width,GM_Height);
					}
				} else {
					DrawTileMap('GM_Tiling_Div',GM_Level,Col,Row,GM_Width,GM_Height);
				}
				DrawTileMapStreetview('GM_Tiling_Div',GM_Level,Col,Row,GM_Width,GM_Height);	
				Shopping_GetDataList();	
				
/*				DrawTileMapAusway('GM_Tiling_Div',GM_Level,Col,Row,GM_Width,GM_Height);
				DrawTileMap('GM_Tiling_Div',GM_Level,Col,Row,GM_Width,GM_Height);
				DrawTileMapStreetview('GM_Tiling_Div',GM_Level,Col,Row,GM_Width,GM_Height);
*/				if (GM_ReDrawLayering && GM_ReDrawLayeringStatus == true)
				{
					GM_ReDrawLayer();
				}
			  }
		  } else if	(GMOnClickMapAction == 2) {
				if ((DZX1&&DZX2&&DZY1&&DZY2)&& (DZX1 != DZX2 && DZY1 != DZY2))
				{
					var TLBR = new Array() ;
					TLBR[0] = GM_ConvertPxToDeg(DZX1,DZY1) ;
					TLBR[1] = GM_ConvertPxToDeg(DZX2,DZY2) ;
					TLBR[2] = GM_ConvertPxToDeg((DZX1+DZX2)/2,(DZY1+DZY2)/2) ;
					var CL = CheckingLevel(TLBR[2].X,TLBR[2].Y,TLBR) ;
					GM_ChangeLevel(CL,TLBR[2].X,TLBR[2].Y);
				}
		  } else if	(GMOnClickMapAction == 3) {
				if (DZX1&&DZY1)
				{
					var NewP = GM_ConvertPxToDeg(DZX1,DZY1);
					var CL = GM_Level - 1 ;
					if (CL<=0)
					{
						CL = 1 ;
					}
					GM_ChangeLevel(CL,NewP.X,NewP.Y);
				}
		  }

		if (document.getElementById('Streetview_checkbox')) {
			if (document.getElementById('Streetview_checkbox').checked)
			{
				if (Regex2.test(DD_sobj.id))
				{
					XMouseStop = DD_nn6 ? e.clientX : event.clientX ;
					YMouseStop = DD_nn6 ? e.clientY : event.clientY ;
					if (XMouseStart == XMouseStop && YMouseStart == YMouseStop) {
						var test = showLongLat(e);
						SV_moveCenterViewToNearestPoint(test);
					}
				}
			}
		}
	 }
  }
  GM_ReDrawLayeringStatus = false ;
}

function nocontextmenu(e)
{
	if (!GMDisabledRightClick) {
		GM_ShowRightClick(e);
	}
	return false;
}


function norightclick(e) {

	// changed by Bayu
	if(typeof e == 'undefined') e = window.event;
	if((e.which || e.button) == 2 || (e.which || e.button) == 3) {
		if(e.cancelBubble) e.cancelBubble = true;
		if(e.returnValue) e.returnValue = false;
		return false;
	}
}

if(window.Event) {
  if(document.captureEvents || Event.MOUSEUP) document.captureEvents(Event.MOUSEUP);
}

if(document.layers) {
  if(document.captureEvents || Event.MOUSEDOWN) document.captureEvents(Event.MOUSEDOWN);
}



	//////////////////////

/*	if (window.Event) 
	{
		if (e.which == 2 || e.which == 3)
		return false;
	}
	else if (e) {
		if (e.button == 2 || e.button == 3)
		{
			e.cancelBubble = true
			e.returnValue = false;
			return false;
		}
	}
*/


//if (window.Event) document.captureEvents(Event.MOUSEUP);
//if (document.layers) document.captureEvents(Event.MOUSEDOWN);



function BlockRightClick(XObj) {
	XObj.oncontextmenu = nocontextmenu;
	XObj.onmousedown = norightclick;
	XObj.onmouseup = norightclick;
}

function GetEncode(S) {
	var Str = S + '';
	for (var i in GK) {
		var regEx = new RegExp (i, 'gi') ;
		Str = Str.replace(regEx,GK[i]);
	}
	return Str ;
}

//******************************//
//   Canvas Drawing Functions   //
//******************************//

var jg_ihtm, jg_ie, jg_fast, jg_dom, jg_moz,
jg_n4 = (document.layers && typeof document.classes != "undefined");


function chkDHTM(x, i)
{
	x = document.body || null;
	jg_ie = x && typeof x.insertAdjacentHTML != "undefined";
	jg_dom = (x && !jg_ie &&
		typeof x.appendChild != "undefined" &&
		typeof document.createRange != "undefined" &&
		typeof (i = document.createRange()).setStartBefore != "undefined" &&
		typeof i.createContextualFragment != "undefined");
	jg_ihtm = !jg_ie && !jg_dom && x && typeof x.innerHTML != "undefined";
	jg_fast = jg_ie && document.all && !window.opera;
	jg_moz = jg_dom && typeof x.style.MozOpacity != "undefined";
}


function pntDoc()
{
	this.wnd.document.write(jg_fast? this.htmRpc() : this.htm);
	this.htm = '';
}


function pntCnvDom()
{
	var x = document.createRange();
	x.setStartBefore(this.cnv);
	x = x.createContextualFragment(jg_fast? this.htmRpc() : this.htm);
	this.cnv.appendChild(x);
	this.htm = '';
}


function pntCnvIe()
{
	this.cnv.insertAdjacentHTML("BeforeEnd", jg_fast? this.htmRpc() : this.htm);
	this.htm = '';
}


function pntCnvIhtm()
{
	this.cnv.innerHTML += this.htm;
	this.htm = '';
}


function pntCnv()
{
	this.htm = '';
}


function mkDiv(x, y, w, h)
{
	this.htm += '<div style="position:absolute;'+
		'left:' + x + 'px;'+
		'top:' + y + 'px;'+
		'width:' + w + 'px;'+
		'height:' + h + 'px;'+
		'clip:rect(0,'+w+'px,'+h+'px,0);'+
		'background-color:' + this.color +
		(!jg_moz? ';overflow:hidden' : '')+
		';"><\/div>';
}


function mkDivIe(x, y, w, h)
{
	this.htm += '%%'+this.color+';'+x+';'+y+';'+w+';'+h+';';
}


function mkDivPrt(x, y, w, h)
{
	this.htm += '<div style="position:absolute;'+
		'border-left:' + w + 'px solid ' + this.color + ';'+
		'left:' + x + 'px;'+
		'top:' + y + 'px;'+
		'width:0px;'+
		'height:' + h + 'px;'+
		'clip:rect(0,'+w+'px,'+h+'px,0);'+
		'background-color:' + this.color +
		(!jg_moz? ';overflow:hidden' : '')+
		';"><\/div>';
}


function mkLyr(x, y, w, h)
{
	this.htm += '<layer '+
		'left="' + x + '" '+
		'top="' + y + '" '+
		'width="' + w + '" '+
		'height="' + h + '" '+
		'bgcolor="' + this.color + '"><\/layer>\n';
}


var regex =  /%%([^;]+);([^;]+);([^;]+);([^;]+);([^;]+);/g;
function htmRpc()
{
	return this.htm.replace(
		regex,
		'<div style="overflow:hidden;position:absolute;background-color:'+
		'$1;left:$2;top:$3;width:$4;height:$5"></div>\n');
}


function htmPrtRpc()
{
	return this.htm.replace(
		regex,
		'<div style="overflow:hidden;position:absolute;background-color:'+
		'$1;left:$2;top:$3;width:$4;height:$5;border-left:$4px solid $1"></div>\n');
}


function mkLin(x1, y1, x2, y2)
{
	if (x1 > x2)
	{
		var _x2 = x2;
		var _y2 = y2;
		x2 = x1;
		y2 = y1;
		x1 = _x2;
		y1 = _y2;
	}
	var dx = x2-x1, dy = Math.abs(y2-y1),
	x = x1, y = y1,
	yIncr = (y1 > y2)? -1 : 1;

	if (dx >= dy)
	{
		var pr = dy<<1,
		pru = pr - (dx<<1),
		p = pr-dx,
		ox = x;
		while ((dx--) > 0)
		{
			++x;
			if (p > 0)
			{
				this.mkDiv(ox, y, x-ox, 1);
				y += yIncr;
				p += pru;
				ox = x;
			}
			else p += pr;
		}
		this.mkDiv(ox, y, x2-ox+1, 1);
	}

	else
	{
		var pr = dx<<1,
		pru = pr - (dy<<1),
		p = pr-dy,
		oy = y;
		if (y2 <= y1)
		{
			while ((dy--) > 0)
			{
				if (p > 0)
				{
					this.mkDiv(x++, y, 1, oy-y+1);
					y += yIncr;
					p += pru;
					oy = y;
				}
				else
				{
					y += yIncr;
					p += pr;
				}
			}
			this.mkDiv(x2, y2, 1, oy-y2+1);
		}
		else
		{
			while ((dy--) > 0)
			{
				y += yIncr;
				if (p > 0)
				{
					this.mkDiv(x++, oy, 1, y-oy);
					p += pru;
					oy = y;
				}
				else p += pr;
			}
			this.mkDiv(x2, oy, 1, y2-oy+1);
		}
	}
}


function mkLin2D(x1, y1, x2, y2)
{
	if (x1 > x2)
	{
		var _x2 = x2;
		var _y2 = y2;
		x2 = x1;
		y2 = y1;
		x1 = _x2;
		y1 = _y2;
	}
	var dx = x2-x1, dy = Math.abs(y2-y1),
	x = x1, y = y1,
	yIncr = (y1 > y2)? -1 : 1;

	var s = this.stroke;
	if (dx >= dy)
	{
		if (dx > 0 && s-3 > 0)
		{
			var _s = (s*dx*Math.sqrt(1+dy*dy/(dx*dx))-dx-(s>>1)*dy) / dx;
			_s = (!(s-4)? Math.ceil(_s) : Math.round(_s)) + 1;
		}
		else var _s = s;
		var ad = Math.ceil(s/2);

		var pr = dy<<1,
		pru = pr - (dx<<1),
		p = pr-dx,
		ox = x;
		while ((dx--) > 0)
		{
			++x;
			if (p > 0)
			{
				this.mkDiv(ox, y, x-ox+ad, _s);
				y += yIncr;
				p += pru;
				ox = x;
			}
			else p += pr;
		}
		this.mkDiv(ox, y, x2-ox+ad+1, _s);
	}

	else
	{
		if (s-3 > 0)
		{
			var _s = (s*dy*Math.sqrt(1+dx*dx/(dy*dy))-(s>>1)*dx-dy) / dy;
			_s = (!(s-4)? Math.ceil(_s) : Math.round(_s)) + 1;
		}
		else var _s = s;
		var ad = Math.round(s/2);

		var pr = dx<<1,
		pru = pr - (dy<<1),
		p = pr-dy,
		oy = y;
		if (y2 <= y1)
		{
			++ad;
			while ((dy--) > 0)
			{
				if (p > 0)
				{
					this.mkDiv(x++, y, _s, oy-y+ad);
					y += yIncr;
					p += pru;
					oy = y;
				}
				else
				{
					y += yIncr;
					p += pr;
				}
			}
			this.mkDiv(x2, y2, _s, oy-y2+ad);
		}
		else
		{
			while ((dy--) > 0)
			{
				y += yIncr;
				if (p > 0)
				{
					this.mkDiv(x++, oy, _s, y-oy+ad);
					p += pru;
					oy = y;
				}
				else p += pr;
			}
			this.mkDiv(x2, oy, _s, y2-oy+ad+1);
		}
	}
}


function mkLinDott(x1, y1, x2, y2)
{
	if (x1 > x2)
	{
		var _x2 = x2;
		var _y2 = y2;
		x2 = x1;
		y2 = y1;
		x1 = _x2;
		y1 = _y2;
	}
	var dx = x2-x1, dy = Math.abs(y2-y1),
	x = x1, y = y1,
	yIncr = (y1 > y2)? -1 : 1,
	drw = true;
	if (dx >= dy)
	{
		var pr = dy<<1,
		pru = pr - (dx<<1),
		p = pr-dx;
		while ((dx--) > 0)
		{
			if (drw) this.mkDiv(x, y, 1, 1);
			drw = !drw;
			if (p > 0)
			{
				y += yIncr;
				p += pru;
			}
			else p += pr;
			++x;
		}
		if (drw) this.mkDiv(x, y, 1, 1);
	}

	else
	{
		var pr = dx<<1,
		pru = pr - (dy<<1),
		p = pr-dy;
		while ((dy--) > 0)
		{
			if (drw) this.mkDiv(x, y, 1, 1);
			drw = !drw;
			y += yIncr;
			if (p > 0)
			{
				++x;
				p += pru;
			}
			else p += pr;
		}
		if (drw) this.mkDiv(x, y, 1, 1);
	}
}


function mkOv(left, top, width, height)
{
	var a = width>>1, b = height>>1,
	wod = width&1, hod = (height&1)+1,
	cx = left+a, cy = top+b,
	x = 0, y = b,
	ox = 0, oy = b,
	aa = (a*a)<<1, bb = (b*b)<<1,
	st = (aa>>1)*(1-(b<<1)) + bb,
	tt = (bb>>1) - aa*((b<<1)-1),
	w, h;
	while (y > 0)
	{
		if (st < 0)
		{
			st += bb*((x<<1)+3);
			tt += (bb<<1)*(++x);
		}
		else if (tt < 0)
		{
			st += bb*((x<<1)+3) - (aa<<1)*(y-1);
			tt += (bb<<1)*(++x) - aa*(((y--)<<1)-3);
			w = x-ox;
			h = oy-y;
			if (w&2 && h&2)
			{
				this.mkOvQds(cx, cy, -x+2, ox+wod, -oy, oy-1+hod, 1, 1);
				this.mkOvQds(cx, cy, -x+1, x-1+wod, -y-1, y+hod, 1, 1);
			}
			else this.mkOvQds(cx, cy, -x+1, ox+wod, -oy, oy-h+hod, w, h);
			ox = x;
			oy = y;
		}
		else
		{
			tt -= aa*((y<<1)-3);
			st -= (aa<<1)*(--y);
		}
	}
	this.mkDiv(cx-a, cy-oy, a-ox+1, (oy<<1)+hod);
	this.mkDiv(cx+ox+wod, cy-oy, a-ox+1, (oy<<1)+hod);
}


function mkOv2D(left, top, width, height)
{
	var s = this.stroke;
	width += s-1;
	height += s-1;
	var a = width>>1, b = height>>1,
	wod = width&1, hod = (height&1)+1,
	cx = left+a, cy = top+b,
	x = 0, y = b,
	aa = (a*a)<<1, bb = (b*b)<<1,
	st = (aa>>1)*(1-(b<<1)) + bb,
	tt = (bb>>1) - aa*((b<<1)-1);

	if (s-4 < 0 && (!(s-2) || width-51 > 0 && height-51 > 0))
	{
		var ox = 0, oy = b,
		w, h,
		pxl, pxr, pxt, pxb, pxw;
		while (y > 0)
		{
			if (st < 0)
			{
				st += bb*((x<<1)+3);
				tt += (bb<<1)*(++x);
			}
			else if (tt < 0)
			{
				st += bb*((x<<1)+3) - (aa<<1)*(y-1);
				tt += (bb<<1)*(++x) - aa*(((y--)<<1)-3);
				w = x-ox;
				h = oy-y;

				if (w-1)
				{
					pxw = w+1+(s&1);
					h = s;
				}
				else if (h-1)
				{
					pxw = s;
					h += 1+(s&1);
				}
				else pxw = h = s;
				this.mkOvQds(cx, cy, -x+1, ox-pxw+w+wod, -oy, -h+oy+hod, pxw, h);
				ox = x;
				oy = y;
			}
			else
			{
				tt -= aa*((y<<1)-3);
				st -= (aa<<1)*(--y);
			}
		}
		this.mkDiv(cx-a, cy-oy, s, (oy<<1)+hod);
		this.mkDiv(cx+a+wod-s+1, cy-oy, s, (oy<<1)+hod);
	}

	else
	{
		var _a = (width-((s-1)<<1))>>1,
		_b = (height-((s-1)<<1))>>1,
		_x = 0, _y = _b,
		_aa = (_a*_a)<<1, _bb = (_b*_b)<<1,
		_st = (_aa>>1)*(1-(_b<<1)) + _bb,
		_tt = (_bb>>1) - _aa*((_b<<1)-1),

		pxl = new Array(),
		pxt = new Array(),
		_pxb = new Array();
		pxl[0] = 0;
		pxt[0] = b;
		_pxb[0] = _b-1;
		while (y > 0)
		{
			if (st < 0)
			{
				st += bb*((x<<1)+3);
				tt += (bb<<1)*(++x);
				pxl[pxl.length] = x;
				pxt[pxt.length] = y;
			}
			else if (tt < 0)
			{
				st += bb*((x<<1)+3) - (aa<<1)*(y-1);
				tt += (bb<<1)*(++x) - aa*(((y--)<<1)-3);
				pxl[pxl.length] = x;
				pxt[pxt.length] = y;
			}
			else
			{
				tt -= aa*((y<<1)-3);
				st -= (aa<<1)*(--y);
			}

			if (_y > 0)
			{
				if (_st < 0)
				{
					_st += _bb*((_x<<1)+3);
					_tt += (_bb<<1)*(++_x);
					_pxb[_pxb.length] = _y-1;
				}
				else if (_tt < 0)
				{
					_st += _bb*((_x<<1)+3) - (_aa<<1)*(_y-1);
					_tt += (_bb<<1)*(++_x) - _aa*(((_y--)<<1)-3);
					_pxb[_pxb.length] = _y-1;
				}
				else
				{
					_tt -= _aa*((_y<<1)-3);
					_st -= (_aa<<1)*(--_y);
					_pxb[_pxb.length-1]--;
				}
			}
		}

		var ox = 0, oy = b,
		_oy = _pxb[0],
		l = pxl.length,
		w, h;
		for (var i = 0; i < l; i++)
		{
			if (typeof _pxb[i] != "undefined")
			{
				if (_pxb[i] < _oy || pxt[i] < oy)
				{
					x = pxl[i];
					this.mkOvQds(cx, cy, -x+1, ox+wod, -oy, _oy+hod, x-ox, oy-_oy);
					ox = x;
					oy = pxt[i];
					_oy = _pxb[i];
				}
			}
			else
			{
				x = pxl[i];
				this.mkDiv(cx-x+1, cy-oy, 1, (oy<<1)+hod);
				this.mkDiv(cx+ox+wod, cy-oy, 1, (oy<<1)+hod);
				ox = x;
				oy = pxt[i];
			}
		}
		this.mkDiv(cx-a, cy-oy, 1, (oy<<1)+hod);
		this.mkDiv(cx+ox+wod, cy-oy, 1, (oy<<1)+hod);
	}
}


function mkOvDott(left, top, width, height)
{
	var a = width>>1, b = height>>1,
	wod = width&1, hod = height&1,
	cx = left+a, cy = top+b,
	x = 0, y = b,
	aa2 = (a*a)<<1, aa4 = aa2<<1, bb = (b*b)<<1,
	st = (aa2>>1)*(1-(b<<1)) + bb,
	tt = (bb>>1) - aa2*((b<<1)-1),
	drw = true;
	while (y > 0)
	{
		if (st < 0)
		{
			st += bb*((x<<1)+3);
			tt += (bb<<1)*(++x);
		}
		else if (tt < 0)
		{
			st += bb*((x<<1)+3) - aa4*(y-1);
			tt += (bb<<1)*(++x) - aa2*(((y--)<<1)-3);
		}
		else
		{
			tt -= aa2*((y<<1)-3);
			st -= aa4*(--y);
		}
		if (drw) this.mkOvQds(cx, cy, -x, x+wod, -y, y+hod, 1, 1);
		drw = !drw;
	}
}


function mkRect(x, y, w, h)
{
	var s = this.stroke;
	this.mkDiv(x, y, w, s);
	this.mkDiv(x+w, y, s, h);
	this.mkDiv(x, y+h, w+s, s);
	this.mkDiv(x, y+s, s, h-s);
}


function mkRectDott(x, y, w, h)
{
	this.drawLine(x, y, x+w, y);
	this.drawLine(x+w, y, x+w, y+h);
	this.drawLine(x, y+h, x+w, y+h);
	this.drawLine(x, y, x, y+h);
}


function jsgFont()
{
	this.PLAIN = 'font-weight:normal;';
	this.BOLD = 'font-weight:bold;';
	this.ITALIC = 'font-style:italic;';
	this.ITALIC_BOLD = this.ITALIC + this.BOLD;
	this.BOLD_ITALIC = this.ITALIC_BOLD;
}
var Font = new jsgFont();


function jsgStroke()
{
	this.DOTTED = -1;
}
var Stroke = new jsgStroke();


function jsGraphics(id, wnd)
{
	this.setColor = new Function('arg', 'this.color = arg.toLowerCase();');

	this.setStroke = function(x)
	{
		this.stroke = x;
		if (!(x+1))
		{
			this.drawLine = mkLinDott;
			this.mkOv = mkOvDott;
			this.drawRect = mkRectDott;
		}
		else if (x-1 > 0)
		{
			this.drawLine = mkLin2D;
			this.mkOv = mkOv2D;
			this.drawRect = mkRect;
		}
		else
		{
			this.drawLine = mkLin;
			this.mkOv = mkOv;
			this.drawRect = mkRect;
		}
	};


	this.setPrintable = function(arg)
	{
		this.printable = arg;
		if (jg_fast)
		{
			this.mkDiv = mkDivIe;
			this.htmRpc = arg? htmPrtRpc : htmRpc;
		}
		else this.mkDiv = jg_n4? mkLyr : arg? mkDivPrt : mkDiv;
	};


	this.setFont = function(fam, sz, sty)
	{
		this.ftFam = fam;
		this.ftSz = sz;
		this.ftSty = sty || Font.PLAIN;
	};


	this.drawPolyline = this.drawPolyLine = function(x, y, s)
	{
		for (var i=0 ; i<x.length-1 ; i++ )
			this.drawLine(x[i], y[i], x[i+1], y[i+1]);
	};


	this.fillRect = function(x, y, w, h)
	{
		this.mkDiv(x, y, w, h);
	};


	this.drawPolygon = function(x, y)
	{
		this.drawPolyline(x, y);
		this.drawLine(x[x.length-1], y[x.length-1], x[0], y[0]);
	};


	this.drawEllipse = this.drawOval = function(x, y, w, h)
	{
		this.mkOv(x, y, w, h);
	};


	this.fillEllipse = this.fillOval = function(left, top, w, h)
	{
		var a = (w -= 1)>>1, b = (h -= 1)>>1,
		wod = (w&1)+1, hod = (h&1)+1,
		cx = left+a, cy = top+b,
		x = 0, y = b,
		ox = 0, oy = b,
		aa2 = (a*a)<<1, aa4 = aa2<<1, bb = (b*b)<<1,
		st = (aa2>>1)*(1-(b<<1)) + bb,
		tt = (bb>>1) - aa2*((b<<1)-1),
		pxl, dw, dh;
		if (w+1) while (y > 0)
		{
			if (st < 0)
			{
				st += bb*((x<<1)+3);
				tt += (bb<<1)*(++x);
			}
			else if (tt < 0)
			{
				st += bb*((x<<1)+3) - aa4*(y-1);
				pxl = cx-x;
				dw = (x<<1)+wod;
				tt += (bb<<1)*(++x) - aa2*(((y--)<<1)-3);
				dh = oy-y;
				this.mkDiv(pxl, cy-oy, dw, dh);
				this.mkDiv(pxl, cy+y+hod, dw, dh);
				ox = x;
				oy = y;
			}
			else
			{
				tt -= aa2*((y<<1)-3);
				st -= aa4*(--y);
			}
		}
		this.mkDiv(cx-a, cy-oy, w+1, (oy<<1)+hod);
	};

	this.fillPolygon = function(array_x, array_y)
	{
		var i;
		var y;
		var miny, maxy;
		var x1, y1;
		var x2, y2;
		var ind1, ind2;
		var ints;

		var n = array_x.length;

		if (!n) return;


		miny = array_y[0];
		maxy = array_y[0];
		for (i = 1; i < n; i++)
		{
			if (array_y[i] < miny)
				miny = array_y[i];

			if (array_y[i] > maxy)
				maxy = array_y[i];
		}
		for (y = miny; y <= maxy; y++)
		{
			var polyInts = new Array();
			ints = 0;
			for (i = 0; i < n; i++)
			{
				if (!i)
				{
					ind1 = n-1;
					ind2 = 0;
				}
				else
				{
					ind1 = i-1;
					ind2 = i;
				}
				y1 = array_y[ind1];
				y2 = array_y[ind2];
				if (y1 < y2)
				{
					x1 = array_x[ind1];
					x2 = array_x[ind2];
				}
				else if (y1 > y2)
				{
					y2 = array_y[ind1];
					y1 = array_y[ind2];
					x2 = array_x[ind1];
					x1 = array_x[ind2];
				}
				else continue;

				if ((y >= y1) && (y < y2))
					polyInts[ints++] = Math.round((y-y1) * (x2-x1) / (y2-y1) + x1);

				else if ((y == maxy) && (y > y1) && (y <= y2))
					polyInts[ints++] = Math.round((y-y1) * (x2-x1) / (y2-y1) + x1);
			}
			polyInts.sort(integer_compare);
			for (i = 0; i < ints; i+=2)
				this.mkDiv(polyInts[i], y, polyInts[i+1]-polyInts[i]+1, 1);
		}
	};


	this.drawString = function(txt, x, y)
	{
		this.htm += '<div style="position:absolute;white-space:nowrap;'+
			'left:' + x + 'px;'+
			'top:' + y + 'px;'+
			'font-family:' +  this.ftFam + ';'+
			'font-size:' + this.ftSz + ';'+
			'color:' + this.color + ';' + this.ftSty + '">'+
			txt +
			'<\/div>';
	};

	this.drawStringRect = function(txt, x, y, width, halign)
	{
		this.htm += '<div style="position:absolute;overflow:hidden;'+
			'left:' + x + 'px;'+
			'top:' + y + 'px;'+
			'width:'+width +'px;'+
			'text-align:'+halign+';'+
			'font-family:' +  this.ftFam + ';'+
			'font-size:' + this.ftSz + ';'+
			'color:' + this.color + ';' + this.ftSty + '">'+
			txt +
			'<\/div>';
	};


	this.drawImage = function(imgSrc, x, y, w, h, a)
	{
		this.htm += '<div style="position:absolute;'+
			'left:' + x + 'px;'+
			'top:' + y + 'px;'+
			'width:' +  w + ';'+
			'height:' + h + ';">'+
			'<img src="' + imgSrc + '" width="' + w + '" height="' + h + '"' + (a? (' '+a) : '') + '>'+
			'<\/div>';
	};


	this.clear = function()
	{
		this.htm = "";
		if (this.cnv) {
			this.cnv.innerHTML = this.defhtm;
		}
	};


	this.mkOvQds = function(cx, cy, xl, xr, yt, yb, w, h)
	{
		this.mkDiv(xr+cx, yt+cy, w, h);
		this.mkDiv(xr+cx, yb+cy, w, h);
		this.mkDiv(xl+cx, yb+cy, w, h);
		this.mkDiv(xl+cx, yt+cy, w, h);
	};

	this.setStroke(1);

// disabled by BK
//	this.setFont('verdana,geneva,helvetica,sans-serif', String.fromCharCode(0x31, 0x32, 0x70, 0x78), Font.PLAIN);
	this.color = '#000000';
	this.htm = '';
	this.wnd = wnd || window;

	if (!(jg_ie || jg_dom || jg_ihtm)) chkDHTM();
	if (typeof id != 'string' || !id) this.paint = pntDoc;
	else
	{
		this.cnv = document.all? (this.wnd.document.all[id] || null)
			: document.getElementById? (this.wnd.document.getElementById(id) || null)
			: null;
		this.defhtm = (this.cnv && this.cnv.innerHTML)? this.cnv.innerHTML : '';
		this.paint = jg_dom? pntCnvDom : jg_ie? pntCnvIe : jg_ihtm? pntCnvIhtm : pntCnv;
	}

	this.setPrintable(false);
}



function integer_compare(x,y)
{
	return (x < y) ? -1 : ((x > y)*1);
}

function Set_Cookie( name, value, expires, path, domain, secure )
{
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
	( ( path ) ? ";path=" + path : "" ) +
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

function Get_Cookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) &&
	( name != document.cookie.substring( 0, name.length ) ) )
	{
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

function in_polygon(X,Y,Vertices) {
    var length = Vertices.length ;
	var out = 1 ;
	j = length - 2;
	for (var i=0; i<length-1; i+=2) {
		if ( ((Vertices[i+1]<=Y) && (Y<=Vertices[j+1])) || ((Vertices[j+1]<=Y) && (Y<=Vertices[i+1]))) {
			var T = ((Vertices[j+1]-Vertices[i+1]) != 0)?(Vertices[j]-Vertices[i])*(Y-Vertices[i+1])/(Vertices[j+1]-Vertices[i+1]):0.0000000000000000001 ;
			if (X <= T+Vertices[i]) {
				out = 1 - out;
			}
		}
		j = i;
	}
 	return out;
}

function GetDistance(A,B) {
	var Distance = 0 ;
	if (!(A.Longitude == B.Longitude && A.Latitude == B.Latitude))
	{
		Distance = (20001.6/Math.PI)*Math.acos(Math.sin(Math.PI*(A.Latitude)/180)*Math.sin(Math.PI*(B.Latitude)/180)+Math.cos(Math.PI*(A.Latitude)/180)*Math.cos(Math.PI*(B.Latitude)/180)*Math.cos(((B.Longitude)-(A.Longitude))*Math.PI/180)) ;
	}
	return Distance ;
}


function ShowOffSet(ID) {
	var left = 0 ;
	var top = 0 ;
	var NewID = document.getElementById(ID);
	left = 0 ;
	top = 0 ;
	while (NewID.offsetParent) {
		top += parseInt(NewID.offsetTop,10) ;
		left += parseInt(NewID.offsetLeft,10) ;
		NewID = NewID.offsetParent ;
	}
	var NewObj = new NewOffSet();
	NewObj.left = left ;
	NewObj.top = top ;
	return NewObj ;
}

function NewOffSet() {
	this.left = '' ;
	this.top = '' ;
}

var dataPolyState = new Array () ; // australia state polygon
//dataPolyState[1]="140.928887,-34.08249974,141.5011046,-34.18054101,141.8262915,-34.00448258,142.4865196,-34.66070274,142.9003937,-34.56467087,143.4029557,-35.05283407,144.2096157,-35.76924599,144.8648119,-36.12299678,145.0584525,-35.87711119,146.044165,-35.88716292,147.8767402,-35.94113244,147.878747,-35.94612139,148.2718647,-36.65361585,149.0690899,-37.17354679,150.0409107,-37.47902961,149.4731111,-37.78975396,148.2063615,-37.83277803,147.6821718,-37.95069495,147.1580148,-38.54027486,146.7648972,-38.95298174,146.1752042,-39.12985476,145.6510473,-38.65818942,145.0613544,-38.24548491,144.9958511,-37.83277803,144.6027334,-38.30444337,143.9475373,-38.83506481,142.8991907,-38.59923332,142.1784585,-38.24548491,141.5887983,-38.42235793,140.953186,-38.03862444,140.928887,-34.08249974";
dataPolyState[1]="140.9422946,-33.9989067,141.514513,-34.09694818,141.8397002,-33.92089036,142.4999278,-34.57711033,142.9138019,-34.4810777,143.416364,-34.96924106,144.2230245,-35.6856531,144.8782199,-36.03940356,145.0718607,-35.79351763,146.0575731,-35.80356992,147.8901481,-35.85753939,147.8921549,-35.86252833,148.285273,-36.57002321,149.0824984,-37.08995414,150.0543188,-37.39543692,149.4865194,-37.70616101,148.2197702,-37.74918536,147.6955803,-37.86710218,147.1714225,-38.45668226,146.7783055,-38.86938911,146.1886118,-39.04626233,145.664455,-38.57459606,145.2315974,-38.44872227,144.9136352,-38.62654662,144.589926,-38.32561341,143.9609451,-38.75147229,142.9125994,-38.51563966,142.1918671,-38.16189222,141.6022055,-38.33876544,140.9665939,-37.95503105,140.9422946,-33.9989067";dataPolyState[2]="150.0409107,-37.47902961,149.0690899,-37.17354679,148.2718647,-36.65361585,147.8767402,-35.94113244,146.0340132,-35.88511384,145.0584525,-35.87711119,144.8648119,-36.12299678,144.2096157,-35.76924599,143.4029557,-35.05283407,142.9003937,-34.56467087,142.4865196,-34.66070274,141.8262915,-34.00448258,141.5011046,-34.18054101,140.928887,-34.08249974,140.9454147,-28.98872371,148.8818611,-29.04281434,149.3857146,-28.51741175,150.310714,-28.522641,151.4143815,-29.16285585,151.4833581,-29.00280036,152.1337374,-28.86675639,151.9957759,-28.40259998,152.4195071,-28.26655364,153.3063815,-28.28255895,153.4344798,-28.05048074,153.5921513,-28.19453092,153.5527314,-28.57865841,153.641418,-28.68269412,153.3753582,-29.2828945,153.3162283,-29.72304414,153.1092984,-30.38726695,152.9713369,-30.72337969,153.0403136,-30.87543015,153.0895884,-30.91544343,152.941772,-31.32358126,152.7545438,-31.85976098,152.508194,-32.08383654,152.5673157,-32.45996326,152.1534395,-32.78007068,151.7297164,-32.99614298,151.3158402,-33.80441501,151.0596354,-34.23655962,150.892109,-34.47664049,150.7935675,-34.85276709,150.8132774,-35.06883969,150.6654692,-35.1888797,150.4092562,-35.48497916,150.2515929,-35.82909573,150.1431964,-36.17321053,150.1037765,-36.50932356,149.9559682,-36.8454366,149.9362583,-37.06951143,150.0446548,-37.21356042,150.0643648,-37.28558432,149.9461132,-37.2535737,150.0409107,-37.47902961";
dataPolyState[3]="129.0112111,-14.8981587,129.0112111,-31.760161,127.3076847,-32.40869937,126.3248741,-32.3497409,124.4247889,-33.1161962,123.4419782,-34.05952689,121.4108538,-33.94160996,119.8383666,-34.11848535,119.3797129,-34.41327294,118.331399,-35.00285284,116.8244151,-35.12076977,115.6450538,-34.76702372,115.0553691,-34.29535601,114.8588102,-33.46994225,115.448495,-33.58785918,115.6450538,-32.82140388,115.7105734,-31.760161,114.7932906,-30.22725041,114.9243299,-29.22496599,114.2036059,-28.34059377,113.7449604,-26.9845633,112.8276776,-25.68748657,113.0242364,-25.51060644,113.8760078,-26.45394186,113.4173623,-24.80311434,113.81048,-23.50603761,113.5484015,-22.50374846,114.0725667,-21.67833943,114.2036059,-22.44479473,114.8588102,-21.5014593,116.6278563,-20.55813335,117.4796276,-20.73500401,118.5934775,-20.20438257,119.8383666,-19.90959498,121.3453341,-19.49689047,121.8694911,-18.43564759,122.459184,-18.08189681,122.2626088,-17.96397988,122.0660499,-17.19752458,122.9178213,-16.43106929,123.6385371,-17.37439524,123.8351123,-16.96169073,123.310939,-16.31315236,123.3764586,-16.0773185,124.2937496,-16.43106929,124.5558281,-15.95941105,124.4247889,-15.60566026,125.079985,-14.42650046,125.9317564,-13.95483274,126.7835278,-13.66004516,127.9628973,-14.36753726,128.4215346,-14.78024177,127.9628973,-14.9571219,128.0939365,-15.19295575,128.356015,-15.01607562,128.2904954,-14.72128804,129.0112111,-14.8981587";
dataPolyState[4]="140.9454147,-28.98872371,148.8615576,-29.04802846,149.3857146,-28.51741175,150.3029892,-28.51741175,150.9582181,-28.87115307,151.416839,-29.16594539,151.482375,-28.98906999,152.1375712,-28.87115307,152.006532,-28.39949483,152.3996497,-28.2815779,153.3169571,-28.2815779,153.5790355,-27.75095646,152.9893426,-27.10241809,153.3169571,-26.45387972,152.8583034,-25.21575671,151.8099567,-24.33138449,150.8926821,-23.32909534,150.7616429,-22.56264951,149.9098715,-22.0909818,149.5822898,-22.14993553,148.7305184,-20.49911748,148.8615576,-20.0864035,147.0269756,-19.14307755,146.109701,-18.37662225,145.4545048,-15.90038571,145.3234656,-14.95705975,144.340655,-14.13164126,143.8164653,-14.48539204,143.4233476,-12.42186001,142.6371122,-10.77104196,142.1784585,-10.77104196,141.8508768,-11.71435844,141.6543016,-12.48081374,141.6543016,-13.54205662,141.5232623,-14.78017963,141.5232623,-15.54663492,141.2611839,-16.72579473,140.8025302,-17.49225003,140.0162948,-17.78704708,139.1645234,-17.25642564,139.0990202,-16.96162859,137.9851703,-16.54892407,137.9874936,-26.0304217,140.9247089,-26.04116574,140.9454147,-28.98872371";
dataPolyState[5]="144.6810738,-40.63631701,144.9842597,-40.74137807,145.2549562,-40.75754204,145.4065491,-40.83835951,145.753042,-40.96766415,146.1320244,-41.10505314,146.4352104,-41.16162466,146.6625957,-41.09697116,146.9116407,-40.98382812,147.0848851,-40.97574613,147.2581377,-40.91917461,147.388071,-40.9272566,147.442212,-40.9919101,147.6154564,-40.81411356,147.7237382,-40.85452111,147.886161,-40.87876706,147.9402938,-40.70097052,148.2543095,-40.87068508,148.3192803,-41.05656361,148.2976206,-41.33133922,148.3192803,-41.63035961,148.3192803,-41.85664569,148.3301019,-42.11525852,148.2001686,-42.12333932,148.0918867,-42.14758527,147.9727832,-42.49509519,147.8969827,-42.58399346,147.9294721,-42.72946325,148.0160943,-43.14970866,147.9078125,-43.24668833,147.7020786,-43.14970866,147.6479459,-42.92342258,147.5721453,-42.84260629,147.3664114,-42.92342258,147.3555898,-43.09313714,147.4205523,-43.34366858,147.3231003,-43.50530116,147.0090927,-43.52954593,146.8358401,-43.66693403,146.5434922,-43.56187268,146.1536841,-43.53762791,146.0345724,-43.55379129,145.7097309,-43.13354529,145.5689678,-42.98807609,145.4715158,-42.95574933,145.1791597,-42.36578937,145.1791597,-42.22031957,145.3524082,-42.31729983,145.4931713,-42.47893241,145.5364865,-42.37387135,145.265786,-42.15566607,145.2224749,-42.03444223,145.0600521,-41.84048172,144.8976334,-41.68693113,144.7893556,-41.43640028,144.6919036,-41.29093167,144.6161071,-40.95958453,144.6485925,-40.89493103,144.7027293,-40.74946005,144.6810738,-40.63631701	";
dataPolyState[6]="129.0147097,-25.99810704,137.9874922,-26.0305467,140.9247089,-26.04116574,140.9451589,-28.9887243,140.928887,-34.08249974,140.953186,-38.03862444,140.4689166,-38.00965105,139.6875865,-37.18423966,139.8178082,-36.77153278,139.2317942,-35.41549995,138.1248935,-35.76924599,137.2784687,-36.06403831,137.8644501,-35.53341214,138.0597989,-34.2363354,137.1482145,-35.29758302,136.5622331,-35.35654148,137.9295772,-33.70571396,137.6691338,-32.70342955,137.0831199,-33.52883857,135.8459975,-34.94383223,135.4553324,-35.0027907,134.7390968,-33.52883857,133.8926395,-32.93925867,134.0879883,-32.52655415,133.1764038,-32.11384491,132.1997411,-32.11384491,131.0928404,-31.46530654,129.0112111,-31.760161,129.0147097,-25.99810704";
dataPolyState[7]="148.8249708,-36.06987036,148.5881236,-35.76393424,148.5516856,-35.32368515,149.1529149,-34.87597449,149.4170947,-35.06998237,149.6812703,-35.19683376,149.6539418,-35.36099417,149.4535327,-35.47292243,149.3259996,-35.88332406,149.207572,-36.07733253,148.8249708,-36.06987036";
dataPolyState[8]="137.9874936,-26.0304217,137.9875461,-16.62223952,136.8734015,-15.79474954,135.4315556,-14.90815791,136.086958,-13.78514055,135.8247774,-13.54871486,136.4801797,-12.89855841,136.8734015,-12.1892813,136.4146264,-11.65732821,136.2180319,-11.95285559,136.3491058,-12.36660532,135.8247774,-12.07107794,135.0383339,-12.13017961,134.0552631,-11.89375392,133.7275947,-11.59822652,133.1377293,-11.42090251,132.4168228,-10.88894942,131.9580641,-11.1844768,132.7445076,-11.89375392,132.2202119,-12.30750365,131.3026781,-12.13017961,130.7128455,-12.60303103,130.1229965,-13.13498412,130.2540704,-13.48961317,129.8608487,-13.60783551,129.4676269,-14.37620482,129.6642378,-14.78994505,129.0088518,-14.90815791,129.0088518,-26.02009004,137.9874936,-26.0304217";



var melwayPoly = new Array () ; // melway polygon
melwayPoly[0]="143.9929851,-38.55972776,143.9929087,-38.51378464,143.9474191,-38.51302554,143.9467384,-38.55927431,143.9929851,-38.55972776";
melwayPoly[1]="144.2079099,-38.43087488,144.2081944,-38.38457282,144.162383,-38.38457282,144.1616691,-38.43034703,144.2079099,-38.43087488";
melwayPoly[2]="145.6431771,-38.02049157,145.6431771,-38.0945073,145.5109963,-38.0945073,145.5109963,-38.13839331,145.4195665,-38.13839331,145.4195665,-38.09468124,145.3775958,-38.09468124,145.3775958,-38.16590891,145.3777698,-38.16590891,145.3777698,-38.19168411,145.4207851,-38.19168411,145.4207851,-38.22964915,145.3768991,-38.22964915,145.3768991,-38.22668815,145.2445443,-38.22668815,145.2445443,-38.32438779,145.2448922,-38.32438779,145.2448922,-38.40258208,145.1095764,-38.40258208,145.1095764,-38.44646809,145.0663861,-38.44646809,145.0663861,-38.49035511,144.9754792,-38.49035511,144.9754792,-38.48965834,144.9540585,-38.48965834,144.9540585,-38.48983228,144.9490082,-38.48983228,144.9490082,-38.50167424,144.8819591,-38.50167424,144.8819591,-38.48983228,144.8417298,-38.48983228,144.8417298,-38.44664203,144.7971471,-38.44664203,144.7971471,-38.40275602,144.7523904,-38.40275602,144.7523904,-38.36862168,144.7079805,-38.36862168,144.7079805,-38.35765143,144.7029313,-38.35765143,144.7029313,-38.35747749,144.6912632,-38.35747749,144.6912632,-38.33257299,144.6456348,-38.33257299,144.6456348,-38.29878653,144.6191639,-38.29878653,144.6191639,-38.31237089,144.5326104,-38.31237089,144.5299983,-38.31237089,144.3662952,-38.31237089,144.3662952,-38.35730154,144.2746905,-38.35730154,144.2746905,-38.3102806,144.3062127,-38.3102806,144.3062127,-38.22545952,144.3062017,-38.22544142,144.2172915,-38.22451039,144.2194834,-38.00272161,144.4887817,-38.00420663,144.4883263,-38.05029654,144.3994553,-38.04986018,144.3988098,-38.13690628,144.3992733,-38.1371868,144.4152365,-38.137039,144.4154648,-38.1222079,144.4330336,-38.12228431,144.4328808,-38.13688718,144.4420835,-38.137039,144.4420835,-38.13597425,144.574193,-38.13646791,144.5743257,-38.09239389,144.7547501,-38.09286041,144.754369,-38.22668011,144.7083555,-38.22675552,144.7083304,-38.22676055,144.7083304,-38.27092305,144.6647923,-38.27092305,144.6647923,-38.29878653,144.6914372,-38.29878653,144.6914372,-38.30993272,144.7044977,-38.30993272,144.7044977,-38.31376442,144.7821702,-38.31376442,144.7821702,-38.35660578,144.7825191,-38.35660578,144.7825191,-38.35782537,144.7971471,-38.35782537,144.7971471,-38.35677972,144.8854419,-38.35677972,144.8853635,-38.31291583,144.9757919,-38.31282937,144.9756833,-38.2563604,145.0203314,-38.25634934,145.0203746,-38.22589386,145.0190686,-38.22589386,145.019156,-38.18118139,145.064696,-38.18118139,145.0646085,-38.13725114,145.1079727,-38.13746932,145.1077344,-38.050197,145.0646528,-38.05027341,145.0646085,-38.00739887,144.9757587,-38.0074421,144.975814,-37.8756041,144.8442635,-37.87546233,144.8444385,-37.91921764,144.8000286,-37.9190437,144.7996808,-37.96319112,144.710841,-37.96312577,144.7107917,-37.98146079,144.6650286,-37.98134717,144.6651271,-37.96302723,144.5809565,-37.96271656,144.5749923,-37.96280403,144.5757323,-37.83356104,144.5757323,-37.83092681,144.4982559,-37.83064932,144.4871539,-37.83060608,144.4876979,-37.74904762,144.4878286,-37.7426923,144.3992944,-37.742267,144.4002516,-37.60826833,144.5783444,-37.6090405,144.5783233,-37.6101515,144.5871721,-37.61017262,144.587161,-37.60286415,144.600483,-37.6028752,144.600483,-37.60654301,144.6048807,-37.60654301,144.6048475,-37.61025405,144.6224918,-37.61027115,144.6224918,-37.60918227,144.6653121,-37.60935118,144.6654418,-37.56760372,144.6653443,-37.56759266,144.5771912,-37.5673041,144.5774516,-37.52336279,144.5333022,-37.52323008,144.5335736,-37.47705872,144.5746304,-37.47723769,144.5776889,-37.47728193,144.5779282,-37.43609952,144.5779392,-37.43385037,144.5779503,-37.43325717,144.6233756,-37.43341301,144.6242473,-37.52132277,144.9759467,-37.52188883,144.9760342,-37.56585427,145.329119,-37.5653968,145.3292789,-37.60934213,145.4845786,-37.60879317,145.4845253,-37.59677124,145.4976633,-37.59678733,145.4978372,-37.60874893,145.4979237,-37.60874893,145.5501688,-37.60850963,145.550387,-37.63892087,145.5604876,-37.63872481,145.5608364,-37.64952213,145.5512577,-37.64934819,145.5524682,-37.75476449,145.6396621,-37.75438444,145.6395747,-37.74139831,145.6396179,-37.73991832,145.7280525,-37.7394146,145.7278263,-37.71163557,145.81758,-37.71111878,145.8181461,-37.75724791,145.7282506,-37.75775364,145.7282556,-37.75778581,145.7285341,-37.78552763,145.6399447,-37.7860022,145.6400864,-37.80040699,145.5528805,-37.80085441,145.5537291,-37.91615309,145.5967665,-37.91596809,145.5970269,-37.94625968,145.5971144,-37.96097616,145.570382,-37.96106262,145.570382,-37.96802925,145.5527045,-37.96802925,145.5529669,-38.0032947,145.5524361,-38.00342541,145.6431771,-38.00342541,145.6431771,-38.01683483,145.6431771,-38.02049157";
melwayPoly[3]="145.0462001,-37.48237242,145.137095,-37.48225277,145.1372126,-37.52811646,145.073409,-37.52835375,145.0464384,-37.52859103,145.0462001,-37.48237242";
melwayPoly[4]="145.0210191,-37.46752222,145.0208864,-37.37746486,144.9301252,-37.37749502,144.9300589,-37.42362616,144.9754762,-37.42366637,144.975446,-37.46755641,144.9529374,-37.4674448,144.9526157,-37.48580395,144.987673,-37.48604123,144.9880883,-37.4675192,145.0210191,-37.46752222,145.0210191,-37.46752222";
melwayPoly[5]="145.3660052,-37.54147762,145.3656071,-37.49521679,145.3202431,-37.49521679,145.3201425,-37.50379109,145.3113692,-37.50389063,145.3114687,-37.52582509,145.3205417,-37.52582509,145.3204422,-37.54147762,145.3660052,-37.54147762";
melwayPoly[6]="145.6691021,-37.71806731,145.6689463,-37.70345942,145.691118,-37.70330257,145.6912749,-37.71801503,145.6691021,-37.71806731";
melwayPoly[7]="144.4854306,-37.94667894,144.532156,-37.94678954,144.5312702,-37.99318209,144.4854306,-37.9925175,144.4854306,-37.94667894";
melwayPoly[8]="143.7847908,-37.46170782, 143.8291614,-37.46332153, 143.8287572,-37.50769116, 143.9614619,-37.50849651, 143.9610577,-37.59602521, 143.9166891,-37.59642939, 143.9166891,-37.68476345, 143.8711099,-37.68355291, 143.8711099,-37.64765504, 143.8674803,-37.6464445, 143.8674803,-37.64120119, 143.8275467,-37.63958848, 143.8271445,-37.59683157, 143.7835812,-37.59602521, 143.7847908,-37.46251518, 143.7847908,-37.46170782";

/*melwayPoly[0]="143.992804,-38.559683,143.993426,-38.513594,143.959574,-38.513345,143.950074,-38.51322,143.949124,-38.514129,143.949078,-38.515585,143.948837,-38.531301,143.948462,-38.531213,143.948175,-38.545692,143.94802,-38.558847,143.948954,-38.559393,143.960113,-38.559434,143.976085,-38.559642,143.992804,-38.559683,143.993011,-38.559642,143.992804,-38.559683";
melwayPoly[1]="144.205401,-38.430786,144.206348,-38.430028,144.206829,-38.385367,144.205934,-38.384634,144.165309,-38.384365,144.163076,-38.384344,144.162197,-38.385089,144.161686,-38.430465,144.163125,-38.430495,144.205401,-38.430786,144.205401,-38.430786";
melwayPoly[2]="144.217181,-38.22456,144.218244,-38.002433,144.489265,-38.004076,144.488381,-38.050493,144.399206,-38.049935,144.398647,-38.136738,144.573928,-38.136599,144.574207,-38.09236,144.754931,-38.092918,144.754373,-38.226612,144.708459,-38.226891,144.70832,-38.270711,144.665058,-38.270571,144.664918,-38.298622,144.633673,-38.298743,144.619144,-38.298622,144.619005,-38.314392,144.36634,-38.312228,144.365915,-38.357234,144.273743,-38.356815,144.274226,-38.310611,144.305442,-38.310611,144.306253,-38.225182,144.217181,-38.22456";
melwayPoly[3]="144.64552,-38.29925,144.645311,-38.332813,144.691503,-38.332952,144.691294,-38.357514,144.70811,-38.357514,144.707901,-38.368399,144.752628,-38.368539,144.752419,-38.40266,144.79589,-38.40273,144.795541,-38.445783,144.796658,-38.44662,144.841595,-38.44662,144.841525,-38.489463,144.881856,-38.489393,144.881786,-38.501465,144.948773,-38.501674,144.948842,-38.489533,144.975428,-38.489463,144.975637,-38.490649,145.065301,-38.490719,145.066417,-38.489812,145.066348,-38.44669,145.108214,-38.44669,145.108144,-38.40266,145.243861,-38.40259,145.244768,-38.401893,145.24435,-38.22703,145.4197,-38.228496,145.419072,-38.192211,145.377625,-38.191653,145.377346,-38.137994,145.377415,-38.094662,145.419212,-38.094593,145.419282,-38.138762,145.51076,-38.138273,145.51062,-38.094174,145.522692,-38.094104,145.643895,-38.093685,145.644035,-38.085312,145.643198,-38.003533,145.552975,-38.004161,145.552766,-37.961108,145.596935,-37.960969,145.597075,-37.940524,145.596516,-37.916102,145.553813,-37.916241,145.553045,-37.80076,145.640058,-37.80048,145.639988,-37.785967,145.728605,-37.785618,145.728256,-37.757707,145.818269,-37.757288,145.817711,-37.711096,145.727698,-37.711584,145.727698,-37.739425,145.639709,-37.739844,145.63936,-37.754148,145.552347,-37.754706,145.551789,-37.65004,145.560511,-37.649901,145.560651,-37.638806,145.551719,-37.638806,145.55144,-37.608453,145.497851,-37.608802,145.497851,-37.59673,145.484384,-37.59672,145.484314,-37.608313,145.329269,-37.60943,145.32906,-37.5654,144.974939,-37.565749,144.975079,-37.521999,144.624447,-37.521301,144.62361,-37.433102,144.577906,-37.433311,144.577347,-37.476853,144.533388,-37.477132,144.533388,-37.523324,144.577627,-37.523324,144.576929,-37.567005,144.665127,-37.568261,144.665267,-37.60922,144.400043,-37.608383,144.399206,-37.742495,144.486707,-37.742775,144.487125,-37.830834,144.575463,-37.831113,144.574626,-37.962853,144.665058,-37.962992,144.664918,-37.981413,144.710971,-37.981693,144.710692,-37.963271,144.799868,-37.96355,144.799868,-37.919451,144.844107,-37.919591,144.844107,-37.875212,144.976125,-37.875631,144.975707,-38.00751,145.065161,-38.00765,145.064464,-38.050633,145.107726,-38.050354,145.107726,-38.137296,145.064743,-38.137017,145.064464,-38.180698,145.019108,-38.180977,145.019108,-38.226193,145.020364,-38.226193,145.019946,-38.256058,144.975567,-38.256476,144.975567,-38.312996,144.885275,-38.312856,144.884717,-38.356677,144.797356,-38.356537,144.797356,-38.357514,144.781725,-38.357933,144.781865,-38.312577,144.736091,-38.312577,144.736091,-38.313973,144.70497,-38.313694,144.704831,-38.310205,144.691364,-38.309716,144.691433,-38.299389,144.64552,-38.29925";
melwayPoly[4]="144.929788,-37.377415,144.929455,-37.423768,144.976251,-37.423879,144.975586,-37.467681,145.020992,-37.467642,145.02083,-37.377526,144.929788,-37.377415";
melwayPoly[5]="145.046252,-37.483481,145.046391,-37.528697,145.137241,-37.528488,145.137172,-37.482295,145.047577,-37.482225,145.046252,-37.483481";
melwayPoly[6]="145.320128,-37.495623,145.320198,-37.541606,145.366111,-37.541397,145.365483,-37.495204,145.320128,-37.495623";
melwayPoly[7]="145.669687,-37.705291,145.690437,-37.705095,145.690507,-37.717445,145.669573,-37.717585,145.669687,-37.705291";
melwayPoly[8]="144.485727,-37.946366,144.531637,-37.946989,144.531261,-37.992921,144.485655,-37.992686,144.485727,-37.946366";
*/
var sidwayPoly = new Array() ; // sidway polygon
sidwayPoly[0]="151.011876,-33.375844,151.009738,-33.467038,151.022278,-33.467251,151.020995,-33.511495,151.104993,-33.512706,151.105919,-33.468463,151.235728,-33.470457,151.235229,-33.514416,151.278333,-33.514914,151.278333,-33.516054,151.407215,-33.517907,151.406146,-33.562364,151.364824,-33.561936,151.361333,-33.743255,151.318159,-33.742899,151.316306,-33.831813,151.315024,-33.832027,151.312815,-33.922864,151.271351,-33.922223,151.268501,-34.05766,151.182009,-34.056449,151.180727,-34.101476,151.007601,-34.098911,151.006817,-34.142157,151.049992,-34.142869,151.048994,-34.188608,151.027336,-34.188323,151.026196,-34.234277,150.937211,-34.232852,150.938208,-34.187326,150.959582,-34.18754,150.960935,-34.1418,150.917405,-34.141587,150.918687,-34.097201,150.834333,-34.095918,150.830699,-34.231071,150.601931,-34.225371,150.601147,-34.243538,150.546004,-34.242327,150.54636,-34.225727,150.526269,-34.2253,150.527836,-34.17899,150.569728,-34.179347,150.570583,-34.154981,150.626653,-34.154767,150.627009,-34.136457,150.658571,-34.136671,150.658927,-34.092285,150.485588,-34.089008,150.486133,-34.043347,150.572578,-34.044266,150.582624,-33.730003,150.497201,-33.728864,150.496346,-33.747031,150.410642,-33.745508,150.410709,-33.734919,150.389051,-33.734492,150.388694,-33.743896,150.367321,-33.743184,150.367535,-33.735276,150.345876,-33.734706,150.345449,-33.742828,150.335118,-33.742614,150.335261,-33.734492,150.323078,-33.734207,150.322793,-33.742115,150.281186,-33.741118,150.281328,-33.732141,150.237085,-33.731286,150.241431,-33.596276,150.199182,-33.595778,150.199824,-33.550394,150.287883,-33.551392,150.286743,-33.596561,150.329632,-33.597274,150.326711,-33.687613,150.411635,-33.689251,150.411707,-33.698299,150.498198,-33.700152,150.498697,-33.682697,150.49713,-33.682768,150.498626,-33.636886,150.584761,-33.638881,150.587255,-33.549468,150.588893,-33.549682,150.589036,-33.532298,150.502687,-33.53066,150.502045,-33.548756,150.415411,-33.546262,150.416551,-33.500452,150.503898,-33.501805,150.504753,-33.483852,150.589748,-33.485561,150.589463,-33.5038,150.761164,-33.507362,150.761805,-33.461908,150.967205,-33.466111,150.968274,-33.374989,151.011876,-33.375844";
sidwayPoly[1]="150.110256,-33.451427,150.123106,-33.45177,150.122962,-33.457723,150.204613,-33.459355,150.203096,-33.505346,150.116208,-33.504401,150.117582,-33.460413,150.110198,-33.460242,150.110256,-33.451427";

var briswayPoly = new Array() ; // brisway polygon
briswayPoly[0]="152.628849,-26.154777,152.711382,-26.154777,152.71121,-26.247626,152.628333,-26.246251,152.628849,-26.154777";
briswayPoly[1]="152.989727,-26.280435,152.999975,-26.280506,152.999921,-26.289376,152.989978,-26.289412,152.989906,-26.287499,152.987581,-26.287463,152.987563,-26.282312,152.989817,-26.282277,152.989727,-26.280435";
briswayPoly[2]="152.757681,-26.35398,153.121284,-26.353981,153.121567,-26.669687,153.161527,-26.670113,153.162093,-26.851913,153.039664,-26.852339,153.039523,-26.941043,153.081608,-26.940618,153.081891,-26.985962,153.161668,-26.986245,153.16266,-27.031022,153.242863,-27.031164,153.243004,-27.12256,153.081324,-27.12256,153.081608,-27.166204,153.122276,-27.167337,153.122417,-27.347579,153.202761,-27.347296,153.20347,-27.438551,153.282255,-27.439684,153.281972,-27.483611,153.323349,-27.483611,153.323632,-27.528105,153.363875,-27.528955,153.363591,-27.573449,153.405251,-27.573165,153.405818,-27.636647,153.417437,-27.63693,153.418004,-27.645149,153.405535,-27.645432,153.407802,-27.843529,153.447761,-27.843812,153.448328,-28.067698,153.488287,-28.068548,153.489704,-28.114458,153.529664,-28.114175,153.530514,-28.158952,153.571324,-28.159236,153.572175,-28.24964,153.612984,-28.248507,153.613268,-28.295835,153.578799,-28.295829,153.578799,-28.321753,153.561405,-28.321624,153.561298,-28.29561,153.529358,-28.29561,153.52938,-28.250774,153.243323,-28.250654,153.24376,-28.02489,152.91955,-28.023577,152.919987,-27.752746,152.755836,-27.755223,152.755836,-27.726536,152.73681,-27.727279,152.736513,-27.709146,152.674681,-27.709889,152.676466,-27.573112,152.594406,-27.572937,152.594465,-27.618317,152.513749,-27.617617,152.513064,-27.482056,152.797832,-27.483986,152.799993,-27.348545,152.838307,-27.348078,152.838148,-27.213025,152.757941,-27.212578,152.757425,-27.166948,152.838852,-27.167124,152.83845,-26.400741,152.758106,-26.400458,152.757681,-26.35398";
briswayPoly[3]="153.437062,-27.384764,153.453453,-27.384708,153.454031,-27.385287,153.454124,-27.407501,153.437249,-27.407539,153.436502,-27.407016,153.436409,-27.385399,153.437062,-27.384764";
briswayPoly[4]="153.399014,-27.486402,153.417547,-27.48646,153.418614,-27.487526,153.418637,-27.507752,153.41764,-27.509038,153.39913,-27.509189,153.398423,-27.508539,153.398307,-27.487062,153.399014,-27.486402";
briswayPoly[5]="151.865393,-27.477895,152.028469,-27.479423,152.026828,-27.66135,151.863526,-27.660501,151.865393,-27.477895";


var streetsmartPoly = new Array() ; // streetsmart polygon
streetsmartPoly[0]="115.5687961,-31.40187925,116.2006545,-31.40801036,116.1964428,-31.63362481,116.2806908,-31.63485244,116.2806908,-31.86537238,116.3171979,-31.86046689,116.3115816,-32.53118415,116.2287382,-32.52873191,116.2273336,-32.75434836,115.5947734,-32.75281508,115.5975806,-32.52995752,115.6818286,-32.53118415,115.6944658,-31.84820567,115.6509377,-31.85065792,115.6551515,-31.62136359,115.5694989,-31.62136359,115.5694989,-31.40187925,115.5687961,-31.40187925";
streetsmartPoly[1]="113.7631285,-23.13789095,113.7785709,-23.13760038,113.778775,-23.1473259,113.7633527,-23.14754408,113.7631285,-23.13789095,113.7631285,-23.13789095";
streetsmartPoly[2]="117.8771405,-35.01910737,117.8933722,-35.01898471,117.8934918,-35.03231972,117.877231,-35.03241725,117.8771405,-35.01910737";
streetsmartPoly[3]="113.5055906,-25.88245518,113.5843168,-25.88073791,113.585837,-25.96990345,113.5075673,-25.9713563,113.5055906,-25.88245518,113.5055906,-25.88245518";
streetsmartPoly[4]="116.6733182,-28.3313275,116.6942995,-28.33136269,116.6945056,-28.34755816,116.6944232,-28.35050206,116.6729874,-28.35050206,116.6728215,-28.3313275,116.6733182,-28.3313275,116.6733182,-28.3313275";
streetsmartPoly[5]="120.2134922,-26.58472283,120.234562,-26.58503954,120.2341809,-26.60386923,120.2128145,-26.60359073,120.2134922,-26.58472283";
streetsmartPoly[6]="119.2872982,-27.97885294,119.3080885,-27.97848294,119.3084816,-27.99719801,119.2878099,-27.99763638,119.2872982,-27.97885294";
streetsmartPoly[7]="115.4969662,-28.52542373,115.5244275,-28.52568012,115.5242013,-28.550286,115.4966827,-28.5500809,115.4969662,-28.52542373";
streetsmartPoly[8]="118.4855855,-26.58157885,118.5116935,-26.58126717,118.5119971,-26.60468564,118.4858388,-26.60495409,118.4855855,-26.58157885";
streetsmartPoly[9]="115.2005051,-25.04329222,115.2207867,-25.04353452,115.2206248,-25.05791016,115.2002779,-25.05775935,115.2005051,-25.04329222";
streetsmartPoly[10]="117.8850774,-27.4131659,117.9043233,-27.41309954,117.9046632,-27.43105853,117.88538,-27.43112589,117.8850774,-27.4131659,117.8850774,-27.4131659";
streetsmartPoly[11]="116.7050194,-31.83368726,116.8503513,-31.83407234,116.8507997,-31.93237725,116.7043447,-31.93165535,116.7050194,-31.83368726,116.7050194,-31.83368726,116.7050194,-31.83368726";
streetsmartPoly[12]="128.0867634,-15.43879238,128.1418489,-15.43893113,128.1419896,-15.50097118,128.0866206,-15.50097118,128.0867634,-15.43879238";
streetsmartPoly[13]="116.3458165,-31.72364698,116.4396854,-31.72432364,116.4391707,-31.82266574,116.3453992,-31.82224346,116.3458165,-31.72364698,116.3458165,-31.72364698";
streetsmartPoly[14]="116.6762339,-30.84073475,116.7696072,-30.84111882,116.7696072,-30.93974044,116.6757905,-30.93897128,116.6762339,-30.84073475";
streetsmartPoly[15]="115.8843332,-32.81241395,115.9525134,-32.81311172,115.9521887,-32.88416847,115.8835228,-32.88375021,115.8843332,-32.81241395,115.8843332,-32.81241395";
streetsmartPoly[16]="116.693658,-34.94539428,116.7802376,-34.94529273,116.7803613,-34.99961912,116.693658,-34.99951757,116.693658,-34.94539428,116.693658,-34.94539428";
streetsmartPoly[17]="116.3791686,-31.50765148,116.5236971,-31.5084518,116.5236971,-31.60643799,116.3782426,-31.60623791,116.3791686,-31.50765148";
streetsmartPoly[18]="117.7697214,-22.66983317,117.8093806,-22.66991662,117.8107389,-22.70932143,117.7692679,-22.70965423,117.7697214,-22.66983317";
streetsmartPoly[19]="117.443384,-31.58979108,117.5360625,-31.58943818,117.5360625,-31.68707145,117.4444246,-31.68760132,117.443384,-31.58979108,117.443384,-31.58979108";
streetsmartPoly[20]="117.3602289,-31.96054537,117.4543522,-31.96016632,117.4536796,-32.05699727,117.3604531,-32.05775536,117.3602289,-31.96054537";
streetsmartPoly[21]="118.5284067,-20.28425266,118.670297,-20.28252734,118.6721641,-20.44375909,118.5306478,-20.44341422,118.5284067,-20.28425266";
streetsmartPoly[22]="116.0113582,-34.41405675,116.0830886,-34.41475653,116.082985,-34.46325746,116.010943,-34.46281909,116.0113582,-34.41405675,116.0113582,-34.41405675";
streetsmartPoly[23]="115.096966,-21.62550017,115.1391307,-21.62617984,115.1389185,-21.65632464,115.0966121,-21.6559848,115.096966,-21.62550017";
streetsmartPoly[24]="116.0902171,-34.60927403,116.170011,-34.6099155,116.1695033,-34.67092297,116.0902171,-34.6708164,116.0902171,-34.60927403";
streetsmartPoly[25]="114.6172723,-28.33774114,114.6544783,-28.33831524,114.6536981,-28.37089519,114.6164921,-28.37067902,114.6172723,-28.33774114";
streetsmartPoly[26]="116.5888269,-31.60817939,116.7352939,-31.60871529,116.7352939,-31.70604593,116.5886188,-31.70604593,116.5888269,-31.60817939";
streetsmartPoly[27]="121.7625208,-32.17952197,121.7954175,-32.1798799,121.7957462,-32.21574258,121.7623569,-32.21531326,121.7625208,-32.17952197";
streetsmartPoly[28]="119.7139192,-23.33597371,119.7584115,-23.33502559,119.7590891,-23.37767593,119.7147909,-23.37827919,119.7139192,-23.33597371";
streetsmartPoly[29]="118.3458649,-32.01700629,118.4386017,-32.01522869,118.4398867,-32.11222955,118.347364,-32.11258547,118.3458649,-32.01700629,118.3458649,-32.01700629,118.3458649,-32.01700629,118.3458649,-32.01700629";
streetsmartPoly[30]="115.7457598,-33.96612164,115.7809046,-33.96660223,115.7805829,-34.00051639,115.7452782,-34.00017153,115.7457598,-33.96612164";
streetsmartPoly[31]="117.8293303,-28.04488153,117.8639262,-28.04463721,117.8639955,-28.07520831,117.82982,-28.07514698,117.8293303,-28.04488153";
streetsmartPoly[32]="117.6221273,-34.610379,117.6869112,-34.60988734,117.6873143,-34.65493563,117.6223284,-34.65493563,117.6221273,-34.610379,117.6221273,-34.610379,117.6221273,-34.610379";
streetsmartPoly[33]="115.956879,-30.593956,116.0494891,-30.59478447,116.0492539,-30.69267313,115.9566437,-30.69184466,115.956879,-30.593956";
streetsmartPoly[34]="118.2118984,-31.43188027,118.3563153,-31.43005039,118.3580648,-31.52834524,118.2134297,-31.52944317,118.2118984,-31.43188027";
streetsmartPoly[35]="114.944766,-33.8970295,115.112339,-33.89909868,115.1099521,-34.0103324,114.9418503,-34.0075735,114.944766,-33.8970295";
streetsmartPoly[36]="116.1169183,-34.21814672,116.178339,-34.21872283,116.1777699,-34.26895914,116.1164628,-34.26867058,116.1169183,-34.21814672";
streetsmartPoly[37]="115.3042444,-30.97471834,115.3966223,-30.97613901,115.3954791,-31.07357422,115.3026427,-31.07296492,115.3042444,-30.97471834";
streetsmartPoly[38]="128.6608488,-15.74932142,128.7796343,-15.74978995,128.7789094,-15.85711959,128.6603651,-15.8585292,128.6608488,-15.74932142";
streetsmartPoly[39]="117.6755016,-31.58883391,117.7686938,-31.58816731,117.769287,-31.68599363,117.6762918,-31.68632744,117.6755016,-31.58883391,117.6755016,-31.58883391";
streetsmartPoly[40]="116.7751451,-20.71243308,116.8886702,-20.71213246,116.8889889,-20.7811894,116.7746655,-20.78058715,116.7751451,-20.71243308";
streetsmartPoly[41]="121.5889203,-31.17679869,121.692372,-31.17841944,121.6918833,-31.23488137,121.5887976,-31.23369295,121.5889203,-31.17679869";
streetsmartPoly[42]="121.4044993,-30.69717142,121.5356385,-30.69908476,121.5337915,-30.83630683,121.4032676,-30.83603336,121.4044993,-30.69717142,121.4044993,-30.69717142";
streetsmartPoly[43]="114.1482765,-27.68179968,114.1952251,-27.68284734,114.1942035,-27.72803437,114.1471544,-27.72736777,114.1482765,-27.68179968";
streetsmartPoly[44]="115.0052989,-30.24907444,115.0972153,-30.25055343,115.0955704,-30.34757641,115.0034489,-30.34646742,115.0052989,-30.24907444";
streetsmartPoly[45]="115.8614175,-33.02985627,115.970204,-33.03116835,115.9700129,-33.11827377,115.8602723,-33.11761823,115.8614175,-33.02985627";
streetsmartPoly[46]="115.8658785,-31.29638754,115.9590537,-31.29736783,115.9579337,-31.39466026,115.8645353,-31.39466026,115.8658785,-31.29638754";
streetsmartPoly[47]="114.5712136,-28.69595269,114.7002223,-28.69799874,114.6973548,-28.83833463,114.5680294,-28.83687274,114.5712136,-28.69595269,114.5712136,-28.69595269,114.5712136,-28.69595269";
streetsmartPoly[48]="125.5525632,-18.16692085,125.6039065,-18.16604009,125.6043278,-18.2152227,125.5531956,-18.21571335,125.5525632,-18.16692085";
streetsmartPoly[49]="114.0963611,-21.91282991,114.153743,-21.91382328,114.1528321,-21.96719854,114.0953356,-21.96631577,114.0963611,-21.91282991";
streetsmartPoly[50]="121.8062289,-33.77643522,121.9738199,-33.77768698,121.9726456,-33.92207577,121.8041748,-33.92107536,121.8062289,-33.77643522,121.8062289,-33.77643522";
streetsmartPoly[51]="116.0089693,-32.66976959,116.11316,-32.67055885,116.112977,-32.75012455,116.0084183,-32.74949415,116.0089693,-32.66976959";
streetsmartPoly[52]="115.052529,-33.55205243,115.1862723,-33.55433676,115.1857927,-33.5842483,115.4470456,-33.58819462,115.4453675,-33.73048205,115.1764452,-33.7271591,115.1783626,-33.65819566,115.0503723,-33.65653369,115.052529,-33.55205243,115.052529,-33.55205243";
streetsmartPoly[53]="115.7725445,-33.524013,115.9220097,-33.52546886,115.9215241,-33.63261752,115.7710846,-33.63157791,115.7725445,-33.524013";
streetsmartPoly[54]="114.903653,-29.22954741,114.9758619,-29.23065941,114.9746383,-29.30613402,114.9026043,-29.30533872,114.903653,-29.22954741";
streetsmartPoly[55]="123.5942954,-17.27090384,123.7126205,-17.27090384,123.7126205,-17.39383272,123.5948223,-17.39408408,123.5942954,-17.27090384";
streetsmartPoly[56]="117.3073161,-34.94068786,117.3830914,-34.94040332,117.3833236,-35.01683108,117.3072779,-35.01698993,117.3073161,-34.94068786,117.3073161,-34.94068786";
streetsmartPoly[57]="116.6257805,-20.62811672,116.7594021,-20.6285199,116.7594021,-20.71772968,116.6259926,-20.71752759,116.6257805,-20.62811672";
streetsmartPoly[58]="116.6159323,-30.23652668,116.7081563,-30.23723249,116.7079542,-30.33502261,116.615327,-30.33414185,116.6159323,-30.23652668";
streetsmartPoly[59]="117.2006722,-31.59955582,117.2937448,-31.59955582,117.293963,-31.69699605,117.200454,-31.69699605,117.2006722,-31.59955582";
streetsmartPoly[60]="121.1417121,-30.93669097,121.1841955,-30.93727713,121.1838305,-30.96843339,121.1410545,-30.96804228,121.1417121,-30.93669097";
streetsmartPoly[61]="116.071499,-33.30520933,116.2200432,-33.30655057,116.2190991,-33.45044167,116.0702412,-33.44963632,116.071499,-33.30520933";
streetsmartPoly[62]="115.0523219,-30.47954009,115.0936048,-30.48028712,115.0927723,-30.52010918,115.0516744,-30.51969394,115.0523219,-30.47954009,115.0523219,-30.47954009,115.0523219,-30.47954009";
streetsmartPoly[63]="113.6018223,-24.79862085,113.8079465,-24.79420601,113.8112142,-24.92770799,113.605089,-24.93160404,113.6018223,-24.79862085";
streetsmartPoly[64]="115.5268405,-33.17472363,115.7724781,-33.17796916,115.7687218,-33.50965747,115.5208311,-33.50835946,115.5268405,-33.17472363";
streetsmartPoly[65]="118.0990369,-31.82996516,118.193308,-31.82885115,118.194419,-31.92707561,118.1008155,-31.92781863,118.0990369,-31.82996516,118.0990369,-31.82996516";
streetsmartPoly[66]="122.1320022,-17.87619174,122.2801654,-17.87713986,122.2798376,-18.01669554,122.1310209,-18.01669554,122.1320022,-17.87619174";
streetsmartPoly[67]="116.3627087,-33.81682334,116.4106959,-33.81698321,116.4106315,-33.84811232,116.3626454,-33.84784387,116.3627087,-33.81682334,116.3627087,-33.81682334";
streetsmartPoly[68]="115.1387627,-34.2949495,115.1755393,-34.2953949,115.1742483,-34.3508695,115.1396656,-34.35042309,115.1387627,-34.2949495,115.1387627,-34.2949495";
streetsmartPoly[69]="117.8171928,-34.96693662,117.9574824,-34.96564665,117.9584406,-35.10631534,117.8191101,-35.10657273,117.8171928,-34.96693662,117.8171928,-34.96693662";
streetsmartPoly[70]="117.0866213,-20.58335498,117.2028399,-20.58358121,117.2013931,-20.7077337,117.0871029,-20.70795992,117.0866213,-20.58335498,117.0866213,-20.58335498";


function checkMelwayPolygon () {
   var result=0;
   for (var i=0; i< melwayPoly.length-1;i++) {
    	if (InsidePolygon(GM_New_X,GM_New_Y,melwayPoly[i])) {
    		result = 1;
    		break;		
    	}
    }
    return result;
}

function checkSidwayPolygon () {
  var result=0;
  for (var i=0; i< sidwayPoly.length-1;i++) {
   	if (InsidePolygon(GM_New_X,GM_New_Y,sidwayPoly[i])) {
  		result = 1;
  		break;		
  	}
  }
  return result;
}

function checkBriswayPolygon () {
   var result=0;
   for (var i=0; i< briswayPoly.length-1;i++) {
    	if (InsidePolygon(GM_New_X,GM_New_Y,briswayPoly[i])) {
    		result = 1;
    		break;		
    	}
    }
    return result;
}

function checkStreetsmartPolygon () {
   var result=0;
   for (var i=0; i< streetsmartPoly.length-1;i++) {
    	if (InsidePolygon(GM_New_X,GM_New_Y,streetsmartPoly[i])) {
    		result = 1;
    		break;		
    	}
    }
    return result;
}


function InsidePolygon (lon,lat,poly) {

  	var dataPolygon = poly.split(",") ;
    	var insidePolyLength = dataPolygon.length ;
        var insidePolyOut =1;
        var j = insidePolyLength - 2;
        for (var i=0; i<insidePolyLength-1; i+=2) {
	        if (((dataPolygon[i+1]<=lat) && (lat<=dataPolygon[j+1])) || ((dataPolygon[j+1]<=lat) && (lat<=dataPolygon[i+1]))) {
	
                        if (lon <= (dataPolygon[j]-dataPolygon[i])*(lat-dataPolygon[i+1])/(dataPolygon[j+1]-dataPolygon[i+1])+parseFloat(dataPolygon[i])) {
                                insidePolyOut = 1 - insidePolyOut;
                        }
                }
                j = i;
        }

	return (insidePolyOut)?0:1;

}

function checkAusway () {
	var result = 0;
	var state  = 0;
	if (GM_Level>=5) {
	  state = getState();
	  switch (state)
	  {
      case "vic" : result = checkMelwayPolygon();  break;
      case "nsw" : result = checkSidwayPolygon();  break;
      case "qld" : result = checkBriswayPolygon(); break;
      case "wa" : result = checkStreetsmartPolygon(); break;
      default    : result = 0; break
    }	    
	
  } else {
	    result = 0;
  }
	
	return result;
}



function getState () {

    var result=0;
    for (var i=1; i< dataPolyState.length-1;i++) {
    	if (InsidePolygon(GM_New_X,GM_New_Y,dataPolyState[i])) {
    		result = i;
    		break;		
    	}
    }

    var dataState = new Array () ;
    dataState[1]="vic";  // Melway
    dataState[2]="nsw";  // Sidway
    dataState[3]="wa";
    dataState[4]="qld";  // Brisway
    dataState[5]="tas";
    dataState[6]="sa";
    dataState[7]="act";
    dataState[8]="nt";

    return dataState[result];
}

