
function Editor_getSelText() {
    var oSelect,oSelectRange;
    document.Forum.SubjectText.focus();
    oSelect = document.selection;
    oSelectRange = oSelect.createRange();
    return oSelectRange;
}
function BBCdir(dirc) {
       Forum.SubjectText.dir=(dirc);
}
function BBClight() {
      var oSelText = Editor_getSelText();
     if (oSelText.text == "")
        alert("يرجى تظليل النص أولاً");
else
             if (oSelText != '') {
 light = showModalDialog("colors.htm","help:no;  resizable: no; scroll: no; status:no; dialogHeight:100px; dialogWidth:150px");

                oSelText.text = "[light=#" + light + "]" + oSelText.text + "[/light]";

		Forum.SubjectText.focus();

        }
    }
    function BBCcolor() {
      var oSelText = Editor_getSelText();
     if (oSelText.text == "")
        alert("يرجى تظليل النص أولاً");
else
              if (oSelText != '') {
      c = showModalDialog("colors.htm","help:no;  resizable: no; scroll: no; status:no; dialogHeight:100px; dialogWidth:150px");

                oSelText.text = "[color=#" + c + "]" + oSelText.text + "[/color]";

		Forum.SubjectText.focus();

        }
}
function Text(){
	var oSelText = Editor_getSelText();

      showModalDialog("format.htm",oSelText,"help:no; center:yes; status:no; dialogHeight:50px; dialogWidth:50px");
}

function BBCgrad() {
  var oSelText = Editor_getSelText();

     if (oSelText.text == "") { alert("يرجى تظليل النص أولاً!!");
return;
}
    if (oSelText.text.length > 120) {
      alert("تدرج الألوان يعمل فقط لأقل من 120 حرف");
      return;
    }
    showModalDialog("gradient.htm",oSelText,"help:no; center:yes; status:no; dialogHeight:50px; dialogWidth:50px");
}

function Code(C)
{
var oSelText = Editor_getSelText();
	if (C==1)
	{
     if (oSelText.text == "")
        alert("يرجى تظليل النص أولا");
else
oSelText.text =  "[B]"+ oSelText.text +"[/B]";

		Forum.SubjectText.focus();

	}

 	if (C==054)
	{
var oSelText = Editor_getSelText();

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,"");

}
	if (C==2)
	{
      if (oSelText.text == "")
        alert("يرجى تظليل النص أولا");
else
oSelText.text =  "[I]"+ oSelText.text +"[/I]";

		Forum.SubjectText.focus();

	}
	if (C==3)
	{
     if (oSelText.text == "")
        alert("يرجى تظليل النص أولا");
else
oSelText.text =  "[U]"+ oSelText.text +"[/U]";

		Forum.SubjectText.focus();

	}
	if (C==4)
	{
     if (oSelText.text == "")
        alert("يرجى تظليل النص أولا");
else
oSelText.text =  "[CENTER]"+ oSelText.text +"[/CENTER]";

		Forum.SubjectText.focus();

	}
	if (C==5)
	{
     if (oSelText.text == "")
        alert("يرجى تظليل النص أولا");
else
oSelText.text =  "[CODE]"+ oSelText.text +"[/CODE]";

		Forum.SubjectText.focus();

	}
 	if (C==6)
	{
      if (oSelText.text == "")
        alert("يرجى تظليل النص أولا");
else
oSelText.text =  "[RIGHT]"+ oSelText.text +"[/RIGHT]";

		Forum.SubjectText.focus();

	}
 	if (C==7)
	{
      if (oSelText.text == "")
        alert("يرجى تظليل النص أولا");
else
oSelText.text =  "[LEFT]"+ oSelText.text +"[/LEFT]";

		Forum.SubjectText.focus();

	}
 	if (C==8)
	{
      if (oSelText.text == "")
        alert("يرجى تظليل النص أولا");
else
oSelText.text =  "[justify]"+ oSelText.text +"[/justify]";

		Forum.SubjectText.focus();

	}

	if (C==9)
	{
      if (oSelText.text == "")
        alert("يرجى تظليل النص أولا");
else
oSelText.text =  "[gl]"+ oSelText.text +"[/gl]";

		Forum.SubjectText.focus();

	}
 	if (C==10)
	{
      if (oSelText.text == "")
        alert("يرجى تظليل النص أولا");
else
oSelText.text =  "[shadow]"+ oSelText.text +"[/shadow]";

		Forum.SubjectText.focus();

	}
 	if (C==11)
	{
      if (oSelText.text == "")
        alert("يرجى تظليل النص أولا");
else
oSelText.text =  "[gold]"+ oSelText.text +"[/gold]";

		Forum.SubjectText.focus();

	}
	if (C==12)
	{
	var X = prompt("إدخل النص","")
	if (X!="" & X!=null)
		{
		Forum.SubjectText.value=Forum.SubjectText.value + "[msg2]"+ X +"[/msg2]";
		}
	}
	if (C==13)
	{
	var X = prompt("إدخل النص","")
	if (X!="" & X!=null)
		{
		Forum.SubjectText.value=Forum.SubjectText.value + "[msg1]"+ X +"[/msg1]";
		}
	}
 	if (C==14)
	{
      if (oSelText.text == "")
        alert("يرجى تظليل النص أولا");
else
oSelText.text =  "[text_u_d]"+ oSelText.text +"[/text_u_d]";

		Forum.SubjectText.focus();

	}
 	if (C==15)
	{
      if (oSelText.text == "")
        alert("يرجى تظليل النص أولا");
else
oSelText.text =  "[wavD]"+ oSelText.text +"[/wavD]";

		Forum.SubjectText.focus();

	}
  	if (C==16)
	{
      if (oSelText.text == "")
        alert("يرجى تظليل النص أولا");
else
oSelText.text =  "[wavU]"+ oSelText.text +"[/wavU]";

		Forum.SubjectText.focus();

	}
	if (C==17)
	{

		Forum.SubjectText.value=Forum.SubjectText.value + "[line]";

	}
  	if (C==18)
	{
      if (oSelText.text == "")
        alert("يرجى تظليل النص أولا");
else
oSelText.text =  "[page]"+ oSelText.text +"[/page]";

		Forum.SubjectText.focus();

	}
	if (C==19)
	{
      if (oSelText.text == "")
        alert("يرجى تظليل النص أولاً، مع مراعاة وضع إشارة المساواة بين كل شطرين، كما يجب عليك وضع كل بيت واحد في كود منفصل");
else
alert("تأكد من أنك وضعت كل بيت واحد في كود منفصل، وأنك فصلت بين كل شطرين بعلامة المساواة");
oSelText.text =  "[poem]"+ oSelText.text +"[/poem]";

		Forum.SubjectText.focus();

	}
}



