jQuery().ready(function(){
     imagePreview();
     //popUpImage();
});
function imagePreview(){
    /* CONFIG */
    xOffset = -100;
    yOffset = -200;
    /* END CONFIG */

    $("div.screenshot a").click(function(e){
        //Elimino residui di vecchie popup
        $("#template_preview_big").remove();
        //aggiungo l'elemento'
        $("#templates").append("<p style='z-index:600;display:block;position:absolute;border:4px solid #666;' id='template_preview_big'><img style='width:400px;height:300px;' src='"+ $(this).attr("bigpreview") +"'/>"+$(this).attr('title')+"</p>");
        //Lo posiziono
        $("#template_preview_big").css("top",($(this).position().top + yOffset) + "px").css("left",($(this).position().left + xOffset) + "px").fadeIn("slow");
        //Imposto l'onclick sulla popup per la selezione
        $("#template_preview_big").click($(this).attr("onclick"));
        //Setto il mouseout in modo da far cancellare il blocco in caso di uscita
        $("#template_preview_big").hover(
            function(e){

            },
            function(e)
            {
                $("#template_preview_big").remove();
            }
            );
    },
    function(){
        //$("#template_preview_big").remove()
        });
}

function popUpImage(){
    /* CONFIG */
    xOffset = -100;
    yOffset = -300;
    /* END CONFIG */

    $("div#text a").click(function(e){
        //Elimino residui di vecchie popup
        $("#template_preview_big").remove();
        //aggiungo l'elemento'
        $("#text").append("<p style='z-index:600;display:block;position:fixed;border:4px solid #666;' id='template_preview_big'><img src='"+ $(this).attr("bigpreview") +"'/>"+$(this).attr('title')+"</p>");
        //Lo posiziono
        $("#template_preview_big").css("top",($(this).position().top + yOffset) + "px").css("left",($(this).position().left + xOffset) + "px").fadeIn("slow");
        //Imposto l'onclick sulla popup per la selezione
        $("#template_preview_big").click($(this).attr("onclick"));
        //Setto il mouseout in modo da far cancellare il blocco in caso di uscita
        $("#template_preview_big").hover(
            function(e){

            },
            function(e)
            {
                $("#template_preview_big").remove();
            }
            );
    },
    function(){
        //$("#template_preview_big").remove()
        });
}