﻿function EzyContact(objectName, focusId, txtEmailId, txtSubjectId, edtMessageId, divEmailId, divSubjectId, divMessageId)
{ // Constructor
	this.ObjectName = objectName;
	this.FocusId = focusId;
	this.TxtEmailId = txtEmailId;
	this.TxtSubjectId = txtSubjectId;
	this.EdtMessageId = edtMessageId;
	this.DivEmailId = divEmailId;
	this.DivSubjectId = divSubjectId;
	this.DivMessageId = divMessageId;
}

EzyContact.prototype.initControls = function()
{
	window.setTimeout(this.ObjectName + ".setFocus('" + this.FocusId + "')", 0);
}

EzyContact.prototype.setFocus = function(id)
{
	var o = $find(id);

	if (o != null)
	{
		var a = id.split('_');

		switch (a[a.length - 1].substr(0, 3))
		{
			case "edt":
				o.setFocus();
				break;
			case "txt":
				o.focus();
				break;
			default:
				break;
		}
	}
}

EzyContact.prototype.onEditorClientLoad = function(editor, args)
{
	var buttonsHolder = $get(editor.get_id() + "Top");
	var buttons = buttonsHolder.getElementsByTagName("A");
	for (var i = 0; i < buttons.length; i++)
	{
		var a = buttons[i];
		a.tabIndex = -1;
		a.tabStop = false;
	}

	editor.get_contentAreaElement().tabIndex = $get(editor.get_id()).tabIndex;
	$get(editor.get_id()).tabIndex = "";
	
	editor.attachEventHandler("onkeydown", function(e)
  {
		if(e.keyCode == '9')
		{
			editor.pasteHtml("&nbsp;&nbsp;&nbsp;&nbsp;"); 
			
			if (!document.all)
			{
				e.preventDefault();
				e.preventBubble();
				e.stopPropagation();              
			}
			else
			{
				e.returnValue = false;
				e.cancelBubble = true;
			}   
		}
	});
}    