function Fonts()
{
var FontSize=document.Forum.FontsList.options.selectedIndex;
 if (FontSize==0) {return;}
 var oSelText = Editor_getSelText();
Forum.FontsList.value = "0"

    if (oSelText.text == "")
        alert("يرجى تظليل النص أولا");
else
oSelText.text =  "[SIZE="+FontSize+"]"+ oSelText.text + "[/SIZE]";

		Forum.SubjectText.focus();

}

function FontsNames()
{
var FontName=Forum.FontNamesList.value
if (FontName=="") {return;}
 var oSelText = Editor_getSelText();
 Forum.FontNamesList.value = "0"

     if (oSelText.text == "")
     
        alert("يرجى تظليل النص أولا");
else
oSelText.text =  "[FONT="+FontName+"]" + oSelText.text + "[/FONT]";

		Forum.SubjectText.focus();

}

function Shorts()
{
var Short=Forum.Short.value
 if (Short==0) {return;}
  Forum.Short.value = "0"
		Forum.SubjectText.value=Forum.SubjectText.value + Short ;
		Forum.SubjectText.focus();

}

function UrlCode()
{
 var oSelText = Editor_getSelText();

     if (oSelText.text == "")

        alert("يرجى كتابة الرابط أولاً ثم تظليله");
else

	var N = prompt("أدخل اسم الموقع ( اختياري)","")

	if (oSelText.text=="" | oSelText.text==null | oSelText.text=='http://') {return;}

	if(oSelText.text.substr(0,4)!="http")
	{
	alert("برجاء إدخال مسار الموقع بطريقة صحيحة \n http://Url");
	Forum.SubjectText.focus();
	return;
	}

	if (N=="" | N==null)
	{
	oSelText.text="[url]"+oSelText.text+"[/url]";
	Forum.SubjectText.focus();
	}
	else
	{
	oSelText.text = "[URL="+oSelText.text+"]"+N+"[/URL]";
	Forum.SubjectText.focus();
	}

}


function ImgCode()
	{
      var oSelText = Editor_getSelText();
     if (oSelText.text == "")
        alert("يرجى تظليل رابط الصورة أولاً");
else
oSelText.text =  "[IMG]"+ oSelText.text +"[/IMG]";

		Forum.SubjectText.focus();

	}

