在哪里声明javascript / jQuery脚本

I'm trying to do some stuff with jquery/js (I don't know which one it is..), for example this script ; http://pastebin.com/V3HpU0NY - > http://blog.mainstreethost.com/light-youtube-embeds-faster-page-load#.VG9HKamkVSJ

But now comes the difficult part.

Url: http://erwin.my89.nl/stage/sieh/

enter image description hereThis is the website when you go to the url.

This loads the "gallery (top)" and all content/ and kinda images(lazyload) for all the 'gallery' posts. If this has to be done another way please say so.

When you click a image you'll get this: enter image description here

I hope you understand the idea.

So everything working ok

but now i go in to the inspector and i encounter this?!

enter image description here

I assume it is because i have the script defined in the loop of the content.. so when i click a gallery image, it loads another bunch of those text/css's.

So my question is: Is this the right way to do it? or should i be doing this different?

while ($loop->have_posts()) : $loop->the_post($post->ID);
 if ($metas) {
      foreach ($metas as $metakey) {

        } elseif ($metakey['url']) {
            preg_match(
                '/[\\?\\&]v=([^\\?\\&]+)/',
                $metakey['url'],
                $matches
            );
            $id = $matches[1];

            ?>
            <div class="youtube" id="<?php echo $id ?>" style="width: 560px; height: 315px;"></div>
            <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/youtube.js"></script>

        <?php

^part of the code, if need more please say so.

Thanks in advance!

Can you put your CSS file/s in the head? That's where it normally goes.

Also, I don't see anywhere in your PHP where it could be loading these <style></style> tags. However it does look like it's going to import the same script at the end of each loop.

Could you provide more information on what your exact problem is?