function getCloseFunction(dialog)
{
    return function(e)
    {
        dialog.hide();
    }
}
function getComponentInnerHTML(type, info)
{
    str = "<div style='text-align:right; width:100%; margin-top:5px;margin-left:-5px;'><img src='http://www.gasduck.com/images/themes/0/close.jpg' onclick=''></img></div>"
    switch(type)
    {
        case "Error":
            str += "<div style='position:relative;left:25px; top:10px; width:550px; background-color:red;'>"+info+"</div>";
            break;
        case "Signup":
            str += "<div style='position:relative;left:25px; top:10px; width:550px;'>"+info+"</div>";
            break;
        default:
            return str + "Could not construct dialog!"
    }
    return str;
}

function Dialog(type,info)
{
    var zIndex = 1000;
    this.type = type;
    this.params = new Array();
    this.type = type;
    this.info = info;
    
    this.component =  new Component();
    //this.animateIN = inAnimation;
    //this.animateOUT = outAnimation;
    this.display = display;
    this.hide = hide;
    this.component.setInnerHTML(getComponentInnerHTML(type,info));
    this.component["positionType"] = "fixed"
    this.component["border"] = "solid #"+ GLOBAL["THEME"].borderColor +" 1px";
    this.component["backgroundColor"] = "#"+GLOBAL["THEME"].containerColor;
    this.component["color"] = "#" + GLOBAL["THEME"].textColor;

    this.component["top"] = "50%"
    this.component["left"] = "50%"
    this.component["width"] = "600px";
    this.component["height"] = "200px";
    this.component["zIndex"] = zIndex;
    this.component["margins"] = "-100px 0px 0px -300px";
    this.component["overflow"] = "auto";
    this.component["hndl"].getElementsByTagName("img")[0].onclick = getCloseFunction(this)
    Dialog.zIndex++;
    
    
    this.animateIN = new Animation();
    this.animateIN.setElement(this.component);
    this.animateIN.setAnimation(ANIMATION.FADEIN);
    
    this.animateOUT = new Animation();
    this.animateOUT.setElement(this.component);
    this.animateOUT.setAnimation(ANIMATION.FADEOUT);
    
    
    function display()
    {
        this.animateIN.execute({RATE:0.1,ACCELERATE:0.05});
    }
    function hide()
    {
        this.animateOUT.execute({RATE:0.05,ACCELERATE:0.025});
        Dialog.zIndex -= 1;
    }
    
    //function inAnimation()
    //{
        
    //}
    
    //function outAnimate()
    //{
        
    //}
}