var browserWidth = 0;
var browserHeight = 0;
function browserSize() {
	if( typeof( window.innerWidth ) == 'number' ) {
		browserWidth = window.innerWidth;
		browserHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		browserWidth = document.documentElement.clientWidth;
		browserHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		browserWidth = document.body.clientWidth;
		browserHeight = document.body.clientHeight;
	}
}

function showClose(imageID){
	var closeDiv = document.getElementById('image' + imageID);
	closeDiv.style.display = 'block';
}

function showImage(imageID, imageWidth, imageHeight){
	var imageDiv = document.getElementById('image' + imageID);
	imageDiv.style.display = 'block';
	browserSize();
	imageDiv.style.top = (Math.random() * (browserHeight - imageHeight)) + 'px';
	imageDiv.style.left = (Math.random() * (browserWidth - imageWidth)) + 'px';
	var imageAnchor = document.getElementById('anchor' + imageID);
	imageAnchor.onHover = Function("showClose(" + imageID + ")");
	imageAnchor.onClick = Function("hideImage(" + imageID + ")");
}

function hideImage(imageID){
	var imageDiv = document.getElementById('image' + imageID);
	imageDiv.style.display = 'none';
	var imageAnchor = document.getElementById('anchor' + imageID);
	imageAnchor.onClick = Function("showImage(" + imageID + ")");
}

