// Universal Related Select Menus - cascading popdown menus
// (Dynamically-sized related menus using JS 1.1's new Option cmd)
// by Andrew King. v1.33 19990715
// Copyright (c) 1999 internet.com LLC. All Rights Reserved.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
// Originally published and documented at http://www.webreference.com
// Contact aking@internet.com for all other uses.
//
// 3-3-96 code optimized, modularized, and made universal-abk
// 3-8-97 jumpPage1 and 2 consolidated into generalized func
// 3-10-97 changeMenu added jumpPage(0,0), for non-ns3 browsers
// make popup act like a live popup when no related functionality
// 8-5-97 browser detect script changed to check for option functionality
// 9-11-97 aln changed to options.length, as IE 4 does not support
// nulling out options
// 12-22-98 added SIZE att to make select lists, used named forms/elements
// 1-1-99 added getFormNum to fix netscape 2 bug (doesn't support named fms)
//  pass formName, elementNum to relate and jmp as workaround
//  pass this.form,0 and increment instead of decrement in relate to get 
//   next form
//  assumes menu2 follows menu1 in HTML
// tested in mac ie3.01/ns2.02 (live), ns 3.01,4.05,4.5 and ie4.01 related
// 990701 - fixed back button bug in ie4+ by resetting all forms onload-abk
//    thanks to peter belesis (pbel@internet.com) for this fix
// 990714 - added IE5 persistence - abk pb, note this vers bombs gecko
//  use the newer vers on next page, intro2.html
// 990715 - went open source, created stipped down example files - abk
// 990720 - jmp() fix getFormNum(formName);->
//     var formNum = getFormNum(formName);
// 990722 - var for scope added, jmp chgd to named form for ns2.02 bug-abk

if(v){a=new Array(22);aln=22;}

function getFormNum (formName) {
	var formNum =-1;
	for (i=0;i<document.forms.length;i++){
		tempForm = document.forms[i];
		if (formName == tempForm) {
			formNum = i;
			correctForm = tempForm;
			break;
		}
	}
	return formNum;
}

function jmp(form, elt)
// The first parameter is a reference to the form.
{
	if (form != null) {
		with (form.elements[elt]) {
			if (0 <= selectedIndex)
				parent.major.location = options[selectedIndex].value;
		}
	}
}


