var PollPosition = 0;

/*
This page was written by Effy Teva for SmartPortal.NET usage only!
Copy of this code or part of it is ILLEGAL.
If you want to use any part of this code, you MUST contact Effy Teva at effy@donkey.co.il.
Any website using parts of this code may be forced to remove it!

All rights reserved (r) to Effy Teva (2006) - SmartPortal.NET v1.0
*/

function Toolbar_Attach(TextBoxName, Toolbar)
{
	Toolbar_Icon_Basic(TextBoxName, Toolbar, "&#x05DE;&#x05D5;&#x05D3;&#x05D2;&#x05E9;", "/Images/Toolbar/Bold.gif", "Bold");
	Toolbar_Icon_Basic(TextBoxName, Toolbar, "&#x05E0;&#x05D8;&#x05D5;&#x05D9;", "/Images/Toolbar/Italic.gif", "Italic");
	Toolbar_Icon_Basic(TextBoxName, Toolbar, "&#x05E7;&#x05D5; &#x05EA;&#x05D7;&#x05EA;&#x05D9;", "/Images/Toolbar/Underline.gif", "Underline");
	Toolbar_Icon_Basic(TextBoxName, Toolbar, "&#x05E7;&#x05D5; &#x05D7;&#x05D5;&#x05E6;&#x05D4;", "/Images/Toolbar/LineThrough.gif", "StrikeThrough");
	
	Toolbar_Icon_Group(Toolbar);
	Toolbar_Icon_Basic(TextBoxName, Toolbar, "&#x05DB;&#x05EA;&#x05D1; &#x05E2;&#x05D9;&#x05DC;&#x05D9;", "/Images/Toolbar/SuperScript.gif", "SuperScript");
	Toolbar_Icon_Basic(TextBoxName, Toolbar, "&#x05DB;&#x05EA;&#x05D1; &#x05EA;&#x05D7;&#x05EA;&#x05D9;", "/Images/Toolbar/SubScript.gif", "SubScript");
	Toolbar_Icon_Basic(TextBoxName, Toolbar, "&#x05D4;&#x05E1;&#x05E8;&#x05EA; &#x05DB;&#x05DC; &#x05D4;&#x05E2;&#x05D9;&#x05E6;&#x05D5;&#x05D1;&#x05D9;&#x05DD;", "/Images/Toolbar/ClearFormatting.gif", "RemoveFormat");
	
	Toolbar_Icon_Group(Toolbar);
	Toolbar_Icon_RTL(TextBoxName, Toolbar, "&#x05D9;&#x05D9;&#x05E9;&#x05D5;&#x05E8; &#x05DC;&#x05D9;&#x05DE;&#x05D9;&#x05DF;", "/Images/Toolbar/Align_Right.gif");
	Toolbar_Icon_Basic(TextBoxName, Toolbar, "&#x05D9;&#x05D9;&#x05E9;&#x05D5;&#x05E8; &#x05DC;&#x05DE;&#x05E8;&#x05DB;&#x05D6;", "/Images/Toolbar/Align_Center.gif", "JustifyCenter");
	Toolbar_Icon_LTR(TextBoxName, Toolbar, "&#x05D9;&#x05D9;&#x05E9;&#x05D5;&#x05E8; &#x05DC;&#x05E9;&#x05DE;&#x05D0;&#x05DC;", "/Images/Toolbar/Align_Left.gif");
	Toolbar_Icon_Basic(TextBoxName, Toolbar, "&#x05D9;&#x05D9;&#x05E9;&#x05D5;&#x05E8; &#x05DE;&#x05DC;&#x05D0;", "/Images/Toolbar/Align_Full.gif", "JustifyFull");
	
	Toolbar_Icon_Group(Toolbar);
	Toolbar_Icon_Basic(TextBoxName, Toolbar, "&#x05DE;&#x05E1;&#x05E4;&#x05D5;&#x05E8;", "/Images/Toolbar/OL.gif", "InsertOrderedList");
	Toolbar_Icon_Basic(TextBoxName, Toolbar, "&#x05EA;&#x05D1;&#x05DC;&#x05D9;&#x05D8;&#x05D9;&#x05DD;", "/Images/Toolbar/UL.gif", "InsertUnorderedList");
	Toolbar_Icon_Basic(TextBoxName, Toolbar, "Indent", "/Images/Toolbar/Indent.gif", "Indent");
	Toolbar_Icon_Basic(TextBoxName, Toolbar, "Outdent", "/Images/Toolbar/Outdent.gif", "Outdent");
	
	Toolbar_Icon_Group(Toolbar);
	Toolbar_Icon_Basic(TextBoxName, Toolbar, "&#x05D2;&#x05D6;&#x05D5;&#x05E8;", "/Images/Toolbar/Cut.gif", "Cut");
	Toolbar_Icon_Basic(TextBoxName, Toolbar, "&#x05D4;&#x05E2;&#x05EA;&#x05E7;", "/Images/Toolbar/Copy.gif", "Copy");
	Toolbar_Icon_Basic(TextBoxName, Toolbar, "&#x05D4;&#x05D3;&#x05D1;&#x05E7;", "/Images/Toolbar/Paste.gif", "Paste");
	
	Toolbar_Icon_Group(Toolbar);
	Toolbar_Icon_Image(TextBoxName, Toolbar, "&#x05EA;&#x05DE;&#x05D5;&#x05E0;&#x05D4;", "/Images/Toolbar/Image.gif");
    Toolbar_Icon_Flash(TextBoxName, Toolbar, "&#x05E4;&#x05DC;&#x05D0;&#x05E9;", "/Images/Toolbar/Flash.gif");
	Toolbar_Icon_Basic(TextBoxName, Toolbar, "&#x05E7;&#x05D5; &#x05D7;&#x05D5;&#x05E6;&#x05E5;", "/Images/Toolbar/HR.gif", "InsertHorizontalRule");
	Toolbar_Icon_HyperLink(TextBoxName, Toolbar, "&#x05E7;&#x05D9;&#x05E9;&#x05D5;&#x05E8;", "_blank", "/Images/Toolbar/Link.gif");
	Toolbar_Icon_Basic(TextBoxName, Toolbar, "&#x05D4;&#x05E1;&#x05E8;&#x05EA; &#x05E7;&#x05D9;&#x05E9;&#x05D5;&#x05E8;", "/Images/Toolbar/RemoveLink.gif", "Unlink");
	Toolbar_Icon_Table(TextBoxName, Toolbar, "&#x05D8;&#x05D1;&#x05DC;&#x05D4;", "/Images/Toolbar/Table.gif");
	
	Toolbar_Icon_LineGroup(Toolbar);
	
	Toolbar_Icon_FontName(TextBoxName, Toolbar, "&#x05D2;&#x05D5;&#x05E4;&#x05DF;");
	
	Toolbar_Icon_Group(Toolbar);
	Toolbar_Icon_FontSize(TextBoxName, Toolbar, "&#x05D2;&#x05D5;&#x05D3;&#x05DC;");
	
	Toolbar_Icon_Group(Toolbar);
	Toolbar_Icon_Color(TextBoxName, Toolbar, "&#x05E6;&#x05D1;&#x05E2; &#x05DB;&#x05EA;&#x05D1;", "ForeColor");
    Toolbar_Icon_CustomColor(TextBoxName, Toolbar, "&#x05E6;&#x05D1;&#x05E2; &#x05DB;&#x05EA;&#x05D1;", "/Images/Toolbar/Color_Custom.gif", "ForeColor");
	
	Toolbar_Icon_Group(Toolbar);
	Toolbar_Icon_Color(TextBoxName, Toolbar, "&#x05E6;&#x05D1;&#x05E2; &#x05E8;&#x05E7;&#x05E2;", "BackColor");
	Toolbar_Icon_CustomColor(TextBoxName, Toolbar, "&#x05E6;&#x05D1;&#x05E2; &#x05E8;&#x05E7;&#x05E2;", "/Images/Toolbar/Background.gif", "BackColor");
}

