//************************************************************************************************* 
// Design           	: FvdM design studios, 2009
// Initial file date	: 18 January, 2009
// Function(s)			: Webstore functions
// Change history		:	Date		By		Revision	Description
//							18-01-2009	FvdM	1.0			Initial version.
//							22-02-2009	FvdM	2.0			First PHP version.
//							31-12-2009	FvdM	2.1			Added ScrollSaver function.
//
//*************************************************************************************************

// Initialisation of variables
// Window dimensions and start positions
ZoomViewWidth	= '525';
ZoomViewHeight	= '570';
ZoomViewStartX	= '140';
ZoomViewStartY	= '75';
// Window view settings
ZoomViewDef		= '\' left=' + ZoomViewStartX + ', top=' + ZoomViewStartY + ', width=' + ZoomViewWidth + ', height=' + ZoomViewHeight + ', toolbar=0, location=0, directories=0, status=0, menuBar=0, scrollBars=0, resizable=0\'';
// Photo dimensions
ZoomPhotoWidth	= '500';
ZoomPhotoHeight	= '423';


function OpenPhoto(i)	{
// Initialisation of local variables
	NewPath			= 'Photos/Large photos/';
	NewFile			= i + '.jpg';
	NewImagePath	= NewPath + NewFile;
	
	ZoomPhotoDef	='<img src=\'' + NewImagePath + '\' alt=\'Vergroting\' title=\'Vergroting\' width=\'' + ZoomPhotoWidth + '\' height=\'' + 		ZoomPhotoHeight + '\' border=\'0\'/>';
	document.write(ZoomPhotoDef);
}


function OpenZoomView(i)	{
// Build Zoomed page HTML / PHP code
	newWindow=window.open('', '',ZoomViewDef);
	newWindow.location.href="Voorbeeld.php?Stockcode=" + i;
}


// OnLoad event; save scroll position on page loading
window.onload = function()	{
					Save_ScrollPos();
				}   


// When the query string in the URL contains scroll=nnn, then the scroll position will be restored
function Save_ScrollPos()	{
	// Get query string parameter with "?"
	var search = window.location.search;
	// If query string exists
	if (search)	{
		// Find scroll parameter in the query string   
		var matches = /scroll=(\d+)/.exec(search);   
		// Jump to the scroll position if scroll parameter exists   
		if (matches) window.scrollTo(0, matches[1]);   
	}
}


// Add the scroll value to the URL
function PosSaved_href(href){
	var scroll;
	// Netscape compliant
	if (typeof(window.pageYOffset) == 'number')
		scroll = window.pageYOffset;

	// DOM compliant
	else if (document.body && document.body.scrollTop)
		scroll = document.body.scrollTop;

	// IE6 standards compliant mode
	else if (document.documentElement && document.documentElement.scrollTop)
		scroll = document.documentElement.scrollTop;

	// needed for IE6 (when vertical scroll bar is on the top)
	else scroll = 0;

	// set href location with scroll position parameter
	window.location.href = href + '&scroll=' + scroll;
}
