/*
 * Digidesk media solutions
 *
 * @link			http://www.digidesk.de
 * @oxidVersion		OXID eShop CE/PE 4.3.2
 * @version			SVN: $$Id: dd_review.js 16 2010-07-12 12:46:53Z Sri $$
 */

function setRatingStars( sId)
{
	if( oUl = $( '#' + sId))
	{
		//sWidth = $( 'a', oUl).width();
		sWidth = 20;
		$( 'a', oUl).hover( function()
				{
					oParent = $( this).parent().parent();
					sUlId = oParent.attr( 'id');
					$( '#' + sUlId + ' .current').css( 'display', 'none');
				},
				function()
				{
					oParent = $( this).parent().parent();
					sUlId = oParent.attr( 'id');
					$( '#' + sUlId + ' .current').css( 'display', 'block');
				}
		);
		$( 'a', oUl).click( function()
				{
					oParent = $( this).parent().parent();
					sUlId = oParent.attr( 'id');
					iPos = $( '#' + sUlId + ' a').index( this) + 1;
					$( '#' + sUlId + ' .current').css( 'width', ( iPos * sWidth) + '%');
					$( '#' + sUlId + ' .current input').val( iPos);
					$( this).blur();
					checkInputs( oParent);
					return false;
				}
		);
	}
}

function setHelpLayer()
{
	if( oSpan = $( '.dd_rating_help'))
	{
		oDiv = null;
		$( oSpan).click( function()
				{
					if( oDiv = $( '.dd_rating_help_layer'))
					{
						$( oDiv).css( 'display', 'block');
					}
				}
		);
		if( oDiv = $( '.dd_rating_help_layer'))
		{
			$( oDiv).click( function()
					{
						$( oDiv).css( 'display', 'none');
					}
			);
		}
		if( oCloseDiv = $( '.dd_rating_close'))
		{
			$( oCloseDiv).click( function()
					{
						$( oDiv).css( 'display', 'none');
					}
			);
		}
	}
}

function checkInputs( oUl)
{
	aInps = $( 'input', oUl.parent().parent());
	blOk = true;
	for( i = 0; i < aInps.length; i++)
	{
		if( $( aInps[ i]).val() == 0)
		{
			blOk = false;
		}
	}
	
	if( blOk)
	{
		oDiv = $( oUl).parent().parent().parent().parent();
		$( oDiv).addClass( 'ok');
	}
}