/*
function mymenu(id)
{
var target = document.getElementById('menu'+id);
if(target.style.display =='inline')
{
target.style.display = 'none';
}
else 
{

for (var i=1; i<=8; i++)
{
 //--------------------------
 // Close All Open Menu......
 var check = document.getElementById('menu'+i);
 if(check.style.display =='inline')	
 {
 check.style.display = 'none';
 }
 //--------------------------
 // Open Select Menu.........
 target.style.display = 'inline';
}

}

}
*/

function showmenu(id)
{
var target = document.getElementById('menu'+id);
target.style.display = 'inline';
}

//------------------------------------
function addBookmark(bookmarkurl, bookmarktitle)
        {
        if (document.all)
                window.external.AddFavorite(bookmarkurl,bookmarktitle)
        }

//------------------------------------
function trim(value) {
   var temp = value;
   var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
   if (obj.test(temp)) { temp = temp.replace(obj, '$2'); }
   var obj = /  /g;
   while (temp.match(obj)) { temp = temp.replace(obj, " "); }
   return temp;
}

function mywin(wi,hi,pages,nwin)
{
var w = wi;
var h=hi;
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=0,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no'
win = window.open( pages, nwin, winprops)
}

//------------------------------------
function submitSearchForm()
        {
        searchBox = frmSearch.txtKeyWord
        if (searchBox.value=="")
                alert ("الرجاء كتابة كلمة البحث")
        else if ((searchBox.value) == " ")
                alert ("الرجاء كتابة كلمة بحث كاملة")
        else if ((searchBox.value).length < 4)
                alert ("الرجاء كتابة كلمة بحث كاملة")
        else
                return true;
        searchBox.value="";
        searchBox.focus();
        return false;
        }
//------------------------------------
function srq()
        {
        searchBox = fserch.txtKeyWord
        if (searchBox.value=="")
                alert ("الرجاء كتابة كلمة البحث")
        else if ((searchBox.value) == "")
                alert ("الرجاء كتابة كلمة بحث كاملة")
        else if ((searchBox.value).length < 4)
                alert ("الرجاء كتابة كلمة بحث كاملة")
				
        else
                return true;
        searchBox.value="";
        searchBox.focus();
        return false;
		
        }
		
function clear(){
alert ("");
fserch.txtKeyWord.value="d";
}


//------------------------------------
function submitContactForm()
        {
        if (frmContact.txtName.value=="")
		    {
                alert ("!الرجاء كتابة الاسم");
				frmContact.txtName.focus();
				return false;
			}
        else if (frmContact.txtEmail.value=="")
		   {
                alert ("!الرجاء كتابة البريد الإلكتروني");
				frmContact.txtEmail.focus();
				return false;
		   }
		 else if (frmContact.txtEmail.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1)
		   {
                alert ("عفوًا لم تكتب بريدك الإلكتروني بشكل صحيح");
				frmContact.txtEmail.focus();
				return false;
		   }	
        else if (frmContact.txtComments.value=="")
		   {
                alert ("!الرجاء كتابة تعليقك");
				frmContact.txtComments.focus();
				return false;	
		   }
		else if (frmContact.txtactive.value=="")
		   {
                alert ("لم تكتب شفرة التدقيق!");
				frmContact.txtactive.focus();
				return false;	
		   }
	
         return true;
        }

//------------------------------------
function submitListForm()
        {
        emailBox = frmList.txtEmail
        eMail = document.frmList.txtEmail.value;

        if (eMail == "")
                alert ("! الرجاء كتابة بريدك الإلكتروني");
        else if (eMail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1)
                alert ("! الرجاء التأكد من البريد الإلكتروني");
        else
                return true;

        emailBox.value="";
        emailBox.focus();
        return false;
        }


//------------------------------------
function submitListForm2()
        {
        emailBox = frmList.txtEmail
        eMail = document.frmList.txtEmail.value;

        if (eMail == "")
                alert ("! الرجاء كتابة البريد الإلكتروني");
        else if (eMail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1)
                alert ("! الرجاء التأكد من البريد الإلكتروني");
        else if ( frmList.txtCat.options(frmList.txtCat.selectedIndex).value>1 && document.frmList.txtName.value=="" )
                alert ("! الرجاء كتابة اسم الطالب/الطالبة")
        else
                return true;

        return false;
        }

