I'm very confused by this line. If you look deeply you are doing-> $($("#advanced-search")).toggle();
Why so?

The obvious answer that you wanted to do-> advancedSearch.toggle();
But even then - Why would you declare a variable to be used only once. You just might better a direct call like-> $("#advanced-search").toggle();

I hope you follow me here.