Loading page within an allready loaded jquery page!

Loading page within an allready loaded jquery page!

i was wondering whether it is possible to load a second page from a already loaded page using jquery,

i have already done loading the first page, in this case its a gallery i can load all the images i want as thumbs now what i want is to click on em and a pop window that will show image details, i have the script for the pop window too, but when i combine the pop window with the gallery loaded with jquery the pop doesn't work .

    <a href="detail.php?iid='.$iid.'" class="ajax"><img name="" style="margin:2px;" src="image.php?width=100&height=100&cropratio=2:2&amp;image=/u/'.$file.'"  alt="" /></a>


    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/base/jquery-ui.css" type="text/css" />
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/jquery-ui.min.js"></script>

   

    <script type="text/javascript">
    $(function (){
        $('a.ajax').click(function() {
            var url = this.href;
            var dialog = $('<div style="display:hidden"></div>').appendTo('body');
            // load remote content
            dialog.load(
                url,
                {},
                function (responseText, textStatus, XMLHttpRequest) {
                    dialog.dialog();
                }
            );
            //prevent the browser to follow the link
            return false;
        });
    });
    </script>

as u can see the detail.php gets the imageid through url property, this dose work when i use it the direct gallery.php, the problem only comes when i load gallery.php using jquery though the index.php.

here is the script to load gallery.php using index.php file..

    $(document).ready(function()
            {
                $("#gl").click(function()
                {
                    //$(this).text("...One Moment Please...");
                    $("#container").append('<div id="glr" "></div>')
                    .children("#glr").hide()
                    .load("gallery.php div#glr", function()
                    {
                    $("#tet").remove();
                    $("#rem").remove();
                    $("#glr").slideDown("slow");
                    });
                    return false;
                });
            });    

as u can see in the bellow pic, when i go directly to gallery.php it works.

http://i.imgur.com/Gyf4A.png

this the gallery.php when loaded through index.php with jquery.

http://i.imgur.com/oqVce.png

i wont the pop detail.php to pop when i load gallery.php ..

any feedbacks will be greatly appreciated,

ThankYou
M.Amin