/*############################################################################
  #                         محرر الفهدي لمنتديات phpbb                         #
  #                           AL-Fahadi BB-Editor                            #
  #                                                                          #
  # رقم الإصدار : 1.0                                                         #
  # تاريخ الإصدار : 1/10/2005م                                                #
  # المبرمج : فهد محمد مسعد علي سنان الزبيدي                                    #
  # البريد الإلكتروني : FahadMM7@hotmail.com                                    #
  #              كل الحقوق محفوظة له ولموقع المجموعة "حلم التصميم"                #
  #                     الموقع : http://www.desdream.com                      #
  #       موقع الدعم لمنتديات الـ بي بي : http://www.phpbbdream.com           #
  ############################################################################
  # ملاحظة : لا تحاول أن تتعبث بهذا الملف ، فقد تتلف الهاك                         #
  ############################################################################*/

temp = new Array();
undo = null;
redo = 0;

function mouseover(obj)
{ obj.style.background = "none";
  obj.style.borderWidth = "1px";
  obj.style.borderStyle = "solid";
  obj.style.borderColor = "#000080";
  obj.style.backgroundColor = "#FFB25C";
}

function mouseout(obj)
{ obj.style.background = "none";
  obj.style.border = "none";
  obj.style.backgroundImage = "url(images/toolbar.bg.gif)";
  document.post.helpspace.value = "شريط المعلومات";
}

function FEabout()
{ retVal = showModalDialog("dialogs/aboutFE.htm","","help:no; center:yes; status:no; dialogHeight:282px; dialogWidth:306px");
}

function FontTyp(name)
{ var code = '<select onChange="FESelectFont(this);" size="1" name="'+ name +'" style="font-family: Tahoma; font-size: 8pt">';
      code += '<option>أختر نوع الخط</option>';
      for(i=0;i<FontsType.length;i++)
      code += '<option value="'+FontsType[i]+'">'+FontsType[i]+'</option>';
      code += '</select>';
      
  return code;
}

function FontSiz(name)
{ var code = '<select onChange="FESelectFontSize(this);" size="1" name="'+ name +'" style="font-family: Tahoma; font-size: 8pt">';
      code += '<option>حجم الخط</option>';
      for(i=0;i<FontSize.length;i++)
      code += '<option value="'+FontSize[i]+'">'+FontSize[i]+'</option>';
      code += '</select>';
      
  return code;
}

function Abbrev(name)
{ var code = '<select onChange="FEInsAbbrev(this);" size="1" name="'+ name +'" style="font-family: Tahoma; font-size: 8pt">';
      code += '<option>اختصارات</option>';
      for(i=0;i<Abbreviations.length;i++)
      code += '<option value="'+Abbreviations[i]+'">'+AbbreviationsName[i]+'</option>';
      code += '</select>';
      
  return code;
}

function Deco(name)
{ var code = '<select onChange="FEInsDeco(this);" size="1" name="'+ name +'" style="font-family: Tahoma; font-size: 8pt">';
      code += '<option>زخارف</option>';
      for(i=0;i<Decos.length;i++)
      code += '<option value="'+Decos[i]+'">'+Decos[i]+'</option>';
      code += '</select>';
      
  return code;
}

function ShowHelpSen(num)
{ document.post.helpspace.value = helpsent[num];
}

function ShowLength(text)
{  document.post.numofchar.value = text.value.length;
}

function ShowError(num)
{ retVal = showModalDialog("dialogs/Massege"+num+".htm","","help:no; center:yes; status:no; dialogHeight:184px; dialogWidth:306px");
}

function FEClearAll()
{ document.post.message.value = '';
  document.post.message.focus();
}

function FEPaste()
{  
var oSelect,oSelectRange;
   if(!window.clipboardData.getData("Text")) ShowError(4);
   else
   {   document.post.message.focus();
       oSelect = document.selection.createRange().execCommand("paste");
   }
}

function FECopy()
{ Select = document.selection.createRange().text;
  if (Select != '') document.execCommand('Copy');
  else if (document.post.message.value.length != 0)
  { text = document.post.message.createTextRange(); 
    text.execCommand("RemoveFormat"); 
    text.execCommand("Copy");
    ShowError(2);
  }
  else ShowError(1);
}