//------------------------------------
function submitBannerForm()
        {
        if (document.frmBanner.txtName.value=="")
                alert ("الرجاء كتابة اسم الاعلان")
        else if (document.frmBanner.txtSrc.value=="")
                alert ("الرجاء ذكر ملف الإعلان")
        else
                return true;
        return false;
        }

//------------------------------------
function delPost(postID, start)
        {
        response = confirm("هل تريد فعلاً حذف هذه المشاركة؟");
        if (response) window.location = "?id=" + postID + "?>&start=" + start + "&action=del"
        }

//------------------------------------
function delBanner(bnrID)
        {
        response = confirm("هل تريد فعلاً حذف هذا الإعلان؟");
        if (response) window.location = "?action=del&bannerID=" + bnrID
        }

//------------------------------------
function delHekma(hekmaID)
        {
        response = confirm("هل تريد فعلاً حذف هذه الحكمة؟");
        if (response) window.location = "?action=del&hekmaID=" + hekmaID
        }

//------------------------------------
function submitDuaaForm()
        {
        if (document.frmDuaa.txtSat.value=="")
                alert ("الرجاء كتابة دعاء يوم السبت");
        else if (document.frmDuaa.txtSun.value=="")
                alert ("الرجاء كتابة دعاء يوم الأحد");
        else if (document.frmDuaa.txtMon.value=="")
                alert ("الرجاء كتابة دعاء يوم الاثنين");
        else if (document.frmDuaa.txtTue.value=="")
                alert ("الرجاء كتابة دعاء يوم الثلاثاء");
        else if (document.frmDuaa.txtWed.value=="")
                alert ("الرجاء كتابة دعاء يوم الأربعاء");
        else if (document.frmDuaa.txtThu.value=="")
                alert ("الرجاء كتابة دعاء يوم الحميس");
        else if (document.frmDuaa.txtFri.value=="")
                alert ("الرجاء كتابة دعاء يوم الجمعة");
        else
                return true;
        return false;
        }

//------------------------------------
function submitHekmaForm()
        {
        if (document.frmHekma.txtBody.value=="")
                alert ("الرجاء كتابة نص الحكمة");
        else
                return true;
        return false;
        }

//------------------------------------
function submitQMainCat()
        {
        if (frmQMain.txtNameMain.value=="")
                alert ("!الرجاء كتابة اسم التصنيف")
        else
                return true;
        return false;
        }

//------------------------------------
function submitQSubCat()
        {
        if (frmQSub.txtNameSub.value=="")
                alert ("!الرجاء كتابة اسم التصنيف")
        else if (frmQSub.txtSubCat.value=="0")
                alert ("!الرجاء اختيار التصنيف الرئيسي")
        else
                return true;
        return false;
        }

//----------------------------------
function submitQSubDel()
        {
        if (frmQSub.txtCat2.value=="0")
                alert ("!الرجاء اختيار التصنيف الفرعي")
        else
                return true;
        return false;
        }


//------------------------------------
function goCat()
        {
        url = "?start=0&cat=" + frmCats.mainCats.options(frmCats.mainCats.selectedIndex).value;
        window.location = url;
        }

//------------------------------------
function goMediaCat()
        {
        url = "?start=0&cat=" + frmMediaCats.mainCats.options(frmMediaCats.mainCats.selectedIndex).value;
        window.location = url;
        }

//------------------------------------
function goBookCat()
        {
        url = "?start=0&cat=" + frmCats.txtCat.options(frmCats.txtCat.selectedIndex).value;
        window.location = url;
        }

//------------------------------------
function goBookCat2()
        {
        url = "?page=books&start=0&cat=" + frmCats.txtCat.options(frmCats.txtCat.selectedIndex).value;
        window.location = url;
        }

//------------------------------------
function submitMainCat()
        {
        if (frmMain.txtNameMain.value=="")
                alert ("!الرجاء كتابة اسم التصنيف")
        else
                return true;
        return false;
        }

//------------------------------------
function submitSubCat()
        {
        if (frmSub.txtNameSub.value=="")
                alert ("!الرجاء كتابة اسم التصنيف")
        else if (frmSub.txtSubCat.value=="0")
                alert ("!الرجاء اختيار التصنيف الفرعي")
        else
                return true;
        return false;
        }

