// JavaScript Document
// generates the menu based on body id
//Author Binu Jose 
var strList;
//var strPreUrl = "http://d793202.u38.infinology.net"; // change a similar line at line no. 172
var strPreUrl = document.URL;
strPreUrl=strPreUrl.substr(0,strPreUrl.indexOf('//')+2)+document.domain;

var intSubNum =0;
var subId="";
var curParentItem="";
function menuStart()
{
	strList = "<div id='masterdiv' class='menutMain'> "
	// alert (strList + "menuStart");
}

function addParentItem(description,url,child) // menu title, optional [url, child yes or no]
{
	// alert (url);
	// alert (description);

	if (!url) // == undefined) 
	{
		intSubNum+=1;																																																									
		strUrl = "<div class='menutitle' onclick=SwitchMenu('sub" + intSubNum + "') id='div" + intSubNum +"'><table width='100%' border='0' cellpadding='0' cellspacing='0'><tr><td width='141'>" + description + "</td><td><span id='spn" + intSubNum + "' class='expCol'><img src='" + strPreUrl + "/images/common/down_arrow.gif'></span></td></tr></table></div>" ;
	}
	else
	{
		if (url.substring(0,7)=="http://" ){
			strPreUrl="";
			//alert(url.substring(0,7));
		}
		
		// if single
		if (!child){
			
				strUrl = "<a href = '" + strPreUrl + url + "' class='aFontMenuSingle' ><div class='menuSingle' onclick=SwitchMenuTop() >" + description + "</div></a>";
			
		}
		else // if child exists
		{
			intSubNum+=1;
			strUrl = "<a href = '" + strPreUrl + url + "' class='aFontMenuSingle'><div class='menutitle' onclick=SwitchMenu('sub" + intSubNum + "') id='div" + intSubNum +"'><table width='100%' border='0' cellpadding='0' cellspacing='0'><a href = '" + strPreUrl + url + "' class='aFontMenuSingle'><tr><td width='141'>" + description + "</td><td><span id='spn" + intSubNum + "' class='expCol'><img src='" + strPreUrl + "/images/common/down_arrow.gif' border='0'></span></td></tr></a></table></div></a>";
		}
	}
	strList = strList + strUrl ;
	// alert (strList + "addParentItem");
	curParentItem=description;
}

function OpenNewWinItem(description,url) {
	// if open new window window.open('ClndrPopUp.aspx?textbox=txtAppDate','cal','width=200,height=200,left=270,top=270')
		
			strUrl = '<a onclick = "' + url + '"  href="javascript:;" class="aFontMenuSingle"><div class="menuSingle">' + description + '</div></a>';
			//alert(strUrl);
		strList = strList + strUrl ;
}

function ChildStart()
{
//subId="Our Church";
	if (subId == curParentItem){
		strList = strList + "<div class='menutitle1'><span class='submenu' id='sub"+ intSubNum +"'><ul class='ulClass'>" ; //child list starts
	}
	else
	{
		strList = strList + "<div class='menutitle1'><span class='submenu' id='sub"+ intSubNum +"' style='display:none'><ul class='ulClass'>" ; //child list starts
	}
	// alert (strList + "ChildStart");
}

function addChildItem(desc,url,target,subExist)
{
	if (!subExist) {
		//alert("hello");
		if (!target){
			strList = strList + "<li class='liClass'> <a href='" + strPreUrl + url + "' class='aFont'>" + desc + "</a></li>" ; //description of child
		}
		if (target=="blank"){	
			strList = strList + "<li class='liClass'> <a href='" + strPreUrl + url + "' class='aFont' target='_blank'>" + desc + "</a></li>" ; //description of child		
		}
	}
	else{
		//alert("alalalallo");
		strList = strList + "<li class='liClass'> <a href='" + strPreUrl + url + "' class='aFont'>" + desc + "</a>" ; //description of child
	}
	// alert (strList + "addChildItem");
}

function ChildEnd()
{
	strList = strList + "</ul></span></div>" ;
	// alert (strList + "ChildEnd");
}

// subchild 3rd level
function subChildStart()
{
	strList = strList + "<ul class='subulClass'>" ; //child list starts
	// alert (strList + "ChildStart");
}

