Ajax link not working when linking to custom scripts

Hi all iv been finding my way around Yii and im enjoying it. But now i have a problem. I have this Template that im using an this template has some custom js for charts, forms etc. Now I have link to the js from the head section in main layout everything kinda off worked fine. But today I wanted to use CJuiDialog and it didnt work (I am kind of new to Ajax anyway), so I went to the yiiPlayground site and found a simple example(the one where you update the time using ajax link) which I then copied but it still didnt work.

I then created a new Yii webapp and it finally worked there. So i went back to my code and removed all my scripts from the head section, only to find that the ajax link from the playground now works and when I put back the script links it stops working again. what am I doing wrong here please somebody help.

Ok I had to search and randomly commenting out some lines in some of my scripts and finally found the one that caused the problem.