/* 
 This file was generated by Dashcode and is covered by the 
 license.txt included in the project.  You may edit this file, 
 however it is recommended to first turn off the Dashcode 
 code generator otherwise the changes will be lost.
 */

// Note: Properties and methods beginning with underbar ("_") are considered private and subject to change in future Dashcode releases.


function CreateMailButton(elementOrID, spec)
{
    var buttonElement = elementOrID;
    if (elementOrID.nodeType != Node.ELEMENT_NODE) {
        buttonElement = document.getElementById(elementOrID);
    }
    
	if (!buttonElement.loaded) {
		buttonElement.loaded = true;
		buttonElement.object = new MailButton(buttonElement, spec);
    }
	
    return buttonElement.object;
}

MailButton.prototype = new PushButton();

function MailButton(buttonElement, spec)
{	
	var _self = this;

    PushButton.call(this, buttonElement, spec);
    this.element = buttonElement;
	this._emailAddress = spec.email;
    this._subject = spec.subject;
    this.onclick = function() { _self.composeEmail() };    
}

MailButton.prototype.composeEmail = function() 
{
    var encodedEmailAddress = encodeURI(this._emailAddress);
    var encodedSubject = encodeURI(this._subject);
    window.location = "mailto:" + encodedEmailAddress + "?subject=" + encodedSubject;
}

MailButton.prototype.setEmailAddress = function(emailAddress)
{
	this._emailAddress = emailAddress;
}

MailButton.prototype.getEmailAddress = function()
{
    return this._emailAddress;
}

MailButton.prototype.setSubject = function(subject)
{
	this._subject = subject;
}

MailButton.prototype.getSubject = function()
{
    return this._subject;
}

