// **********************************
// الرجاء عدم إزالة الحقوق والتعديل على الملفات اخوك ابو عمر  www.bdr130.net   www.p5s.net
// Please don't remove the copyright note
// MagicToolBox hack 2.5 by Alawi Hussain Ba3qeel © http://www.rayaheen.net, software@rayaheen.net
// ( free software )
// **********************************

function insertHTML() {
        var SelectColor = "background-color:white;color:black";
document.write('<select style="' + SelectColor + ';font-family:MS Sans Serif;font-size:xx-small" onchange="var oSelText = Editor_getSelText();oSelText.text = oSelText.text + this[this.selectedIndex].value;this.selectedIndex=0">');
document.write('<option selected>جُمل مختصرة</option>');
document.write('<option value="السلام عليكم ورحمة الله وبركاته\n">السلام</option>');
document.write('<option value="وعليكم السلام ورحمة الله وبركاته\n">رد السلام</option>');
document.write('<option value="بسم الله الرحمن الرحيم\n">البسملة</option>');
document.write('<option value="هلاوالله ومليون غلا تو مانور المنتدى ">ترحيب</option>');
document.write('<option value="اللهم صل على محمد وعلى آله وصحبه أجمعين\n">الصلاة على محمد</option>');
document.write('<option value="مشكوووووور والله يعطيف الف عافيه\n">شكراً</option>');
document.write('<option value="مبرووووووك من الاعماق والى الامام">مباركة</option>');
document.write('<option value="هههههههههه والله موتني ضحك">ضحكه</option>');
document.write('</select>'),
//document.write('&nbsp;&nbsp;&nbsp;');
//==نصوص جاهزه

//==========
document.write('<select style="' + SelectColor + ';font-family:MS Sans Serif;font-size:xx-small" onchange="Editor_addCode(\'\'+this[this.selectedIndex].value+\'\',\'\'+this[this.selectedIndex].value+\'\',\'\');this.selectedIndex=0">');
document.write('<option selected>زخــرفــة نصــوص</option>');
document.write('<option value="«®°·.¸.•°°·.¸¸.•°°·.¸.•°®»">«®°·.¸.•°°·.¸¸.•°°·.¸.•°®»</option>');
document.write('<option value="][®][^][®][">][®][^][®][</option>');
document.write('<option value="][`~*¤!||!¤*~`][">][`~*¤!||!¤*~`][</option>');
document.write('<option value="°ˆ~*¤®§(*§*)§®¤*~ˆ°">°ˆ~*¤®§(*§*)§®¤*~ˆ°</option>');
document.write('<option value="^&)§¤°^°§°^°¤§(&^">^&)§¤°^°§°^°¤§(&^</option>');
document.write('<option value="*·~-.¸¸,.-~*">*·~-.¸¸,.-~*</option>');
document.write('<option value="×?°"?`"°?×">×?°"?`"°?×</option>');
document.write('<option value="|--*¨®¨*--|">|--*¨®¨*--|</option>');
document.write('<option value="~*¤ô§ô¤*~">~*¤ô§ô¤*~</option>');
document.write('<option value="~*¤ô§ô¤*~*¤ô§ô¤*~">~*¤ô§ô¤*~*¤ô§ô¤*~</option>');
document.write('<option value="|؛¤ّ,¸¸,ّ¤؛|">|؛¤ّ,¸¸,ّ¤؛|</option>');
document.write('<option value="][][§¤°^°¤§][][">][][§¤°^°¤§][][</option>');
document.write('<option value="§¤~¤§¤~¤§">§¤~¤§¤~¤§</option>');
document.write('<option value="§¤°~®~°¤§">§¤°~®~°¤§</option>');
document.write('</select>');

//////////////////
document.write('<select style="' + SelectColor + ';font-family:MS Sans Serif;font-size:xx-small" onchange="Editor_addCode(\'[size=\'+this[this.selectedIndex].value+\']\',\'[/size]\');this.selectedIndex=0">');
document.write('<option selected>حجم الخط</option>');
document.write('<option value="1">1</option>');
document.write('<option value="2">2</option>');
document.write('<option value="3">3</option>');
document.write('<option value="4">4</option>');
document.write('<option value="5">5</option>');
document.write('<option value="6">6</option>');
document.write('<option value="7">7</option>');
document.write('<option value="8">8</option>');
document.write('<option value="9">9</option>');
document.write('</select>'),
//document.write('</select><br>')),
//////////////////

document.write('<select style="' + SelectColor + ';font-family:MS Sans Serif;font-size:xx-small" onchange="Editor_addCode(\'[font=\'+this[this.selectedIndex].value+\']\',\'[/font]\');this.selectedIndex=0">');
document.write('<option selected>نــوع الخــط</option>');
document.write('<option value="Arial">Arial</option>');
document.write('<option value="Arial Black">Arial Black</option>');
document.write('<option value="Arial Narrow">Arial Narrow</option>');
document.write('<option value="Comic Sans MS">Comic Sans MS</option>');
document.write('<option value="Courier New">Courier New</option>');
document.write('<option value="System">System</option>');
document.write('<option value="Tahoma">Tahoma</option>');
document.write('<option value="Times New Roman">Times New Roman</option>');
document.write('<option value="Simplified Arabic">Simplified Arabic</option>');
document.write('<option value="Verdana">Verdana</option>');
document.write('<option value="Wingdings">Wingdings</option>');
document.write('<option value="MS Sans Serif">MS Sans Serif</option>');
document.write('</select>'),
//document.write('</select><br>')),

document.write('<select style="' + SelectColor + ';font-family:MS Sans Serif;font-size:xx-small" onchange="Editor_addCode(\'[color=\'+this[this.selectedIndex].value+\']\',\'[/color]\');this.selectedIndex=0">');
document.write('<option selected>لون الخط</option>');
document.write('<option style="background-color:#000000" value="000000">');
document.write('<option style="background-color:#FFFFFF" value="FFFFFF">');
document.write('<option style="background-color:#87CEEB" value="87CEEB">');
document.write('<option style="background-color:#00FFFF" value="00FFFF">');
document.write('<option style="background-color:#4169E1" value="4169E1">');
document.write('<option style="background-color:#0000FF" value="0000FF">');
document.write('<option style="background-color:#00008B" value="00008B">');
document.write('<option style="background-color:#FFFF00" value="FFFF00">');
document.write('<option style="background-color:#FF8C00" value="FF8C00">');
document.write('<option style="background-color:#FFA500" value="FFA500">');
document.write('<option style="background-color:#FF6347" value="FF6347">');
document.write('<option style="background-color:#FF7F50" value="FF7F50">');
document.write('<option style="background-color:#FF0000" value="FF0000">');
document.write('<option style="background-color:#8B0000" value="8B0000">');
document.write('<option style="background-color:#00FF00" value="00FF00">');
document.write('<option style="background-color:#008000" value="008000">');
document.write('<option style="background-color:#32CD32" value="32CD32">');
document.write('<option style="background-color:#2E8B57" value="2E8B57">');
document.write('<option style="background-color:#FF1493" value="FF1493">');
document.write('<option style="background-color:#800080" value="800080">');
document.write('<option style="background-color:#4B0082" value="4B0082">');
document.write('<option style="background-color:#DEB887" value="DEB887">');
document.write('<option style="background-color:#F4A460" value="F4A460">');
document.write('<option style="background-color:#A0522D" value="A0522D">');
document.write('<option style="background-color:#D2691E" value="D2691E">');
document.write('<option style="background-color:#008080" value="008080">');
document.write('<option style="background-color:#C0C0C0" value="C0C0C0">');
document.write('<option style="background-color:#808080" value="808080">');
document.write('<option style="background-color:#AC5668" value="AC5668">');
document.write('<option style="background-color:#F2B7F0" value="F2B7F0">');
document.write('<option style="background-color:#B7D8FB" value="B7D8FB">');
document.write('<option style="background-color:#5C92CC" value="5C92CC">');
document.write('<option style="background-color:#144273" value="144273">');
document.write('<option style="background-color:#497418" value="497418">');
document.write('<option style="background-color:#F6C9D2" value="F6C9D2">');
document.write('<option style="background-color:#DE94A4" value="DE94A4">');
document.write('<option style="background-color:#E4CDA1" value="E4CDA1">');
document.write('<option style="background-color:#B09664" value="B09664">');
document.write('<option style="background-color:#6D5423" value="6D5423">');
document.write('<option style="background-color:#722C70" value="722C70">');
document.write('<option style="background-color:#D6D3D6" value="D6D3D6">');
document.write('<option style="background-color:#A8A5A8" value="A8A5A8">');
document.write('<option style="background-color:#706E70" value="706E70">');
document.write('<option style="background-color:#808000" value="808000">');
document.write('<option style="background-color:#708090" value="708090">');
document.write('<option style="background-color:#696969" value="696969">');
document.write('<option style="background-color:#F4A460" value="F4A460">');
document.write('<option style="background-color:#9ACD32" value="9ACD32">');
document.write('<option style="background-color:#2E8B57" value="2E8B57">');
document.write('<option style="background-color:#48D1CC" value="48D1CC">');
document.write('<option style="background-color:#4169E1" value="4169E1">');
document.write('<option style="background-color:#800080" value="800080">');
document.write('<option style="background-color:#808080" value="808080">');
document.write('<option style="background-color:#FF00FF" value="FF00FF">');
document.write('<option style="background-color:#8B0000" value="8B0000">');
document.write('<option style="background-color:#4B0082" value="4B0082">');
document.write('<option style="background-color:#000080" value="000080">');
document.write('<option style="background-color:#483D8B" value="483D8B">');
document.write('<option style="background-color:#006400" value="006400">');
document.write('<option style="background-color:#556B2F" value="556B2F">');
document.write('<option style="background-color:#9932CC" value="9932CC">');
document.write('<option style="background-color:#C0C0C0" value="C0C0C0">');
document.write('<option style="background-color:#FFC0CB" value="FFC0CB">');
document.write('<option style="background-color:#F5DEB3" value="F5DEB3">');
document.write('<option style="background-color:#FFFACD" value="FFFACD">');
document.write('<option style="background-color:#98FB98" value="98FB98">');
document.write('<option style="background-color:#AFEEEE" value="AFEEEE">');
document.write('<option style="background-color:#ADD8E6" value="ADD8E6">');
document.write('<option style="background-color:#DDA0DD" value="DDA0DD">');
document.write('<option style="background-color:#FFF2F7" value="FFF2F7">');
document.write('<option style="background-color:#FF99BD" value="FF99BD">');
document.write('</select>&nbsp;');


}
var buttons = new Array();

