// Programmed By Saleh AlMatrafe
		vB_Text_Editor.prototype.msg = function(e,selection)
		{
			this.apply_format('removeformat');
            if (typeof selection == 'undefined')
    		{
    			selection = this.get_selection();
    			if (selection === false)
    			{
    				selection = this.show_prompt("من فضلك أدخل محتوى الرسالة :", "");
    			}
    			else
    			{
    				selection = new String(selection);
                    selection = this.show_prompt("من فضلك أدخل محتوى الرسالة :", selection);
    			}
    		}
            if(selection){
      		    var text = '[msg]' + selection + '[/msg]';
            }else{
		        return false
            }

      		this.insert_text(text, false);

      		return false;
		};
		vB_Text_Editor.prototype.shr71 = function(e)
		{
            imgsrc  = this.show_prompt("من فضلك أدخل رابط الصورة:", "http://");
            imgdesc = this.show_prompt("من فضلك أدخل شرح الصورة:", "مثلا : هذه الصورة لفلان او هذه صورة سيارة موديل كذا وكذا الخ");
            if(imgsrc){
      		    var text = '[shr71='+ imgsrc +']' + imgdesc + '[/shr71]';
            }else{
		        return false
            }

      		this.insert_text(text, false);

      		return false;
		};
		vB_Text_Editor.prototype.mtohg = function(e)
		{
            color = showModalDialog("massy/color.html","","help:no; center:yes; status:no; dialogHeight:176px; dialogWidth:356px");
            imgsrc  = this.show_prompt("من فضلك أدخل رابط الصورة:", "http://");
            if(imgsrc){
      		    var text = '[mtohg='+ color +']' + imgsrc + '[/mtohg]';
            }else{
		        return false
            }
      		this.insert_text(text, false);

      		return false;
		};
		vB_Text_Editor.prototype.youtube = function(e)
		{
            clip = this.show_prompt("من فضلك أدخل رابط المفطع :", "http://www.youtube.com/watch?v=XXXXXXXXXXX");
            if(clip = this.verify_prompt(clip)){
      		    var text = '[youtube]' + clip + '[/youtube]';
            }else{
		        return false
            }

      		this.insert_text(text, false);

      		return false;
		};
        vB_Text_Editor.prototype.inserthr = function(e)
        {
            code = showModalDialog("massy/color.html","","help:no; center:yes; status:no; dialogHeight:176px; dialogWidth:356px");
        	if (!code)
        		return;
            	this.insert_text('[hr]' + code + '[/hr]', false);
                return false;
        };
		vB_Text_Editor.prototype.poem = function(e)
		{
		    oSelText = this.get_selection();
            if (oSelText == "") {
    		    alert("يجب تضليل أو تحديد النص أولا");
    		    return;
    	    }
            code = showModalDialog("massy/poem_form.htm","","help:no; center:yes; status:no; dialogHeight:500px; dialogWidth:700px");
    	    if (!code)
    		return;
    		return this.insert_text('[poem='+code+'"]\n'+oSelText+'[/poem]', false);
		};
        vB_Text_Editor.prototype.gradient = function(e)
        {
        	oSelText = this.get_selection();
        	if (oSelText == "") {
        		alert("يجب تضليل أو تحديد النص أولا");
        		return;
        	}
            code = showModalDialog("massy/gradient_form.htm","","help:no; center:yes; status:no; dialogHeight:220px; dialogWidth:500px");
        	if (!code)
        		return;
        		return this.insert_text('[grade="'+code+'"]'+oSelText+'[/grade]', false);
        };
        vB_Text_Editor.prototype.frame = function(e)
        {
        	oSelText = this.get_selection();
        	if (oSelText == "") {
        		alert("يجب تضليل أو تحديد النص أولا");
        		return;
        	}
            code = showModalDialog("massy/frame_form.htm","","help:no; center:yes; status:no; dialogHeight:250px; dialogWidth:450px");
        	if (!code)
        		return;
        		return this.insert_text('[frame="'+code+'"]'+oSelText+'[/frame]', false);
        };
        vB_Text_Editor.prototype.marq = function(e)
        {
        	oSelText = this.get_selection();
        	if (oSelText == "") {
        		alert("يجب تضليل أو تحديد النص أولا");
        		return;
        	}
            code = showModalDialog("massy.php?action=marq","","help:no; center:yes; status:no; dialogHeight:450px; dialogWidth:420px");
        	if (!code)
        		return;
        		return this.insert_text('[marq="'+code+'"]'+oSelText+'[/marq]', false);
        };
        vB_Text_Editor.prototype.textformat = function(e)
        {
        	oSelText = this.get_selection();
        	if (oSelText == "") {
        		alert("يجب تضليل أو تحديد النص أولا");
        		return;
        	}
            ubb  = "[/ALIGN]";
            ubb += "[/COLOR][/SIZE][/FONT]";
            ubb += "[/CELL][/TABLETEXT][/ALIGN]";
            code = showModalDialog("massy.php?action=text",oSelText,"help:no; center:yes; status:no; dialogHeight:400px; dialogWidth:700px");
        	if (!code)
        		return;
        		return this.insert_text(code+oSelText+ubb, false);
        };
      function _createRequestObject() {
          var ro;
          var browser = navigator.appName;
          if(browser == "Microsoft Internet Explorer"){
              ro = new ActiveXObject("Microsoft.XMLHTTP");
          }else{
              ro = new XMLHttpRequest();
          }
          return ro;
      }
        vB_Text_Editor.prototype.hcal = function(e)
        {
            _sndReplaceReq('GET', 'hijri', null);
        };
        vB_Text_Editor.prototype.numbers = function(e)
        {
        	oSelText = this.get_selection();
        	if (oSelText == "") {
        		alert("يجب تضليل أو تحديد الارقام أولا");
        		return;
        	}
            _sndReplaceReq('POST', 'number', 'param=' + oSelText);
        };
        vB_Text_Editor.prototype.keyb = function(e)
        {
            this.apply_format('removeformat');
        	oSelText = this.get_selection();
        	if (oSelText == "") {
        		alert("يجب تضليل أو تحديد النص أولا");
        		return;
        	}
            _sndReplaceReq('POST', 'keyboard', 'param=' + oSelText);
        };
        vB_Text_Editor.prototype.terms = function(e)
        {
            this.apply_format('removeformat');
        	oSelText = this.get_selection();
        	if (oSelText == "") {
        		alert("يجب تضليل أو تحديد النص أولا");
        		return;
        	}
            _sndReplaceReq('POST', 'en_terms', 'param=' + oSelText);
        };
    	bdr130_button = function(e)
    	{
    	    e = do_an_e(e);
        	if (e.type == 'click')
        	{
        		bdr130_warp_format(this.cmd.substr(6), this.editorid, (this.cmd.substr(4, 1) == '1' ? true : false));
        	}else if (e.type == 'mouseover')
            {
                mbar = fetch_object('massybar');
				mbar.innerHTML = this.title;
            }else if (e.type == 'mouseout')
            {
                mbar = fetch_object('massybar');
				mbar.innerHTML = 'الصندوق الماسي الخامس -  Massy Version 5';
            }
    		vB_Editor[this.editorid].button_context(this, e.type);
    	}
    	updatebar = function(e)
    	{
    	    e = do_an_e(e);
        	if (e.type == 'mouseover')
            {
                mbar = fetch_object('massybar');
				mbar.innerHTML = this.title;
                this._onmouseover(e);
            }else if (e.type == 'mouseout')
            {
                mbar = fetch_object('massybar');
				mbar.innerHTML = 'الصندوق الماسي الخامس -  Massy Version 5';
                this._onmouseout(e);
            }
    	}
        bdr130_warp_format = function(tag,editorid,remove_format){
            if(remove_format){
			    vB_Editor[editorid].apply_format('removeformat');
            }
    		selection = vB_Editor[editorid].get_selection();
            if(selection){
      		    var text = '['+tag+']' + selection + '[/'+tag+']';
            }else{
                alert("يرجى تحديد النص");
		        return false
            }

      		vB_Editor[editorid].insert_text(text, false);
        }
        vB_Text_Editor.prototype.init_bdr130_button = function()
        {
    		var controls = new Array();
    		var i, j, buttons, imgs, control;

    		if (this.controlbar == null)
    		{
    			return;
    		}
                obj = fetch_object(this.editorid + '_popbdr_shorts');
                this.init_popup_bdr130(obj);
    		buttons = fetch_tags(this.controlbar, 'div');
    		for (i = 0; i < buttons.length; i++)
    		{
    			if (buttons[i].className == 'bdr130button' && buttons[i].id)
    			{
                    obj = buttons[i];
                    obj.cmd = obj.id.substr(obj.id.indexOf('_bdr130_') + 8);
		            buttons[i].editorid = this.editorid;
		            buttons[i].cmd = obj.cmd;
    				controls[controls.length] = buttons[i].id;
    					imgs = buttons[i].getElementsByTagName("img");
    					for (j = 0; j < imgs.length; j++)
    					{
    						if (imgs[j].alt == "")
    						{
    							imgs[j].title = buttons[i].title;
    						}else{
		                        buttons[i].title = imgs[j].alt;
    						}
    					}
                        if (obj.cmd.substr(0, 4) == 'wrap')
		                {
                            buttons[i].onclick = buttons[i].onmousedown = buttons[i].onmouseover = buttons[i].onmouseout = bdr130_button;
                        }else{
                            buttons[i].onmousedown = buttons[i].onmouseover = buttons[i].onmouseout = bdr130_button;
                        }
    			}
                else if (buttons[i].className == 'imagebutton' && buttons[i].id)
      			{
  					imgs = buttons[i].getElementsByTagName("img");
  					for (j = 0; j < imgs.length; j++)
  					{
  						if (imgs[j].alt == "")
  						{
  							imgs[j].title = buttons[i].title;
  						}else{
                            buttons[i].title = imgs[j].alt;
  						}
  					}
                    buttons[i]._onmouseover = buttons[i].onmouseover;
                    buttons[i]._onmouseout  = buttons[i].onmouseout;
                    buttons[i].onmouseover = buttons[i].onmouseout = updatebar;
      			}
    		}
        }
	vB_Text_Editor.prototype.init_popup_bdr130 = function(obj)
	{
		obj.cmd = obj.id.substr(obj.id.indexOf('_popbdr_') + 8);
		if (this.popupmode)
		{
			vBmenu.register(obj.id, true);
			vBmenu.menus[obj.id].open_steps = 5;

			obj.editorid = this.editorid;
			obj.state = false;
			this.buttons[obj.cmd] = obj;
			var option, div;

            if (obj.cmd == 'shorts')
			{
				this.shortout = fetch_object(this.editorid + '_short_out');
				this.shortout.innerHTML = obj.title;
				this.shortoptions = {'' : this.shortout};

				for (option in shortoptions)
				{
    				div = document.createElement('div');
    				div.id = this.editorid + '_shortoption_' + shortoptions[option];
    				div.style.width = this.shortout.style.width;
    				div.style.display = 'none';
    				div.innerHTML = shortoptions[option];
    				this.shortoptions[shortoptions[option]] = this.shortout.parentNode.appendChild(div);
				}
			}

			obj._onmouseover = obj.onmouseover;
			obj._onclick = obj.onclick;
			obj.onmouseover = obj.onmouseout = obj.onclick = vB_Text_Editor_Events.prototype.popup_button_onmouseevent ;
			vBmenu.menus[obj.id]._show = vBmenu.menus[obj.id].show;
			vBmenu.menus[obj.id].show = bdr130_button_show;
		}
		else
		{
			this.bdr130_build_select(obj);
		}
	}
    bdr130_button_show = function(obj, instant)
    {
    	var show = true;
    	if (typeof vB_Editor[obj.editorid].popups[obj.cmd] == 'undefined' || vB_Editor[obj.editorid].popups[obj.cmd] == null)
    	{
    		show = vB_Editor[obj.editorid].init_shorts_menu(obj);
    	}

    	if (show)
    	{
    		this._show(obj, instant);
    	}
    }
	vB_Text_Editor.prototype.bdr130_build_select = function(obj)
	{
		var sel = document.createElement('select');
		sel.id = this.editorid + '_select_' + obj.cmd;
		sel.editorid = this.editorid;
		sel.cmd = obj.cmd;

		var opt = document.createElement('option');
		opt.value = '';
		opt.text = obj.title;
		sel.add(opt, is_ie ? sel.options.length : null);

		opt = document.createElement('option');
		opt.value = '';
		opt.text = ' ';
		sel.add(opt, is_ie ? sel.options.length : null);

		var i;

		switch (obj.cmd)
		{
			case 'shorts':
			{
				for (i = 0; i < shortoptions.length; i++)
				{
					opt = document.createElement('option');
					opt.value = shortoptions[i];
					opt.text = (shortoptions[i].length > 10 ? (shortoptions[i].substr(0, 10) + '...') : shortoptions[i]);
					sel.add(opt, is_ie ? sel.options.length : null);
				}

				sel.onchange = bdr130_select_onchange;
				break;
			}

		}

		while (obj.hasChildNodes())
		{
			obj.removeChild(obj.firstChild);
		}

		this.buttons[obj.cmd] = obj.appendChild(sel);
	}
	vB_Text_Editor.prototype.init_shorts_menu = function(obj)
	{
		if (this.disabled)
		{
			return false;
		}
		var menu;
		switch (obj.cmd)
		{
			case 'shorts':
			{
				menu = this.bdr130_menu_container('shorts', '200px', '250px', 'auto');
				this.build_shorts_popup(obj, menu);
				break;
			}
		}

		this.popups[obj.cmd] = this.controlbar.appendChild(menu);
		set_unselectable(menu);

		return true;
	};
	vB_Text_Editor.prototype.bdr130_menu_container = function(cmd, width, height, overflow)
	{
		var menu = document.createElement('div');

		menu.id = this.editorid + '_popbdr_' + cmd + '_menu';
		menu.className = 'vbmenu_popup';
		menu.style.display = 'none';
		menu.style.cursor = 'default';
		menu.style.padding = '3px';
		menu.style.width = width;
		menu.style.height = height;
		menu.style.overflow = overflow;

		return menu;
	}
      	vB_Text_Editor.prototype.build_shorts_popup = function(obj, menu)
      	{
      		for (var n in shortoptions)
      		{
  				var option = document.createElement('div');
                option.innerHTML = '<font style="font-size: 11px">'+(shortoptions[n].length > 10 ? (shortoptions[n].substr(0, 25) + '...') : shortoptions[n])+'</size>';
  				option.className = 'ofont';
  				option.style.textAlign = 'right';
  				option.title = shortoptions[n];
  				option.cmd = obj.cmd;
  				option.controlkey = obj.id;
  				option.editorid = this.editorid;
  				option.onmouseover = option.onmouseout = option.onmouseup = option.onmousedown = vB_Text_Editor_Events.prototype.menuoption_onmouseevent;
  				option.onclick = bdr130_option_onclick;
  				menu.appendChild(option);
      		}
      	}
function showKeyboard() {
    var buttons = new Array("!","||","(",")","[","]","™","©","®","^","¸",".","•","«","§","ô","¤","*","~","+","=","_","»","؟","×",",","-","÷","¨","%","?","ّ","$","#","@","}","{","ْ"," "," "," ","ـ","،","؛","؟");
    addKeys(buttons);
}
