Switching quickly between cases basic and advance link giving error

I am facing an issue which is causing when I quickly switch between basic and advance search of cases module especially when I quickly click basic seach link from advance search section.

It says-
Uncaught TypeError: Cannot read property ‘setAttribute’ of null
at handleDisplay (sugar_grp1.js?v=wc2L04d0ef6QRXCC9q1n1Q:520)
at Object.success (sugar_grp1.js?v=wc2L04d0ef6QRXCC9q1n1Q:528)
at Object.handleTransactionResponse (sugar_grp1_yui.js?v=wc2L04d0ef6QRXCC9q1n1Q:55)
at sugar_grp1_yui.js?v=wc2L04d0ef6QRXCC9q1n1Q:55

& the code that is causing this problem is-

adv.setAttribute(‘accesskey’,’’);bas.setAttribute(‘accesskey’,’’);a_key=SUGAR.language.get(“app_strings”,“LBL_ADV_SEARCH_LNK_KEY”);if(theView===‘advanced_search’){bas.setAttribute(‘accesskey’,a_key);}else{adv.setAttribute(‘accesskey’,a_key);}

Can you please help me in this Error?