// JavaScript Document
function popup_open (href, params)
{
    // Defaults (don't leave it to the browser)
    var defaultParams = {
        "width":       "700",   // Window width
        "height":      "500",   // Window height
        "top":         "50",     // Y offset (in pixels) from top of screen
        "left":        "40",     // X offset (in pixels) from left side of screen
        "directories": "no",    // Show directories/Links bar?
        "location":    "no",    // Show location/address bar?
        "resizable":  "yes",   // Make the window resizable?
        "menubar":     "no",    // Show the menu bar?
        "toolbar":     "no",    // Show the tool (Back button etc.) bar?
        "scrollbars":  "yes",   // Show scrollbars?
        "status":      "no"     // Show the status bar?
    };

    var windowName = params["windowName"] || "new_window";

    var i, useParams = "";

    // Override defaults with custom values while we construct the params string
    for (i in defaultParams)
    {
        useParams += (useParams === "") ? "" : ",";
        useParams += i + "=";
        useParams += params[i] || defaultParams[i];
    }

    return window.open(href, windowName, useParams);
};

$(document).ready(function() {

    $("a[rel*=popup]").click(function (){

           // Grab parameters using jQuery's data() method
            var params = $(this).data("popup") || {};            
            if ($(this).attr("target"))
            {
                params.windowName = $(this).attr("target");
            }
            var windowObject = popup_open(this.href, params);
            // Save the window object for other code to use
            $(this).data("windowObject", windowObject);
			return false;
    });

});