function FECut()
{ Select = document.selection.createRange().text;
  if (Select != '') document.execCommand('Cut');
  else if (document.post.message.value.length != 0)
  { text = document.post.message.createTextRange(); 
    text.execCommand("RemoveFormat"); 
    text.execCommand("Cut");
    ShowError(3);
  }
  else ShowError(1);
}

function FEdir(dir)
{  document.post.message.focus();
   document.post.message.dir = dir;
}

function FEInsertDate()  
{  var d = new Date(); 
   document.post.message.focus();
   document.selection.createRange().text = d.toLocaleDateString();
}

function FEInsertTime()  
{  var d = new Date();
   document.post.message.focus();
   document.selection.createRange().text = d.toLocaleTimeString();
}

function FEEnglish()
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   if (theSelection != '') 
   {  document.selection.createRange().text = "[en]" + theSelection + "[/en]";
      document.post.message.focus();
   }
   else ShowError(1);
}

function FEPlain()
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   if (theSelection != '') 
   {  temp = theSelection;
      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");
      document.selection.createRange().text = temp.replace(/\[[^\]]*\]/gi,"");
      document.post.message.focus();
   }
   else ShowError(1);
}

function FESub()
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   if (theSelection != '') 
   {  document.selection.createRange().text = "[mon]" + theSelection + "[/mon]";
      document.post.message.focus();
   }
   else ShowError(1);
}

function FESup()
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   if (theSelection != '') 
   {  document.selection.createRange().text = "[mor]" + theSelection + "[/mor]";
      document.post.message.focus();
   }
   else ShowError(1);
}

function FETab()
{  document.post.message.focus();
   document.selection.createRange().text = "[tab]";
}

function FEHr()
{  document.post.message.focus();
   document.selection.createRange().text = "[hr]";
}

function FETable()
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   if (theSelection != '') 
   {  document.selection.createRange().text = "[table]" + theSelection + "[/table]";
      document.post.message.focus();
   }
   else ShowError(1);
}

function FEAlign(align)
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   if (theSelection != '') 
   {  document.selection.createRange().text = "[align=" + align + "]" + theSelection + "[/align]";
      document.post.message.focus();
   }
   else ShowError(1);
}

function FEFontStyle(st)
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   if (theSelection != '') 
   {  document.selection.createRange().text = "["+st+"]" + theSelection + "[/"+st+"]";
      document.post.message.focus();
   }
   else ShowError(1);
}

function FEHide()
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   if (theSelection != '') 
   {  document.selection.createRange().text = "[hide]" + theSelection + "[/hide]";
      document.post.message.focus();
   }
   else ShowError(1);
}

function FEQuote()
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   if (theSelection != '') 
   {  document.selection.createRange().text = "[quote]" + theSelection + "[/quote]";
      document.post.message.focus();
   }
   else ShowError(1);
}

function FECode()
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   if (theSelection != '') 
   {  document.selection.createRange().text = "[code]" + theSelection + "[/code]";
      document.post.message.focus();
   }
   else ShowError(1);
}

function FEPHP()
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   if (theSelection != '') 
   {  document.selection.createRange().text = "[php]" + theSelection + "[/php]";
      document.post.message.focus();
   }
   else ShowError(1);
}

function FEGoogle()
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   if (theSelection != '') 
   {  document.selection.createRange().text = "[google]" + theSelection + "[/google]";
      document.post.message.focus();
   }
   else ShowError(1);
}

function FEForum()
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   if (theSelection != '') 
   {  document.selection.createRange().text = "[nj3]" + theSelection + "[/nj3]";
      document.post.message.focus();
   }
   else ShowError(1);
}

function FEUser()
{  document.post.message.focus();
   document.selection.createRange().text = "[username]";
}

function FEMog(dir)
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   if (theSelection != '') 
   {  document.selection.createRange().text = "[moj="+dir+"]" + theSelection + "[/moj]";
      document.post.message.focus();
   }
   else ShowError(1);
}

function FEGB()
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   if (theSelection != '') 
   {  document.selection.createRange().text = "[gb]" + theSelection + "[/gb]";
      document.post.message.focus();
   }
   else ShowError(1);
}

function FEMarq(dir)
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   if (theSelection != '') 
   {  document.selection.createRange().text = "[marq="+dir+"]" + theSelection + "[/marq]";
      document.post.message.focus();
   }
   else ShowError(1);
}

