Create Pop-Up Box with Custom Field Content Inside the Loop

The problem is that you’re not assigning a unique ID to each popup element. HTML element IDs should be unique, and each time you call animatedcollapse.show( 'script-sample' ) it will target the first element with the id “script-sample”. What you could do is assign a unique ID to each popup element by using the post IDs:

<div id="script-sample-<?php the_ID(); ?>" [..]

You could target that particular element by using

animatedcollapse.show( 'script-sample-<?php the_ID(); ?>' )

By the way, you probably shouldn’t be using query_posts, it’s quite horrible and there are better alternatives.

error code: 523