var quranMenu;
var indexMenu;
var tafseerMenu;
var translationMenu;
var a7kamMenu;
//var booksMenu;
var treeMenu;

function InitLoad()
{
	quranMenu = false;
	indexMenu = false;
	tafseerMenu = false;
	translationMenu = false;
	a7kamMenu = false;
//	booksMenu = false;
	treeMenu = false;
	
	
	var openedMenu = document.getElementById( "src" );
	if( openedMenu  == null )
		return;
	
	switch( openedMenu.value )
	{
		case "quran":
			ShowQuranMenu();
			break;
			
		case "index":
			ShowQuranMenu();
			//ShowIndexMenu();
			break;
			
		case "tafseer":
			ShowTafseerMenu();
			break;
			
		case "translation":
			ShowTranslationMenu();
			break;
			
		case "tree":
			ShowTreeMenu();
			break;
			
	}
}

//Function to show item
function ShowItem( ID )
{
	var menuItem = document.getElementById( ID );
	if( menuItem != null )
		menuItem.style.display = 'list-item';
	//else
	//	//alert( ID );
		
}

//Function to hide item
function HideItem( ID )
{
	var menuItem = document.getElementById( ID );
	if( menuItem != null )
		menuItem.style.display = 'none';
	//else
	//	//alert( ID );

}


//Function to show QuranMenu
function ShowQuranMenu()
{
	if( quranMenu == false )
	{
		//show items of quran menu
		ShowItem( "TelawaID" );
		ShowItem( "SoarIndex" );
		ShowItem( "PartsIndex" );
//		ShowItem( "MemorizationID" );
		ShowItem( "DisplayID" );
		
		//close other menus
//		if( indexMenu == true )
//			ShowIndexMenu();
		if( tafseerMenu == true )
			ShowTafseerMenu();
		if( translationMenu == true )
			ShowTranslationMenu();
		if( a7kamMenu == true )
			ShowA7kamMenu();
//		if( lessonsMenu == true )
//			ShowLessonsMenu();
/*	
		if( booksMenu == true )
		{
			ShowBooksMenu();
			a7kamMenu = true;
			ShowA7kamMenu();
		}
	*/	
		
		if( treeMenu == true )
			ShowTreeMenu();
		
		quranMenu = true;
	}
	else
	{
		HideItem( "TelawaID" );
		//HideItem( "IndexID" );
		HideItem( "SoarIndex" );
		HideItem( "PartsIndex" );
		HideItem( "DisplayID" );
		
		quranMenu = false;
	}
}


//function to show Index menu
function ShowIndexMenu()
{
	if( indexMenu == false )
	{
		ShowItem( "SoarIndex" );
		ShowItem( "PartsIndex" );
		
		indexMenu = true;
	}
	else
	{
		HideItem( "SoarIndex" );
		HideItem( "PartsIndex" );
		
		indexMenu = false;
	}
}

//show tafseer menu
function ShowTafseerMenu()
{
	if( tafseerMenu == false )
	{
		ShowItem( "Katheer" );
		ShowItem( "ElGalaleen" );
		ShowItem( "Kortoby" );
		
		if( quranMenu == true )
			ShowQuranMenu();
		if( translationMenu == true )
			ShowTranslationMenu();
			
		if( treeMenu == true )
			ShowTreeMenu();
//		if( lessonsMenu == true )
//			ShowLessonsMenu();	
		if( a7kamMenu == true )
			ShowA7kamMenu();
/*			
		if( booksMenu == true )
		{
			ShowBooksMenu();
			a7kamMenu = true;
			ShowA7kamMenu();
		}
*/	
		tafseerMenu = true;
	}
	else
	{
		HideItem( "Katheer" );
		HideItem( "ElGalaleen" );
		HideItem( "Kortoby" );
		
		tafseerMenu = false;
	}
	
}

//Show translation menu
function ShowTranslationMenu()
{
	if( translationMenu == false )
	{
		ShowItem( "EnglishID");
		//ShowItem( "FrenchID" );
		
		if( quranMenu == true )
			ShowQuranMenu();
		if( tafseerMenu == true )
			ShowTafseerMenu();
//		if( lessonsMenu == true )
//			ShowLessonsMenu();	
		if( treeMenu == true )
			ShowTreeMenu();
		
		if( a7kamMenu == true )
			ShowA7kamMenu();
/*	
		if( booksMenu == true )
		{
			ShowBooksMenu();
			a7kamMenu = true;
			ShowA7kamMenu();
		}
*/		
		translationMenu = true;
	}
	else
	{
		HideItem( "EnglishID" );
		//HideItem( "FrenchID" );
		
		translationMenu = false;
	}
}

