window.onload = function () { 
	if ( document.body.className == 'contact' ) {
		document.getElementById( 'name' ).focus();
		}
	else {
		setup_answers();
		}
	}

function setup_answers() {
	var answers = document.getElementsByTagName( 'a' );
	for ( var answer = 0; answer < answers.length; answer ++ ) {
		if ( answers[ answer ].className.match( /fullscreen/ ) ) {
			answers[ answer ].onclick = function () { view_image( this ); return false; };
			}
		}
	}

image_size = window.innerWidth;

function view_image( link ) {
	var image = link.getElementsByTagName( 'img' )[0];
	var description = image.getAttribute( 'alt' );
	var viewer = window.open( '', 'large_image', 'status=no, toolbar=no, location=no, scrollbars=yes, width='+screen.width+', height='+screen.height+', top=0, left=0' );
	if ( link.className.match( /higher/ ))
		{ var imgsize =  'height: ' + ( screen.height - 150 ) +'px;'; }
	else
		{ var imgsize =  'width: ' + ( screen.width - 300 ) +'px;'; }
	viewer.document.write( '\
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\n\
<html lang="en-GB">\n\
<head>\n\
<title>' + description + '</title>\n\
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" >\n\
<style type="text/css">\n\
body { background: #000000; font-family: arial, helvetica, sans-serif; }\n\
img { display: block; margin: 10px auto; ' + imgsize + ' }\n\
p { color: white; margin-top: 10px; }\n\
button { display: block; }\n\
</style>\n\
</head>\n\
<body>\n\
<div style="float: left; width: 85%;">\n\
<img src="' + link.href + '">\n\
</div>\n\
<p>' + description + '</p>\n\
<button onclick="window.close(); return false;">Close Window</button>\n\
<br style="clear: both;">\n\
</body>' );
	viewer.document.close();
}

