I am getting document.getElementById("pr_book") is null error
<script language="javascript">
google.load("books", "0");
function load_viewport()
{
var viewportDiv = document.getElementById("viewport");
var identifier = '<?php echo $var ?>';
var viewer = new google.books.DefaultViewer(viewportDiv,
{showLinkChrome: false});
viewer.load(identifier,handle_not_found,success);
var d = document.getElementById('parent');
d.removeChild(viewportDiv);
}
function handle_not_found()
{
document.getElementById("pr_book").style.display = 'none';
}
function success()
{
document.getElementById("pr_book").style.display = 'inline';
}
google.setOnLoadCallback(function() {
load_viewport()
});
function popitup(url) {
newwindow=window.open(url,'book','height=650,width=850,left=50,top=50,location=no,status=no,scrollbars=no,resizable=no');
if (window.focus) {newwindow.focus()}
return false;
}
</script>
<div id="parent"><div id="viewport" style="visibility:hidden;"></div></div>
<?php if ($Isbn !='') { ?>
<a id="pr_book" style="display:none;" onclick="return popitup('<?php echo $this->getUrl('book/book/new',array('isbn'=>$Isbn,'name'=>$trimName))?>','book', 'width=850,height=650,left=50,top=50,location=no,status=no,scrollbars=no,resizable=no');" href="#" class="link-style_button1"><strong>PREVIEW THIS PRODUCT</strong>
<!--img src="<?php //echo $this->getSkinUrl($this->__('images/google_preview_btn.gif'))?>"></a-->
<?php }