$(document).ready( function() {
    //*****************************************************
    // Resize Iframe to make it look better
    //*****************************************************
    var iframe_height = document.documentElement.clientHeight - 5;
    $("iframe").css("height", iframe_height);
    
    // Center the Form Container
    $("div.form_container").center();
    
    // Fade the Background
    $("div.fade_box").css("height", $(window).height());
    $("div.fade_box").css("width", $(window).width());
    
    // close everything
    $("a[name='close']").click(function() {
        $("div.form_container").hide();
        $("div.fade_box").hide();
        return false;
    });
    
    /*
    //*********************************************************
    // Do the ajax
    //*********************************************************
    $("div.form_container form input[type='submit']").click(function () {
        var url = $("div.form_container form").attr("action");
        var url_string = "";
        $("div.form_container form input").each(function() {
            url_string += $(this).attr("name") + "=" + $(this).val() + "&";
        });
        url_string = url_string.slice(0, -1);
        
        alert(url_string);
        
        $.ajax({
            type: "POST",
            url: url,
            data: url_string,
            success: function(msg){
                alert( "Data Saved: " + msg );
            },
            error: function(XMLHttpRequest, textStatus, errorThrown){
                alert( "Error: " + XMLHttpRequest );
            }
        });

        return false;
    });
    */
    
});

//**************************************************************
// Center Function
//**************************************************************
jQuery.fn.center = function () {
    this.css("position","absolute");
    this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
    this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
    return this;
}