function FEFormat(format)
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   if (theSelection != '') 
   {  document.selection.createRange().text = "["+format+"]" + theSelection + "[/"+format+"]";
      document.post.message.focus();
   }
   else ShowError(1);
}

function FEColor(type)
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   if (theSelection != '') 
   {  retVal = showModalDialog("dialogs/colors.htm","","help:no; center:yes; status:no; dialogHeight:224px; dialogWidth:250px");
      if(!retVal) return;
      document.selection.createRange().text = "["+type+"="+retVal+"]" + theSelection + "[/"+type+"]";
      document.post.message.focus();
   }
   else ShowError(1);
}

function FESelectFont(selector)
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   if (theSelection != '') 
   {  retVal = selector.value;
      selector.selectedIndex=0;
      document.selection.createRange().text = "[font="+retVal+"]" + theSelection + "[/font]";
      document.post.message.focus();
   }
   else 
   { selector.selectedIndex=0;
     ShowError(1);
   }
}

function FESelectFontSize(selector)
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   if (theSelection != '') 
   {  retVal = selector.value;
      selector.selectedIndex=0;
      document.selection.createRange().text = "[size="+retVal+"]" + theSelection + "[/size]";
      document.post.message.focus();
   }
   else 
   { selector.selectedIndex=0;
     ShowError(1);
   }
}

function FEInsAbbrev(selector)
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   retVal = selector.value;
   selector.selectedIndex=0;
   document.selection.createRange().text = retVal;
   document.post.message.focus();
}

function FEInsDeco(selector)
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   if (theSelection != '') 
   {  retVal = selector.value;
      selector.selectedIndex=0;
      document.selection.createRange().text = retVal + theSelection + retVal;
      document.post.message.focus();
   }
   else 
   { selector.selectedIndex=0;
     ShowError(1);
   }
}

function FEUniKey()
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   retVal = showModalDialog("dialogs/universalkey.htm","","help:no; center:yes; status:no; dialogHeight:318px; dialogWidth:410px");
   if(!retVal) return;
   document.selection.createRange().text = retVal;
   document.post.message.focus();
}

function FESpecialChar()
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   retVal = showModalDialog("dialogs/specialchar.htm","","help:no; center:yes; status:no; dialogHeight:253px; dialogWidth:406px");
   if(!retVal) return;
   document.selection.createRange().text = "[font=Symbol]" + retVal + "[/font]";
   document.post.message.focus();
}

function FEPoet()
{  document.post.message.focus();
   var oSelTex = document.selection.createRange();
   theSelection = document.selection.createRange().text;
   if (theSelection != '') 
   {  retVal = showModalDialog("dialogs/hackpoet.htm",oSelTex,"help:no; center:yes; status:no; dialogHeight:350px; dialogWidth:440px");
   }
   else ShowError(1);
}

function FEImage()
{  document.post.message.focus();
   var URL = prompt("أدخل رابط الصورة","http://");
   if(!URL) ShowError(5);
   else document.selection.createRange().text = "[img]" + URL + "[/img]"; 
}

function FESound()
{  document.post.message.focus();
   var URL = prompt("أدخل رابط الملف الصوتي","http://");
   if(!URL) ShowError(5);
   else document.selection.createRange().text = "[stream]" + URL + "[/stream]"; 
}

function FERPlay()
{  document.post.message.focus();
   var URL = prompt("أدخل رابط ملف الـReal Player","http://");
   if(!URL) ShowError(5);
   else document.selection.createRange().text = "[ram]" + URL + "[/ram]"; 
}

function FEVedio()
{  document.post.message.focus();
   var URL = prompt("أدخل رابط الملف الصوتي","http://");
   if(!URL){ ShowError(5); return; }
   var width = prompt("أدخل عرض الصورة بوحدة البكسل","400");
   if(!width){ ShowError(5); return; }
   var height = prompt("أدخل طول الصورة بوحدة البكسل","350");
   if(!height){ ShowError(5); return; }
   else document.selection.createRange().text = "[video width="+width+" height="+height+"]" + URL + "[/video]"; 
}

function FEFlash()
{  document.post.message.focus();
   var URL = prompt("أدخل رابط الملف الفلاشي","http://");
   if(!URL){ ShowError(5); return; }
   var width = prompt("أدخل عرض الصورة بوحدة البكسل","400");
   if(!width){ ShowError(5); return; }
   var height = prompt("أدخل طول الصورة بوحدة البكسل","350");
   if(!height){ ShowError(5); return; }
   else document.selection.createRange().text = "[flash width="+width+" height="+height+"]" + URL + "[/flash]"; 
}

