function startFormatWidth()
{
	if( typeof( window.innerWidth ) == 'number' && window.innerWidth != 0 ) 
	{
		//Non-IE
		//alert('non-IE');
		myWidth = window.innerWidth - 15;
	}
	else if( document.documentElement && document.documentElement.clientWidth)
	{
		//IE 6+ in 'standards compliant mode'
		//alert('IE');
		myWidth = document.documentElement.clientWidth - 15;
	}
	return myWidth;
}
function startFormatHeight()
{
	if( typeof( window.innerHeight ) == 'number' ) 
	{
		//Non-IE
		myHeight = window.innerHeight;
	}
	else if( document.documentElement && document.documentElement.clientHeight )
	{
		//IE 6+ in 'standards compliant mode'
		myHeight = document.documentElement.clientHeight;
	}
	return myHeight;
}

function closeFullScreen(docID, docKEY, exit, searchVar, indexFile, indexUrl, downloadURL)
{
	if(!exit)
	{
		window.close();
	}
	window.opener.changeViewStyle(docID, docKEY, scribd_doc.api.getViewMode(), scribd_doc.api.getPage(), false, false, searchVar, indexFile, indexUrl, downloadURL);
}


function getSize()
{
	var myWidth = 0;
	var myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) 
	{
		//Non-IE
		//myWidth = window.innerWidth;
		myWidth = screen.width - 10;
		//myHeight = window.innerHeight;
		myHeight = screen.height - 85;
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		//IE 6+ in 'standards compliant mode'
		//myWidth = document.documentElement.clientWidth;
		myWidth = screen.width - 10;
		//myHeight = document.documentElement.clientHeight;
		myHeight = screen.height - 85;
	}
	
		var setSizeArray = new Array();
		setSizeArray[0] = myWidth;
		setSizeArray[1] = myHeight +35;

		return setSizeArray;
}

function oniPaperReady()
{
	if(scribd_doc.api)
	{
		changePageNumText();
		document.getElementById('menuDiv').style.visibility = 'visible';
		if(searchVar=='yes')
		{
			if(viewMode=='fullscreen')
			{
				document.getElementById('menuDivOmbouwFullscreen').style.width = getSize()[0] - 128 + 'px';
			}
			else
			{
				document.getElementById('menuDivOmbouw').style.width = (parseFloat(document.getElementById('menuDivOmbouw').style.width) - 128) + 'px';
			}
		}
	}
}
function onPageChanged()
{
	if(scribd_doc.api)
	{
		changePageNumText();
	}
}
function changePageNumText()
{
	if(scribd_doc.api)
	{
		var curPages = scribd_doc.api.getPage();
		var pageCount = scribd_doc.api.getPageCount();
	
		document.getElementById('pageInfoDiv').innerHTML = curPages + ' / ' +  pageCount;
	}
}

function prevPage()
{
	if(scribd_doc.api)
	{
		if(scribd_doc.api.getViewMode()=='book')
		{
			if(scribd_doc.api.getPage()>2)
			{
				scribd_doc.api.setPage(scribd_doc.api.getPage()-2);
			}
			else if(scribd_doc.api.getPage()!=1)
			{
				scribd_doc.api.setPage(scribd_doc.api.getPage()-1);
			}
		}
		else
		{
			if(scribd_doc.api.getPage()!=1)
			{
				scribd_doc.api.setPage(scribd_doc.api.getPage()-1);
			}
		}
		changePageNumText();
	}
}


			
			
function nextPage()
{
	if(scribd_doc.api)
	{
		if(scribd_doc.api.getViewMode()=='book')
		{
			if(scribd_doc.api.getPage() <= scribd_doc.api.getPageCount()-2)
			{
				scribd_doc.api.setPage(scribd_doc.api.getPage()+2);
			}
			else if(scribd_doc.api.getPage() != scribd_doc.api.getPageCount())
			{
				scribd_doc.api.setPage(scribd_doc.api.getPage()+1);
			}
		}
		else
		{	
			if(scribd_doc.api.getPage() != scribd_doc.api.getPageCount())
			{
				scribd_doc.api.setPage(scribd_doc.api.getPage()+1);
			}
		}
		changePageNumText();
	}
}
function zoomIn()
{
	if(scribd_doc.api)
	{
		if(scribd_doc.api.getZoom() < 3)
		{
			scribd_doc.api.setZoom(scribd_doc.api.getZoom()+0.2);
		}
	}
}
function zoomOut()
{
	if(scribd_doc.api)
	{
		if(scribd_doc.api.getZoom() > 0.3)
		{
			scribd_doc.api.setZoom(scribd_doc.api.getZoom()-0.2);
		}
	}
}
function showIndex()
{
	document.getElementById('scribdViewerIndexOverlay').style.display = 'block';
	document.getElementById('indexBtn').innerHTML = "<a href='javascript:hideIndex();'><img src='img/indexBtn.gif' alt='Hide Index' width='22' height='22' border='0' title='Hide Index' /></a>";
}
function hideIndex()
{
	document.getElementById('scribdViewerIndexOverlay').style.display = 'none';
	document.getElementById('indexBtn').innerHTML = "<a href='javascript:showIndex();'><img src='img/indexBtn.gif' alt='Show Index' width='22' height='22' border='0' title='Show Index' /></a>";
}


