The basic law of supply and demand dictates that when there is a change in supply, such as in the case of surplus, there is a correlated and directly proportional change in the price which in turn affects demand. Accordingly, in the first scenario, if there is a surplus of supply, this means that the price that demand (consumers) is willing to purchase at is lower. If there is a scarcity in supply, it can be expected that if demand remains the same there will be an increase in price since there is a limited number of goods that are available.
This basic law of supply and demand is only applicable, however, if the goods are considered as it is. In cases there exist substitutes or when there is no real demand (necessity) for the good, the rules are now different. When a good is not necessary, demand is affected by changes in price at a higher degree than the normal direct correlation. This means that if consumers do not need an item, a slight change of 1 unit in price can directly translate into a decrease of demand by more than 1 unit.
This means that the demand is elastic in that if there are sudden changes in price, due to the fact that the good is deemed unnecessary, the consumers will decide not to purchase that item. On the other hand, the concept of substitutions is also based on the elasticity (willingness) to the price. In this case, when the price of good A increases, demand will decrease and shift, depending on the available substitutes.
An example is the sale of Shampoo, when the leading brand increases its price, the availability of another brand of shampoo will meant that consumers will forego the purchase of the leading Shampoo and instead purchase another brand of shampoo. As such, it can be seen that the necessity of a good and the availability if substitutes makes the impact of changes in price vary from the basic model of supply and demand.
Davidson, Scott. (2003). Economics: Perfect Competition and Monopolistic Competition. 2nd Series. Bantham Books: 103-105.