//----------------------------------
function submitMainDel()
        {
        if (frmMain.txtCat2.value=="0")
                alert ("!الرجاء اختيار التصنيف")
        else
                return true;
        return false;
        }

//----------------------------------
function submitSubDel()
        {
        if (frmSub.txtCat2.value=="0")
                alert ("!الرجاء اختيار التصنيف الفرعي")
        else
                return true;
        return false;
        }

//------------------------------------
function submitLectureForm()
        {
        if (frmLecture.txtTitle.value=="")
                alert ("!الرجاء كتابة العنوان")
        else if (frmLecture.txtType.value=="0")
                alert ("!اختر القسم الفرعي المناسب")
        else if (frmLecture.txtEnDate.value=="")
                alert ("!الرجاء كتابة التاريخ الميلادي")
        else if (frmLecture.txtDetails.value=="")
                alert ("!الرجاء كتابة التفاصيل")
        else if (frmLecture.txtShow.status && frmLecture.txtSummary.value=="")
                alert ("!الرجاء كتابة الملخص إذا أردت عرض الموضوع في الواجهة")
        else
                return true;
        return false;
        }


//------------------------------------
function printThis(lecID)
        {
                var w = 550;
                var h=364;
                var winl = (screen.width - w) / 2;
                var wint = (screen.height - h) / 2;
                winurl = 'print.php?lecID=' + lecID
                winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=1,resizable=0'
                win = window.open(winurl, 'mywindow', winprops)
        }

//------------------------------------
function printq(qID)
        {
                var w = 550;
                var h=364;
                var winl = (screen.width - w) / 2;
                var wint = (screen.height - h) / 2;
                winurl = 'printq.php?qID=' + qID
                winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=1,resizable=0'
                win = window.open(winurl, 'mywindow', winprops)
        }

//------------------------------------
function submitMasaelForm()
        {
        if (frmMasael.txtName.value=="")
                alert ("!الرجاء كتابة الاسم");
        else if (frmMasael.txtEmail.value=="" || frmMasael.txtEmail.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1)
                alert ("الرجاء كتابة البريد الإلكتروني بشكل صحيح..!");
        else if (frmMasael.txtQuestion.value=="")
                alert ("!الرجاء كتابة نص السؤال");
        else if (frmMasael.txtMoqalad.value=="")
                alert ("!الرجاء ذكر اسم مرجع التقليد");
        else
                return true;
        return false;
        }

//------------------------------------
function submitAnswerForm()
        {
        if (frmAnswer.txtTitle.value=="")
                alert ("!الرجاء كتابة عنوان السؤال")
        else if (frmAnswer.txtQuestion.value=="")
                alert ("!الرجاء ذكر السؤال")
        else if (frmAnswer.txtAnswer.value=="")
                alert ("!الرجاء ذكر الجواب")
        else if (frmAnswer.txtType.value=="0")
                alert ("!الرجاء اختيار التصنيف المناسب")
        else
                return true;
        return false;
        }

//------------------------------------
function delQuestion(start, cat, id)
        {
        response = confirm("هل تريد فعلاً حذف هذه  المسألة ؟");
        if (response) window.location = '?start=' + start + '&cat=' + cat + '&action=del&qID=' + id
        }


//----------------------------------
function submitBookForm()
        {
        if (frmBook.txtName.value=="")
                alert ("!الرجاء كتابة اسم الكتاب")
        else if (frmBook.txtAuthor.value=="")
                alert ("!الرجاء ذكر اسم المؤلف")
        else if (frmBook.txtSrc.value=="")
                alert ("!الرجاء ذكر رابط الكتاب")
        else if (frmBook.txtCat.value=="")
                alert ("!الرجاء اختيار تصنيف الكتاب")
        else
                return true;
        return false;
        }

//------------------------------------
function delBook(id)
        {
        response = confirm("هل تريد فعلاً حذف هذا الكتاب؟");
        if (response) window.location = '?action=del&bookID=' + id
        }

//------------------------------------
function delTopic(id, start, cat)
        {
        response = confirm("هل تريد فعلاً حذف هذا الموضوع؟");
        if (response) window.location = '?action=del&id=' + id + '&start=' + start + '&cat=' + cat;
        }

//----------------------------------
function submitPubForm()
        {
        if (frmPub.txtName.value=="")
                alert ("!الرجاء كتابة اسم الإصدار")
        else if (frmPub.txtPhoto.value=="")
                alert ("!الرجاء ذكر ملف الإعلان")
        else
                return true;
        return false;
        }

