// JavaScript Document

link210_on=new Image;
link210_on.src="images/links/mfeqh-on.gif";
link210_off=new Image;
link210_off.src="images/links/mfeqh.gif";

function CheckLayer(x)
{
 if (x)
 {
 mLayer= eval("div"+x);
 mImage= eval("link" + x); 
 mImage.src = eval("link" + x + "_on.src");
 mLayer.style.display='';
 }
}

function swap(img1, img2)
{
  document.images[img1].src=eval(img2+".src");
}

function swap2(img1, img2, LayerName)
{
	if (LayerName.style.display=='none')
		{
			document.images[img1].src=eval(img2+".src");		
		}		
}

function ShowLayer(LayerName, img0)
{
	var temp;
	temp=LayerName.style.display;
	
	div1.style.display='none';
	div3.style.display='none';
	div5.style.display='none';
	div8.style.display='none';
	
	link1.src=link1_off.src;
	link3.src=link3_off.src;
	link5.src=link5_off.src;
	link8.src=link8_off.src;
	
	LayerName.style.display=temp;
		
	if (LayerName.style.display=='none')
		{
		LayerName.style.display='';
		document.images[img0].src=eval(img0+"_on.src");
		}
	else
		{
		LayerName.style.display='none';
		document.images[img0].src=eval(img0+"_off.src");		
		}	
}



//------------------------------------
function submitGuestForm()	
	{
	if (frmGuest.txtName.value=="")
		alert ("!الرجاء كتابة الاسم");
	else if (frmGuest.txtEmail.value=="")
		alert ("!الرجاء كتابة البريد الإلكتروني");
	else if (frmGuest.txtComments.value=="")
		alert ("!الرجاء كتابة تعليقك");
	else
		return true;
	return false;
	}

//------------------------------------
function submitContactForm()	
	{
	if (frmContact.txtName.value=="")
		alert ("!الرجاء كتابة الاسم");
	else if (frmContact.txtEmail.value=="")
		alert ("!الرجاء كتابة البريد الإلكتروني");
	else if (frmContact.txtComments.value=="")
		alert ("!الرجاء كتابة تعليقك");
	else if (frmContact.txtMobile.value=="")
		alert ("!الرجاء كتابة رقم هاتفك الصحيح");
	else
		return true;
	return false;
	}

//------------------------------------
function submitMasaelForm()	
	{
	if (frmMasael.txtName.value=="")
		alert ("!الرجاء كتابة الاسم");
	else if (frmMasael.txtEmail.value=="")
		alert ("!الرجاء كتابة البريد الإلكتروني");
	else if (frmMasael.txtQuestion.value=="")
		alert ("!الرجاء كتابة نص السؤال");
	else if (frmMasael.txtMoqalad.value=="")
		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.txtSummary.value=="")
			alert ("!الرجاء كتابة الملخص")
	else if (frmLecture.txtAdmin.value=="")
		alert ("ضع اسم الادمن - أي اسمك لكي يتم التعرف على من الذي وضع هذا الموضوع")
	else if (frmLecture.txtDetails.value=="")
		alert ("!الرجاء كتابة التفاصيل")
	else
		return true; 
	return false;
	}

