Hello guys and gals,

Im new to javascript, and im creating a site that requires a few scripts on the same page, however, on seems to return strange results based on its identifier, sometimes working fully, sometimes for one item or the first few.

web address is
Zaks Custom Cues | Zaks Custom Cues | Quality Handcrafted Pool and Snooker Cues

you will see on tab 'main splice' all toggle images work and as do their targets - go to tab 'four splice' and you will see the first item works only. (targets not loaded yet for this tab) and same again for the partially finished 'badges' tab.

changing the identifier from groupone to grouptwo switches these states and sometimes returns strange results like the first 9 or 10 working only.

the site is based in php, on a xoops platform, and this problem has been killing me for 5 days straight now!

the script seems simple enough
Code:
	// toggle script
function toggleany(here,suffix,imagenum)
{
    var group = document.getElementById("group" + suffix);
    var Sets = group.getElementsByTagName("a");
    for ( x = 0 ; x < Sets.length ; ++x )
    {
        var alink = Sets[x]; /* get reference to one a tag */
        var images = alink.getElementsByTagName("img"); /* find images in that tag */

        /* hide or show the select.png depending on which clicked */
        document.getElementById("cbselectortoggle" + suffix + x).style.visibility = ( x == imagenum ) ? "visible" : "hidden";

        /* ditto for the contentDiv that matches suffix and imagenum */
        document.getElementById("contentDiv" + suffix + x).style.display = ( x == imagenum ) ? "block" : "none";
    }
}
and the output code for first two entries of the working tab...
HTML Code:
<ul id="mainsplice" class="hide">
	<li>
		<div id="groupop1">
			<div class="cbselector" id="popup">
				<a onclick="javascript:toggleany(this,'op1',0 ); emailone='variableOne0';">
					<img class="toggleimage" id="cbselectortoggleop10" src="http://www.java-forums.org/images/cb/select.png" style="visibility: hidden;" />
					<img id="cbtimbericon" src="http://www.java-forums.org/images/cb/timbers/icons/1.png" />
					<em>Gabon Ebony</em>
					<span>
					     <em class="spanem">Gabon Ebony</em>
					     <strong>Diospyros crassiflora</strong>
					     <img src="http://www.java-forums.org/images/cb/timbers/icons/1.png" />
					     <small>From equatorial Africa, Gabon Ebony is usually found in wet lowlands near rivers and swaps. Devoid of color, Gabon Ebony has ink black with lighter streaks. Only a small percentage of Ebony (three to five percent) produce the highest quality jet black Ebony. Most pieces contain 50-70% sapwood with d....</small>
					     <b>Hardness = 3220</b>
					</span>
				</a>
			</div>
			<div class="cbselector" id="popup">
				<a onclick="javascript:toggleany(this,'op1',1 ); emailone='variableOne1';">
					<img class="toggleimage" id="cbselectortoggleop11" src="http://www.java-forums.org/images/cb/select.png" style="visibility: hidden;" />
					<img id="cbtimbericon" src="http://www.java-forums.org/images/cb/timbers/icons/2.png" />
					<em>Purpleheart</em>
					<span>
						<em class="spanem">Purpleheart</em>
						<strong>Peltogyne paniculata</strong>
						<img src="http://www.java-forums.org/images/cb/timbers/icons/2.png" />
						<small>A brilliantly colored hardwood from South America, Purpleheart is very popular for its deep purple color. Ideal for inlay, marquetry, and other fine articles. Occasionally the trees produce either fiddleback or a ropey mottled curl from interlocked grain. The color is a pale brown when freshly cut, ....</small>
						<b>Hardness = 2710</b>
					</span>
				</a>
			</div>
  		        <div id="spanclear"></div>	
 		</div>
         </li>
</ul>
and for the non working code
HTML Code:
<ul id="foursplice" class="hide">
      <li>
		<div id="groupicons">
			<div class="cbselector" id="popup">
				<a onclick="javascript:toggleany(this,'icons','0' ); emailone='variableOne0';">
					<img class="toggleimage" id="cbselectortoggleicons0" src="http://www.java-forums.org/images/cb/select.png" style="visibility: hidden;" />
					<img id="cbtimbericon" src="http://www.java-forums.org/images/cb/timbers/icons/1.png" />
					<em>Gabon Ebony</em>
					<span>
						<em class="spanem">Gabon Ebony</em>
						<strong>Diospyros crassiflora</strong>
						<img src="http://www.java-forums.org/images/cb/timbers/icons/1.png" />
						<small>From equatorial Africa, Gabon Ebony is usually found in wet lowlands near rivers and swaps. Devoid of color, Gabon Ebony has ink black with lighter streaks. Only a small percentage of Ebony (three to five percent) produce the highest quality jet black Ebony. Most pieces contain 50-70% sapwood with d....</small>
						<b>Hardness = 3220</b>
					</span>
				</a>
			</div>
			<div class="cbselector" id="popup">
				<a onclick="javascript:toggleany(this,'icons','1' ); emailone='variableOne1';">
					<img class="toggleimage" id="cbselectortoggleicons1" src="http://www.java-forums.org/images/cb/select.png" style="visibility: hidden;" />
					<img id="cbtimbericon" src="http://www.java-forums.org/images/cb/timbers/icons/2.png" />
					<em>Purpleheart</em>
					<span>
						<em class="spanem">Purpleheart</em>
						<strong>Peltogyne paniculata</strong>
						<img src="http://www.java-forums.org/images/cb/timbers/icons/2.png" />
						<small>A brilliantly colored hardwood from South America, Purpleheart is very popular for its deep purple color. Ideal for inlay, marquetry, and other fine articles. Occasionally the trees produce either fiddleback or a ropey mottled curl from interlocked grain. The color is a pale brown when freshly cut, ....</small>
						<b>Hardness = 2710</b>
					</span>
				</a>
			</div>
			<div id="spanclear"></div>	
 		</div>
          </li>    		
</ul>
thank you advance
steve