function addRow(a) {
        buttons = buttons.concat("*");
        buttons = buttons.concat(a);
}
function showButtons() {

addRow (new Array("cut|قص","copy|نسخ","paste|لصق","delete|إزالة","","preview|معاينة الرسالة","keyb|إظهار لوحة المفاتيح العربية","plain|الغاء التنسيق","overline|خط بالاعلى","","smile|عرض الوجوه التعبيرية","colorpicker|اختيار كود اللون","link|رابط الكتروني","email|بريد الكتروني","","image|صورة","web|صفحة انترنت","ltr|تحويل الكتابة من اليسار إلى اليمين","rtl|تحويل الكتابة من اليمين إلى اليسار","","help|التعليمات","cc|زر لاخراج محتوى مخفي","3mr|خلفية صورية للموضوع"));

addRow (new Array("mklb|نص مقلوب افقي","mklb1|نص مقلوب عمودي","mklb2|نص مقلوب للاعلى","motfrk|حروف متفرقه غير متشابكه مثال :ا بـ وعـ مـ ر","","bold|داكن","italic|مائل","uline|خط سفلي","strike|خط بالوسط","","left|إلى اليسار","center|توسيط","right|إلى اليمين","justify|محاذاة إلى الأطراف","","php|كود بي اتش بي","code|كود","quote|اقتباس","list|قائمة","","line|خط فاصل","bdr|خط فاصل احمر","p5s|خط فاصل ازرق"));

addRow (new Array("mleft|تحريك انسيابي إلى اليسار","mright|تحريك انسيابي إلى اليمين","mup|تحريك انسيابي إلى الأعلى","mdown|تحريك انسيابي إلى الأسفل","","kleft|نص متحرك لليسار يقف مع مرور الماوس عليه","kright|نص متحرك لليمين يقف مع مرور الماوس عليه","kup|نص متحرك للاعلى يقف مع مرور الماوس عليه","kdown|نص متحرك للاسفل يقف مع مرور الماوس عليه","","tleft|نص متقطع متحرك لليسار","tright|نص متقطع متحرك لليمين","tup|نص متقطع متحرك للاعلى","tdown|نص متقطع متحرك للاسفل","","oleft|نص متحرك لليسار بطيء مع وضع الماوس عليه","oright|نص متحرك لليمين بطيء مع وضع الماوس عليه","oup|نص متحرك للاعلى بطيء مع وضع الماوس عليه","odown|نص متحرك للاسفل بطيء مع وضع الماوس عليه","","motr|نص متأرجح من اليمين الى اليسار","motr1|نص متأرجح من الاسفل الى الاعلى مع ملاحظة ان الخاصية ثابته بالنص المتوسط","poem|تنسيق قصيدة شعرية"));

addRow (new Array("glow|وضع إشعاعي","glow1|نص محدد بلون","blink|وميض","glint|بريق","","gradient|ألوان متدرجة","all1|ضل متدرج للنص","a7la1|ظل ثابت للنص","mark|تظليل النص","","fot1|نص بالوان عشوائية متحركه لكل حرف : ملاحظة لابد من اختيار هذه الميزة قبل اختيار الحجم ونوع الخط","blur|نص مشوش درجة متوسطه","blur1|نص مشوش درجة عاليه","hide|كتابه مخفيه","","color|لون النص","lon|أفضل اداة لانتقاء اللون","list1|زخارف ورسوم ونقوش مسنجر","bimg|وضع مصغر لصورة كبيره","","foq|نص متموج للاعلى","foq1|نص متموج للاسفل","frame|إنشاء إطار"));

addRow (new Array("msg|يمكنك وضع رسالة تخرج تلقائياً بمجرد دخول الزائر لموضوعك","mouseover|يمكنك وضع رسالة على اي نص تخرج بمجرد مرور الماوس على الكلمة المراده","click|يمكنك وضع رسالة على اي كلمة تريد وتخرج بمجرد النقر عليها","button|زر شرح برسالة مستقله  ملاحظه يجب ان تكون الرسالة غير طويله","","shr7|بالون حوار او شرح لاي كلمة تحددها ملاحظه لاتحدد الكلمة قبل اختيار الزر","shr71|بالون حوار وشرح لاي صورة تختارها ملاحظه لاتحدد عنوان الصورة قبل النقر على الزر","Unload|ضع الرسالة التي تحب ان تودع قارىء موضوعك بها اثناء خروجه من الموضوع","shr72|شرح كلمة تختارها اسفل المتصفح انظر اسفل المتصفح بعد وضع الماوس على الكلمة 42 حرف فقط","","img2|صورة بمؤثر التلاشي وبمجرد وضع الماوس عليها تتضح بشكلها الحقيقي","img3|مؤثر اهتزاز عشوائي على اي صورة تختارها حاول ان لاتكون الصورة كبيره","m3ft1|نص معرج من اليمين الى اليسار","m3ft2|نص معرج من اليسار الى اليمين","","up|مركز تحميل الملفات والصور الخاص باعضاء المنتدى فقط","AREA|وضع النص داخل مربع محدد بشريط تمرير . ملاحظة لن يعمل اي كود يوضع داخل المربع مثلا لن يعمل تكبير الخط هكذا [AREA][B]-----[/B][/AREA]","rplayer|تشغيل ملف رييل بلاير (rm,ra,ram)","media|تشغيل ملفات الصوت والصورة (mp3,wav,au,wma,mpg,mpeg,wmv,avi)","","flash|تشغيل ملف فلاش (swf)","flash1|فلاش شفاف","caps|تحويل الحروف الانجليزية الصغيرة الى كبيرة . ملاحظة لاتعمل الخاصية مع النص العربي"));

addRow (new Array("mtmoeg|صورة متموجه","mshosh4|صورة بتأثير اسقاط","mshosh3|صورة بتأثير ريح","mshosh2|صورة بتشويش ازاحه","","mshosh1|صورة بتشويش ضبابي","mtohg|صورة متوهجه","mn7ot2|صورة منحوته2","mn7ot1|صورة منحوته1","","aldl|صورة بظل","shfaf2|صورة شفافه من الاطراف","shfaf1|صورة شفافه من اليسار","rmade|صورة بدرجات رمادي","","ash3h|صورة اشعه سينيه","shfaf|صورة شفاف من اليمين","m3kos|عكس اللون صورة","sor1|صورة مقلوبه افقيا","","sor2|صورة صورة مقلوبه عموديا","gdwl|اضافة اطار صورة مولون بالوان متحركه","bor|جدول متقطع بخيار اللون"));

        addButtons(buttons, 0);
        buttons = null;
}
var tip = "الصندوق الماسي  Version :4 الحقوق محفوظـة © : ابو عمر";
var keyboardColor,statusColor,tipColor;
var btn_backcolor_over, btn_backcolor_down, btn_bordercolor;
var toolbox_background,toolbox_backcolor;
var btn_obj = "";

