OK, so we can go in the head and use jQuery, great! Get rid of the old script and markup:
Code:
<!--adds rotating photos to banner--> <!--preload banner images and slideshow--> <div id="preloadDiv" style="width: 1px; height: 1px; visibility:hidden"></div> <div id="preloadDiv2" style="width: 1px; height: 1px; visibility:hidden"><img src="/uimg/image/1281074682525/1281197417300.jpg" height=1 width=1><img src="/uimg/image/1281074682525/1281197420672.jpg" height=1 width=1></div> <div id="myDiv"> </div> <script language="javascript"> var imgurl = new Array( "/uimg/image/1281074682525/1285481996880.jpg", "/uimg/image/1281074682525/1285481996852.jpg", "/uimg/image/1281074682525/1285481996856.jpg", "/uimg/image/1281074682525/1285481996873.jpg", "/uimg/image/1281074682525/1285481996884.jpg", "/uimg/image/1281074682525/1285481996843.jpg"); function imagerotate(i) { if(i>=imgurl.length) i=0; var stylecode = "<style type='text/css' media='screen'>.header_table {background: url(" + imgurl[i] + ") right no-repeat;}</style>"; document.getElementById('myDiv').innerHTML=stylecode; document.getElementById('preloadDiv').innerHTML="<img src='" + imgurl[i+1] + "' width=1 height=1>"; window.setTimeout("imagerotate(" + (i+1) + ")",5000); } imagerotate(0); </script> <!--end rotating banner edit-->
Add this (highlighted) as shown:
Code:
<!-- begin JS Section local_js=-->
<script type="text/javascript" src="http://cdn.schoolloop.com/1010281645/static/lib/jquery_old/1.3/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
(function($){
$('head').append('<style type="text/css">.header_table {background: right no-repeat}<\/style>');
$.each(['/uimg/image/1281074682525/1281197417300.jpg', '/uimg/image/1281074682525/1281197420672.jpg'], function(i, im){
$(new Image()).attr('src', im);
});
var imgurl = [
'/uimg/image/1281074682525/1285481996880.jpg',
'/uimg/image/1281074682525/1285481996852.jpg',
'/uimg/image/1281074682525/1285481996856.jpg',
'/uimg/image/1281074682525/1285481996873.jpg',
'/uimg/image/1281074682525/1285481996884.jpg',
'/uimg/image/1281074682525/1285481996843.jpg' //<-- No comma after last image!
], $table, its = false;
function imagerotate(i){
$table = $('.header_table');
if(!$table.size()){
setTimeout(function(){imagerotate(0);}, 300);
return;
}
if(i >= imgurl.length){
i = 0;
if(i){
its = true;
}
}
$table.css({backgroundImage: 'url(' + imgurl[i] + ')'});
if(!its){
$(new Image()).attr('src', imgurl[i+1]);
}
setTimeout(function(){imagerotate(i+1);}, 5000);
}
imagerotate(0);
})(jQuery);
</script>
<script type="text/javascript" src="http://cdn.schoolloop.com/1010281645/static/lib/jquery/1.4/js/jquery-ui-1.8.1.custom.min.js"></script>
<script type="text/javascript" src="/javascript/version_1010281645/master.js"></script>
<script type="text/javascript" src="http://cdn.schoolloop.com/1010281645/static/lib/jquery/extra/js/jquery.form.js"></script>
<script type="text/javascript" src="http://cdn.schoolloop.com/1010281645/static/lib/jquery_old/jScrollPane.js"></script>
Notes:
This added script may be made external.
You should update to jQuery 1.4.2 - anything that works with 1.3.2 will work with it, and 1.4.2 is more efficient.
To answer your question about adding a div the page, sure you can do that. But that can't really be done from the head unless you first determine that where you want to add it has been sufficiently parsed by the browser to permit it. Sort of like in my code where I wait until the table is there to set its background image.
Bookmarks