function FEList()
{  document.post.message.focus();
   listtype = prompt("إختر نوع القائمة\n  أضغط مفتاح الإدخال للقائمة العادية أو رقم 1 للقائمة المرقمة", "");
	if ((listtype == "a") || (listtype == "1")) {
		thelist = "[list="+listtype+"]\n";
		listend = "[/list] ";
		}
	else {
		thelist = "[list]\n";
		listend = "[/list] ";
		}
	listentry = "initial";
	while ((listentry != "") && (listentry != null)) {
		listentry = prompt("أدخل محتويات القائمة \n عند الإنتهاء إضغط مفتاح الإدخال للخروج من هذا الإختيار", "");
		if ((listentry != "") && (listentry != null))
			thelist = thelist+"[*]"+listentry+"\n";
		}
	document.selection.createRange().text = thelist+listend;
}

function FESmiles()
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   retVal = showModalDialog("dialogs/Smiles.htm","","help:no; center:yes; status:no; dialogHeight:422px; dialogWidth:510px");
   if(!retVal) return;
   document.selection.createRange().text = "[simg]" + retVal + ".gif[/simg]";
   document.post.message.focus();
}

function FEEmail()
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   var entermail   = prompt("أكتب البريد الألكتروني","");
   if (!entermail) 
   {  ShowError(5); 
      return;
   }
   var ToAdd = "[email]"+entermail+"[/email]";
   document.selection.createRange().text = ToAdd;
   document.post.message.focus();
}

function FEWebPage()
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   var enterweb   = prompt("أكتب رابط الصفحة","http://");
   if (!enterweb) 
   {  ShowError(5); 
      return;
   }
   var ToAdd = "[web]"+enterweb+"[/web]";
   document.selection.createRange().text = ToAdd;
   document.post.message.focus();
}

function FEELink()
{  document.post.message.focus();
   theSelection = document.selection.createRange().text;
   if ( theSelection != '')
   {  var enterURL   = prompt("أدخل رابط الموقع", "http://");
      if (!enterURL) 
      {  ShowError(5); 
         return;
      }
      var ToAdd = "[url="+enterURL+"]"+theSelection+"[/url]";
      document.selection.createRange().text = ToAdd;
      document.post.message.focus();
   }
   else
   {  var enterURL   = prompt("أدخل رابط الموقع", "http://");
      if (!enterURL) 
      {  ShowError(5); 
         return;
      }
      var enterTitle   = prompt("أدخل عنوان الموقع", "");
      if (!enterTitle) 
      {  ShowError(5); 
         return;
      }
      var ToAdd = "[url="+enterURL+"]"+enterTitle+"[/url]";
      document.selection.createRange().text = ToAdd;
      document.post.message.focus();
   }
}

function FEgrad()
{   var oSelect,oSelectRange;
    document.post.message.focus();
    oSelect = document.selection;
    oSelectRange = oSelect.createRange();
    if (oSelectRange.text.length < 1) { ShowError(1);
return;
}
    if (oSelectRange.text.length > 120) {
      alert("تدرج الألوان يعمل فقط لأقل من 120 حرف");
      return;
    }
    showModalDialog("dialogs/gradient.htm",oSelectRange,"help:no; center:yes; status:no; dialogHeight:50px; dialogWidth:50px");
}

function FEPush()
{  temp.push(document.post.message.value);
   undo = null;
   redo = 0;
}

function FEUndo()
{  if(undo == null)
   { if(temp.length > 0)
     {  undo = temp.length;
        document.post.message.value = temp[--undo];
        document.post.message.focus();
     }
     else alert("لم تكن هناك عملية للتراجع عنها ..!!!");
   }
   else
   {  if(undo-- > 0)
      {  document.post.message.value = temp[undo];
         document.post.message.focus();
      }
      else alert("لقد انتهت عملية التراجع");
   }
}

function FERedo()
{  if(undo != null)
   { redo += undo;
     if (++redo < temp.length)
     {  document.post.message.value = temp[redo];
        document.post.message.focus();
     }
     else alert("لقد انتهت عملية التقدم");
   }
   else alert("لا يمكنك إجراء هذا الحدث ..!!!\nما لم تقم بأية عملية تراجع");
}
        