function RamCode()
	{
      var oSelText = Editor_getSelText();
     if (oSelText.text == "")
        alert("يرجى تظليل رابط الملف أولاً");
else
oSelText.text =  "[RAM]"+ oSelText.text +"[/RAM]";

		Forum.SubjectText.focus();

	}


function MidiCode()
	{
      var oSelText = Editor_getSelText();
     if (oSelText.text == "")
        alert("يرجى تظليل رابط الملف أولاً");
else
oSelText.text =  "[midi]"+ oSelText.text +"[/midi]";

		Forum.SubjectText.focus();

	}


function FlashCode()
{
	var X = prompt("إدخل رابط الفلاش","http://")
	if (X!="" & X!=null)
		{
		var W = prompt("إدخل عرض ملف الفلاش (إختيارى(","")
		var H = prompt("إدخل إرتفاع ملف الفلاش (إختيارى(","")

		if (W>580) {W=580};
		if (H>580) {H=580};

			if ((W=="" | W==null) & (H=="" | H==null))
			{
			Forum.SubjectText.value=Forum.SubjectText.value + "[swf="+X+"[/swf]";
			Forum.SubjectText.focus();
			return;
			}

			if ((W!="" | W!=null) & (H=="" | H==null))
			{
			Forum.SubjectText.value=Forum.SubjectText.value + "[swf="+X+"'"+" width='"+W+"[/swf]";
			Forum.SubjectText.focus();
			return;
			}

			if ((W=="" | W==null) & (H!="" | H!=null))
			{
			Forum.SubjectText.value=Forum.SubjectText.value + "[swf="+X+"'"+" height='"+H+"[/swf]";
			Forum.SubjectText.focus();
			return;
			}

			if ((W!="" | W!=null) & (H!="" | H!=null))
			{
			Forum.SubjectText.value=Forum.SubjectText.value + "[swf="+X+"'"+" width="+W+" height='"+H+"[/swf]";
			Forum.SubjectText.focus();
			return;
			}

		}

}

function MarqueeRight()
	{
      var oSelText = Editor_getSelText();
     if (oSelText.text == "")
        alert("يرجى تظليل النص أولاً");
else
oSelText.text =  "[MARQUEE-R]"+ oSelText.text +"[/MARQUEE]";

		Forum.SubjectText.focus();

	}



function MarqueeLeft()
	{
      var oSelText = Editor_getSelText();
     if (oSelText.text == "")
        alert("يرجى تظليل النص أولاً");
else
oSelText.text =  "[MARQUEE-L]"+ oSelText.text +"[/MARQUEE]";

		Forum.SubjectText.focus();

	}
 function MarqueeUp()
	{
      var oSelText = Editor_getSelText();
     if (oSelText.text == "")
        alert("يرجى تظليل النص أولاً");
else
oSelText.text =  "[MARQUEE-U]"+ oSelText.text +"[/MARQUEE]";

		Forum.SubjectText.focus();

	}
 function MarqueeDown()
	{
      var oSelText = Editor_getSelText();
     if (oSelText.text == "")
        alert("يرجى تظليل النص أولاً");
else
oSelText.text =  "[MARQUEE-D]"+ oSelText.text +"[/MARQUEE]";

		Forum.SubjectText.focus();

	}
  function isEmpty(str)
	{
	var i;
	var len;
	if( str == null )
	return true;

	len = str.length;
	for( var i=0; i<len; i++ )
   	{
	if( str.charAt(i) != ' ')
	return false;
	}
	return true;
	}
function button_over(eButton)
	{
	eButton.style.backgroundColor = "#B5BDD6";
	eButton.style.borderColor = "darkblue darkblue darkblue darkblue";
	}
function button_out(eButton)
	{
    eButton.style.backgroundColor = "";
	eButton.style.borderColor = "";
	}
function button_down(eButton)
	{
	eButton.style.backgroundColor = "#8494B5";
	eButton.style.borderColor = "darkblue darkblue darkblue darkblue";
	}
function button_up(eButton)
	{
	eButton.style.backgroundColor = "#B5BDD6";
	eButton.style.borderColor = "darkblue darkblue darkblue darkblue";
	eButton = null;
	}
function key(){
props=window.open('key.htm', 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=500, height=360');
}
function GoToFourm(FourmList) {
newPage = FourmList.options[FourmList.selectedIndex].value
if (newPage != "") { window.location.href = newPage }
}
function small(Url)
{
window.open (Url, "MyNewWindow", "toolbar=No, location=No, directories=no,status=no, menubar=no, scrollbars=yes, resizable=No,width=400,height=300,left=150,top=100");
}