function ShowA7kamMenu()
{
	if( a7kamMenu == false )
	{
		ShowItem( "A7kamID" );
		ShowItem( "LessonsID" );
		//ShowItem( "BooksID" );
		
		a7kamMenu = true;
		
		if( quranMenu == true )
			ShowQuranMenu();
		if( tafseerMenu == true )
			ShowTafseerMenu();
		if( translationMenu == true )
			ShowTranslationMenu();
//		if( lessonsMenu == true )
//			ShowLessonsMenu();
		if( treeMenu == true )
			ShowTreeMenu();
	}
	else
	{
		HideItem( "A7kamID" );
		HideItem( "LessonsID" );
//		HideItem( "BooksID" );
		
		a7kamMenu = false;
		
		booksMenu = true;
		ShowBooksMenu();
		
//		lessonsMenu = true;
//		ShowLessonsMenu();
	}
}
/*
function ShowBooksMenu()
{
	if( booksMenu == false )
	{
		
		
//		if( lessonsMenu == true )
//			ShowLessonsMenu();
			
		ShowItem( "Book1" );
		ShowItem( "Book2" );
		ShowItem( "Book3" );
		
		booksMenu = true;
		
	}
	else
	{
		HideItem( "Book1" );
		HideItem( "Book2" );
		HideItem( "Book3" );
		
		booksMenu = false;
	}
}
*/
function ShowTreeMenu()
{
	if( treeMenu == false )
	{
		ShowItem( "TreeID" );
		
		//close other menus
		if( quranMenu == true )
			ShowQuranMenu();
		if( indexMenu == true )
			ShowIndexMenu();
		if( tafseerMenu == true )
			ShowTafseerMenu();
		if( translationMenu == true )
			ShowTranslationMenu();
		if( a7kamMenu == true )
			ShowA7kamMenu();
//		if( lessonsMenu == true )
//			ShowLessonsMenu();
/*
		if( booksMenu == true )
		{
			ShowBooksMenu();
			a7kamMenu = true;
			ShowA7kamMenu();
		}
*/		
		
		treeMenu = true;
	}
	else
	{
		HideItem( "TreeID" );
		treeMenu = false;
	}
}

function ShowLessonsMenu()
{
	if( lessonsMenu == false )
	{
		ShowItem( "Lesson1" );
		ShowItem( "Lesson2" );
		ShowItem( "Lesson3" );
		ShowItem( "Lesson4" );
		ShowItem( "Lesson5" );
		
		//close other menus
		if( quranMenu == true )
			ShowQuranMenu();
		if( indexMenu == true )
			ShowIndexMenu();
		if( tafseerMenu == true )
			ShowTafseerMenu();
		if( translationMenu == true )
			ShowTranslationMenu();
		if( tafseerMenu == true )
			ShowTreeMenu();
		if( booksMenu == true )
		{
			a7kamMenu = true;
			ShowBooksMenu();
			ShowA7kamMenu();
		}
		
		lessonsMenu = true;
	}
	else
	{
		HideItem( "Lesson1" );
		HideItem( "Lesson2" );
		HideItem( "Lesson3" );
		HideItem( "Lesson4" );
		HideItem( "Lesson5" );
		
		lessonsMenu = false;
	}
}

//Links
function LinkMe( nLinkID )
{
	switch( nLinkID )
	{
		case 'TelawaID':
		
			window.top.frames.Quran.location = "QuranKareem/QuranTelawa.aspx?telawa=true";
			//document.location = "QuranPane.aspx?src=quran";
			break;
			
		case 'SoarIndex':
			window.top.frames.Quran.location = "QuranKareem/QuranIndex.aspx?index=soar";
			//document.location = "QuranPane.aspx?src=quran";
			break;
			
		case 'PartsIndex':
			window.top.frames.Quran.location = "QuranKareem/QuranIndex.aspx?index=parts";
			//document.location = "QuranPane.aspx?src=quran";
			break;
			
		case 'MemorizationID':
			window.top.frames.Quran.location = "QuranKareem/QuranTelawa.aspx?telawa=false";
			//document.location = "QuranPane.aspx?src=quran";
			break;
			
		case 'DisplayID':
			window.top.frames.Quran.location = "QuranKareem/QuranDisplay.aspx";
			//document.location = "QuranPane.aspx?src=quran";
			break;
			
		case 'Katheer':
			window.top.document.getElementById( "QuranTD" ).height = 500;
			window.top.frames.Quran.location = "Tafseer/QuranTafseer.aspx?val=Ebn-Katheer&MofasserID=2";
			//document.location = "QuranPane.aspx?src=tafseer";
			break;
			
		case 'ElGalaleen':
		window.top.document.getElementById( "QuranTD" ).height = 500;
			window.top.frames.Quran.location = "Tafseer/QuranTafseer.aspx?val=El-Galaleen&MofasserID=1";
			//document.location = "QuranPane.aspx?src=tafseer";
			break;
			
		case 'Kortoby':
			window.top.document.getElementById( "QuranTD" ).height = 500;
			window.top.frames.Quran.location = "Tafseer/QuranTafseer.aspx?val=Kortoby&MofasserID=3";
			//document.location = "QuranPane.aspx?src=tafseer";
			break;
			
		case 'EnglishID':
			window.top.frames.Quran.location = "Translation/QuranTranslation.aspx?val=English&LangID=1";
			//document.location = "QuranPane.aspx?src=translation";
			break;
			
	
		case 'A7kamID':
			window.top.frames.Quran.location = "A7kam/A7kam.aspx";
			break;
			
		case 'Book1':
			window.top.frames.Quran.location = "A7kam/Books/Tree1.htm";
			break;
			
		case 'Book2':
			window.top.frames.Quran.location = "A7kam/Books/Tree2.htm";
			break;
			
		case 'Book3':
			window.top.frames.Quran.location = "A7kam/Books/Tree3.htm";
			break;
			
		case 'TreeID':
			window.top.frames.Quran.location = "SubjectsTree/SubjectsTree.html";
			break;
			
		case 'Lessons':
			//window.top.frames.Quran.location = "Lessons/Lessons.aspx?lesson=1";
			window.top.document.getElementById( "QuranTD" ).height = 440;
			//window.top.frames.Quran.location = "Lessons/Lesson_01/Tajweed_Main.swf";
			window.top.frames.Quran.location = "Lessons/mainLessons.aspx"; //"Lessons/main.swf";
			//window.open( "Lessons/Lessons.aspx?lesson=1", "LessonsWin", "scrollbars=1,width=550,height=350,resizable=1,titlebar=no,toolbar=no,menubar=no" );
			break;
						
		default:
			break;
	}
	
	
}