//------------------------------------
function delPub(id)
        {
        response = confirm("هل تريد فعلاً حذف هذا الإصدار؟");
        if (response) window.location = '?action=del&pubID=' + id;
        }

//------------------------------------
function delMedia(id, start, cat)
        {
        response = confirm("هل تريد فعلاً حذف هذه المحاضرة/الدعاء؟");
        if (response) window.location = '?start=' + start + '&cat=' + cat + '&action=del&id=' + id;
        }


//------------------------------------
function delLesson(id)
        {
        response = confirm("هل تريد فعلاً حذف هذا الدرس؟");
        if (response) window.location = '?action=del&id=' + id;
        }


//----------------------------------
function submitMediaForm()
        {
        if (frmMedia.txtName.value=="")
                alert ("!الرجاء كتابة الاسم")
        else if (frmMedia.txtCat.value==0)
                alert ("!الرجاء اختيار التصنيف")
        else if (frmMedia.txtSrc.value=="")
                alert ("!الرجاء ذكر الملف")
        else if (frmMedia.txtLen.value=="")
                alert ("!الرجاء ذكر المدة")
        else
                return true;
        return false;
        }

//----------------------------------
function submitLessonForm()
        {
        if (frmLesson.txtName.value=="")
                alert ("!الرجاء كتابة الاسم")
        else if (frmLesson.txtCat.value==0)
                alert ("!الرجاء اختيار التصنيف")
        else if (frmLesson.txtSrc.value=="")
                alert ("!الرجاء ذكر الملف")
        else if (frmLesson.txtLen.value=="")
                alert ("!الرجاء ذكر المدة")
        else
                return true;
        return false;
        }


//------------------------------------
function delStatic(id)
        {
        response = confirm("هل تريد فعلاً حذف هذه الصفحة؟");
        if (response) window.location = '?action=del&stID=' + id;
        }

//----------------------------------
function submitStaticForm()
        {
        if (frmStatic.txtName.value=="")
                alert ("!الرجاء كتابة الاسم")
        else if (frmStatic.txtCdoe.value==0)
                alert ("!الرجاء كتابة الرمز")
        else if (frmStatic.txtBody.value=="")
                alert ("!الرجاء ذكر التفاصيل")
        else
                return true;
        return false;
        }

//------------------------------------
function delLink(id)
        {
        response = confirm("هل تريد فعلاً حذف هذا الرابط؟");
        if (response) window.location = '?action=del&linkID=' + id;
        }

//----------------------------------
function submitLinkForm()
        {
        if (frmLink.txtName.value=="")
                alert ("!الرجاء كتابة الاسم")
        else if (frmLink.txtURL.value==0)
                alert ("!الرجاء كتابة الرابط")
        else
                return true;
        return false;
        }

//------------------------------------
function goStoryCat()
        {
        url = "?page=story&start=0&cat=" + frmCats.txtCat.options(frmCats.txtCat.selectedIndex).value;
        window.location = url;
        }

//------------------------------------
function submitSendForm()
        {
        if (frmSend.txtFromName.value=="")
                alert ("!الرجاء كتابة اسمك")
        else if (frmSend.txtFromEmail.value=="")
                alert ("!الرجاء كتابة بريدك الإلكتروني")
		else if (frmSend.txtFromEmail.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1)
		   {
                alert ("عفوًا لم تكتب بريدك الإلكتروني بشكل صحيح");
				frmSend.txtFromEmail.focus();
				return false;
		   }
        else if (frmSend.txtToName.value=="")
                alert ("!الرجاء كتابة اسم صديقك")
        else if (frmSend.txtToEmail.value=="")
                alert ("!الرجاء كتابة بريد صديقك")
		else if (frmSend.txtToEmail.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1)
		   {
                alert ("عفوًا لم تكتب بريد صديقك الإلكتروني بشكل صحيح!");
				frmSend.txtToEmail.focus();
				return false;
		   }
        else
                return true;
        return false;
}


//------------------------------------
function printNew()
        {
                var w = 640;
                var h=364;
                var winl = (screen.width - w) / 2;
                var wint = (screen.height - h) / 2;
                winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=1,resizable=0'
                win = window.open('qprint.php', 'mywindow', winprops)
        }

