//Create the RSXAlertWindow object

function RSXAlertWindow() {
    
    //Create the alert window
    //Return the object
    
    this.window         =   $('<div class="RSXAlertWindow">' +
                                '<h2>RSX Alert</h2>' +
                                '<div class="text"></div>' +
                                '<div class="button_field">' +
                                    '<div></div>' +
                                '</div>' +
                              '</div>');
    
    this.buttons        =   [["Okay", this.dismiss]];
    
    return this;
    
}



//Dismiss the window

RSXAlertWindow.prototype        =   {
    
    buttons     :   [ ] ,
    title       :   'RSX Alert' ,
    message     :   '' ,
    
    
    
    dismiss     :   function () { $('.RSXAlertWindow').remove(); } ,
    
    setTitleAndMessage      :   function (title, message) {
        
        //Set the message and the title
        
        this.title      =   String(title);
        this.message    =   String(message);
        
    } ,
    
    show        :   function () {
        
        //Get the div tags for the message and button container
        
        messageDiv      =   $(this.window).children('div')[0];
        buttonDiv       =   $($(this.window).children('div')[1]).find('div');
        
        //Set the title and the message
        
        $(this.window).find('h2').text(this.title);
        $(messageDiv).text(this.message);
        
        //Create the dismiss button
        
        for(i in this.buttons) {
            
            //Create the button
            
            var button          =   $('<input class="RSXButton" type="submit" name="' + i + '" value="' + this.buttons[i][0] + '" />');
            $(button).click(this.buttons[i][1]);
            
            //Append the button to the window
            
            $(buttonDiv).append(button);
            
        }
        
        //Append the window to the document body
        
        $(this.window).insertBefore(document.body.childNodes[0]);
        
        //Get the current window's height and width
        
        windowHeight        =   $(window).height();
        windowWidth         =   $(window).width();
        
        //Center the alert window
        
        $(this.window).css("top", String((windowHeight/2 - $(this.window).height()/2)) + "px");
        $(this.window).css("left", String((windowWidth/2 - 350/2)) + "px");
            
    }
    
};
