
var MyMapType;

function resizeElements()
{
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}

	//window.alert( 'Width = ' + myWidth );
	//window.alert( 'Height = ' + myHeight );

	$('wrapper').style.height = myHeight + 'px';
	$('map').style.height = myHeight + 'px';
	$('layers').style.height = (myHeight - 150) + 'px';
	
	$('wrapper').style.width = myWidth + 'px';
	$('map').style.width = (myWidth - 270) + 'px';

}

function displayLayers(mapObject, layerNames)
{
	var layerObjects = [];
	
	// get the actual layer objects from the names
	for (var i=0; i < layerNames.length; i++)
	{
		layerObjects[i] = AllLayers[layerNames[i]];
	}
	
	// change the map type
	MyMapType = new GMapType(layerObjects, G_SATELLITE_MAP.getProjection(), "PhilaGeoHistory");
	
	mapObject.getMapTypes().length = 0;
	mapObject.addMapType(MyMapType);
	mapObject.setMapType(MyMapType);
}


function refreshLayers(mapObject)
{
	var layerNames = [];
	var cbShowLayer;
	var j = 0;
	
	layerItems = Sortable.sequence('LayersList');
	
	for (var i=layerItems.length - 1; i >= 0; i--)
	{
		cbShowLayer = $('ShowLayer_' + layerItems[i]);
		
		if (cbShowLayer.checked == true)
		{
			layerNames[j] = layerItems[i];
			j++;
		}
	}
	
	if (layerNames.length == 0)
	{
		layerNames = ['Normal'];
	}
	
	//alert('Layers = ' + layerNames.join(', '));
	displayLayers(mapObject, layerNames);
}
