var map = null;
var largemap = null;

var locs = new Array;
var poly, points;
var ShapeLittleArray=new Array();

var locs = new Array;
var poly, points;

function DisposeMap() //dispose map etc
{
	if (map != null)
	{ map.Dispose(); }
	if (largemap != null)
	{ largemap.Dispose(); }
}

function switchmap()
{
	if(document.getElementById('bigmap').style.display == 'none')
	{
		document.getElementById('bigmap').style.display = 'block';
		document.getElementById('showmap').value = 'Hide map';
		if(!isAMapLoaded())
            GetLargeMap();
        else 
            checkForResize();
	}
	else
	{
		document.getElementById('bigmap').style.display = 'none';
		document.getElementById('showmap').value = 'Show large map';
	    HideOpenPushpinInfo();
    }
}
function switchotellist()
{
	if(document.getElementById('hotellist').style.display == 'none')
	{
		document.getElementById('hotellist').style.display = 'block';
		document.getElementById('hotellistswitcher').innerHTML = 'Hide hotel list';
	}
	else
	{
		document.getElementById('hotellist').style.display = 'none';
		document.getElementById('hotellistswitcher').innerHTML = 'Show hotel list';
	}
}

function openmapfromselectfield(key)
{
	var array;
	var ID, longitude, latitude;
	array = key.split('|');
	ID = array[0];
	longitude = array[2];
	latitude = array[1];
	openpushpin(ID, latitude, longitude);
}

function openmap(pushpinid, latitude, longitude)
{
	if(document.getElementById('bigmap').style.display == 'none')
	{
		document.getElementById('bigmap').style.display = 'block';
		if(document.getElementById('showmap'))
			document.getElementById('showmap').value = 'Hide map';
		if(!isAMapLoaded())
            GetLargeMap();
        else 
            checkForResize();
	}
	location.hash = 'largemapanchor';
	openpushpin(pushpinid, latitude, longitude);
}

function openmapfromselectfieldd(key)
{
    var array;
			var ID, longitude, latitude;
    array = key.split('|');
    ID = array[0];
    longitude = array[2];
    latitude = array[1];
    openpushpin(ID, latitude, longitude);
}

function openpushpin(pushpinid, latitude, longitude)
{
    var intZoom = 17;
    var hmidShape = "h_"+pushpinid;
	
    window.setTimeout(function(){
    window[objMapName].SetZoomLevel(1);
    window[objMapName].SetCenterAndZoom(new VELatLong(latitude, longitude),intZoom);
    window[objMapName].ShowInfoBox(window[hmidShape], null, new VEPixel(-11, DescriptionOffsetNeeded()));
    }, 400);
}

function DescriptionOffsetNeeded()
{
    if(!window.pageYOffset && document.body.scrollTop && document.body.scrollTop >0)
        return 170;
    return -11;
}
		
function MyHandleTokenExpire()
{
	alert('Token expired. Please reload the page')
}

function MyHandleTokenError()
{
	alert('An error with your current token occured, please reload the page');					
}		

function isAMapLoaded()
{
    if(window[objMapName])
        return true;
    return false;
}

function HideOpenPushpinInfo()
{
    if(window[objMapName])
        window[objMapName].HideInfoBox();
}

function UseClickDelegate(DivId)
{
	switch(DivId) 
	{
	default:
	case "hotellist":
		controlHotelListBox(DivId);
		break;
	case "totalmap":
		controlHotelListBox(DivId);
		break;						
	}
}