function Toolbar_Icon_Group(Toolbar)
{
    Toolbar.innerHTML += ("<img src=\"/Images/Toolbar/ToolbarGroup.gif\" />");
}

function Toolbar_Icon_LineGroup(Toolbar)
{
    Toolbar.innerHTML += "<br />";
}

function Toolbar_Icon_Basic(TextBoxName, Toolbar, AlternativeText, ImageURL, TagName, Variable1, Variable2)
{
	Toolbar.innerHTML += ("<img width=\"21\" height=\"22\" alt=\"" + AlternativeText + "\" style=\"cursor:pointer;margin:1px\" onmouseover=\"this.style.backgroundColor='#F09050'\" onmouseout=\"this.style.backgroundColor=''\" onclick=\"Toolbar_Render_Basic('" + TextBoxName + "', '" + TagName + "', '" + Variable1 + "', '" + Variable2 + "')\" src=\"" + ImageURL + "\" />");
}

function Toolbar_Render_Basic(TextBoxName, TagName, Variable1, Variable2)
{
    if (Variable1 == 'undefined')
        Variable1 = null;
    if (Variable2 == 'undefined')
        Variable2 = null;
    window.frames[TextBoxName].document.execCommand(TagName, Variable1, Variable2);
}

function Toolbar_Icon_RTL(TextBoxName, Toolbar, AlternativeText, ImageURL)
{
	Toolbar.innerHTML += ("<img width=\"21\" height=\"22\" alt=\"" + AlternativeText + "\" style=\"cursor:pointer;margin:1px\" onmouseover=\"this.style.backgroundColor='#F09050'\" onmouseout=\"this.style.backgroundColor=''\" onclick=\"Toolbar_Render_RTL('" + TextBoxName + "')\" src=\"" + ImageURL + "\" />");
}

