8:16 pm on Apr 28, 2010 (utc 0)

I currently have a website that I am using SPRY Accordion on for the navigation. anu-d dot c o m

When I try to add another javascript element the SPRY Accordion stops working and the javascript element I am adding does not work.

I have had this problem trying to add a javascript slide show and now with a javascript twitter element (I have included the code I am using for that below).

Does anyone know why my javascript shuts down when I use more than on script? Also, would anyone be able to help me fix this so that I can implement other javascript elements on my webpage?

Here is the CSS/Javascript I am currently trying to add:


#twitter_badge_container{width: 300px; background: #C1EAFF}
#twitter_badge_tl{background: transparent url(twitter_tl.png) top left no-repeat;}
#twitter_badge_tr{background: transparent url(twitter_tr.png) top right no-repeat;}
#twitter_badge_bl{background: transparent url(twitter_bl.png) bottom left no-repeat;}
#twitter_badge_br{background: transparent url(twitter_br.png) bottom right no-repeat; }
#twitter_badge_inner{padding: 45px 10px 10px 10px;}
#twitter_badge_via {font-size: 10px;}
#twitter_badge_via a {color: #666;}

/* defaults */
#my_twitter_status_time{color: #666; font-size: 10px;}

<script type="text/javascript">
  function relative_time(time_value) {
    var values = time_value.split(" ");
    time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];
    var parsed_date = Date.parse(time_value);
    var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
    var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
    delta = delta + (relative_to.getTimezoneOffset() * 60);

    if (delta < 60) {
      return 'less than a minute ago';
    } else if(delta < 120) {
      return 'about a minute ago';
    } else if(delta < (45*60)) {
      return (parseInt(delta / 60)).toString() + ' minutes ago';
    } else if(delta < (90*60)) {
      return 'about an hour ago';
    } else if(delta < (24*60*60)) {
      return 'about ' + (parseInt(delta / 3600)).toString() + ' hours ago';
    } else if(delta < (48*60*60)) {
      return '1 day ago';
    } else {
      return (parseInt(delta / 86400)).toString() + ' days ago';

    function twitterCallback(obj) {
        var id = obj[0].user.id;
        document.getElementById('my_twitter_status').innerHTML = obj[0].text;
        document.getElementById('my_twitter_status_time').innerHTML = relative_time(obj[0].created_at);
<div id="twitter_badge_container">
    <div id="twitter_badge_tl">
        <div id="twitter_badge_tr">
            <div id="twitter_badge_bl">
                <div id="twitter_badge_br">
                    <div id="twitter_badge_inner">
                        <span id="my_twitter_status"></span> <span id="my_twitter_status_time"></span><span id="twitter_badge_via"> <a href="http://twitter.com/">via twitter</a></span>
                        <script type="text/javascript" src="http://www.twitter.com/statuses/user_timeline/95953197.json?callback=twitterCallback&count=1">

Does anyone know why my javascript shuts down when I use more than on script?

Conflicts are possible between event handlers that are not registered correctly [especially for 'onload'], var names [including array/scalar or local/global differences], elem ids, and so on. Adding a script that uses browser-specific properties or methods could have a similar effect. [I'm assuming that either script runs properly on its own, so outright errors can be excluded.]

Have you tried Firebug (or equivalent)?