var hasPhoto = true function ShowDetail() { document.write(""); } if( hasPhoto ) { ShowDetail(); }