function Toolbar_Render_RTL(TextBoxName, TagName, Variable1, Variable2)
{
    var Doc = window.frames[TextBoxName].document;
    Doc.execCommand("JustifyRight", null, null);
    Doc.execCommand("BlockDirRTL", null, null);
}

function Toolbar_Icon_LTR(TextBoxName, Toolbar, AlternativeText, ImageURL)
{
	Toolbar.innerHTML += ("<img width=\"21\" height=\"22\" alt=\"" + AlternativeText + "\" style=\"cursor:pointer;margin:1px\" onmouseover=\"this.style.backgroundColor='#F09050'\" onmouseout=\"this.style.backgroundColor=''\" onclick=\"Toolbar_Render_LTR('" + TextBoxName + "')\" src=\"" + ImageURL + "\" />");
}

function Toolbar_Render_LTR(TextBoxName, TagName, Variable1, Variable2)
{
    var Doc = window.frames[TextBoxName].document;
    Doc.execCommand("JustifyLeft", null, null);
    Doc.execCommand("BlockDirLTR", null, null);
}

function Toolbar_Icon_CustomColor(TextBoxName, Toolbar, AlternativeText, ImageURL, TagName)
{
    Toolbar.innerHTML += ("<img width=\"21\" height=\"22\" alt=\"" + AlternativeText + "\" style=\"cursor:pointer;margin:1px\" onmouseover=\"this.style.backgroundColor='#F09050'\" onmouseout=\"this.style.backgroundColor=''\" onclick=\"Toolbar_Render_CustomColor('" + TextBoxName + "', '" + TagName + "')\" src=\"" + ImageURL + "\" />");
}

function Toolbar_Render_CustomColor(TextBoxName, TagName)
{
    var PickedColor = ColorPicker();
    if (PickedColor)
       window.frames[TextBoxName].document.execCommand(TagName, null, "#" + PickedColor);
}

function Toolbar_Icon_Flash(TextBoxName, Toolbar, AlternativeText, ImageURL)
{
    Toolbar.innerHTML += ("<img width=\"21\" height=\"22\" alt=\"" + AlternativeText + "\" style=\"cursor:pointer;margin:1px\" onmouseover=\"this.style.backgroundColor='#F09050'\" onmouseout=\"this.style.backgroundColor=''\" onclick=\"Toolbar_Render_Flash('" + TextBoxName + "')\" src=\"" + ImageURL + "\">");
}

