Two javascripts conflicting with one another
<p>I have searched through every website possible, I've reached out to our site developer, who's not really a professional designer or coder, and I'm stuck. I've got two scripts running on my homepage and according to her, whenever there are two, the "NewsRotator" script gets cancelled out and functions incorrectly. From everything I've read, it sounds like it could be an issue with the <code>window.onload</code> command, but I'm still pretty new at this javascript stuff.</p>

<p>I will post the programming here and if anyone could PLEASE help, it would be greatly appreciated. First, the News Rotator, the one that malfunctions:</p>

<pre><code>&lt;div id="NewsBox"&gt;
&lt;div id="NewsContainer"&gt;
  &lt;div id="NewsRotator"&gt;
    &lt;div&gt;
  &lt;img src="images/loading.gif" border="0" alt="Loading..."&gt;&lt;br&gt;Loading...
}    
&lt;/div&gt;
  &lt;/div&gt;
&lt;div style="clear:both;height:1px;overflow:hidden"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div id="NewsPreview"&gt;&lt;/div&gt;
&lt;div id="NewsItems" style="display:none"&gt;
[!Ditto? &amp;startID=`[[CurrentPress]]` &amp;summarize=`4` &amp;tpl=`NewsRotatorArticle`      &amp;sortBy=`pub_date` &amp;sortDir=`DESC`!]
&lt;/div&gt;
&lt;/div&gt;
&lt;script language="javascript"&gt;
// Change the value below to modify the delay between news items.
var delaySeconds = 8;
var currentItem = 0;
var timer = null;
var newsItems;
var articles = new Array();

window.onload=initializeItems;

// Intialize Variables
function initializeItems() {
init();

newsItems = document.getElementById('NewsItems');
var divs = newsItems.getElementsByTagName('DIV');
for (var i=0;i&lt;divs.length;i++) {
    if (divs[i].getAttribute("type") == 'article')
        articles[articles.length] = divs[i];
}
displayItem();
}

// Display item
function displayItem() {
if (currentItem &gt; articles.length - 1) currentItem = 0;
if (articles[currentItem]) {
var url = articles[currentItem].getAttribute("url");
var html = articles[currentItem].innerHTML;


document.getElementById("NewsRotator").innerHTML = html;
var newslink = document.getElementById("NewsLink");
var links = newslink.getElementsByTagName("A");
links[0].href = url;
newslink.style.display = "block";

currentItem++;
updatePreview();
timer = window.setTimeout("displayItem()",delaySeconds*1000);
}
}

function updatePreview() {
    var imgs = new Array();
    var html = "";

    // Get main image from each article;
for (var i=0; i&lt;articles.length; i++) {
    var tmp = articles[i].getElementsByTagName("IMG");
    if (tmp &amp;&amp; tmp.length &gt; 0)
        imgs[imgs.length] = tmp[0].src;
    else
        imgs[imgs.length] = null;
}

var end = (currentItem &gt; articles.length-1) ? articles.length-1 : currentItem;
var begin = end-3;
if (begin &lt; 0) {
    begin = 0;
    end = (articles.length &gt;= 4) ? 3 : articles.length-1;
}

for (var j=begin; j&lt;=end; j++) {
    //alert('begin: ' + begin + "\n end:" + end);
    if (imgs[j] != null) {
       if(j+1 == currentItem) {
           html += '&lt;li&gt;&lt;a href="#" onclick="currentItem=' + j + ';window.clearTimeout(timer);displayItem();return false;" class="current"&gt;';
           html += '&lt;img src="/images/news/prev'+(j+1)+'-over.gif" alt="'+(j+1)+'" border="0"&gt;&lt;/a&gt;&lt;/li&gt;' + "\n";+'&lt;/a&gt;&lt;/li&gt;' + "\n";
       }
       else {
           html += '&lt;li&gt;&lt;a href="#" onclick="currentItem=' + j + ';window.clearTimeout(timer);displayItem();return false;"&gt;';
           html += '&lt;img src="/images/news/prev'+(j+1)+'.gif" alt="'+(j+1)+'" border="0"&gt;&lt;/a&gt;&lt;/li&gt;' + "\n";+'&lt;/a&gt;&lt;/li&gt;' + "\n";
       }
    }
}

if (html != "") {
    html = '&lt;ul&gt;' + html + '&lt;/ul&gt;&lt;div style="clear:both"&gt;&lt;/div&gt;';
    document.getElementById('NewsPreview').innerHTML = html;
}
}
&lt;/script&gt;
</code></pre>

<p>This is the 2nd, it works beautifully when it's on the page, but it shuts down my news rotator.</p>

<pre><code>//Specify the slider's width (in pixels)
var sliderwidth="300px"
//Specify the slider's height
var sliderheight="150px"
//Specify the slider's slide speed (larger is faster 1-10)
var slidespeed=3
//configure background color:
slidebgcolor="#EAEAEA"

