/*写真の影を設定一覧画面用*/
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;
  
  /*
  alert(imageName);
  alert(document.getElementById("shadow_left" + imageno).height);
  alert(document.getElementById("shadow_right" + imageno).height);
  */
}

/*写真の影を設定詳細画面用*/
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;
  
  /*
  alert(imageName);
  alert(document.getElementById("shadow_left" + imageno).height);
  alert(document.getElementById("shadow_right" + imageno).height);
  */
}

/*画像の横幅と縦幅を比較して大きい方をイメージサイズに指定した値に設定（画像の縦横比は維持）*/
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';

/*
	var rate = 1;
	var img = document.images[imageName];
	if( img.width >= img.height )
	{
		rate = maxSize/img.width;
	}
	else
	{
		rate = maxSize/img.height;
	}
		
	//img.style.visibility = 'visible';
	img.width = img.width * rate;
	img.height = img.height * rate;
*/
  /*
  alert(document.images[imageName].width);
  */
}

// 画面のトップへ移動する
function backToTop() {
  var x1 = x2 = x3 = 0;
  var y1 = y2 = y3 = 0;
  if (document.documentElement) {
      x1 = document.documentElement.scrollLeft || 0;
      y1 = document.documentElement.scrollTop || 0;
  }
  if (document.body) {
      x2 = document.body.scrollLeft || 0;
      y2 = document.body.scrollTop || 0;
  }
  x3 = window.scrollX || 0;
  y3 = window.scrollY || 0;
  var x = Math.max(x1, Math.max(x2, x3));
  var y = Math.max(y1, Math.max(y2, y3));
  window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));
  if (x > 0 || y > 0) {
      window.setTimeout("backToTop()", 25);
  }
}

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';
		//alert( i.width);
		/*
		// 読み込みに失敗していた場合、再試行する
		var max_length = ((i.width>i.height) ? i.width : i.height);
		if(max_length < 10)
		{
			loadImage(i.id, imageName, s);
		}
		*/

		++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)
	{
		// Image オブジェクトにロードした画像から
		// 縮小率を求める
		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.all(categoryId).style.visibility == "visible")
	{
		document.all(categoryId).style.visibility = "hidden";
	}
	else if(document.all(categoryId).style.visibility == "hidden")
	{
		document.all(categoryId).style.visibility = "visible";
	}
	else 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";
	}
*/
	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";
	}

}