function Capture(b) {
        if (document.activeElement.name != "message") {
                return;
        }
        if (event.srcElement.tagName.toLowerCase() == "select")
                return;
        if (btn_obj) {
                btn_obj.releaseCapture();
                btn_obj = "";
        } else if (b == 1) {
                btn_obj = event.srcElement;
                btn_obj.setCapture();
        }
}

function button_over(eButton, w) {
        if (w == "qkeys") {
                eButton.parentElement.background = "images/toolbox/key_2.gif";
                eButton.style.color = "white";
        } else {
                vbform.toolboxbar.style.color = statusColor;
                vbform.toolboxbar.value = w;
                doButton(btn_backcolor_over, 1, eButton);
        }
}

function button_out(eButton, w) {
        if (w == "qkeys") {
                eButton.parentElement.background = "transparent";
                eButton.style.color = "black";
        } else {
                vbform.toolboxbar.style.color = tipColor;
                vbform.toolboxbar.value = tip;
                doButton("transparent", 0, eButton);
        }
}

function button_down(eButton, w) {
        if (w != "qkeys")
                doButton(btn_backcolor_down, 1, eButton);
}

function button_up(eButton, w) {
        if (w != "qkeys")
                doButton(btn_backcolor_over, 1, eButton);
        eButton = null;
}

