Showing Div ID on Scroll
<p>I have this JS code that in a popup box shows the id value of the div when scrolling past it. It works fine when the id looks like this: id="1". But how can I change it to detect an id that looks like this: id="1:1" or id="23:4"? Two numbers separated by a colon.</p>

<pre><code>&lt;div id="sayverse"&gt;&lt;/div&gt;
&lt;div id="1"&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque et facilisis elit. Ut interdum, odio et aliquam tempor, felis odio auctor erat, eget elementum lectus arcu tempus elit.&lt;/div&gt;

&lt;div id="2"&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque et facilisis elit. Ut interdum, odio et aliquam tempor, felis odio auctor erat, eget elementum lectus arcu tempus elit.&lt;/div&gt;

function findPosition( oElement ) { 
    if( typeof( oElement.offsetParent ) != 'undefined' ) { 
      for( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ) { 
      posX += oElement.offsetLeft; posY += oElement.offsetTop; } 
      return [ posX, posY ]; 
    } else { 
      return [ oElement.x, oElement.y ]; 
  } 
}

function functionThatSetsPosition() {
var scrolledFromTop = getScrollXY()[1];
var topposition, lastone, offsetFromTop, currentverse, firstVerse = 1;
while(!document.getElementById('vs'+firstVerse) &amp;&amp; firstVerse &lt; 10000) {
    firstVerse++;
}
for(var i = firstVerse, onediv; onediv = document.getElementById('vs'+i); i++) {
    topposition = findPosition(onediv)[1];
    offsetFromTop = topposition - scrolledFromTop;
    if( i == firstVerse &amp;&amp; offsetFromTop &gt;= 0 ) {

        currentverse = i;
        break;
    }
    if( offsetFromTop &gt;= 0 &amp;&amp; offsetFromTop &lt;= 20 ) {

        currentverse = i;
        break;
    }
    if( offsetFromTop &gt; 20 ) {

        currentverse = lastone;
        break;
    }
    //store this as the last one for checking afterwards
    lastone = i;
}
if( !currentverse ) {
    currentverse = lastone;
}
document.getElementById('sayverse').innerHTML = 'Verse '+currentverse;
</code></pre>

<p>}</p>

<p>Philip</p>