function addSubChildItem(desc,url)
{
	strList = strList + "<li class='subliClass'> <a href='" + strPreUrl + url + "' class='aFontsub'>" + desc + "</a></li>" ; //description of child
	// alert (strList + "addChildItem");
}

function subChildEnd()
{
	strList = strList + "</ul></li>" ;
	// alert (strList + "ChildEnd");
}
//
function menuEnd()
{
	strList = strList + "</div>" ;
	// alert (strList + "menuEnd");
}	



function createlist(id,sId)
{
subId=sId;
// alert(id);
switch (id)
	{
		case "cca":
			//alert(id  + "inside body");
		
			menuStart();
				addParentItem("Home","/default.asp");
				addParentItem("Our Church","/church/church.asp","yes"); // first main item 
					ChildStart();
						addChildItem("Our Belief","/church/belief.asp");
						addChildItem("Our Mission","/church/Our_Mission.asp");
						addChildItem("Our Pastor","/church/pastor.asp");
						addChildItem("Church Leadership","/church/leadership.asp");
						addChildItem("Directions","/church/directions.asp");

					ChildEnd(); // child list ends 
				addParentItem("New Creation","/New_Creation/default.asp","yes"); // first main item 
					ChildStart();
						addChildItem("Leadership","/New_Creation/leadership.asp");
						addChildItem("Wednesday Night","/New_Creation/Wednesday/wednesday_notes.asp");
						addChildItem("Missions Ministry","/New_Creation/missions.asp");
						addChildItem("Skit Ministry","/New_Creation/skit.asp");
						addChildItem("Scribblers","/New_Creation/Scribblers/default.asp");
						addChildItem("Praise n' Worship","/New_Creation/pw.asp");
						addChildItem("Stone House","/New_Creation/stonehouse.asp");
						addChildItem("Articles - Poems","/New_Creation/Articles/articles.asp");					
					ChildEnd(); // child list ends 
				addParentItem("Sunday School","/sunday_school/default.asp","yes"); // first main item 
				ChildStart();
						addChildItem("History","/sunday_school/history.asp");
						//addChildItem("Classes","/sunday_school/Classes.asp");
					ChildEnd(); // child list ends 
				addParentItem("Word of God","/Word/default.asp"); // first main item 					
				addParentItem("Calendar","/calendar/calendarcca.asp"); // first main item 
				addParentItem("Contact Us","/contactus.asp"); // first main item 
				addParentItem("E-mail Login","http://mail.ccatenn.org"); // first main item 
				addParentItem("Login","/calendar/ccalogin.asp"); // first main item 
			menuEnd();
				intSubNum=0;
			 //alert (strList);
		document.write(strList);
		break;
		
	
	}
}
//-------------------------- Page specific menu lists -------------------------------------

//------------------------------Menu functions---------------------------------------

 //strPreUrl1 = "http://d793202.u38.infinology.net";
var strPreUrl1 = document.URL;
strPreUrl1 =strPreUrl1.substr(0,strPreUrl1.indexOf('//')+2)+document.domain;

function subMenuStart()
{
	strListSub = "<div id='subList'>";
	// alert (strList + "menuStart");
}
function SubAddParentItem(id){
	strListSub = strListSub + "<div class='wordTitle1'>" + id +	"</div>";
}

function subChildStart(){
	strListSub = strListSub  + "<div class='wordContent1'>";
}
function subAddChildItem(title,url1){
//alert(strPreUrl);
	if(url1){
		strListSub = strListSub  + "<a href='"+ strPreUrl1 + url1 + "' class='linkSubs'>" + title + "</a><br>";
	}
	else{
		strListSub = strListSub  +  title + "<br>";
	}

}
function startIntendedChild(){
	strListSub = strListSub  + "<blockquote>";
}
function intendedChild(title,url1){
	strListSub = strListSub  + "<a href='"+ strPreUrl1 + url1 + "' class='linkSubs'>" + title + "</a><br>";
}
function endIntendedChild(){
	strListSub = strListSub  + "</blockquote>";
}
function subChildEnd(){
	strListSub = strListSub  + "<br></div>";
}

