function childElements(node) { var children = new Array(); for (var i = 0; i < node.childNodes.length; i++) { if (node.childNodes[i].nodeType == 1) { children[children.length] = node.childNodes[i]; } } return children; } function show(which) { var smallDiv = document.getElementById("img" + which); var smallPics = childElements(smallDiv); var smallActive = (smallPics[0].style.display == "none") ? 1 : 0; var smallInactive = (smallActive == 1) ? 0 : 1; var bigDiv = document.getElementById("slideshow"); var bigPics = childElements(bigDiv); var bigActive = (bigPics[0].style.display == "none") ? 1 : 0; var bigInactive = (bigActive == 1) ? 0 : 1; // the small pics have an A tag, then the IMG tag // the big pics are IMG tags smallPics[smallInactive].getElementsByTagName("img")[0].src = bigPics[bigActive].src; bigPics[bigInactive].src = smallPics[smallActive].getElementsByTagName("img")[0].src; $('#img' + which).cycle(smallInactive); $('#slideshow').cycle(bigInactive); }