var img;
function showPopupImg( imgSrc, imgWidth, imgHeight )
{
	img = new Image();
	img.onload = function(){ internalShowPopupImg( img.src, img.width, img.height ) };
	img.src = imgSrc;
}

var documentViewport = document.viewport;
function internalShowPopupImg( imgSrc, imgWidth, imgHeight )
{
	new Sky.Window(
		{
			contentURL:			'popup-img.html?width=' + imgWidth + '&height=' + imgHeight + '&src=' + encodeURI( imgSrc ),
			maxWindowHeight:	documentViewport.getHeight(),
			maxWindowWidth:		documentViewport.getWidth(),
			overlayClose:		true,
			draggable:			false,
			headerVisible:		false,
			slideDownDuration:	.2,
			slideUpDuration:	.2, 	 	
			resizeDuration:		.2,
			fadeDuration:		.2,
			overlayDuration:	.1
		}
	);
}

function showSkyInfo( layerId, webroot )
{
	var opts = {
		contentCode: 			'<div style="width: 350px;">' + $( layerId ).innerHTML + '</div>',
		maxWindowHeight:		documentViewport.getHeight(),
		maxWindowWidth:			documentViewport.getWidth(),
		overlayClose:			false,
		draggable:				true,
		headerVisible:			true,
		modal:					false,
		slideDownDuration:		.2,
		slideUpDuration:		.2, 	 	
		resizeDuration:			.2,
		fadeDuration:			.2,
		overlayDuration:		.1,
		cssClassDragger:		'skyLegendDragger',
		cssClassHeader:			'skyLegendHeader',
		closeVisible:	 		true,
		closeCode:				'<a href="#" class="skyWindowCloseLegend" onclick="return false;"><img src="' + webroot + 'img/layout/btn-legendclose.gif" height="24" width="24" /></a>',
		closeVisibleAfterLoad:	true,
		windowId:				"skyWindow_" + layerId,
		inactiveFade:			false
	};
	
	new Sky.Window( opts );

	return false;
}

function showSkyLegend( layerId, webroot )
{
	var opts = {
		contentCode: 			'<div style="width: 213px;">' + $( layerId ).innerHTML + '</div>',
		maxWindowHeight:		documentViewport.getHeight(),
		maxWindowWidth:			documentViewport.getWidth(),
		overlayClose:			false,
		draggable:				true,
		headerVisible:			true,
		modal:					false,
		slideDownDuration:		.2,
		slideUpDuration:		.2, 	 	
		resizeDuration:			.2,
		fadeDuration:			.2,
		overlayDuration:		.1,
		cssClassDragger:		'skyLegendDragger',
		cssClassHeader:			'skyLegendHeader',
		closeVisible:	 		true,
		closeCode:				'<a href="#" class="skyWindowCloseLegend" onclick="return false;"><img src="' + webroot + 'img/layout/btn-legendclose.gif" height="24" width="24" /></a>',
		closeVisibleAfterLoad:	true,
		windowId:				"skyWindow_" + layerId,
		inactiveFade:			false
	};
	
	new Sky.Window( opts );

	return false;
}

function switchAndReposLayer (layerName,linkObj)
{
    mySwitchAndReposLayer(layerName,linkObj,'closelayer', 2, -10, 0, true,false);
}
