


//Not working yet

function Message() {}

var AlertContainer;



Message.prototype.Display = function( title, message, type, yesLabel, noLabel ) 
{
    this.Message = (message == '' || message == null) ? 'Message missing' : message;
    this.Type = (type == '' || type == null) ? 'OK' : type; // string: [YESNO | OK ] 
    this.YesLabel = (yesLabel == '' || yesLabel == null) ? 'yes' : yesLabel;
    this.NoLabel = (noLabel == '' || noLabel == null) ? 'no' : noLabel;
    this.Title = (title == '' || title == null) ? null : title;    
    var AlertContainer = document.createElement('div');
    AlertContainer.unselectable = 'on';
    AlertContainer.id = "AlertContainer";

    var ShadeContainer = document.createElement('div');
    ShadeContainer.id = "ShadeContainer";

    var StageContainer = document.createElement('div');
    StageContainer.id = "StageContainer";
    StageContainer.unselectable = 'on';
    
    var TxtHeading = document.createTextNode(this.Title);
    var HeadingContainer = document.createElement('h5');
    HeadingContainer.appendChild(TxtHeading);
    HeadingContainer.unselectable = 'on';
    
    
    var MessageContainer = document.createElement('div');
    MessageContainer.id = "MessageContainer";
    MessageContainer.innerHTML = this.Message;

    var ButtonContainer = document.createElement('div');
    ButtonContainer.id = "ButtonContainer";
    
    var AlertOKButton = document.createElement('input');
    AlertOKButton.type = "button";
    AlertOKButton.onclick = new Function ("message.OK()");
    AlertOKButton.value = yesLabel;
           
    var AlertCancelButton = document.createElement('input');
    AlertCancelButton.type = "button";
    AlertCancelButton.onclick = new Function ("message.Cancel()");
    AlertCancelButton.value = noLabel;
    
    //Appending elements
    AlertContainer.appendChild(StageContainer);
    AlertContainer.appendChild(ShadeContainer);
    
    if(this.Title != null)
        StageContainer.appendChild(HeadingContainer);
    
    StageContainer.appendChild(MessageContainer);
    StageContainer.appendChild(ButtonContainer);
    
    ButtonContainer.appendChild(AlertOKButton);
    
    if (this.Type == "YESNO")
        ButtonContainer.appendChild(AlertCancelButton);
    
    
    if (AlertContainer)
        document.getElementById('MessageContainer').appendChild(AlertContainer);
    else
    {
        AlertContainer = document.getElementById('AlertContainer');
        AlertContainer.style.display = 'block';
    }
    
    AlertContainer.style.left = ((screen.width) / 2) - 200 + 'px';
    AlertContainer.style.top = ((screen.height) / 2) - 300 + 'px';
    
    
}



Message.prototype.Cancel = function() 
{
    
    message.Hide();
    event.cancelBubble = true; 
}

Message.prototype.OK = function() 
{
    message.Hide();
}
Message.prototype.Hide = function() 
{
    var MessageContainer = document.getElementById('MessageContainer');
    
    //while (MessageContainer.hasChildNodes()) 
    //    MessageContainer.ChildNodes[ MessageContainer.firstChild].remove();
    
}


var message = new Message();