//Specify the slider's images
var leftrightslide=new Array()
var finalslide=''
//Specify the slider's width (in pixels)
var sliderwidth="940px"
//Specify the slider's height
var sliderheight="125px"
//Specify the slider's slide speed (larger is faster 1-10)
var slidespeed=2
//configure background color:
slidebgcolor="#ffffff"

//Specify the slider's images
var leftrightslide=new Array()
var finalslide=''
leftrightslide[0]='&lt;a href="http://deals.sheraton.com/promos/NAD-massachusetts-Springfield-falcons-hockey"&gt;&lt;img src="assets/images/new web graphics/Corporate Logos/sheraton.png" border=1&gt;&lt;/a&gt;'
leftrightslide[1]='&lt;a href="http://www.libboslaw.com"&gt;&lt;img src="assets/images/new web graphics/Corporate Logos//libboslaw.png" border=1&gt;&lt;/a&gt;'
leftrightslide[2]='&lt;a href="http://www.amicaconnections.com"&gt;&lt;img src="assets/images/new web graphics/Corporate Logos/amica.png" border=1&gt;&lt;/a&gt;'
leftrightslide[3]='&lt;a href="http://www.artiolidodge.com"&gt;&lt;img src="assets/images/new web graphics/Corporate Logos/artiolidodge.png" border=1&gt;&lt;/a&gt;'
leftrightslide[4]='&lt;a href="http://www.bigy.com"&gt;&lt;img src="assets/images/new web graphics/Corporate Logos/bigy.png" border=1&gt;&lt;/a&gt;'
leftrightslide[5]='&lt;a href="http://www.bltees.com"&gt;&lt;img src="assets/images/new web graphics/Corporate Logos/bltees.png" border=1&gt;&lt;/a&gt;'
leftrightslide[6]='&lt;a href="http://www.completepayrollsolutions.com"&gt;&lt;img src="assets/images/new web graphics/Corporate Logos/cps.png" border=1&gt;&lt;/a&gt;'
leftrightslide[7]='&lt;a href="http://www.baliseauto.com"&gt;&lt;img src="assets/images/new web graphics/Corporate Logos/balise.png" border=1&gt;&lt;/a&gt;'
leftrightslide[8]='&lt;a href="http://www.facebook.com/70054351104/posts/10151037727871105"&gt;&lt;img src="assets/images/new web graphics/Corporate Logos/garyrome.png" border=1&gt;&lt;/a&gt;'
leftrightslide[9]='&lt;a href="http://www.mylimo5.com"&gt;&lt;img src="assets/images/new web graphics/Corporate Logos/exclusivelimo.png" border=1&gt;&lt;/a&gt;'
leftrightslide[10]='&lt;a href="http://www.businesswest.com"&gt;&lt;img src="assets/images/new web graphics/Corporate Logos/businesswest.png" border=1&gt;&lt;/a&gt;'
leftrightslide[11]='&lt;a href="http://www.springfieldmagnet.com/website"&gt;&lt;img src="assets/images/new web graphics/Corporate Logos/magnetschools.png" border=1&gt;&lt;/a&gt;'
leftrightslide[12]='&lt;a href="http://www.mymamamiaspizza.com"&gt;&lt;img src="assets/images/new web graphics/Corporate Logos/mama mias.png" border=1&gt;&lt;/a&gt;'
leftrightslide[13]='&lt;a href="http://www.maplegaterehab.com"&gt;&lt;img src="assets/images/new web graphics/Corporate Logos/maplegate.png" border=1&gt;&lt;/a&gt;'
leftrightslide[14]='&lt;a href="http://www.massmutual.com"&gt;&lt;img src="assets/images/new web graphics/Corporate Logos/massmutual.png" border=1&gt;&lt;/a&gt;'
leftrightslide[15]='&lt;a href="http://www.mricenter.com/locations/Massachusetts_Springfield.htm"&gt;&lt;img src="assets/images/new web graphics/Corporate Logos/mricenter.png" border=1&gt;&lt;/a&gt;'
leftrightslide[16]='&lt;a href="http://www.hampdenbank.com"&gt;&lt;img src="assets/images/new web graphics/Corporate Logos/hampdenbank.png" border=1&gt;&lt;/a&gt;'
leftrightslide[17]='&lt;a href="http://www.springfielddowntown.com"&gt;&lt;img src="assets/images/new web graphics/Corporate Logos/sbid.png" border=1&gt;&lt;/a&gt;'
leftrightslide[18]='&lt;a href="http://www.jtssportspub.com"&gt;&lt;img src="assets/images/new web graphics/Corporate Logos/jts.png" border=1&gt;&lt;/a&gt;'
leftrightslide[19]='&lt;a href="http://www.wne.edu"&gt;&lt;img src="assets/images/new web graphics/Corporate Logos/wne.png" border=1&gt;&lt;/a&gt;'
leftrightslide[20]='&lt;a href="http://www.reminderpublications.com"&gt;&lt;img src="assets/images/new web graphics/Corporate Logos/reminder.png" border=1&gt;&lt;/a&gt;'
leftrightslide[21]='&lt;a href="http://www.theobbq.com"&gt;&lt;img src="assets/images/new web graphics/Corporate Logos/theodores.png" border=1&gt;&lt;/a&gt;'
leftrightslide[22]='&lt;a href="http://forms.prideaccounts.com/gas.html"&gt;&lt;img src="assets/images/new web graphics/Corporate Logos/pride.png" border=1&gt;&lt;/a&gt;'
leftrightslide[23]='&lt;a href="http://www.reliabletemps.com"&gt;&lt;img src="assets/images/new web graphics/Corporate Logos/reliabletemps.png" border=1&gt;&lt;/a&gt;'