function Toolbar_Render_Flash(TextBoxName)
{
    var Width = prompt("Please type the flash width:", "");
    var Height = prompt("Please type the flash height:", "");
    var URL = prompt("Please type the flash url:", "http://");
    if (Width != null && Height != null && URL != null && URL != "" && URL != "http://" && Width != "" && Height != "" && Width > 0 && Height > 0)
    {
        if (URL.substring(0, 4) == "www.")
            URL = "http://" + URL;
        
        RichTextBox_ReplaceSelectionWithHTML(window.frames[TextBoxName], "<embed width=\"" + Width + "\" height=\"" + Height + "\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" src=\"" + URL + "\" type=\"application/x-shockwave-flash\" quality=\"high\" swLiveConnect=\"false\">");
        
        //RichTextBox_ReplaceSelectionWithHTML(window.frames[TextBoxName], "[FLASH]" + Width + "[-FLASH]" + Height + "[FLASH-]" + URL + "[-FLASH-]");
    }
}


function Toolbar_Icon_HyperLink(TextBoxName, Toolbar, AlternativeText, Target, ImageURL)
{
    Toolbar.innerHTML += ("<img width=\"21\" height=\"22\" alt=\"" + AlternativeText + "\" style=\"cursor:pointer;margin:1px\" onmouseover=\"this.style.backgroundColor='#F09050'\" onmouseout=\"this.style.backgroundColor=''\" onclick=\"Toolbar_Render_HyperLink('" + TextBoxName + "', '" + Target + "')\" src=\"" + ImageURL + "\">");
}

function Toolbar_Render_HyperLink(TextBoxName, Target)
{
    var TextBox = window.frames[TextBoxName];
    var Selection = RichTextBox_GetCurrentSelectionHTML(TextBox);
    if (Selection && Selection.length > 0)
    {
        var URL = prompt("Please type the link url:", "http://");
        if (URL.length > 0 && URL != "http://")
            RichTextBox_SurroundSelectionWithHTML(TextBox, "<a href=\"" + URL + "\" target=\"" + Target + "\">", "</a>");
    }
    else
    {
        var URL = prompt("Please type the link url:", "http://");
        var Text = prompt("Please type the link text:", "");
        if (URL.length > 0 && URL != "http://")
        {
            if (Text.length > 0)
                RichTextBox_ReplaceSelectionWithHTML(TextBox, "<a href=\"" + URL + "\" target=\"" + Target + "\">" + Text + "</a>");
            else
                RichTextBox_ReplaceSelectionWithHTML(TextBox, "<a href=\"" + URL + "\" target=\"" + Target + "\">" + URL + "</a>");
        }
    }
}

function Toolbar_Icon_Image(TextBoxName, Toolbar, AlternativeText, ImageURL)
{
	Toolbar.innerHTML += ("<img width=\"21\" height=\"22\" alt=\"" + AlternativeText + "\" style=\"cursor:pointer;margin:1px\" onmouseover=\"this.style.backgroundColor='#F09050'\" onmouseout=\"this.style.backgroundColor=''\" onclick=\"Toolbar_Render_Image('" + TextBoxName + "')\" src=\"" + ImageURL + "\" />");
}

function Toolbar_Render_Image(TextBoxName)
{
    var TextBox = window.frames[TextBoxName];
    var Selection = RichTextBox_GetCurrentSelectionText(TextBox);
    if (Selection && Selection.length > 0)
    {
        TextBox.document.execCommand("Unlink", null, null);
        RichTextBox_ReplaceSelectionWithHTML(TextBox, "<img border=\"0\" src=\"" + Selection + "\" />");
    }
    else
    {
        var ImageURL = prompt("Please enter the image url", "http://");
        if (ImageURL.length > 0)
            RichTextBox_ReplaceSelectionWithHTML(TextBox, "<img border=\"0\" src=\"" + ImageURL + "\" />");
    }
}