//------------------------------------
function submitOptionsForm()	
	{
	if (frmOptions.txtPass.value=="")
		alert ("!لا تجعل حق الكلمة السرية فارغا")
	else if (frmOptions.txtType.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 swap2(img1, img2, LayerName)
{
	if (LayerName.style.display=='none')
		{
			document.images[img1].src=eval(img2+".src");		
		}		
}

//------------------------------------
function ShowLayer(LayerName, img0)
{
	if (LayerName.style.display=='none')
		{
		LayerName.style.display='';
		document.images[img0].src=eval(img0+"_on.src");
		}
	else
		{
		LayerName.style.display='none';
		document.images[img0].src=eval(img0+"_off.src");		
		}	
}

//------------------------------------
function printThis(lecID)
	{
		var w = 550;
		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'
		winurl = 'print.php?lecID=' + lecID
		win = window.open(winurl, 'mywindow', winprops)
	}

//------------------------------------
function submitSendForm()	
	{
	if (frmSend.txtFromName.value=="")
		alert ("!الرجاء كتابة اسمك")
	else if (frmSend.txtFromEmail.value=="")
		alert ("!الرجاء كتابة بريدك الإلكتروني")
	else if (frmSend.txtToName.value=="")
		alert ("!الرجاء كتابة اسم صديقك")
	else if (frmSend.txtToEmail.value=="")
		alert ("!الرجاء كتابة بريد صديقك")
	else
		return true; 
	return false;
	}

//------------------------------------
function submitListForm()
	{
	if (frmList.txtEmail.value=="")
		alert ("!الرجاء كتابة بريدك الإلكتروني")
	else
		return true; 
	return false;		
	}
	
//------------------------------------
function submitAnswerForm()
	{
	if (frmAnswer.txtQuestion.value=="")
		alert ("!الرجاء ذكر السؤال")
	else if (frmAnswer.txtAnswer.value=="")
		alert ("!الرجاء ذكر الجواب")
	else if (frmAnswer.txtType.value=="0")
		alert ("!الرجاء اختيار التصنيف المناسب")
	else
		return true; 
	return false;		
	}

//-------------------------------------
function disableIt(obj)
{
	obj.disabled = !(obj.disabled);
	var z = (obj.disabled) ? 'disabled' : 'enabled';
}

//------------------------------------
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 submitDelForm()
	{
	if (frmDel.txtCat.value=="0")
		alert ("!الرجاء اختيار التصنيف المناسب")
	else
		return true; 
	return false;		
	}


//----------------------------------
function submitBookForm()
	{
	if (frmBook.txtName.value=="")
		alert ("!الرجاء كتابة اسم الكتاب")
	else if (frmBook.txtPhoto.value=="")
		alert ("!الرجاء ذكر غلاف الكتاب")
	else if (frmBook.txtSrc.value=="")
		alert ("!الرجاء ذكر رابط الكتاب")
	else
		return true; 
	return false;		
	}


//------------------------------------
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 submitSearchForm()
	{
	searchBox = frmSearch.txtKeyWord
	if (searchBox.value=="")
		alert ("الرجاء كتابة كلمة البحث")
	else if (trim(searchBox.value) == " ")
		alert ("الرجاء كتابة كلمة بحث كاملة")
	else if (trim(searchBox.value).length < 4)
		alert ("الرجاء كتابة كلمة بحث كاملة")
	else
		return true; 
	searchBox.value="";
	searchBox.focus();
	return false;			
	}
	
//------------------------------------
function goMediaCat()
	{
	url = "?start=0&cat=" + frmMediaCats.mainCats.options(frmMediaCats.mainCats.selectedIndex).value;
	window.location = url;
	}
function goAllMediaCat()
	{
	url = "?p=Media&start=0&cat=" + frmAllMediaCats.mainCats.options(frmMediaCats.mainCats.selectedIndex).value;
	window.location = url;
	}
//------------------------------------
function delMedia(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.txtLen.value=="")
		alert ("!الرجاء ذكر المدة")
	else
		return true; 
	return false;		
	}

//------------------------------------
function goVideoCat()
	{
	url = "?p=video&start=0&cat=" + frmVideoCats.mainCats.options(frmVideoCats.mainCats.selectedIndex).value;
	window.location = url;
	}
	
//------------------------------------
function delVideo(id)
	{	
	response = confirm("هل تريد فعلا حذف هذا الملف المرئي؟");
	if (response) window.location = '?action=del&id=' + id;
	}

//----------------------------------
function submitVideoForm()
	{
	if (frmVideo.txtName.value=="")
		alert ("!الرجاء كتابة الاسم")
	else if (frmVideo.txtCat.value==0)
		alert ("!الرجاء اختيار التصنيف")
	else if (frmVideo.txtLen.value=="")
		alert ("!الرجاء ذكر المدة")
	else
		return true; 
	return false;		
	}

//------------------------------------
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;
	}

//---------------------------mailling list

//------------------------------------
function goLinksCat()
	{
	url = "?start=0&cat=" + frmLinksCats.mainCats.options(frmLinksCats.mainCats.selectedIndex).value;
	window.location = url;
	}