//Specify gap between each image (use HTML):
var imagegap="&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;"

//Specify pixels gap between each slideshow rotation (use integer):
var slideshowgap=25


//Specify gap between each image (use HTML):
var imagegap=" "

//Specify pixels gap between each slideshow rotation (use integer):
var slideshowgap=5


////NO NEED TO EDIT BELOW THIS LINE////////////

var copyspeed=slidespeed
leftrightslide='&lt;nobr&gt;'+leftrightslide.join(imagegap)+'&lt;/nobr&gt;'
var iedom=document.all||document.getElementById
if (iedom)
document.write('&lt;span id="temp" style="visibility:hidden;position:absolute;top:-100px;left:-9000px"&gt;'+leftrightslide+'&lt;/span&gt;')
var actualwidth=''
var cross_slide, ns_slide

function fillup(){
if (iedom){
cross_slide=document.getElementById? document.getElementById("test2") : document.all.test2
cross_slide2=document.getElementById? document.getElementById("test3") : document.all.test3
cross_slide.innerHTML=cross_slide2.innerHTML=leftrightslide
actualwidth=document.all? cross_slide.offsetWidth : document.getElementById("temp").offsetWidth
cross_slide2.style.left=actualwidth+slideshowgap+"px"
}
else if (document.layers){
ns_slide=document.ns_slidemenu.document.ns_slidemenu2
ns_slide2=document.ns_slidemenu.document.ns_slidemenu3
ns_slide.document.write(leftrightslide)
ns_slide.document.close()
actualwidth=ns_slide.document.width
ns_slide2.left=actualwidth+slideshowgap
ns_slide2.document.write(leftrightslide)
ns_slide2.document.close()
}
lefttime=setInterval("slideleft()",30)
}
window.onload=delay

function slideleft(){
if (iedom){
if (parseInt(cross_slide.style.left)&gt;(actualwidth*(-1)+8))
cross_slide.style.left=parseInt(cross_slide.style.left)-copyspeed+"px"
else
cross_slide.style.left=parseInt(cross_slide2.style.left)+actualwidth+slideshowgap+"px"

if (parseInt(cross_slide2.style.left)&gt;(actualwidth*(-1)+8))
cross_slide2.style.left=parseInt(cross_slide2.style.left)-copyspeed+"px"
else
cross_slide2.style.left=parseInt(cross_slide.style.left)+actualwidth+slideshowgap+"px"

}
else if (document.layers){
if (ns_slide.left&gt;(actualwidth*(-1)+8))
ns_slide.left-=copyspeed
else
ns_slide.left=ns_slide2.left+actualwidth+slideshowgap

if (ns_slide2.left&gt;(actualwidth*(-1)+8))
ns_slide2.left-=copyspeed
else
ns_slide2.left=ns_slide.left+actualwidth+slideshowgap
}
}


if (iedom||document.layers){
with (document){
document.write('&lt;table border="0" cellspacing="0" cellpadding="0"&gt;&lt;td&gt;')
if (iedom){
write('&lt;div style="position:relative;width:'+sliderwidth+';height:'+sliderheight+';overflow:hidden"&gt;')
write('&lt;div style="position:absolute;width:'+sliderwidth+';height:'+sliderheight+';background-color:'+slidebgcolor+'" onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed"&gt;')
write('&lt;div id="test2" style="position:absolute;left:0px;top:0px"&gt;&lt;/div&gt;')
write('&lt;div id="test3" style="position:absolute;left:-1000px;top:0px"&gt;&lt;/div&gt;')
write('&lt;/div&gt;&lt;/div&gt;')
}
else if (document.layers){
write('&lt;ilayer width='+sliderwidth+' height='+sliderheight+' name="ns_slidemenu" bgColor='+slidebgcolor+'&gt;')
write('&lt;layer name="ns_slidemenu2" left=0 top=0 onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed"&gt;&lt;/layer&gt;')
write('&lt;layer name="ns_slidemenu3" left=0 top=0 onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed"&gt;&lt;/layer&gt;')
write('&lt;/ilayer&gt;')
}
document.write('&lt;/td&gt;&lt;/table&gt;')
}
}
</code></pre>
