function Wysiwyg(_prefix) {
	
	this.isGecko = 0;
	this.iframe = null;
	this.iWin 	= null;
	this.iDoc 	= null;
	
	this.doInit = function() {
		this.isGecko = navigator.userAgent.toLowerCase().indexOf("gecko") != -1;

		this.iframe = (this.isGecko) ? document.getElementById(_prefix+"WysiwygFrame") : frames[_prefix+"WysiwygFrame"];
		this.iWin 	=	(this.isGecko) ? this.iframe.contentWindow : this.iframe.window;
		this.iDoc 	=	(this.isGecko) ? this.iframe.contentDocument : this.iframe.document;
			
		this.iDoc.open();
		this.iDoc.write("hi");
		this.iDoc.close();
		
		if (!this.iDoc.designMode) {
			alert("Визуальный режим редактирования не поддерживается Вашим браузером");
		}
		else {
			this.iDoc.designMode = (this.isGecko) ? "on" : "On";
		}		
	}

	this.setContent = function(_strText) {
		iHTML = "<html><head>\n";
		iHTML += "<link href='./css/text.css' rel='stylesheet' type='text/css' />\n";
		iHTML += "</head>\n";
		iHTML += "<body class='dackGray'>" + _strText + "</body>";
		iHTML += "</html>";

		this.iDoc.open();
		this.iDoc.write(iHTML);
		this.iDoc.close();
	}

	this.getContent = function() {
		return this.iDoc.body.innerHTML;
	}

	this.setFocus = function() {
		this.iWin.focus();
//		this.setCursorPosition(10,10);
	}

	this.setCursorPosition = function(oStart,oEnd) {
		if(this.iWin.setSelectionRange) {
					A.setSelectionRange(A.value.length,A.value.length);
					A.focus()
		}
		else if(this.iDoc.createTextRange) {
					A.focus();
					var B = A.createTextRange();
					B.collapse(false);
					B.select();
		}
	}

/*	this.setCursorPosition = function(oStart,oEnd) {
		if(this.iDoc.setSelectionRange) {
			this.iDoc.setSelectionRange(oStart,oEnd);
		}
		else if(this.iDoc.createTextRange) {
			var range = this.iDoc.createTextRange();
			range.collapse(true);
			range.moveEnd('character',oEnd);
			range.moveStart('character',oStart);
			range.select();
		}
	}
*/	
	this.setBold = function() {
		this.iWin.focus();
		this.iWin.document.execCommand("bold", null, "");
	}
	
	this.setItal = function() {
		this.iWin.focus();
		this.iWin.document.execCommand("italic", null, "");
	}
	
	this.setUnder = function() {
		this.iWin.focus();
		this.iWin.document.execCommand("underline", null, "");
	}
	
	this.setSmile = function(_imgSrc) {
		this.iWin.focus();
		this.iWin.document.execCommand("insertimage", null, _imgSrc);
	}

	this.setLink = function() {
		var srcUrl = prompt("Введите url:", "http://");

		if(srcUrl != null)
		{
			this.iWin.focus();
			this.iWin.document.execCommand("CreateLink", null, srcUrl);
		}
	}
	
	this.doInit();
}