function goAllLinksCat()
	{
	url = "?p=links&start=0&cat=" + frmLinksCats.mainCats.options(frmLinksCats.mainCats.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 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;
	}
//---------------------------- end mailling list
//------------------------------------
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 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(bnrID)
	{
	response = confirm("هل تريد فعلاً حذف هذه الحكمة؟");
	if (response) window.location = "?action=del&hekmaID=" + bnrID
	}

//------------------------------------

//------------------------------------
function delLink(id, cat)
	{	
	response = confirm("هل تريد فعلاً حذف هذا الرابط؟");
	if (response) window.location = '?action=del&linkID=' + id + '&cat=' + cat;
	}

//------------------------------------
function submitLinkForm()
	{
	if (frmLink.txtName.value=="")
		alert ("!الرجاء كتابة إسم الموقع");
	else if (frmLink.txtURL.value=="")
		alert ("!الرجاء كتابة رابط الموقع");
	else
		return true;
	return false;		
	}


//------------------------------------
function goLinksCat()
	{
	url = "?start=0&cat=" + frmLinksCats.mainCats.options(frmLinksCats.mainCats.selectedIndex).value;
	window.location = url;
	}
//------------------------------------
function sendThis(lecID)
	{
		var w = 565;
		var h= 247;		
		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'
		winurl = 'send.php?lecID=' + lecID
		win = window.open(winurl, 'mywindow', winprops)
	}
		//------------------------------------
function delSms(id)
	{	
	response = confirm("هل تريد فعلاً حذف هذا الرقم؟");
	if (response) window.location = '?action=del&smsID=' + id;
	}
//----------------------------------
function submitSmsForm()
	{
	if (frmSms.txtName.value=="")
		alert ("!الرجاء كتابة الاسم الثلاثي")
	else if (frmSms.txtSex.value==0)
		alert ("!الرجاء اختيار الجنس")
	else if (frmSms.txtMobile.value=="")
		alert ("!الرجاء كتابة رقم الموبايل")
	else
	if (frmSms.txtCountry.value=="")
		alert ("!الرجاء كتابة إسم دولتك")
	else
	if (frmSms.txtQaryah.value=="")
		alert ("!الرجاء كتابة إسم مدينتك / قريتك")
	else
			return true; 
	return false;		
	}

//------------------------------------

function submitAlsalatForm()	
	{
	if (frmAlsalat.txtDate.value=="")
		alert ("!الرجاء كتابة التاريخ الميلادي")
	else 
if (frmAlsalat.txtHdate.value=="")
		alert ("!الرجاء كتابة التاريخ الهجري")
	else 
if (frmAlsalat.txtDay.value=="")
		alert ("!الرجاء إسم اليوم")
	else 
if (frmAlsalat.txtFajr.value=="")
		alert ("!الرجاء كتابة أوقات صلاة الصبح")
	else 
if (frmAlsalat.txtShurooq.value=="")
		alert ("!الرجاء كتابة أوقات الشروق")
	else 
if (frmAlsalat.txtThuhr.value=="")
		alert ("!الرجاء كتابة أوقات صلاة الظهرين")
	else 
if (frmAlsalat.txtGhuroob.value=="")
		alert ("!الرجاء كتابة أوقات الغروب")
	else
if (frmAlsalat.txtEshaain.value=="")
		alert ("!الرجاء كتابة أوقات صلاة العشائين")
	else  
		return true; 
	return false;
	}
//--------------------------------------
function delAlsalat(id)
	{	
	response = confirm("هل تريد فعلاً حذف هذه الأوقات؟");
	if (response) window.location = '?action=del&alsalatID=' + id;
	}
//--------------------------------------
function delAlhussainia(id)
	{	
	response = confirm("هل تريد فعلاً حذف هذه الفعالية؟");
	if (response) window.location = '?action=del&alhussainiaID=' + id;
	}
	
	//------------------------------------
function goMasaelCat()
	{
	url = "?p=masala&cat=" + frmMasaelCats.mainCats.options(frmMasaelCats.mainCats.selectedIndex).value;
	window.location = url;
	}

//------------------------------------
function delMasael(id)
	{	
	response = confirm("هل تريد فعلا حذف هذه المسألة؟");
	if (response) window.location = '?action=del&id=' + id;
	}

//----------------------------------
function submitMasaelForm()
	{
	if (frmMasael.txtSoaal.value=="")
		alert ("!الرجاء كتابة السؤال")
	else if (frmMasael.txtCat.value==0)
		alert ("!الرجاء اختيار التصنيف")
	else if (frmMasael.txtGawab.value=="")
		alert ("!الرجاء كتابة الجواب")
	else
	 if (frmMasael.txtDate.value=="")
		alert ("!الرجاء كتابة التاريخ")
	else
		return true; 
	return false;		
	}
//------------------------------------
function OpenThis(ID)
	{
		var w = 604;
		var h=537;		
		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'
		winurl = 'malthekropen.php?ID=' +ID
		win = window.open(winurl, 'mywindow', winprops)
	}




//------------------------------------
function submitVoteForm()
	{
	if (frmVote.txtName.value=="")
		alert ("!الرجاء كتابة اسم التصويت");
	else if (frmVote.txtQuestion.value=="")
		alert ("!الرجاء كتابة السؤال");
	else if (frmVote.txtAnswer[0].value=='')
		alert ("!الرجاء ذكر إجابتين على الأقل");
	else if (frmVote.txtAnswer[1].value=='')
		alert ("!الرجاء ذكر إجابتين على الأقل");
	else 
		{
		results = '';
		votes = '';		
		for (i=0; i<5; i++)
			if (frmVote.txtAnswer[i].value!='')
				{
				results += frmVote.txtAnswer[i].value + '|';			
				votes += "0|";			
				}
		frmVote.txtAnswers.value = results.substring(0, results.length-1);
		frmVote.txtVotes.value = votes.substring(0, votes.length-1);
		return true; 
		}
	return false;
	}

//------------------------------------
function delVote(id)
	{	
	msg = "هل تريد فعلاً حذف هذا التصويت؟";
	response = confirm(msg);
	if (response) window.location = '?action=del&vID=' + id;
	}
	

//------------------------------------
function submitUserVoteForm()
	{
	for (i=0; i<frmVote.txtVotes.length; i++)
		if (frmVote.txtVotes[i].status)
			{
			frmVote.txtChoice.value= i;
			return true;
			}
	alert ("!الرجاء تحديد أحد الخيارات");
	return false;
	}
//------------------------------------
function submitCatLinksForm()
	{
	if (frmCatLinks.txtName.value=="")
		alert ("!الرجاء كتابة اسم التصنيف");
	else
		return true;
	return false;		
	}

//------------------------------------
function editCat(id, name)
	{
		document.frmCatLinks.txtName.value=name;
		document.frmCatLinks.txtID.value=id;
		document.frmCatLinks.btnSubmit.value='تحديث تصنيف';
	}

//------------------------------------
function delCatLinks(id)
	{	
	msg = "هل تريد فعلاً حذف هذا التصنيف؟";
	response = confirm(msg);
	if (response) window.location = 'delLinksCat.php?cat=' + id;
	}

//------------------------------------
function delLinkscat(id)
	{	
	response = confirm("هل تريد فعلاً حذف هذا التصنيف؟");
	if (response) window.location = '?action=del&linkscatID=' + id;
	}
	
//----------------------------------
function submitBannerForm()
	{
	if (frmBanner.txtName.value=="")
		alert ("!الرجاء كتابة الاسم")
	else if (frmBanner.txtExpair.value=="")
		alert ("!الرجاء ذكر تاريخ إنتهاء الإعلان")
	else
		return true; 
	return false;		
	}

//------------------------------------
function submitCatPicsForm()
	{
	if (frmCatPics.txtName.value=="")
		alert ("!الرجاء كتابة اسم القسم");
	else
		return true;
	return false;		
	}

//------------------------------------
function editCat(id, name)
	{
		document.frmCatPics.txtName.value=name;
		document.frmCatPics.txtID.value=id;
		document.frmCatPics.btnSubmit.value='تحديث قسم';
	}


//------------------------------------
function delPicscat(id)
	{	
	response = confirm("هل تريد فعلاً حذف هذا القسم؟");
	if (response) window.location = '?action=del&picsscatID=' + id;
	}
	
//------------------------------------
function goPicsCat()
	{
	url = "?start=0&cat=" + frmPicsCats.mainCats.options(frmPicsCats.mainCats.selectedIndex).value;
	window.location = url;
	}

function goAllPicsCat()
	{
	url = "?p=pics&start=0&cat=" + frmPicsCats.mainCats.options(frmPicsCats.mainCats.selectedIndex).value;
	window.location = url;
	}


	//------------------------------------
function delPics(id, cat)
	{	
	response = confirm("هل تريد فعلاً حذف هذه الصورة؟");
	if (response) window.location = '?action=del&picsID=' + id + '&cat=' + cat;
	}

//------------------------------------
function submitPicsForm()
	{
	if (frmPics.txtName.value=="")
		alert ("!الرجاء كتابة إسم الصورة");
	else if (frmPics.txtImg.value=="")
		alert ("!الرجاء كتابة عنوان الصورة");
	else
		return true;
	return false;		
	}