function changeViewStyle(docID, accessKey, viewStyle, curPage, fullscreen, active, searchVar, indexFile, indexUrl, downloadURL)
{
	if(fullscreen)
	{
		if(active)
		{
			var newURL = window.location.protocol + "//" + window.location.host + window.location.pathname + "?docID=" + docID + "&accessKey=" + accessKey + "&searchVar=" + searchVar + "&indexFile=" + indexFile + "&indexUrl=" + indexUrl + "&downloadVar=" + downloadURL + "&viewStyle=" + viewStyle + "&curPage=" + curPage + "&viewMode=" + fullscreen;;
			window.location.href = newURL;
		}
		else
		{
			var newURL = window.location.protocol + "//" + window.location.host + window.location.pathname + "?docID=" + docID + "&accessKey=" + accessKey + "&searchVar=" + searchVar + "&indexFile=" + indexFile + "&indexUrl=" + indexUrl + "&downloadVar=" + downloadURL + "&viewStyle=" + viewStyle + "&curPage=" + curPage + "&viewMode=" + fullscreen;
			mywindow = window.open (newURL,'fullscreen','location=0,status=0,scrollbars=0, width='+getSize()[0]+',height='+getSize()[0]+'');
			mywindow.moveTo(0,0);
		}
	}
	else
	{
		var newURL = window.location.protocol + "//" + window.location.host + window.location.pathname + "?docID=" + docID + "&accessKey=" + accessKey + "&searchVar=" + searchVar + "&indexFile=" + indexFile + "&indexUrl=" + indexUrl + "&downloadVar=" + downloadURL + "&viewStyle=" + viewStyle + "&curPage=" + curPage;
   		window.location.href = newURL;
	}
}
function buildViewer(viewStyle, width, height, divID, curPage)
{
	scribd_doc.addParam( 'page', curPage );
	scribd_doc.addParam('mode', viewStyle);
	scribd_doc.addParam('width', width);
	scribd_doc.addParam('height', height);
	scribd_doc.addParam('auto_size', false);
	scribd_doc.addParam('jsapi_version', 1);
	scribd_doc.addParam('hide_full_screen_button', true);
	scribd_doc.addParam('disable_resume_reading', true);
	scribd_doc.addParam('disable_related_docs', true);
	scribd_doc.write(divID);
}

function setDivsNormal(ombouwW,ombouwH, searchVar, indexFile, indexUrl)
{
	
	document.getElementById('scribdViewerOmbouw').style.width = ombouwW - 2 + 'px';
	document.getElementById('scribdViewerOmbouw').style.height = ombouwH - 35 + 'px';
	
	document.getElementById('scribdViewerIndexOverlay').style.width = ombouwW - 2 + 'px';
	document.getElementById('scribdViewerIndexOverlay').style.height = ombouwH - 35 - 27 + 'px';
	
	if(indexFile == 'yes')
	{
		var IndexOverlayAantal = Math.floor(parseFloat(document.getElementById('scribdViewerIndexOverlay').style.width)/232);
		document.getElementById('indexContainerOmbouw').style.marginLeft = (parseFloat(document.getElementById('scribdViewerIndexOverlay').style.width) - (IndexOverlayAantal * 232)) / 2 + 'px';
	}
	
	document.getElementById('ombouw').style.width = ombouwW + 'px';
	document.getElementById('ombouw').style.height = ombouwH-55 + 'px';
	
	//document.getElementById('menuDivOmbouw').style.width = ombouwW - 128 + 'px';
	document.getElementById('menuDivOmbouw').style.width = ombouwW - 2 + 'px';
	document.getElementById('menuDivOmbouw').style.marginTop = ombouwH - 35 - 27 + 'px';
	document.getElementById('menuDivOmbouw').style.marginLeft = 1 + 'px';
	
	if(ombouwW < 580)
	{
		var correctWidth = (580 - ombouwW)/2;
		document.getElementById('volgVorigDiv').style.marginLeft = (ombouwW/2) - (110/2) + correctWidth + 'px';
	}
	else
	{
		document.getElementById('volgVorigDiv').style.marginLeft = (ombouwW/2) - (110/2) + 'px';
	}
}
function setDivsFullscreen(searchVar, indexFile, indexUrl)
{
	//document.getElementById('menuDivOmbouwFullscreen').style.width = getSize()[0] - 128 + 'px';
	document.getElementById('menuDivOmbouwFullscreen').style.width = getSize()[0] - 2 + 'px';
	
	document.getElementById('scribdViewerFullscreen').style.width = getSize()[0] + 'px';
	document.getElementById('scribdViewerFullscreen').style.height = getSize()[1] + 'px';
	
	document.getElementById('scribdViewerIndexOverlay').style.width = getSize()[0] + 'px';
	document.getElementById('scribdViewerIndexOverlay').style.height = getSize()[1] - 35 - 28 + 'px';
	
	if(indexFile == 'yes')
	{
		var IndexOverlayAantal = Math.floor(parseFloat(document.getElementById('scribdViewerIndexOverlay').style.width)/232);
		document.getElementById('indexContainerOmbouw').style.marginLeft = (parseFloat(document.getElementById('scribdViewerIndexOverlay').style.width) - (IndexOverlayAantal * 232)) / 2 + 'px';
	}
	
	document.getElementById('menuDivOmbouwFullscreen').style.marginTop = getSize()[1] - 35 - 28 + 'px';
	document.getElementById('volgVorigDiv').style.marginLeft = (getSize()[0]/2) - (110/2) + 'px';
}
