<?php
function throwAttributesValuesSelects( $bOnlyProductListVisible = false ){
	$oDB = & DataBase::getInstance( );
	$oTpl = & TplParser::getInstance( );
	$aAttributes = $oDB->executeSQL( 'SELECT `iAttribute`, `sName`, `iProductListVisible` FROM `' . $oDB->throwTableName( DB_ATTRIBUTES ) . '` '.($bOnlyProductListVisible ? 'WHERE `iProductListVisible`' : null).' ORDER BY `iPosition`, `sName`', true, DataBase::ASSOCIATIVE, 'iAttribute' );
	if( is_array( $aAttributes ) ){
		foreach( $aAttributes as &$aAttribute ){
			$sql = 'SELECT `iAttributeValue`, `sValue` FROM `' . $oDB->throwTableName( DB_ATTRIBUTES_VALUES ) . '` WHERE `iAttribute` = ' . intval( $aAttribute['iAttribute'] ) . ' ORDER BY `iPosition`, `sValue`';
			$aAttribute['aAValues'] = $oDB->executeSQL( $sql, true, DataBase::ASSOCIATIVE );
		}
		return $aAttributes;
	}
}
?>