//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//	AJAX Framework / Style
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//	cheltenham software
//	http://cheltenham-software.com/
//	無断配布や二次利用を禁止します。
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// 要素の表示をSet
function cheltenhamStyle_setDisplay( id, flagView )
{
	var objectTarget = document.getElementById( id );
	if( objectTarget == null )
	{
		alert( '[' + id + '] is not defined.' );
	}
	if( eval( flagView ) )
	{
		objectTarget.style.display = 'block';
	}
	else
	{
		objectTarget.style.display = 'none';
	}
}
// 要素の表示をGet
function cheltenhamStyle_getDisplay( id )
{
	var objectTarget = document.getElementById( id );
	if( objectTarget.style.display == 'block' )
	{
		return( 1 );
	}
	else
	{
		return( 0 );
	}
}
// 要素の表示をSwap
function cheltenhamStyle_swapDisplay( id )
{
	if( cheltenhamStyle_getDisplay( id ) )
	{
		cheltenhamStyle_setDisplay( id, 0 );
	}
	else
	{
		cheltenhamStyle_setDisplay( id, 1 );
	}
}

// 要素の表示をSet
function cheltenhamStyle_setVisibility( id, flagView )
{
	var objectTarget = document.getElementById( id );
	if( objectTarget == null )
	{
		alert( '[' + id + '] is not defined.' );
	}
	if( eval( flagView ) )
	{
		objectTarget.style.visibility = 'visible';
	}
	else
	{
		objectTarget.style.visibility = 'hidden';
	}
}
// 要素の表示をGet
function cheltenhamStyle_getVisibility( id )
{
	var objectTarget = document.getElementById( id );
	if( objectTarget.style.visibility == 'visible' )
	{
		return( 1 );
	}
	else
	{
		return( 0 );
	}
}
// 要素の表示をSwap
function cheltenhamStyle_swapVisibility( id )
{
	if( cheltenhamStyle_getVisibility( id ) )
	{
		cheltenhamStyle_setVisibility( id, 0 );
	}
	else
	{
		cheltenhamStyle_setVisibility( id, 1 );
	}
}

// Class名をSet
function cheltenhamStyle_setClass( id, nameClass )
{
	var objectTarget = document.getElementById( id );
	if( objectTarget == null )
	{
		alert( '[' + id + '] is not defined.' );
	}
	if( nameClass == null )
	{
		alert( 'class is not defined.' );
	}
	else
	{
		objectTarget.className = nameClass;
	}
}
// Class名をGet
function cheltenhamStyle_getClass( id )
{
	var objectTarget = document.getElementById( id );
	if( objectTarget == null )
	{
		alert( '[' + id + '] is not defined.' );
	}
	else
	{
		return( objectTarget.className );
	}
}
// Z IndexをSet
function cheltenhamStyle_setZIndex( id, indexTarget )
{
	var objectTarget = document.getElementById( id );
	if( objectTarget == null )
	{
		alert( '[' + id + '] is not defined.' );
	}
	else if( indexTarget == null )
	{
		alert( 'z-index value is not defined.' );
	}
	else
	{
		objectTarget.style.zIndex = indexTarget;
	}
}
// Z IndexをGet
function cheltenhamStyle_getZIndex( id )
{
	var objectTarget = document.getElementById( id );
	if( objectTarget == null )
	{
		alert( '[' + id + '] is not defined.' );
	}
	else
	{
		return( objectTarget.style.zIndex );
	}
}


// 要素のスタイル値をGet
function cheltenhamStyle_getStyleValue( id, nameStyle )
{
	// 要Yahoo UIの場合（yahoo-min.js, dom-min.js）
	var x = YAHOO.util.Dom.getStyle( id, nameStyle );
	// 要prototype.jsの場合
//	var x = Element.getStyle( id, nameStyle );

	return( x );
}
// 要素のサイズをGet
function cheltenhamStyle_getSize( id )
{
	var result = { "width" : null, "height" : null, "left" : null, "top" : null };
	result.width = cheltenhamStyle_getStyleValue( id, 'width' );
	if( result.width != null )
	{
		result.width = parseInt( result.width.replace( 'px', '' ) );
	}
	result.height = cheltenhamStyle_getStyleValue( id, 'height' );
	if( result.height != null )
	{
		result.height = result.height.replace( 'px', '' );
	}
	result.left = cheltenhamStyle_getStyleValue( id, 'left' );
	if( result.left != null )
	{
		result.left = result.left.replace( 'px', '' );
	}
	result.top = cheltenhamStyle_getStyleValue( id, 'top' );
	if( result.top != null )
	{
		result.top = result.top.replace( 'px', '' );
	}
	return( result );
}
// 要素をウィンドウの真ん中に移動
function cheltenhamStyle_setPositionToCenterOfWindow( id, shiftLeft, shiftTop )
{
	var objectTarget = document.getElementById( id );
	var sizeObjectTarget = cheltenhamStyle_getSize( id );
	var sizeWindow = cheltenhamWindow_getSizeDisplay();
	if( sizeObjectTarget == null )
	{
		return;
	}

	var positionLeft = Math.max( Math.floor( ( sizeWindow.width - sizeObjectTarget.width ) / 2 ) + shiftLeft, 0 );
	var positionTop = Math.max( Math.floor( ( sizeWindow.height - sizeObjectTarget.height ) / 2 ) + shiftTop, 0 );

	objectTarget.style.left = positionLeft + 'px';
	objectTarget.style.top = positionTop + 'px';
}