function doButton(bk, s, btn) {
        if (event.button == 2) return;
        btn.style.backgroundColor = bk;
        if (s == 0)        {
                btn.parentElement.style.backgroundColor = "transparent";
        } else {
                btn.parentElement.style.backgroundColor = btn_bordercolor;
        }
}

function do_button(c) {
        var bn, ob, k;
        ob = window.event.srcElement;
        if (bn=ob.tag) {
                if (bn.indexOf("|||") >= 0) {
                        if (ob.tagName == "IMG")
                                ob = ob.parentElement;
                        bn = bn.split("|||");
                        if (c == 1) //click
                                execTool(bn[0]);
                        else if (c == 2) //mouse over
                                button_over(ob, bn[1]);
                        else if (c == 3) //mouse out
                                button_out(ob, bn[1]);
                        else if (c == 4) //mouse down
                                button_down(ob, bn[1]);
                        else if (c == 5) //mouse up
                                button_up(ob, bn[1]);
                }
        }
}

function addKeys(buttons) {
        var tbl, newRow;
        document.write('<table onclick="do_button(1)" onmouseover="do_button(2)" onmouseout="do_button(3)" onmousedown="do_button(4)" onmouseup="do_button(5)" dir="rtl" id="keyboardTable" border="0" cellpadding="0" cellspacing="0" width="1px" style="display:none">');
        document.write('<tr><td>');
        newRow = 1;
        for (var i = 0; i < buttons.length; i++) {
                if (i % 15 == 0) {
                        document.write('<table dir="rtl" align="center" background="images/toolbox/key_1.gif" border="0" cellpadding="0" cellspacing="0" width="1px"><tr>');
                        newRow = 0;
                }
                tbl = '<td height="29px"><div style="font-size:x-small;font-family:arial;font-weight:bold;cursor:hand;text-align:center;width:30px;height:20px;color:black" tag="qkeys_' + buttons[i] + '|||qkeys">';
                if (buttons[i] == " ")
                        buttons[i] = "&nbsp;";
                tbl += buttons[i] + '</div>';
                tbl += '</td>';
                document.write(tbl);
                if ((i + 1) % 15 == 0) {
                        document.write('</tr></table>');
                        newRow = 1;
                }
        }
        if (newRow == 0) {
                document.write('</tr></table>');
        }
        document.write('</td></tr></table>');
}

function addButtons(buttons) {
        var tbl, bn, newRow;
        document.write('<table onclick="do_button(1)" onmouseover="do_button(2)" onmouseout="do_button(3)" onmousedown="do_button(4)" onmouseup="do_button(5)" bgcolor="' + toolbox_backcolor + '" background="' + toolbox_background + '" dir="ltr" border="0" cellpadding="0" cellspacing="0" width="1px" style="border:1px ridge">');
        document.write('<tr><td align="left">');
        document.write('<table dir="ltr" border="0" cellpadding="0" cellspacing="0" width="100%" style="border:1px ridge" height=23px><tr><td align="right">');
        insertHTML();
        document.write('</td></tr></table>');
        newRow = 1;
        for (var i = 0; i < buttons.length; i++) {
                if (buttons[i] == "*") {
                        if (newRow == 0) {
                                document.write('</tr></table>');
                                document.write('</td></tr></table>');
                                newRow = 1;
                        }
                        continue;
                }
                if (newRow) {
                        document.write('<table dir="ltr" border="0" cellpadding="0" cellspacing="0" width="1px" style="merge:5px;"><tr><td style="border:1px ridge;padding-right:10px;padding-left:10px">');
                        document.write('<table align="left" width="1px" border="0" cellpadding="0" cellspacing="0"><tr>');
                        newRow = 0
                }
                if (buttons[i] == "") {
                        tbl = '</tr></table><td style="border:1px ridge;padding-right:10px;padding-left:10px">';
                        tbl += '<table align="left" width="1px" border="0" cellpadding="0" cellspacing="0"><tr>';
                } else if (buttons[i] == " ") {
                        tbl = '<td style="padding:1px"><div class="cbtn" style="font-size:1pt">&nbsp;';
                } else {
                        bn = buttons[i] + "| ";
                        bn = bn.split("|");
                        tbl = '<td style="padding:1px"><div align="center" class="cbtn" tag="' + bn[0] + '|||' + bn[1] + '">';
                        tbl += '<img tag="' + bn[0] + '|||' + bn[1] + '" border="0" align="absmiddle" width="18px" height="18px" src="images/toolbox/' + bn[0] + '.gif" alt="' + bn[1] + '">';
                }
                tbl += '</div></td>';
                document.write(tbl);
        }
        if (newRow == 0) {
                document.write('</tr></table>');
                document.write('</td></tr></table>');
        }
        document.write('<table dir="rtl" border="0" cellpadding="0" cellspacing="0" width="100%" style="border:1px ridge"><tr>');
        document.write('<td width="1px"><img border="0" align="middle" src="images/toolbox/tip.gif"></td>');
        document.write('<td><input type="text" name="toolboxbar" value="' + tip + '" style="height:18px;border-style:none;width:100%;font:8pt tahoma ;background-color:transparent;color:' + tipColor + '"></td></tr>');
        document.write('</table>');
        document.write('</td></tr></table>');
}

function showKeyboard() {
        var buttons = new Array("ا","ب","ت","ث","ج","ح","خ","د","ذ","ر","ز","س","ش","ص","ض","ط","ظ","ع","غ","ف","ق","ك","ل","م","ن","هـ","و","ي","ة","أ","إ","آ","ء","ؤ","ئ","ى","لا","لإ","لآ"," "," ","ـ","،","؛","؟");
        addKeys(buttons);
}