function Toolbar_Icon_FontName(TextBoxName, Toolbar, AlternativeText)
{
    var SelectBox = "<select title=\"" + AlternativeText + "\" tabindex=\"100\" dir=\"ltr\" onchange=\"Toolbar_Render_FontName('" + TextBoxName + "', this.value);window.frames['" + TextBoxName + "'].document.body.focus()\" style=\"vertical-align:4px;font-size:10px\" name=\"FontName\">";
    SelectBox += "<option value=\"0\"> -- " + AlternativeText + " -- </option>";
    SelectBox += "<option value=\"Arial\">Arial</option>";
    SelectBox += "<option value=\"David\">David</option>";
    SelectBox += "<option value=\"Tahoma\">Tahoma</option>";
    SelectBox += "<option value=\"Times New Roman\">Times New Roman</option>";
    SelectBox += "</select>";
    Toolbar.innerHTML += SelectBox;
}

function Toolbar_Render_FontName(TextBoxName, Name)
{
    if (Name == null || Name.length == 0)
        return;
    if (Name == "0")
        Toolbar_Render_Basic(TextBoxName, "FontName", null, null);
    else
        Toolbar_Render_Basic(TextBoxName, "FontName", null, Name);
}

function Toolbar_Icon_FontSize(TextBoxName, Toolbar, AlternativeText)
{
    var SelectBox = "<select title=\"" + AlternativeText + "\" tabindex=\"100\" onchange=\"Toolbar_Render_FontSize('" + TextBoxName + "', this.value);window.frames['" + TextBoxName + "'].document.body.focus()\" style=\"vertical-align:4px;font-size:10px\" name=\"FontSize\">";
    SelectBox += "<option value=\"0\"> -- " + AlternativeText + " -- </option>";
    SelectBox += "<option value=\"1\">1</option>";
    SelectBox += "<option value=\"2\">2</option>";
    SelectBox += "<option value=\"3\">3</option>";
    SelectBox += "<option value=\"4\">4</option>";
    SelectBox += "<option value=\"5\">5</option>";
    SelectBox += "<option value=\"6\">6</option>";
    SelectBox += "</select>";
    Toolbar.innerHTML += SelectBox;
}

function Toolbar_Render_FontSize(TextBoxName, Name)
{
    if (Name == null || Name.length == 0)
        return;
    if (Name == "0")
        Toolbar_Render_Basic(TextBoxName, "FontSize", null, null);
    else
        Toolbar_Render_Basic(TextBoxName, "FontSize", null, Name);
}

function Toolbar_Icon_Color(TextBoxName, Toolbar, AlternativeText, TagName)
{
    var SelectBox = "<select title=\"" + AlternativeText + "\" tabindex=\"100\" onchange=\"Toolbar_Render_Color('" + TextBoxName + "', '" + TagName + "', this.value);window.frames['" + TextBoxName + "'].document.body.focus()\" style=\"vertical-align:4px;font-size:10px\" name=\"Color\">";
    SelectBox += "<option value=\"Transparent\"> -- " + AlternativeText + " -- </option>";
    SelectBox += "<option value=\"#000000\" style=\"background-color:#000000\"></option>";
    SelectBox += "<option value=\"#808080\" style=\"background-color:#808080\"></option>";
    SelectBox += "<option value=\"#A9A9A9\" style=\"background-color:#A9A9A9\"></option>";
    SelectBox += "<option value=\"#D3D3D3\" style=\"background-color:#D3D3D3\"></option>";
    SelectBox += "<option value=\"#FFFFFF\" style=\"background-color:#FFFFFF\"></option>";
    SelectBox += "<option value=\"#7FFFD4\" style=\"background-color:#7FFFD4\"></option>";
    SelectBox += "<option value=\"#0000FF\" style=\"background-color:#0000FF\"></option>";
    SelectBox += "<option value=\"#000080\" style=\"background-color:#000080\"></option>";
    SelectBox += "<option value=\"#800080\" style=\"background-color:#800080\"></option>";
    SelectBox += "<option value=\"#FF1493\" style=\"background-color:#FF1493\"></option>";
    SelectBox += "<option value=\"#EE82EE\" style=\"background-color:#EE82EE\"></option>";
    SelectBox += "<option value=\"#FFC0CB\" style=\"background-color:#FFC0CB\"></option>";
    SelectBox += "<option value=\"#006400\" style=\"background-color:#006400\"></option>";
    SelectBox += "<option value=\"#008000\" style=\"background-color:#008000\"></option>";
    SelectBox += "<option value=\"#9ACD32\" style=\"background-color:#9ACD32\"></option>";
    SelectBox += "<option value=\"#FFFF00\" style=\"background-color:#FFFF00\"></option>";
    SelectBox += "<option value=\"#FFA500\" style=\"background-color:#FFA500\"></option>";
    SelectBox += "<option value=\"#FF0000\" style=\"background-color:#FF0000\"></option>";
    SelectBox += "<option value=\"#A52A2A\" style=\"background-color:#A52A2A\"></option>";
    SelectBox += "<option value=\"#DEB887\" style=\"background-color:#DEB887\"></option>";
    SelectBox += "<option value=\"#F5F5DC\" style=\"background-color:#F5F5DC\"></option>";
    SelectBox += "</select>";

    Toolbar.innerHTML += SelectBox;
}

