var sofa_width, sofa_height;

window.onload = showMenuItem;

function showMenuItem(itemId) 
{
	var d = document.getElementById(itemId);
	for (var i = 1; i<=10; i++) 
	{
		if (document.getElementById('s_menu'+i)) {document.getElementById('s_menu'+i).style.display='none';}
	}
	if (d) 
	{
		d.style.display='block';
	}
}

function showPicture(aparent) 
{
	var sofa_bkg = document.getElementById('sofa_bg');
	var sofa_ld = document.getElementById('sofa_ldg');
	var sofa_frm = document.getElementById('sofa_frame');
	var sofa_img = document.getElementById('sofa_img');
	var scrollH, scrollL;

	sofa_width = document.body.scrollWidth;
	sofa_height = document.body.scrollHeight;

	if (document.body.offsetHeight)
		if (document.body.offsetHeight > sofa_height) sofa_height = document.body.offsetHeight;

	sofa_bkg.style.top = 0;
	sofa_bkg.style.left = 0;
	sofa_bkg.style.height = sofa_height;
	sofa_bkg.style.width = sofa_width;

	if (window.innerHeight) 
	{
		sofa_width = window.innerWidth;
		sofa_height = window.innerHeight;
	} 
	else 
	{
		sofa_width = document.body.offsetWidth;
		sofa_height = document.body.offsetHeight;
	}
	if (window.pageYOffset) 
	{
		scrollH = window.pageYOffset;
		scrollL = window.pageXOffset;
	} 
	else 
	{
		scrollH = document.body.scrollTop;
		scrollL = document.body.scrollLeft;
	}
	sofa_ld.style.left = scrollH + (sofa_width - 508) / 2 + 'px';
	sofa_ld.style.top = scrollL + (sofa_height - 381) / 2 + 'px';
	sofa_ld.style.display = 'block';
	sofa_bkg.style.display = 'block';
	sofa_bkg.style.left = scrollL + 'px';
	sofa_bkg.style.top = scrollH + 'px';
	img = new Image();
	img.onload=function() 
	{
		var imgl = img.width;
		var imgh = img.height;
		if (imgl + 60 > sofa_width) 
		{
			imgl = sofa_width - 60;
			imgh = img.height * imgl / img.width;
		}
		if (imgh + 60 > sofa_height) 
		{
			imgh = sofa_height - 60;
			imgl = img.width * imgh / img.height;
		}
		sofa_frm.style.top = scrollH + (sofa_height - imgh - 20) / 2 + 'px';
		sofa_frm.style.left = scrollL + (sofa_width - imgl - 20) / 2 + 'px';
		sofa_frm.style.width = 920 + 'px'
		sofa_frm.style.height = 720 + 'px'
		sofa_img.src= aparent.href;
		sofa_img.width = imgl;
		sofa_img.height = imgh;
		sofa_frm.style.display = 'block';
		sofa_ld.style.display = 'none';
		return false;
	}
	img.src= aparent.href;
}

function hidePicture() 
{
	var sofa_bkg = document.getElementById('sofa_bg');
	var sofa_frm = document.getElementById('sofa_frame');
	sofa_bkg.style.display = 'none';
	sofa_frm.style.display = 'none';
	return false;
}

function scrollPicture() 
{
	if (document.getElementById('sofa_bg').style.display != 'block') return;
	var sofa_frm = document.getElementById('sofa_frame');
	if (sofa_frm.style.display != 'block') sofa_frm = document.getElementById('sofa_ldg');
	var scrollH, scrollL;
	if (window.pageYOffset) 
	{
		scrollH = window.pageYOffset;
		scrollL = window.pageXOffset;
	} 
	else 
	{
		scrollH = document.body.scrollTop;
		scrollL = document.body.scrollLeft;
	}
	sofa_frm.style.top = scrollH + (sofa_height - parseInt(sofa_frm.style.height) - 20) / 2 + 'px';
	sofa_frm.style.left = scrollL + (sofa_width - parseInt(sofa_frm.style.width) - 20) / 2 + 'px';
	var sofa_bkg = document.getElementById('sofa_bg');
	sofa_bkg.style.left = scrollL + 'px';
	sofa_bkg.style.top = scrollH + 'px' ;
}
