Ah, that helps, thanks. This is what I finally ended up doing. It seems to work in all browsers without giving errors, and still gives me the flexibility to use as many divs as I need on a page, without having to specify more than necessary.
Code:
var x = 0;
var elementArray = [];
if (typeof document.all != "undefined")
{
elementArray = document.all;
}
else
{
elementArray = document.getElementsByTagName("a");
}
var matchedArray = [];
var pattern = new RegExp("javascript:animatedcollapse.toggle");
for (var i = 0; i < elementArray.length; i++)
{
if (pattern.test(elementArray[i].href))
{
x = elementArray.length;
}
}
for (var i=1; i<=x; i++){
animatedcollapse.addDiv('v'+i, 'fade=1,')
}
animatedcollapse.ontoggle=function($, divobj, state){ //fires each time a DIV is expanded/contracted
//$: Access to jQuery
//divobj: DOM reference to DIV being expanded/ collapsed. Use "divobj.id" to get its ID
//state: "block" or "none", depending on state
if (divobj)
document.getElementById(divobj.id+"-toggle").src=(state=="block")? "http://www.cjcraig.com/images/selected_open.gif" :"http://www.cjcraig.com/images/selected_closed.gif" ;
}
animatedcollapse.init()
Bookmarks