function showColorsWindow() {
        var posX = event.screenX;
        var posY = event.screenY + 5;
        var screenW = screen.width;                                 // screen size
        var screenH = screen.height - 20;                           // take taskbar into account
        if (posX + 232 > screenW) { posX = posX - 232 - 40; }       // if mouse too far right
        if (posY + 164 > screenH) { posY = posY - 164 - 80; }       // if mouse too far down
        var wPosition = "dialogLeft:" +posX+ "; dialogTop:" +posY;
        return showModalDialog("colors.html", "",
                "dialogWidth:238px; dialogHeight: 195px; resizable: no; help: no; status: no; scroll: no; "        + wPosition);
}
function execTool(btn) {
if (event.altKey) {
if (btn.substr(0,4) != "key_") {
open("help.php?toolsel=" + btn, "help", "toolbar=no,scrollbars=yes,resizable=yes,width=550px,height=350px,left=50px,top=100px");
}
} else
EditorFunctions(btn);
}
function Editor_getSelText() {
var oSelect,oSelectRange;
document.vbform.message.focus();
oSelect = document.selection;
oSelectRange = oSelect.createRange();
return oSelectRange;
}
function Editor_addCode(tag1,tag2) {
var oSelText = Editor_getSelText();
if (oSelText.text == "")
alert("يرجى تظليل النص أولا");
else
oSelText.text = tag1 + oSelText.text + tag2;
}
function EditorFunctions(tag) {
  if (tag.substr(0, 6) == "qkeys_") {  // Arabic Keyboard
        var oSelText = Editor_getSelText();
        tag = tag.substr(6);
        if (tag == "هـ") tag = "ه";
        oSelText.text = tag;
  }
else if (tag == "rtl" || tag == "ltr") {
document.vbform.message.dir=tag.substr(tag);
}

else if (tag == "mtmoeg") {
Editor_addCode("[mtmoeg]","[/mtmoeg]");
}
else if (tag == "mshosh4") {
Editor_addCode("[mshosh4]","[/mshosh4]");
}
else if (tag == "mshosh3") {
Editor_addCode("[mshosh3]","[/mshosh3]");
}
else if (tag == "mshosh2") {
Editor_addCode("[mshosh2]","[/mshosh2]");
}
else if (tag == "mshosh1") {
Editor_addCode("[mshosh1]","[/mshosh1]");
}

else if (tag == "mn7ot2") {
Editor_addCode("[mn7ot2]","[/mn7ot2]");
}
else if (tag == "mn7ot1") {
Editor_addCode("[mn7ot1]","[/mn7ot1]");
}
else if (tag == "aldl") {
Editor_addCode("[aldl]","[/aldl]");
}
else if (tag == "shfaf2") {
Editor_addCode("[shfaf2]","[/shfaf2]");
}
else if (tag == "shfaf1") {
Editor_addCode("[shfaf1]","[/shfaf1]");
}
else if (tag == "rmade") {
Editor_addCode("[rmade]","[/rmade]");
}
else if (tag == "ash3h") {
Editor_addCode("[ash3h]","[/ash3h]");
}
else if (tag == "shfaf") {
Editor_addCode("[shfaf]","[/shfaf]");
}
else if (tag == "m3kos") {
Editor_addCode("[m3kos]","[/m3kos]");
}
else if (tag == "bold") {
Editor_addCode("[B]","[/B]");
}
else if (tag == "mtargh") {
Editor_addCode("[mtargh]","[/mtargh]");
}
else if (tag == "m3ft1") {
Editor_addCode("[m3ft1]","[/m3ft1]");
}
else if (tag == "m3ft2") {
Editor_addCode("[m3ft2]","[/m3ft2]");
}
else if (tag == "mklb") {
Editor_addCode("[mklb]","[/mklb]");
}
else if (tag == "sor1") {
Editor_addCode("[sor1]","[/sor1]");
}
else if (tag == "sor2") {
Editor_addCode("[sor2]","[/sor2]");
}
else if (tag == "mklb1") {
Editor_addCode("[mklb1]","[/mklb1]");
}
else if (tag == "mklb2") {
Editor_addCode("[mklb2]","[/mklb2]");
}
else if (tag == "foq") {
Editor_addCode("[foq]","[/foq]");
}
else if (tag == "foq1") {
Editor_addCode("[foq1]","[/foq1]");
}
else if (tag == "motr") {
Editor_addCode("[motr]","[/motr]");
}
else if (tag == "motr1") {
Editor_addCode("[motr1]","[/motr1]");
}
else if (tag == "fot1") {
Editor_addCode("[fot1]","[/fot1]");
}
else if (tag == "AREA") {
Editor_addCode("[AREA]","[/AREA]");
}
else if (tag == "blur") {
Editor_addCode("[blur]","[/blur]");
}
else if (tag == "blur1") {
Editor_addCode("[blur1]","[/blur1]");
}
else if (tag == "hide") {
Editor_addCode("[hide]\n","\n[/hide]");
}
//else if (tag == "msg") {
//Editor_addCode("[msg]","[/msg]");
//}
else if (tag == "italic") {
Editor_addCode("[I]","[/I]");
}
else if (tag == "uline") {
Editor_addCode("[U]","[/U]");
}
else if (tag == "quote") {
Editor_addCode("[quote]","[/quote]");
}
else if (tag == "code") {
Editor_addCode("[code]","[/code]");
}
else if (tag == "php") {
Editor_addCode("[php]","[/php]");
}
else if (tag == "line") {
var oSelText = Editor_getSelText();
oSelText.text = "[line][/line]";
}
else if (tag == "bdr") {
var oSelText = Editor_getSelText();
oSelText.text = "[bdr][/bdr]";
}
else if (tag == "p5s") {
var oSelText = Editor_getSelText();
oSelText.text = "[p5s][/p5s]";
}
else if (tag == "blink") {
Editor_addCode("[blink]","[/blink]");
}
else if (tag == "list") {
Editor_addCode("[list]\n","\n[/list]");
}

else if (tag == "glint") {
Editor_addCode("[glint]","[/glint]");
}
else if (tag == "gdwl") {
Editor_addCode("[gdwl]","[/gdwl]");
}
else if (tag == "strike") {
Editor_addCode("[S]","[/S]");
}
else if (tag == "overline") {
Editor_addCode("[overline]","[/overline]");
}
else if (tag == "caps") {
Editor_addCode("[caps]","[/caps]");
}
else if (tag == "motfrk") {
Editor_addCode("[motfrk]","[/motfrk]");
}




else if (tag=="mktsr") {
var oSelText = Editor_getSelText();
if (oSelText.parentElement().name=="message")
showModalDialog("cannedtext.php",oSelText,"help:no; center:yes; status:no; dialogHeight:400px; dialogWidth:400px");
}
else if (tag=="up") {
var oSelText = Editor_getSelText();
if (oSelText.parentElement().name=="message")
showModalDialog("http://up.bdr130.net/",oSelText,"help:no; center:yes; status:no; dialogHeight:500px; dialogWidth:770px");
}
else if (tag=="music") {
var oSelText = Editor_getSelText();
if (oSelText.parentElement().name=="message")
showModalDialog("music.htm",oSelText,"help:no; center:yes; status:no; dialogHeight:360px; dialogWidth:350px");
}
else if (tag=="video") {
var oSelText = Editor_getSelText();
if (oSelText.parentElement().name=="message")
showModalDialog("video.htm",oSelText,"help:no; center:yes; status:no; dialogHeight:360px; dialogWidth:350px");
}

else if (tag=="poetry") {
var oSelText = Editor_getSelText();
if (oSelText.parentElement().name=="message")
showModalDialog("hackpoet.htm",oSelText,"help:no; center:yes; status:no; dialogHeight:360px; dialogWidth:390px");
}

else if (tag=="lon") {
var oSelText = Editor_getSelText();
if (oSelText.parentElement().name=="message")
showModalDialog("colo.htm",oSelText,"help:no; center:yes; status:no; dialogHeight:319px; dialogWidth:457px");
}

else if (tag=="list1") {
var oSelText = Editor_getSelText();
if (oSelText.parentElement().name=="message")
showModalDialog("msn.htm",oSelText,"help:no; center:yes; status:no; dialogHeight:359px; dialogWidth:457px");
}

else if (tag == "gradient") {
var oSelText = Editor_getSelText();
if (oSelText.text == "") {
alert("يرجى تظليل النص أولا");
return;
}
code = showModalDialog("gradient_form.htm","","help:no; center:yes; status:no; dialogHeight:150px; dialogWidth:420px");
if (!code)
return;
oSelText.text = "[grade=\"" + code + "\"]" + oSelText.text + "[/grade]"
}


else if (tag == "left" || tag == "center" || tag == "right" || tag == "justify") {
Editor_addCode("[align="+tag.toLowerCase()+"]","[/align]");
}
else if (tag == "link") {
var oSelText = Editor_getSelText();
var ob = window.prompt("أدخل الرابط:","http://");
txt = oSelText.text;
if (ob) {
if (txt=="")
txt = window.prompt("أدخل التعليق على الرابط","");
if (txt)
oSelText.text = "[url="+ob+"]"+txt+"[/url]";
else
oSelText.text = "[url]"+ob+"[/url]";
}
}

else if (tag == "mouseover") {
var oSelText = Editor_getSelText();
var ob = window.prompt("أدخل ماتريد ان يخرج للقارىء قبل وضع الجمله:","مثل شرح او رساله او تعليق الخ");
txt = oSelText.text;
if (ob) {
if (txt=="")
txt = window.prompt("ادخل الجمله اللتي تود ان يخرج الشرح مجرد تمرير الماوس عليها","مثلا مرر الماوس هنا او شاهد الشرح بتمرير الماوس هنا الخ");
if (txt)
oSelText.text = "[mouseover="+ob+"]"+txt+"[/mouseover]";
else
oSelText.text = "[mouseover]"+ob+"[/mouseover]";
}
}

else if (tag == "shr7") {
var oSelText = Editor_getSelText();
var ob = window.prompt("أدخل ماتريد ان يخرج للقارىء قبل وضع الجمله:","مثل شرح او رساله او تعليق الخ");
txt = oSelText.text;
if (ob) {
if (txt=="")
txt = window.prompt("ادخل الجمله اللتي تود ان يخرج الشرح مجرد تمرير الماوس عليها","مثلا مرر الماوس هنا او شاهد الشرح بتمرير الماوس هنا الخ");
if (txt)
oSelText.text = "[shr7="+ob+"]"+txt+"[/shr7]";
else
oSelText.text = "[shr7]"+ob+"[/shr7]";
}
}

else if (tag == "shr72") {
var oSelText = Editor_getSelText();
var ob = window.prompt("أدخل ماتريد ان يخرج للقارىء قبل وضع الجمله:","مثل شرح او رساله او تعليق الخ");
txt = oSelText.text;
if (ob) {
if (txt=="")
txt = window.prompt("ادخل الجمله اللتي تود ان يخرج الشرح مجرد تمرير الماوس عليها","مثلا مرر الماوس هنا او شاهد الشرح بتمرير الماوس هنا الخ");
if (txt)
oSelText.text = "[shr72="+ob+"]"+txt+"[/shr72]";
else
oSelText.text = "[shr72]"+ob+"[/shr72]";
}
}

else if (tag == "click") {
var oSelText = Editor_getSelText();
var ob = window.prompt("أدخل ماتريد ان يخرج للقارىء قبل وضع الجمله:","مثل شرح او رساله او تعليق الخ");
txt = oSelText.text;
if (ob) {
if (txt=="")
txt = window.prompt("ادخل الجمله اللتي تود ان يخرج الشرح مجرد النقر عليها","مثلا اضغط هنا او انقر هنا او شاهد الشرح بالنقر هنا الخ");
if (txt)
oSelText.text = "[click="+ob+"]"+txt+"[/click]";
else
oSelText.text = "[click]"+ob+"[/click]";
}
}

else if (tag == "button") {
var oSelText = Editor_getSelText();
var ob = window.prompt("أدخل عنوان الزر مثلا اضغط هنا الخ:","ضع الرسالة الناتجه عن ضغط الزر مثل شرح او رساله او تعليق الخ");
txt = oSelText.text;
if (ob) {
if (txt=="")
txt = window.prompt("ادخل الجمله اللتي تود ان يخرج الشرح مجرد النقر عليها","مثلا اضغط هنا او انقر هنا او شاهد الشرح بالنقر هنا الخ");
if (txt)
oSelText.text = "[button="+ob+"]"+txt+"[/button]";
else
oSelText.text = "[button]"+ob+"[/button]";
}
}

else if (tag == "shr71") {
var oSelText = Editor_getSelText();
var ob = window.prompt("ادخل رابط الصورة اللتي ترغب وضع شرح عليها:","http://");
txt = oSelText.text;
if (ob) {
if (txt=="")
txt = window.prompt("ادخل الشرح الذي تود ان يخرج على الصورة عند وضع الماوس عليها","مثلا : هذه الصورة لفلان او هذه صورة سيارة موديل كذا وكذا الخ");
if (txt)
oSelText.text = "[shr71="+ob+"]"+txt+"[/shr71]";
else
oSelText.text = "[shr71]"+ob+"[/shr71]";
}
}



else if (tag == "email") {
var oSelText = Editor_getSelText();
var ob = window.prompt("أدخل عنوان البريد الالكتروني:","@");
if (ob)
if (oSelText.text=="")
oSelText.text = "[email]"+ob+"[/email]";
else
oSelText.text = "[email="+ob+"]"+oSelText.text +"[/email]";
}

else if (tag == "image") {
var oSelText = Editor_getSelText();
var link=((oSelText.text=="")?"http://":oSelText.text);
var ob = window.prompt("أدخل رابط الصورة:",link);
if (ob)
oSelText.text = "[img]"+ob+"[/img]";
}
else if (tag == "img2") {
var oSelText = Editor_getSelText();
var link=((oSelText.text=="")?"http://":oSelText.text);
var ob = window.prompt("أدخل رابط الصورة:",link);
if (ob)
oSelText.text = "[img2]"+ob+"[/img2]";
}

else if (tag == "img4") {
var oSelText = Editor_getSelText();
var link=((oSelText.text=="")?"http://":oSelText.text);
var ob = window.prompt("أدخل رابط الصورة:",link);
if (ob)
oSelText.text = "[img4]"+ob+"[/img4]";
}

else if (tag == "Unload") {
var oSelText = Editor_getSelText();
var link=((oSelText.text=="")?"سررت بمرورك الكريم على موضوع تحياتي لك اخوك البدر":oSelText.text);
var ob = window.prompt("أدخل رسالة توديع لمن يقرأ موضوعك بمجرد الخروج منه:",link);
if (ob)
oSelText.text = "[Unload]"+ob+"[/Unload]";
}



else if (tag == "3mr") {
var oSelText = Editor_getSelText();
if (oSelText.text == "") {
alert("يرجى تظليل النص أولا");
return;
}
var ob = window.prompt("أدخل رابط صورة الخلفية:","backgrounds/16.gif");
if (ob)
if (oSelText.text=="")
oSelText.text = "[3mr]"+ob+"[/3mr]";
else
oSelText.text = "[3mr="+ob+"]"+oSelText.text +"[/3mr]";
}

else if (tag == "cc") {
var oSelText = Editor_getSelText();
if (oSelText.text == "") {
alert("يرجى تظليل النص أولا");
return;
}
var ob = window.prompt("أدخل اسم الزر :","مثلا انقر هنا لمشاهدة المحتوى المخفي");
if (ob)
if (oSelText.text=="")
oSelText.text = "[cc]"+ob+"[/cc]";
else
oSelText.text = "[cc="+ob+"]"+oSelText.text +"[/cc]";
}

else if (tag == "img3") {
var oSelText = Editor_getSelText();
var link=((oSelText.text=="")?"http://":oSelText.text);
var ob = window.prompt("أدخل رابط الصورة:",link);
if (ob)
oSelText.text = "[img3]"+ob+"[/img3]";
}

else if (tag == "msg") {
var oSelText = Editor_getSelText();
var link=((oSelText.text=="")?"":oSelText.text);
var ob = window.prompt("ادخل الرسالة اللتي تود خروجها بمجرد الدخول لموضوعك : ملاحظة مهمه جدا الرجاء عدم استخدام هذه الميزة بالردود فهي مخصصه للمواضيع فقط:",link);
if (ob)
oSelText.text = "[msg]"+ob+"[/msg]";
}

else if (tag == "bimg") {
var oSelText = Editor_getSelText();
var link=((oSelText.text=="")?"http://":oSelText.text);
var ob = window.prompt("أدخل رابط الصورة المراد ضبطها:",link);
if (ob)
oSelText.text = "[bimg]"+ob+"[/bimg]";
}

  else if (tag == "mleft" || tag == "mright" || tag == "mup" || tag == "mdown") {
    Editor_addCode("[move="+tag.substr(1).toLowerCase()+"]","[/move]");
  }

  else if (tag == "tleft" || tag == "tright" || tag == "tup" || tag == "tdown") {
    Editor_addCode("[movet="+tag.substr(1).toLowerCase()+"]","[/movet]");
  }

  else if (tag == "oleft" || tag == "oright" || tag == "oup" || tag == "odown") {
    Editor_addCode("[moveo="+tag.substr(1).toLowerCase()+"]","[/moveo]");
  }

  else if (tag == "kleft" || tag == "kright" || tag == "kup" || tag == "kdown") {
    Editor_addCode("[movek="+tag.substr(1).toLowerCase()+"]","[/movek]");
  }

  else if (tag == "sleft" || tag == "sright" || tag == "sup" || tag == "sdown") {
    Editor_addCode("[moves="+tag.substr(1).toLowerCase()+"]","[/moves]");
  }
else if (tag == "rplayer") {
var oSelText = Editor_getSelText();
var link=((oSelText.text=="")?"http://":oSelText.text);
var ob = window.prompt("أدخل رابط ملف الرييل بلاير:", link);
if (ob) {
t = window.prompt("صوت فقط = 0\r\nصورة = 1", 0);
if (t) {
if (t==0)
oSelText.text = "[rams]"+ob+"[/rams]";
else
oSelText.text = "[ramv]"+ob+"[/ramv]";
}
}
}
else if (tag == "media") {
var oSelText = Editor_getSelText();
var link=((oSelText.text=="")?"http://":oSelText.text);
var ob = window.prompt("أدخل ملف الصوت والصورة:", link);
if (ob)
oSelText.text = "[media]"+ob+"[/media]";
}


else if (tag == "flash") {
var oSelText = Editor_getSelText();
var link=((oSelText.text=="")?"http://":oSelText.text);
var ob = window.prompt("أدخل رابط ملف الفلاش:", link);
if (!ob) return;
var w = window.prompt("أدخل طول شاشة الفلاش بوحدة البيكسل:","400");
if (!w) return;
var h = window.prompt("أدخل عرض شاشة الفلاش بوحدة البيكسل:","350");
if (!h) return;
oSelText.text = "[flash="+ob+"]WIDTH="+w+" HEIGHT="+h+"[/flash]";
}

else if (tag == "flash1") {
var oSelText = Editor_getSelText();
var link=((oSelText.text=="")?"http://":oSelText.text);
var ob = window.prompt("أدخل رابط ملف الفلاش الشفاف:", link);
if (!ob) return;
var w = window.prompt("أدخل طول شاشة الفلاش بوحدة البيكسل:","400");
if (!w) return;
var h = window.prompt("أدخل عرض شاشة الفلاش بوحدة البيكسل:","350");
if (!h) return;
oSelText.text = "[flash1="+ob+"]WIDTH="+w+" HEIGHT="+h+"[/flash1]";
}

else if (tag == "web") {
var oSelText = Editor_getSelText();
var link=((oSelText.text=="")?"http://":oSelText.text);
var ob = window.prompt("أدخل رابط الصفحة:", link);
if (ob)
oSelText.text = "[web]"+ob+"[/web]";
}
else if (tag == "poem") {
var oSelText = Editor_getSelText();
if (oSelText.text == "") {
alert("عفوا،\nعليك تظليل القصيدة أولا . تذكر أن تفصل شطري كل بيت بعلامة المساواة (=)");
return;
}
code = showModalDialog("poem_form.htm","","help:no; center:yes; status:no; dialogHeight:450px; dialogWidth:560px");
if (!code)
return;
oSelText.text = "[poem=" + code + "]\n" + oSelText.text + "[/poem]"
}
else if (tag == "frame") {
var oSelText = Editor_getSelText();
if (oSelText.text == "") {
alert("يرجى تظليل النص أولا");
return;
}
code = showModalDialog("frame_form.htm","","help:no; center:yes; status:no; dialogHeight:290px; dialogWidth:450px");
if (!code)
return;
oSelText.text = '[frame="' + code + '"]' + oSelText.text + '[/frame]';
}
else if (tag == "plain") {
var oSelText = Editor_getSelText();
if (oSelText.parentElement().name=="message") {
var temp = oSelText.text;
temp = temp.replace(/\[FLASH=([^\]]*)\]WIDTH=[0-9]{0,4} HEIGHT=[0-9]{0,4}\[\/FLASH\]/gi,"$1");
temp = temp.replace(/\[VIDEO=([^\]]*)\]WIDTH=[0-9]{0,4} HEIGHT=[0-9]{0,4}\[\/VIDEO\]/gi,"$1");
oSelText.text = temp.replace(/\[[^\]]*\]/gi,"");
}
}
else if (tag == "cut" || tag == "copy" || tag == "paste" || tag == "delete" || tag == "close") {
var oSelText = Editor_getSelText();
oSelText.execCommand(tag);
}
  else if (tag == "smile") {
            window.open("misc.php?do=getsmilies&editorid=vB_Editor_001", "smilies", "toolbar=no,status=no,scrollbars=yes,resizable=yes,width=440px,height=280px");
  }
