map.extent = yourextent;
// make sure the whole extent is visible
if (!map.extent.contains(extent))
{
map.level--;
}