//------------------------------------
function goQCat()
        {
        param = frmCats.subCats.options(frmCats.subCats.selectedIndex).value;

        if (param=="0")
                url = "?page=qlist&cat=3";

        else if (param == "-1")
                url = "";

        else
                {
                paramArray = param.split("-");
                mainCatID = paramArray[0];
                subCatID = paramArray[1];
                url = "?page=qlist&cat=" + mainCatID + "&scat=" + subCatID;
                }

        if (url!="") window.location = url;
        }

//------------------------------------
function goMonth()
        {
        url = "?month=" + frmMonth.txtMonth.options(frmMonth.txtMonth.selectedIndex).value;
        window.location = url;
        }

//------------------------------------
function goListCat()
        {
        url = "?start=0&cat=" + frmListCats.listCats.options(frmListCats.listCats.selectedIndex).value;
        window.location = url;
        }


//------------------------------------
function delUser(usrID, start, cat)
        {
        response = confirm("هل تريد فعلاً حذف هذا المشترك؟");
        if (response) window.location = "?id=" + usrID + "?>&start=" + start + "&action=del&cat=" + cat
        }

//------------------------------------
function selectAll()
        {
                if (document.frmMsg.chkAll.checked)
                        {
                                document.frmMsg.chkSub.checked = true;
                                document.frmMsg.chkMale.checked = true;
                                document.frmMsg.chkFemale.checked = true;
                        }
                else if (document.frmMsg.chkFemale.checked && document.frmMsg.chkMale.checked && document.frmMsg.chkSub.checked)
                                document.frmMsg.chkAll.checked = true;

        }

//------------------------------------
function deSelectAll(check)
        {
                        if (check.checked==false)
                                document.frmMsg.chkAll.checked = false;
                        else if (document.frmMsg.chkFemale.checked && document.frmMsg.chkMale.checked && document.frmMsg.chkSub.checked)
                                document.frmMsg.chkAll.checked = true;
        }

//------------------------------------
function submitMsgForm()
        {
                if (! (frmMsg.chkAll.checked || frmMsg.chkSub.checked || frmMsg.chkMale.checked || frmMsg.chkFemale.checked) )
                        alert ("! الرجاء اختيار الفئة التي تود الإرسال إليها");
                else if (frmMsg.txtTitle.value=="")
                        alert ("! الرجاء ذكر عنوان الرسالة");
                else if (frmMsg.txtDetails.value=="")
                        alert ("! الرجاء ذكر نص الرسالة");
                else
                        return true;
                return false;
        }

//------------------------------------
function delMsg(msgID, start)
        {
        response = confirm("هل تريد فعلاً حذف هذه الرسالة من الأرشيف؟");
        if (response) window.location = "?id=" + msgID + "?>&start=" + start + "&action=del"
        }

//------------------------------------
function submitImportForm()
        {
        if (frmImport.txtFile.value=='')
                {
                alert ("الرجاء تحديد الملف المراد تحميله");
                return false;
                }
        else
                return true;
        }
		
function testemail()
        {
        emailBox = FormElist.txtemail
        eMail = document.FormElist.txtemail.value;
		

        if (eMail == ""){
                alert ("عفوًا.. لم تقم بكتابة بريدك الإلكتروني");
				emailBox.value="";
        		emailBox.focus(); }
      /*  else if (
				 
		var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
		var regex = new RegExp(emailReg);
		if (!regex.test(document.FormElist.txtemail.value))
		{
			alert ("يجب إدخال بريد صحيح");
				emailBox.value="";
        		emailBox.focus(); 
			return false;
		}			 
			
				}*/
        else if (document.FormElist.txtactive.value==""){
			    alert("عفوًا.. لم تقم بكتابة شفرة التدقيق في المكان المخصص");
				FormElist.txtactive.focus();}
				
		else {
                return true; }

        return false;
        }


//------------------------------------
function soundview(sdid)
{                                            
window.open('new.php?veiw='+ sdid ,'links','width=400,height=356,status=nomenubar=no,scrollbars=no,toolbar=no,location=no,directories=no,resizable=no,top=200,left=200');
}

//------------------------------------
function sdvi()
{                                            
window.open('shaban.html' ,'myew','width=670,height=400,status=nomenubar=no,scrollbars=yes,toolbar=no,location=no,directories=no,resizable=no,top=200,left=200');
}