function Toolbar_Render_Color(TextBoxName, TagName, Name)
{
    if (Name == null || Name.length == 0)
        return;
    Toolbar_Render_Basic(TextBoxName, TagName, null, Name);
}

function Toolbar_Icon_Table(TextBoxName, Toolbar, AlternativeText, ImageURL)
{
    Toolbar.innerHTML += ("<img width=\"21\" height=\"22\" alt=\"" + AlternativeText + "\" style=\"cursor:pointer;margin:1px\" onmouseover=\"this.style.backgroundColor='#F09050'\" onmouseout=\"this.style.backgroundColor=''\" onclick=\"Toolbar_Render_Table('" + TextBoxName + "')\" src=\"" + ImageURL + "\">");
}

function Toolbar_Render_Table(TextBoxName)
{
    var Rows = prompt("Please type the number of rows:", 2);
    var Columns = prompt("Please type the number of columns:", 2);
    if (Rows != "" && Columns != "" && !isNaN(Rows) && !isNaN(Columns) && Rows < 51 && Columns < 11 && Rows > 0 && Columns > 0)
    {
        var Value = "<table border=\"1\" style=\"border-collapse:collapse\">";
        for (var i = 0; i < Rows; i++)
        {
            Value += "<tr>";
            for (var j = 0; j < Columns; j++)
                Value += "<td width=\"20\"></td>";
            Value += "</tr>";
        }        
        Value += "</table>";
        RichTextBox_ReplaceSelectionWithHTML(window.frames[TextBoxName], Value);
    }
}

function Toolbar_Icon_Smilies(TextBoxName, Toolbar)
{
	Toolbar_Icon_Group(Toolbar);
	Toolbar.innerHTML += ("<img width=\"21\" height=\"22\" alt=\"&#x05E1;&#x05DE;&#x05D9;&#x05D9;&#x05DC;&#x05D9;&#x05DD;\" style=\"cursor:pointer;margin:1px\" onmouseover=\"this.style.backgroundColor='#F09050'\" onmouseout=\"this.style.backgroundColor=''\" onclick=\"Toolbar_Render_Smilies('" + TextBoxName + "')\" src=\"/Images/Toolbar/Smilies.gif\" />");
}

function Toolbar_Render_Smilies(TextBoxName)
{
    ModelessWindow("/SmiliesSmallList.aspx?TextBoxName=" + TextBoxName + "_Text", 300, 500);
}

function Toolbar_Render_CustomTag(TextBoxName, TagName)
{
    RichTextBox_SurroundSelectionWithHTML(window.frames[TextBoxName + "_Text"], "[" + TagName + "]", "[-" + TagName + "-]");
}