else if (tag == "undo") {
alert("للتراجع\nاضغط CTRL مع مفتاح Z");
}
else if (tag == "redo") {
alert("للإعادة\nاضغط CTRL مع مفتاح Y");
}
  else if (tag == "keyb") {
          if (keyboardTable.style.display == "none") {
                  event.srcElement.src = "images/toolbox/keybx.gif";
                  keyboardTable.style.display = "inline";
                  event.srcElement.alt = "إخفاء لوحة المفاتيح العربية";
          }
          else {
                  event.srcElement.src = "images/toolbox/keyb.gif";
                  keyboardTable.style.display = "none";
                  event.srcElement.alt = "إظهار لوحة المفاتيح العربية";
          }
  }
else if (tag == "preview") {
var maxchars = -1;
var l = document.vbform.message.value.replace(/^[\r\n\t ]*|[\r\n\t ]*$/gi, "").length;
if (l == 0)
alert("حقل الموضوع أو التعقيب فارغ");
else {
try { maxchars = postmaxchars } catch(e) { try { maxchars = pmmaxchars } catch(e) { ; } }
if (l > maxchars && maxchars != -1)
alert("الرسالة طويلة جدا.\n\nيرجى تحديد نص الرسالة  بـ  " + maxchars + " حرفاً كحد أقصى.\nثم إعادة المحاولة "+l+" حرف الحد المسموح.");
else
open("postpreview.php", "postpreview");
}
}
  else if (tag == "colorpicker") {
var c = showColorsWindow();
if (c) {
var oSelText = Editor_getSelText();
oSelText.text = c;}
} else if (tag == "glow" || tag == "glow1" || tag == "mark" || tag == "a7la1" || tag == "bor" || tag == "all1" || tag == "color" || tag == "mtohg") {
var oSelText = Editor_getSelText();
if (oSelText.text == "") {
alert("يرجى تظليل النص أولا");
return;
}
var c = showColorsWindow();
if (c) {
oSelText.text = "[" + tag + "=" + c + "]" + oSelText.text + "[/" + tag + "]";
}

} else if (tag == "help") {
open("help.php", "help",  "toolbar=no,scrollbars=yes,resizable=yes,width=550px,height=350px,left=50px,top=100px");
}
}



// ******************* [blink] code ******************* //
setInterval("doBlinkText()", 500);
document.write('<span id="myblinktext" style="display:none"></span>');
function doBlinkText() {
        try {
                for (var i = 1; i < myblinktext.length; i++)
                        if (myblinktext[i].style.visibility == "hidden")
                                myblinktext[i].style.visibility = "visible";
                        else
                                myblinktext[i].style.visibility = "hidden";
        } catch(e) {
        ;
        }
}