﻿//Copyright WebMail Wou3, Inc. 2007-2010
Type.registerNamespace('WebMail2');
WebMail2.MessageBase=function
(
	From,ReplyTo,To,Cc,Bcc,
	Subject,PlainTextBody,HTMLBody,
	FileNameIndex,ToolBarObject,
	ListAttachmentDivID,ShowHiddenAttachmentsID,DefaultAttachmentListHTML
)
{
	this._From=From;
	this._To=To;
	this._ReplyTo=ReplyTo;
	this._Cc=Cc;
	this._Bcc=Bcc;
	this._Subject=Subject;
	//don't create the object right away, if it is not visibile when initialized, it will always be null
	this._PlainTextBodyID=PlainTextBody;
	//don't create the object right away, if it is not visibile when initialized, it will always be null
	this._HTMLBodyID=HTMLBody;
	this._FileNameIndex=document.getElementById(FileNameIndex);
	this._FirstTabIndex=null;
	if(ListAttachmentDivID!=null)
		this._ListAttachment=document.getElementById(ListAttachmentDivID);
	else
		this._ListAttachment=null;
	this._DefaultAttachmentListHTML=DefaultAttachmentListHTML;
	this._ToolBarObject=ToolBarObject;
	
	//this is the anchor reference that will display hidden attachments if any
	this._ShowHiddenAttachmentsID=ShowHiddenAttachmentsID;
	this._ShowHiddenAttachments=null;
}

WebMail2.MessageBase.prototype=
{
//////////////////////////////////////////////////////////////////////////////////////////////////////
//Toolbar references
//////////////////////////////////////////////////////////////////////////////////////////////////////
get_Toolbar:function() {return this._ToolBarObject;},
//////////////////////////////////////////////////////////////////////////////////////////////////////

get_To:function()             {return getObjectValue(this._To);},
set_To:function(value)        {setObjectValue(this._To, value);},

get_ReplyTo:function()        {return getObjectValue(this._ReplyTo);},
set_ReplyTo:function(value)   {setObjectValue(this._ReplyTo, value);},

get_From:function()           {return getObjectValue(this._From);},
set_From:function(value)      {setObjectValue(this._From, value);},

get_Cc:function()             {return getObjectValue(this._Cc);},
set_Cc:function(value)        {setObjectValue(this._Cc, value);},

get_Bcc:function()            {return getObjectValue(this._Bcc);},
set_Bcc:function(value)       {setObjectValue(this._Bcc, value);},

get_Subject:function()        {return getObjectValue(this._Subject);},
set_Subject:function(value)   {setObjectValue(this._Subject, value);},

get_TabIndex:function()       {return this.get_FileNameIndex() + this._FirstTabIndex;},
get_FileNameIndex:function()  {return Number(this._FileNameIndex.value);},

setthisTabVisible:function(value) {page.setTabVisible(this.get_TabIndex(),value);},
selectThisTab:function()          {page.setSelectedTabIndex(this.get_TabIndex());},
setTabText:function(value)        {page.setTabText(this.get_TabIndex(),value);},

set_AttachmentList:function(htmlString,hasHidden)
{
	if(this._ListAttachment!=null)
	{
		if(htmlString==null)
			this._ListAttachment.innerHTML=this._DefaultAttachmentListHTML;
		else if(htmlString.length==0)
			this.set_AttachmentList(null,hasHidden);
		else
			this._ListAttachment.innerHTML=htmlString;
	}
	
	if(this._ShowHiddenAttachments==null)
	{
		try{this._ShowHiddenAttachments=document.getElementById(this._ShowHiddenAttachmentsID);}
		catch(e){}
		if(this._ShowHiddenAttachments==null)
			return;
	}
	
	if(hasHidden==1)
		this._ShowHiddenAttachments.style.display='block';
	else
		this._ShowHiddenAttachments.style.display='none';
}
}
WebMail2.MessageBase.registerClass("WebMail2.MessageBase");



