How to convert this PHP code to Javascript?
<p>I have been recently trying to convert a calendar I wrote to Javascript. Sorry, I asked a question here before, but I should have included this one in that one.</p>

<p>The procedure I followed to get the code was: to go through the PHP line by line, and convert everything to the equivalent syntax in Javascript. Instead of using POST to send information to the page in PHP, I call the calendar function using onclick links. Instead of using array_search I used indexOf (etc, etc). You get the picture.</p>

<p>In order to properly convert the code to Javascript, what else would I need to do? I'm not looking for anyone to do my homework for me. The calendar runs fine in PHP, and I think I've substituted all the necessary functions (such as indexOf for array_search and so on). The javascript code is identically equivalent to the PHP program:</p>

<p>PHP: <a href="http://codepad.org/87T2EFW9" rel="nofollow">http://codepad.org/87T2EFW9</a></p>

<p>Javascript: <a href="http://codepad.org/it10aljf" rel="nofollow">http://codepad.org/it10aljf</a></p>

<p>It shows October incorrectly, with just a previous link. Run it for yourself to see what I mean.</p>

<p>What kind of advice would you give me from here? Some folks have suggested to use JSHint, but it's giving me a lot of errors which I think aren't really necessary (obviously, I have declared variables multiple times, but nothing that would break the program). Are there any useful procedures I should undertake? Maybe I should start again, and go through it line by line, as thoroughly as possible? What do you guys do when porting (crappy, or noncrappy) code?</p>

<p>I see someone here has voted me down for asking this question, have I done something wrong? Should I not bother at all to ask?</p>
