Javascript date time comparission returns false but branch stmt still executed
<p>I am confused with this Javascript behaviour. Check this code.</p>

<pre><code>var NoOfMonthsElapsed = 6; //Should be &gt;= 1 and &lt;= 12
var MsgURL = "about:blank";
var PopupTitle = "ContactInfoUpdate";
var OptionString = "height=165,width=400,menubar=0,toolbar=0,location=1,status=0,resizable=0,status=0,HAlign=center,top=300";

var lastUpdatedDate = crmForm.all.dxb_lastcontactinfoupdatedon.DataValue; //Reads a field with date value = 01 Jan 2010
if (lastUpdatedDate)
{
  var month = lastUpdatedDate.getMonth();
  var year  = lastUpdatedDate.getYear();
  var date  = lastUpdatedDate.getDate();

  month = month + NoOfMonthsElapsed;
  year  = year  + parseInt(month / 11);
  month = (month % 11);

  var today = new Date();
  var showPopupAfterDate = new Date();

  showPopupAfterDate.setYear(year);
  showPopupAfterDate.setMonth(month);

  var alertMsg  = "LastUpdatedDate          = "+ lastUpdatedDate + "\n"
  var alertMsg += "Today                    = "+ today + "\n"
  var alertMsg += "PopupAfterDate           = "+ showPopupAfterDate + "\n"
  var alertMsg += "Today&gt;showPopupAfterDate = "+ (today&gt;showPopupAfterDate) + "\n"

  alert(alertMsg);

  if (today&gt;showPopupAfterDate); 
  {
    window.open(MsgURL, PopupTitle, OptionString);
  }
}
else 
{
  window.open(MsgURL, PopupTitle, OptionString);
}




//
// It displays the following output
//
LastUpdatedDate          = Wed May 18 20:56:00 UTC+0400 2011
Today                    = Fri May 18 20:23:49 UTC+0400 2011
PopupAfterDate           = Fri Nov 18 20:23:49 UTC+0400 2011
Today&gt;showPopupAfterDate = false
</code></pre>

<p>Why today is shown as Fri May 18 2011... though May 18 2011 is Wed
Why PopupAfterDate is shown as Fri Nov 18 2011...
And Even though the dates comparission returns false; The window.open still get executed.</p>