function subMenuEnd()
{
	strListSub = strListSub  + "</div>";
	// alert (strListSub);n gasdfds
}

//------------------------------------Menu lists------------------------------------------

function subLists(id){

switch (id)
	{
		case "articles":
			subMenuStart();
				SubAddParentItem("More articles...");
					subChildStart();
						subAddChildItem("<b>Articles</b>","");
							startIntendedChild();
								intendedChild("NEW CREATION","/New_Creation/new_creation.asp");
								intendedChild("God's timing in your life","/New_Creation/Articles/Gods_timing.asp");
								intendedChild("Overcoming temptations","/New_Creation/Articles/overcome_temptations.asp");
								intendedChild("God is more than enough","/New_Creation/Articles/Gods_enough.asp");
								intendedChild("Now is the time","/New_Creation/Articles/now_is_the_time.asp");
								intendedChild("Curse God and Die","/New_Creation/Articles/curse_god_and_die.asp");
								intendedChild("Email and Spam","/New_Creation/Articles/email_and_spam.asp");
								intendedChild("Fasting and Prayer","/New_Creation/Articles/fasting.asp");
								intendedChild("Who is a Friend?","/New_Creation/Articles/friend.asp");
								intendedChild("Who is NOT a friend?","/New_Creation/Articles/not_friend.asp");
							endIntendedChild();
						subAddChildItem(" ","");
						subAddChildItem("<b>Poems</b>","");
							startIntendedChild();
								intendedChild("A Glare At The Cross","/New_Creation/Poems/Glare_at_the_Cross.asp");
								intendedChild("Christ Is My...","/New_Creation/Poems/Christ_Is_My.asp");
								intendedChild("Light in Mere Darkness","/New_Creation/Poems/Light_in_Mere_Darkness.asp");
							endIntendedChild();

					subChildEnd();
			subMenuEnd();
		document.write(strListSub);
		break;
		
	}
	
switch (id)
	{
		case "sunday_school":
			subMenuStart();
				SubAddParentItem("Sunday School Classes");
					subChildStart();
						//subAddChildItem("Pre-K","/sunday_school/no_page.asp");
						//subAddChildItem("1-3 Grades","/sunday_school/no_page.asp");
						//subAddChildItem("4-6 Grades","/sunday_school/no_page.asp");
						//subAddChildItem("7-10 Grades","/sunday_school/no_page.asp");
						//subAddChildItem("Intermediate Class","/sunday_school/no_page.asp");
						subAddChildItem("Senior Class","/sunday_school/senior.asp");

						//subAddChildItem("Pre-K","");
							//startIntendedChild();
							//	intendedChild("1-2 grades","#");
								//intendedChild("3-5 grades","#");
							//	intendedChild("6-7 grades","#");
							//	intendedChild("8-10 grades","#");
							//	intendedChild("College","#");
						//	endIntendedChild();
						//subAddChildItem("Senior Class","/New_Creation/sunday_school/senior.asp");
						
					subChildEnd();
			subMenuEnd();
			
		document.write(strListSub);
		break;
		
	}
	
switch (id)
	{
			
		case "Wednesday":
			subMenuStart();
				SubAddParentItem("Wednesday Night notes");
					subChildStart();
						subAddChildItem("Summary of the book of James","/New_Creation/Wednesday/intro_to_james.asp");
						subAddChildItem("The Purpose of Testing a Christian","/New_Creation/Wednesday/james1_2-4.asp");
						subAddChildItem("The Secret to Answered Prayers.","/New_Creation/Wednesday/james1_5-8.asp");
					subChildEnd();
			subMenuEnd();
					
		document.write(strListSub);
		break;
		
	}

switch (id)
	{
			
		case "Word":
			subMenuStart();
				SubAddParentItem("Messages");
					subChildStart();
						subAddChildItem("Importance of prayer in church","/Word/importance_of_prayerInChurch.asp");
						subAddChildItem("You are important","/Word/you_are_important.asp");
						subAddChildItem("Power during the End Times","/Word/power.asp");
						subAddChildItem("Inheritance of the Saints of God","/Word/inheritance.asp");
						subAddChildItem("Can the glory of God depart from us?","/Word/glory_depart.asp");
						subAddChildItem("Have you seen the glory of God?","/Word/seen_the_glory.asp");
						subAddChildItem("Power of Praise","/Word/praise.asp");
			
					subChildEnd();
			subMenuEnd();
					
		document.write(strListSub);
		break;
		
	}
switch (id)
	{
			
		case "missions":
			subMenuStart();
				SubAddParentItem("Missions Ministry");
					subChildStart();
						subAddChildItem("North American Meetings","/New_Creation/Missions/america.asp");
						subAddChildItem("South African Mission Trips","/New_Creation/Missions/south_africa.asp");
						subAddChildItem("Trinidad Mission Trip","/New_Creation/Missions/Trinidad.asp");
						subAddChildItem("Kottayam Ministries","/New_Creation/Missions/kottayam.asp");
						subAddChildItem("Missions Awareness Programs","/New_Creation/Missions/missions_awareness.asp");
								
					subChildEnd();
			subMenuEnd();
					
		document.write(strListSub);
		break;
		
	}

switch (id)
	{
			
			case "Fallen_Angels":
			subMenuStart();
				SubAddParentItem("Judgment on the Angels");
					subChildStart();
						subAddChildItem("1. Introduction","/sunday_school/fallen_angels/default.asp");
						subAddChildItem("2. Angelic Kingdom","/sunday_school/fallen_angels/angels.asp");
						subAddChildItem("3. Devil's Kingdom","/sunday_school/fallen_angels/Devils.asp");
						subAddChildItem("4. Lucifer","/sunday_school/fallen_angels/Lucifer.asp");
						subAddChildItem("5. Anointed Cherub","/sunday_school/fallen_angels/anointed_cherub.asp");
						subAddChildItem("6. The Angels at Euphrates","/sunday_school/fallen_angels/angels_euphrates.asp");
						subAddChildItem("7. Angels that lost their first Estate","/sunday_school/fallen_angels/first_estate.asp");
						subAddChildItem("8. Satan","/sunday_school/fallen_angels/Satan.asp");
						subAddChildItem("9. Conclusion","/sunday_school/fallen_angels/conclusion.asp");
						
					subChildEnd();
			subMenuEnd();
					
		document.write(strListSub);
		break;
		
	}
	
switch (id)
	{
		case "scribblers":
			subMenuStart();
				SubAddParentItem("Scribblers");
					subChildStart();
						subAddChildItem("About us","/New_Creation/Scribblers/aboutScribblers.asp");
						subAddChildItem(" ","");
						subAddChildItem("<b>Articles</b>","");
						startIntendedChild();
						    intendedChild("Friends of God?","/New_Creation/Scribblers/Friends_of_God.asp");
						    intendedChild("Always Remember","/New_Creation/Scribblers/Always_remember.asp");
							intendedChild("Why God?...","/New_Creation/Scribblers/why_God.asp");
  							intendedChild("Bunch of Bananas!","/New_Creation/Scribblers/Bunch_of_Bananas.asp");
							intendedChild("Whom to Choose...","/New_Creation/Scribblers/Whom_to_choose.asp");
							intendedChild("Deaf","/New_Creation/Scribblers/Deaf.asp");
							intendedChild("What is your next move?","/New_Creation/Scribblers/Whats_your_next_move.asp");
							intendedChild("Delight thyself in the Lord","/New_Creation/Scribblers/delight.asp");
							intendedChild("Another Story","/New_Creation/Scribblers/another_story.asp");
							intendedChild("A Boy A Cry...","/New_Creation/Scribblers/a_boy_a cry.asp");
							intendedChild("Finding Favor with God","/New_Creation/Scribblers/Finding_Favor_with_God.asp");	
							intendedChild("God! Show Yourself","/New_Creation/Scribblers/God_Show_Yourself.asp");								
							//intendedChild("3-5 grades","#");
							//	intendedChild("6-7 grades","#");
							//	intendedChild("8-10 grades","#");
							//	intendedChild("College","#");
						endIntendedChild();
					subChildEnd();
			subMenuEnd();
		document.write(strListSub);
		break;
		
	}

}
