function pngdisplay(image, width, height, cl, alt, onclk) 
{
	if(navigator.appName=='Microsoft Internet Explorer') 
	{ 
		document.write('<img src="images/empty.gif" style="width: ' + width + '; height: ' + height + '; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' + image + ', sizingMethod=scale)" alt="' + alt + '" title="' + alt + '" class="' + cl + '" id="' + cl + '" onclick="' + onclk + '">');
	} 
	else 
	{
		document.write('<img src="' + image + '" style="width: ' + width + '; height: ' + height + ';" alt="' + alt + '" title="' + alt + '" class="' + cl + '" id="' + cl + '" onclick="' + onclk + '">');
	}
}

function SwpDiv(obj)
{
	var o=document.getElementById(obj);
	
	if(o && o.style.display=='none') o.style.display='block';
	else o.style.display='none';
}

function GetIndex()
{
	document.location.href='index.php';
}

function Init(menu_index)
{
	if(menu_index!=-1) OverButton(menu_index);
	
	if(window.addEventListener) 
	{
		window.addEventListener('resize', ReplacePhoto, false);
		window.addEventListener('resize', PositionShadow, false);
	} 
	else if (window.attachEvent) 
	{
		window.attachEvent('onresize', ReplacePhoto);
		window.attachEvent('onresize', PositionShadow);
	}
}

function ReplacePhoto()
{
	if(document.getElementById('photo-is-active') && document.getElementById('photo-is-active').value!=0)
	{
		PositionPhoto();
	}
}

