//////////////////////////////////////////////////////////////////////////////////
//記事詳細ページ
//////////////////////////////////////////////////////////////////////////////////


//デフォルトメイン画像のパス
var _InitPicSrc;
//デフォルトメインの画像サイズ
var _InitPicWidth;

//横幅の許容値
var LIMITEDWIDTH = 300;

var LIMITEDWIDTHFORSMALL = 146;

//イメージの横幅情報
var ImgWidthInfos;

//イメージのエレメント名情報
var ImgElementIds;


function InitInstance()
{
	_InitPicSrc = document.getElementById( "imgMain" ).src;
//	_InitPicWidth = document.getElementById( "imgMain" ).width;

//	ImgElementIds = new Array(
//		"imgMain",
//		"imgMini1",
//		"imgMini2",
//		"imgMini3",
//		"imgMini4",
//		"imgMini5",
//		"imgMini6"
//	);

//	ImgWidthInfos = new Array(ImgElementIds.length);

//	for( index = 0; index< ImgElementIds.length; index ++ )
//	{
//		ImgWidthInfos[ index ] = document.getElementById( ImgElementIds[index] ).width;
//	}
}

//
//初期化処理
//
function InitPicture()
{
	InitInstance();
	
	SetMainWidth( _InitPicWidth );

	SetSubWidth();

}

//
//マウスオーバー時の処理
//
function ChangeMainPicture( elementName )
{
	tempImg = document.getElementById( elementName );
	document.getElementById( "imgMain" ).src = tempImg.src;	
	//SetMainWidth( FindOriginalWidth( elementName ) );
}

//
//マウスアウト時の処理
//
function ResetMainPicture( mainImgPath )
{
	document.getElementById( "imgMain" ).src = mainImgPath;
	//SetMainWidth( _InitPicWidth );
}

//
//メインの横幅を調整
//
function SetMainWidth( width )
{

//	if( document.getElementById( "imgMain" ).width >= LIMITEDWIDTH  )

	if( width >= LIMITEDWIDTH )
	{
		width = LIMITEDWIDTH;
	}
	//document.getElementById( "imgMain" ).width = width;
	document.getElementById( "imgMain" ).width = 300;

}

function SetSubWidth()
{
	for( index = 1; index < ImgElementIds.length; index++ )
	{
		if( document.getElementById( ImgElementIds[index] ).width >= LIMITEDWIDTHFORSMALL  )
		{
			document.getElementById( ImgElementIds[index] ).width = LIMITEDWIDTHFORSMALL;
		}
	}
}

function FindOriginalWidth( elementName )
{
	for( index = 0; index < ImgElementIds.length; index++ )
	{
		if( ImgElementIds[index] == elementName )
		{
			return ImgWidthInfos[index];
		}
	}
	return 0;
}


function WindowOpen( imgOrder,ItemID )
{
	window.open("ArticlePhoto.php?IID=" +ItemID + "&Pic=" + imgOrder +"","","dirctories=0, location=0, menubar=0, scrollbars=0, status=0, toolbar=0, resizable=0, width=840, height=700");
}



//////////////////////////////////////////////////////////////////////////////////
//写真詳細ページ
//////////////////////////////////////////////////////////////////////////////////
//
//マウスクリック時の処理
//
function PhotoMainPicture( elementName,imgNumber )
{
	tempImg = document.getElementById( elementName );
	document.getElementById( "imgMain" ).src = tempImg.src;	
	document.getElementById( "imgNowMainNum" ).width = imgNumber;
}


//
//矢印クリック時の処理(次へ)
//
function PhotoAdd()
{
	numImg = document.getElementById( "imgNowMainNum" );
	
	if( numImg.width < 7 )
	{
		nextNum = numImg.width + 1;
		nextImg = document.getElementById( "imgMini" + nextNum );
	}
	else
	{
		nextImg = document.getElementById( "imgMini1" );
		nextNum = 1;
	}
	
	if(nextImg.width == 1)
	{
		newNum = nextNum;
		for( $i = 1; newNum < 8 ; $i++ )
		{
			newNum = nextNum + $i;
			nextImg = document.getElementById( "imgMini" + newNum ); 
			if(nextImg.width > 1) break;
			
			if( newNum == 7 )
			{
				nextImg = document.getElementById( "imgMini1");
				if(nextImg.width > 1) break;
			}
			
		}
		nextNum = newNum;
	}
	document.getElementById( "imgNowMainNum" ).width = nextNum;
	document.getElementById( "imgMain" ).src = nextImg.src;
}

//
//矢印クリック時の処理(前へ)
//	
function PhotoSubtract()
{
	numImg = document.getElementById( "imgNowMainNum" );
	
	if( numImg.width > 1 )
	{
		nextNum = numImg.width - 1;
		nextImg = document.getElementById( "imgMini" + nextNum ); 
	}
	else
	{
		nextImg = document.getElementById( "imgMini7" );
		nextNum = 7;
	}
	
	if(nextImg.width == 1)
	{
		newNum = nextNum;
		for( $i = 1; newNum > 1 ; $i++ )
		{
			newNum = nextNum - $i;
			nextImg = document.getElementById( "imgMini" + newNum ); 
			if(nextImg.width > 1) break;
		}
		nextNum = newNum;
	}
		
	document.getElementById( "imgNowMainNum" ).width = nextNum;
	document.getElementById( "imgMain" ).src = nextImg.src;
}





//////////////////////////////////////////////////////////////////////////////////
//記事画像確認ページ(使用していない)
//////////////////////////////////////////////////////////////////////////////////

function SetArticleWidth( mainWidth,sideWidth )
{
	if( document.getElementById( 'imgMain' ).width >= mainWidth  )
	{
		document.getElementById( 'imgMain' ).width = mainWidth;
	}
	
	if( document.getElementById( 'imgside0' ) != null )
	{
		if( document.getElementById( 'imgside0' ).width >= sideWidth  )
		{
			document.getElementById( 'imgside0' ).width = sideWidth;
		}
	}
	if( document.getElementById( 'imgside1' ) != null )
	{
		if( document.getElementById( 'imgside1' ).width >= sideWidth  )
		{
			document.getElementById( 'imgside1' ).width = sideWidth;
		}
	}
	if( document.getElementById( 'imgside2' ) != null )
	{
		if( document.getElementById( 'imgside2' ).width >= sideWidth  )
		{
			document.getElementById( 'imgside2' ).width = sideWidth;
		}
	}
	if( document.getElementById( 'imgside3' ) != null )
	{
		if( document.getElementById( 'imgside3' ).width >= sideWidth  )
		{
			document.getElementById( 'imgside3' ).width = sideWidth;
		}
	}
	if( document.getElementById( 'imgside4' ) != null )
	{
		if( document.getElementById( 'imgside4' ).width >= sideWidth  )
		{
			document.getElementById( 'imgside4' ).width = sideWidth;
		}
	}
	if( document.getElementById( 'imgside5' ) != null )
	{
		if( document.getElementById( 'imgside5' ).width >= sideWidth  )
		{
			document.getElementById( 'imgside5' ).width = sideWidth;
		}
	}
		
}

//////////////////////////////////////////////////////////////////////////////////
//記事変更ページ(20060428)
//////////////////////////////////////////////////////////////////////////////////

function IsConfirm(edit,hdnName){
		document.getElementById( hdnName ).value = edit;
}