function Toolbar_Icon_HiddenText(TextBoxName, Toolbar)
{
	Toolbar_Icon_Group(Toolbar);
	Toolbar.innerHTML += ("<img width=\"21\" height=\"22\" alt=\"&#x05DB;&#x05EA;&#x05D1; &#x05DE;&#x05D5;&#x05E1;&#x05EA;&#x05E8;\" style=\"cursor:pointer;margin:1px\" onmouseover=\"this.style.backgroundColor='#F09050'\" onmouseout=\"this.style.backgroundColor=''\" onclick=\"Toolbar_Render_CustomTag('" + TextBoxName + "', '&#x05DE;&#x05D5;&#x05E1;&#x05EA;&#x05E8;')\" src=\"/Images/Toolbar/Hidden.gif\" />");
}

function Toolbar_Icon_SloganText(TextBoxName, Toolbar)
{
	Toolbar_Icon_Group(Toolbar);
	Toolbar.innerHTML += ("<img width=\"21\" height=\"22\" alt=\"&#x05E1;&#x05DC;&#x05D5;&#x05D2;&#x05DF;\" style=\"cursor:pointer;margin:1px\" onmouseover=\"this.style.backgroundColor='#F09050'\" onmouseout=\"this.style.backgroundColor=''\" onclick=\"Toolbar_Render_CustomTag('" + TextBoxName + "', '&#x05E1;&#x05DC;&#x05D5;&#x05D2;&#x05DF;')\" src=\"/Images/Toolbar/Slogan.gif\" />");
}

function Toolbar_Icon_Poll(TextBoxName, Toolbar)
{
	PollPosition = 1;
	Toolbar_Icon_Group(Toolbar);
	Toolbar.innerHTML += ("<img width=\"21\" height=\"22\" alt=\"&#x05E1;&#x05E7;&#x05E8;\" style=\"cursor:pointer;margin:1px\" onmouseover=\"this.style.backgroundColor='#F09050'\" onmouseout=\"this.style.backgroundColor=''\" onclick=\"Toolbar_Render_Poll('" + TextBoxName + "')\" src=\"/Images/Toolbar/Poll.gif\" />");
}

function Toolbar_Render_Poll(TextBoxName)
{
    Toolbar_Render_CustomTag(TextBoxName, "&#x05D0;&#x05E4;&#x05E9;&#x05E8;&#x05D5;&#x05EA;_" + PollPosition++)
}

function RichTextBox_GetCurrentRange(TextBox)
{
    if (TextBox.getSelection)
    {
        var Selection = TextBox.getSelection();
        if (typeof(Selection) != "undefined") 
        {
			try 
			{
				return Selection.getRangeAt(0);
			} 
			catch(e) 
			{
				return TextBox.document.createRange();
			}
		} 
		else 
		{
			return TextBox.document.createRange();
		}
    }
    else
    {
        return TextBox.document.selection.createRange();
    }
}

function RichTextBox_GetCurrentSelectionText(TextBox)
{
    var Range = RichTextBox_GetCurrentRange(TextBox);
    if (!TextBox.getSelection)
        return Range.text;
    else
        return new String(Range);
}

function RichTextBox_GetCurrentSelectionHTML(TextBox)
{
    var Range = RichTextBox_GetCurrentRange(TextBox);
    if (!TextBox.getSelection)
        return Range.htmlText;
    else
        return new String(Range);
}

function RichTextBox_SurroundSelectionWithHTML(TextBox, BeforeSelectionHTML, AfterSelectionHTML)
{
    TextBox.document.body.focus();
    if (TextBox.getSelection)
    {
        var Selection = TextBox.getSelection();
        var Range = RichTextBox_GetCurrentRange(TextBox);
        
        var CurrentText = Range.toString();
        
        Selection.removeAllRanges();
    	
	    var NewNode = document.createElement("SPAN");
	    NewNode.innerHTML = BeforeSelectionHTML + CurrentText + AfterSelectionHTML;
	    Range.deleteContents();
	    Range.insertNode(NewNode);
    }
    else
    {
        var Selection = TextBox.document.selection;
        var Range = Selection.createRange();
        var Bookmark = Range.getBookmark();
        var htmlText = Range.htmlText;
        
        Range.execCommand("unlink", null, null);
        Range.pasteHTML(BeforeSelectionHTML + htmlText + AfterSelectionHTML);
        
        Range.moveToBookmark(Bookmark);
        Range.select();
    }
}

