﻿function shadow_image(imageName,imageno)
{
  var shadowTableWidth = document.images[imageName].width + 4;
  var shadowTableHeight = document.images[imageName].height + 4;

  if( document.getElementById("shadow_left" + imageno) == undefined )
  {
	return;
  }
  document.getElementById("shadow_left" + imageno).width = shadowTableWidth;
  document.getElementById("shadow_left" + imageno).height = shadowTableHeight;
  document.getElementById("shadow_right" + imageno).width = shadowTableWidth;
  document.getElementById("shadow_right" + imageno).height = shadowTableHeight;
}
function shadow_image_big(imageName)
{
  var shadowTableWidth = document.images[imageName].width + 4;
  var shadowTableHeight = document.images[imageName].height + 4;
  document.getElementById("shadow_left").width = shadowTableWidth;
  document.getElementById("shadow_left").height = shadowTableHeight;
  document.getElementById("shadow_right").width = shadowTableWidth;
  document.getElementById("shadow_right").height = shadowTableHeight;
}
function image_size(imageName,maxSize)
{
  document.images[imageName].style.display = 'none';
  if (document.images[imageName].width > document.images[imageName].height) 
  {
	document.images[imageName].width = maxSize;
  }
  else 
  {
	document.images[imageName].height = maxSize;
  }
  document.images[imageName].style.display = 'inline';
}

function loadImageAll(parentName, s)
{
	var cnt = 0;
	while(true)
	{
		var imageName = parentName + cnt;
		var i = document.images[imageName];

		if( i == undefined)
		{
			break;
		}
		
		i.style.display = 'inline';
		++cnt;
	}
}
function loadImage(imagePath, imageName, s)
{
	var myImage = new Image();
	myImage.src = imagePath;

	var i = document.images[imageName];

	var rate = 1;
	if( myImage.width > 10)
	{
		if( myImage.width > myImage.height)
		{
			rate = (s/myImage.width);
		}
		else
		{
			rate = (s/myImage.height);
		}
		
		if( rate > 1)
		{
			rate = 1;
		}
		i.width = rate * myImage.width;
		i.height = rate * myImage.height;
	}
	else
	{
		i.width = s;
	}

	i.style.display = 'inline';
}
function loadImageByID(imageID, s)
{
    var i = document.getElementById(imageID);

	var myImage = new Image();
	myImage.src = i.src;	

	var rate = 1;
	if( myImage.width > 10)
	{
		if( myImage.width > myImage.height)
		{
			rate = (s/myImage.width);
		}
		else
		{
			rate = (s/myImage.height);
		}
		
		if( rate > 1)
		{
			rate = 1;
		}
		i.width = rate * myImage.width;
		i.height = rate * myImage.height;
	}
	else
	{
		i.width = s;
	}

	i.style.display = 'inline';
}
function pullDown(categoryId) 
{
	if(document.getElementById(categoryId).style.visibility == "visible")
	{
		document.getElementById(categoryId).style.visibility == "hidden";
	}
	else if(document.getElementById(categoryId).style.visibility == "hidden")
	{
		document.getElementById(categoryId).style.visibility == "visible";
	}

}
