Intanto vedo che in questa riga
if($widht > 280)
hai invertito la t e la h.