function getPageSize()
{
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) 
	{	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} 
	else if (document.body.scrollHeight > document.body.offsetHeight)
	{ 
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} 
	else 
	{ 
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
	if (self.innerHeight) 
	{	
		if(document.documentElement.clientWidth)
		{
			windowWidth = document.documentElement.clientWidth; 
		} 
		else 
		{
			windowWidth = self.innerWidth;
		}
		
		windowHeight = self.innerHeight;
	} 
	else if (document.documentElement && document.documentElement.clientHeight) 
	{ 
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} 
	else if (document.body) 
	{ 
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	if(yScroll < windowHeight)
	{
		pageHeight = windowHeight;
	} 
	else 
	{ 
		pageHeight = yScroll;
	}

	if(xScroll < windowWidth)
	{	
		pageWidth = xScroll;		
	} 
	else 
	{
		pageWidth = windowWidth;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 

	return arrayPageSize;
}

function HeightObj()
{
	var height=parseFloat(document.getElementById('photo-td').style.height.substr(0,3));
	var w=document.getElementById('photo-width').value;
	var h=document.getElementById('photo-height').value;
	var nn=document.getElementById('photo-is-active').value;

	if(height < h - 100)
	{
		document.getElementById('photo-td').style.height=height + 100;
	}
	else
	{
		if(height >= h - 100 && height < h - 10)
		{
			document.getElementById('photo-td').style.height=height + 10;
		}
		else
		{
			if(height >= h - 10 && height <= h)
			{
				document.getElementById('photo-td').style.height=height + 1;
			}
		}
	}

	if(height!=h) setTimeout('HeightObj()', 0.5);
	
	if(height==h)
	{
		document.getElementById('photo-td').innerHTML=document.getElementById('img'+nn).innerHTML;
		//document.getElementById('img'+nn).innerHTML='';
	}
}

function WidthObj()
{
	var width=parseFloat(document.getElementById('photo-td').style.width.substr(0,3));
	var w=document.getElementById('photo-width').value;
	var h=document.getElementById('photo-height').value;

	if(width < w - 100)
	{
		document.getElementById('photo-td').style.width=width + 100;
	}
	else
	{
		if(width >= w - 100 && width <= w - 10)
		{
			document.getElementById('photo-td').style.width=width + 10;
		}
		else
		{
			if(width >= w - 10 && width <= w)
			{
				document.getElementById('photo-td').style.width=width + 1;
			}
		}
	}

	if(width!=w) setTimeout('WidthObj()', 0.5);

	if(width==w) HeightObj();
}

function PositionPhoto()
{
	var x=(window.innerWidth)?window.innerWidth:((document.all)?document.body.offsetWidth:null);
	var y=(window.innerHeight)?window.innerHeight:((document.all)?document.body.offsetHeight:null);
	
	var w=document.getElementById('photo-width').value;
	var h=document.getElementById('photo-height').value;

	PositionShadow();
	
	document.getElementById('photo').style.top=document.body.scrollTop + ((y / 2) - h / 2 - 10);
	document.getElementById('photo').style.left=x / 2 - w / 2 - 30;
	document.getElementById('photo').style.display='block';
}

function PositionShadow()
{
	if(document.getElementById('shadow') && document.getElementById('shadow').style.display=='block')
	{
		var arrayPageSize=getPageSize();

		document.getElementById('shadow').style.height=arrayPageSize[1];
		document.getElementById('shadow').style.width=arrayPageSize[0];
	}
}

function ShowBigPhoto(w,h,nn)
{
	document.getElementById('photo-is-active').value=nn;
	document.getElementById('photo-width').value=w;
	document.getElementById('photo-height').value=h;

	document.getElementById('shadow').style.display='block';
	PositionPhoto();

	document.getElementById('photo-td').style.width=0;
	document.getElementById('photo-td').style.height=100;

	WidthObj();
}

function PrevBigPhoto(n)
{
	var flag=0;
	for(var i=0;i<photo.length;i++)
	{
		if(i==n)
		{
			if(photo[i-1])
			{
				flag=1;
			}
		}
	}
	
	if(flag==1)
	{
		var nn=photo[n-1][0];
		var w=photo[n-1][1]+19;
		var h=photo[n-1][2]+39;

		document.getElementById('photo-is-active').value=nn;
		document.getElementById('photo-width').value=w;
		document.getElementById('photo-height').value=h;

		PositionPhoto();
	
		document.getElementById('photo-td').style.width=0;
		document.getElementById('photo-td').style.height=100;

		WidthObj();
	}
}

function NextBigPhoto(n)
{
	var flag=0;
	for(var i=0;i<photo.length;i++)
	{
		if(i==n)
		{
			if(photo[i+1])
			{
				flag=1;
			}
		}
	}
	
	if(flag==1)
	{
		var nn=photo[n+1][0];
		var w=photo[n+1][1]+19;
		var h=photo[n+1][2]+39;

		document.getElementById('photo-is-active').value=nn;
		document.getElementById('photo-width').value=w;
		document.getElementById('photo-height').value=h;

		PositionPhoto();
	
		document.getElementById('photo-td').style.width=0;
		document.getElementById('photo-td').style.height=100;

		WidthObj();
	}
}

function CloseBigPhoto(nn)
{
	document.getElementById('shadow').style.display='none';
	document.getElementById('photo-is-active').value=0;		
	document.getElementById('photo-width').value=0;
	document.getElementById('photo-height').value=0;
	
	document.getElementById('photo').style.top=0;
	document.getElementById('photo').style.left=0;
	document.getElementById('photo').style.display='none';

	document.getElementById('photo-td').style.width='0px';
	document.getElementById('photo-td').style.height='0px';

	document.getElementById('img'+nn).innerHTML=document.getElementById('photo-td').innerHTML;
	document.getElementById('photo-td').innerHTML='';
	
}

function OverButton(num)
{
	var butt=document.getElementById('b'+num);
	var num2=num+1;
	var lft=document.getElementById('m'+num);
	var rgh=document.getElementById('m'+num2);
	var submenu=document.getElementById('submenu'+num);
	var activesubmenu=document.getElementById('active-submenu');
	
	if(activesubmenu.value!='')
	{
		if(document.getElementById('submenu'+activesubmenu.value)) document.getElementById('submenu'+activesubmenu.value).style.display='none';
		OutButton(activesubmenu.value);
	}
	
	if(butt)
	{
		butt.src=eval('b'+num+'over').src;
		if(lft && num!=0)
		{
			lft.src=rightbutton.src;
		}

		if(lft && num==0)
		{
			lft.src=rightbutton0.src;
		}
				
		if(rgh)
		{
			rgh.src=leftbutton.src;
		}
		
		if(submenu)
		{
			submenu.style.display='block';
		}
		
		activesubmenu.value=num;
	}
}

function OutButton(num)
{
	var butt=document.getElementById('b'+num);
	var num2=parseFloat(num)+1;
	var lft=document.getElementById('m'+num);
	var rgh=document.getElementById('m'+num2);
	
	if(butt)
	{
		butt.src=eval('b'+num+'out').src;
		
		if(lft)
		{
			lft.src=ebutton.src;
		}

		if(rgh)
		{
			rgh.src=ebutton.src;
		}
	}
}