function RichTextBox_ReplaceSelectionWithHTML(TextBox, HTML)
{
    TextBox.document.body.focus();
    if (TextBox.getSelection)
    {
        var Selection = TextBox.getSelection();
        var Range = RichTextBox_GetCurrentRange(TextBox);
        
        Selection.removeAllRanges();
    	
	    var NewNode = document.createElement("SPAN");
	    NewNode.innerHTML = HTML;
	    Range.deleteContents();
	    Range.insertNode(NewNode);
    }
    else
    {
        var Range = RichTextBox_GetCurrentRange(TextBox);
        
        var Bookmark = Range.getBookmark();
        Range.select();
        
        Range.pasteHTML(HTML);
        
        Range.moveToBookmark(Bookmark);
        Range.select();
    }
}

function RichTextBox_SetMode(TextBoxName, Mode)
{
    var TextBox = window.frames[TextBoxName + "_Text"];
    var NormalButton = document.getElementById(TextBoxName + "_Normal");
    var HTMLButton = document.getElementById(TextBoxName + "_HTML");
    if (Mode == 0) //Normal
    {
        //TextBox.document.body.innerHTML = TextBox.document.body.innerText;
        
        TextBox.document.body.innerHTML = TextBox.document.body.innerHTML.replace(/\&lt\;/g, "<").replace(/\&gt\;/g, ">");
        
        NormalButton.disabled = "disabled";
        NormalButton.tag = "";
        HTMLButton.disabled = "";
    }
    else //HTML
    {
        //alert(TextBox.document.body.innerText);
        //TextBox.document.body.innerText = TextBox.document.body.innerHTML;
        
        TextBox.document.body.innerHTML = TextBox.document.body.innerHTML.replace(/\</g, "&lt;").replace(/\>/g, "&gt;");
        NormalButton.disabled = "";
        NormalButton.tag = "enabled";
        HTMLButton.disabled = "disabled";
    }
}

function ColorPicker(DefaultColor)
{
    var Object = document.getElementById("dlgHelper");
    var Color;
    if (DefaultColor == null)
        Color = Object.ChooseColorDlg();
    else
        Color = Object.ChooseColorDlg(DefaultColor);
    Color = Color.toString(16); //change decimal to hex
    if (Color.length < 6) //add extra zeroes if hex number is less than 6 digits
        Color = ("000000".substring(0, 6 - Color.length)).concat(Color);
    return Color;
}

function ModelessWindow(URL, Width, Height)
{
    var ToReturn;
    if (document.all && window.print) //if ie5
        ToReturn = window.showModelessDialog(URL, window, "help:0;center:1;resizable:0;dialogWidth:" + Width + "px;dialogHeight:" + Height + "px");
    else
        ToReturn = window.open(URL, "", "width=" + Width + "px,height=" + Height + "px,resizable=0,scrollbars=0");

    return ToReturn;
}

function AddEventListener(Element, Event, Listener, Bubble) 
{
    if (Element.addEventListener) 
    {
        if (typeof(Bubble) == "undefined") 
            Bubble = false;
        Element.addEventListener(Event, Listener, Bubble);
    } 
    else if (this.attachEvent) 
    {
        Element.attachEvent("on" + Event, Listener);
    }
}

function RichTextBox_SetHiddenInputValue(TextBoxName)
{
    if (document.getElementById(TextBoxName + "_Normal").tag == "enabled")
        document.getElementById(TextBoxName).value = frames[TextBoxName + "_Text"].document.body.innerText;
    else
        document.getElementById(TextBoxName).value = frames[TextBoxName + "_Text"].document.body.innerHTML;
}