polearmik,
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
</head>
<body>
<div id="foto" style="display: none">12345</div>
<input name="" type="button" value="открыть/закрыть" onclick="openbox('foto')">
<script>
function openbox(id) {
var div = document.getElementById(id);
if (div.style.display != 'none') {
div.innerHTML = '';
div.style.display = 'none';
} else {
div.style.display = 'block';
}
}
</script>
</body>
</html>