function O(txt,url) {
a[k]=new Option(txt,url);k++;
}
function relate(formName,elementNum,j) {
if(v){
k=1;
if(j==0){
parent.major.location = "main.htm";
a=new Array(1);
O("العناوين الفرعية لما تختاره في القائمة الأولى","main.htm");
}
if(j==1){
parent.major.location = "inside/1.htm";
a=new Array(2);
O("المقدمة","inside/1.htm");
O("شرائط وجوب الحج","inside/2.htm");
}
if(j==2){
parent.major.location = "inside/3.htm";
a=new Array(3);
O("المقدمة","inside/3.htm");
O("فصل في النيابة","inside/4.htm");
O("الحج المندوب","inside/5.htm");
}
if(j==3){
parent.major.location = "inside/6.htm";
a=new Array(1);
O("أقسام العمرة","inside/6.htm");
}
if(j==4){
parent.major.location = "inside/7.htm";
a=new Array(4);
O("المقدمة","inside/7.htm");
O("حج التمتع","inside/8.htm");
O("حج الإفراد","inside/9.htm");
O("حج القران","inside/10.htm");
}
if(j==5){
parent.major.location = "inside/14.htm";
a=new Array(2);
O("المقدمة","inside/14.htm");
O("أحكام المواقيت","inside/15.htm");
}
if(j==6){
parent.major.location = "inside/16.htm";
a=new Array(1);
O("كيفية الإحرام","inside/16.htm");
}
if(j==7){
parent.major.location = "inside/20.htm";
a=new Array(26);
O("المقدمة","inside/20.htm");
O("الصيد البري","inside/21.htm");
O("مجامعة النساء","inside/23.htm");
O("تقبيل النساء","inside/24.htm");
O("مس النساء","inside/25.htm");
O("النظر إلى المرأة وملاعبتها","inside/26.htm");
O("الاستمناء","inside/27.htm");
O("عقد النكاح","inside/28.htm");
O("استعمالات الطيب","inside/29.htm");
O("لبس المخيط أو ما بحكمه للرجل","inside/30.htm");
O("الاكتحال","inside/31.htm");
O("النظر في المرآة","inside/32.htm");
O("لبس الخف والجورب للرجال","inside/33.htm");
O("الفسوق","inside/34.htm");
O("الجدال","inside/35.htm");
O("قتل هوام الجسم","inside/36.htm");
O("التزين","inside/37.htm");
O("الادّهان","inside/38.htm");
O("إزالة الشعر عن البدن","inside/39.htm");
O("ستر الرأس للرجال","inside/40.htm");
O("ستر الوجه للنساء","inside/41.htm");
O("التظليل للرجال","inside/42.htm");
O("إخراج الدم من البدن","inside/43.htm");
O("التقليم","inside/44.htm");
O("قلع الضرس","inside/45.htm");
O("حمل السلاح","inside/45b.htm");
}
if(j==8){
parent.major.location = "inside/46.htm";
a=new Array(4);
O("المقدمة","inside/46.htm");
O("حدود الحرم","inside/47.htm");
O("محل التكفير","inside/48.htm");
O("مصرف الكفارة","inside/49.htm");
}
if(j==9){
parent.major.location = "inside/50.htm";
a=new Array(8);
O("المقدمة","inside/50.htm");
O("شرائط الطواف","inside/51.htm");
O("واجبات الطواف","inside/52.htm");
O("الخروج عن المطاف","inside/53.htm");
O("قطع الطواف ونقصانه","inside/54.htm");
O("الزيادة في الطواف","inside/55.htm");
O("الشك في عدد الأشواط","inside/56.htm");
O("صلاة الطواف","inside/57.htm");
}
if(j==10){
parent.major.location = "inside/58.htm";
a=new Array(3);
O("المقدمة","inside/58.htm");
O("أحكام السعي","inside/59.htm");
O("الشك في السعي","inside/60.htm");
}
if(j==11){
parent.major.location = "inside/61.htm";
a=new Array(1);
O("التقصير","inside/61.htm");
}
if(j==12){
parent.major.location = "inside/62.htm";
a=new Array(1);
O("إحرام الحج","inside/62.htm");
}
if(j==13){
parent.major.location = "inside/63.htm";
a=new Array(3);
O("الوقوف بعرفات","inside/63.htm");
O("الوقوف في المزدلفة","inside/64.htm");
O("إدراك الوقوفين أو أحدهما","inside/65.htm");
}
if(j==14){
parent.major.location = "inside/66.htm";
a=new Array(1);
O("المقدمة","inside/66.htm");
O("رمي جمرة العقبة","inside/66b.htm");
O("الذبح أو النحر في منى","inside/66c.htm");
O("الحلق أو التقصير","inside/66d.htm");
}
if(j==15){
parent.major.location = "inside/67.htm";
a=new Array(1);
O("طواف الحج وصلاته والسعي","inside/67.htm");
}
if(j==16){
parent.major.location = "inside/68.htm";
a=new Array(1);
O("طواف النساء","inside/68.htm");
}
if(j==17){
parent.major.location = "inside/69.htm";
a=new Array(1);
O("المبيت في منى","inside/69.htm");
}
if(j==18){
parent.major.location = "inside/70.htm";
a=new Array(1);
O("رمي الجمار","inside/70.htm");
}
if(j==19){
parent.major.location = "inside/71.htm";
a=new Array(1);
O("أحكام المصدود","inside/71.htm");
}
if(j==20){
parent.major.location = "inside/72.htm";
a=new Array(1);
O("أحكام المحصور","inside/72.htm");
}
if(j==21){
parent.major.location = "inside/73.htm";
a=new Array(1);
O("مستحبات الإحرام","inside/73.htm");
}
if(j==22){
parent.major.location = "inside/74.htm";
a=new Array(1);
O("مكروهات الإحرام","inside/74.htm");
}
if(j==23){
parent.major.location = "inside/75.htm";
a=new Array(1);
O("دخول الحرم ومستحباته","inside/75.htm");
}
if(j==24){
parent.major.location = "inside/76.htm";
a=new Array(13);
O("آداب دخول مكة المكرمة والمسجد الحرام","inside/76.htm");
O("آداب الطواف","inside/77.htm");
O("آداب صلاة الطواف","inside/78.htm");
O("آداب السعي","inside/79.htm");
O("آداب الإحرام إلى الوقوف بعرفات","inside/80.htm");
O("آداب الوقوف بعرفات","inside/81.htm");
O("آداب الوقوف بالمزدلفة","inside/85.htm");
O("آداب رمي الجمرات","inside/86.htm");
O("آداب الهدي","inside/87.htm");
O("آداب الحلق","inside/88.htm");
O("آداب طواف الحج والسعي","inside/89.htm");
O("آداب منى","inside/90.htm");
O("آداب مكة المعظمة","inside/91.htm");
}
if(j==25){
parent.major.location = "inside/92.htm";
a=new Array(1);
O("طواف الوداع","inside/92.htm");
}
if(j==26){
parent.major.location = "inside/93.htm";
a=new Array(3);
O("زيارة الرسول الأعظم (ص)","inside/93.htm");
O("زيارة الصديقة الزهراء (ع)","inside/94.htm");
O("الزيارة الجامعة لأئمة البقيع (ع)","inside/95.htm");
}
if(j==27){
parent.major.location = "inside/96.htm";
a=new Array(17);
O("مفاد الأحوط","inside/96.htm");
O("أحكام الصلاة","inside/97.htm");
O("الاستطاعة","inside/98.htm");
O("تخميس المال الذي يحج به","inside/99.htm");
O("الوصية بالحج","inside/100.htm");
O("أحكام النيابة","inside/101.htm");
O("أحكام التوكيل","inside/102.htm");
O("أقسام العمرة","inside/103.htm");
O("محرمات الإحرام (ستر الرأس)","inside/104.htm");
O("محرمات الإحرام (التضليل)","inside/105.htm");
O("أحكام الكفارة","inside/106.htm");
O("أحكام الطواف وصلاته","inside/107.htm");
O("أحكام السعي","inside/108.htm");
O("الوقوف بعرفات","inside/109.htm");
O("المبيت بمنى","inside/110.htm");
O("أحكام الهدي","inside/111.htm");
O("أحكام رمي الجمار","inside/112.htm");
}
aln2=a.length;
var formNum = getFormNum(formName); // var formNum added, explicit var pass
if (formNum>=0) {
	formNum++; // reference next form, assume it follows in HTML
	with (document.forms[formNum].elements[elementNum]) {
		for (var i=options.length-1;i>0;i--) options[i]=null;
		for (var i=1;i<aln2;i++) options[i-1]=a[i];
		options[0].selected=true;
	}
}
} else {
jmp(formName,elementNum);
}
}

// BACK BUTTON FIX for ie4+- or
// MEMORY-CACHE-STORING-ONLY-INDEX-AND-NOT-CONTENT
//
// from peter belesis:
// IE4+ remembers the index of each SELECT but NOT the CONTENTS of each
// SELECT, so it gets it wrong.
//
// it has to do with MEMORY CACHE (where form input is stored) and how
// IE stores information about SELECT menus.
//
// IE stores the selectedINDEX ONLY of the SELECT menu, not the
// CONTENTS-AT-THE-TIME-OF-SELECTION
//
// when we return to a page, it displays the default contents of each
// SELECT, grabs the stored index from cache and aligns the default
// contents to that index.
// 
// Netscape, on the other hand, seems to remember both INDEX and CONTENTS
// added ie5 persistence 990714

function IEsetup(){
	if(!document.all) return;
	IE5 = navigator.appVersion.indexOf("5.")!=-1;
	if(!IE5) {
		for (i=0;i<document.forms.length;i++) {
			document.forms[i].reset();
		}
	}
}

window.onload = IEsetup;
