﻿var sizeH=0;
var menuTopPosition = 100;
var menuItem = new Array();

function Display(id) {
    try {
    var oObject=document.getElementById(id);
    oObject.style.display="block";
    } catch(err) {
    }
}

function Hide(id) {
    try {
    var oObject=document.getElementById(id);
    oObject.style.display="none";
    } catch(err) {
    }
}

function MouseOver(menutype,Id) {
    array=getArray(menutype);
    var index=getIndex(array,Id);
    
    obj = document.getElementById(Id);
    obj.style.backgroundColor=array[index].bgcolorsel;
    obj.style.color=array[index].textcolorsel;
} 

function LoadImg(oId,sImg) {
  var oObject=document.getElementById(oId);
  oObject.src=sImg;
}

function LoadBGImg(oId,sImg) {
  var oObject=document.getElementById(oId);
  oObject.style.backgroundImage="url('" + sImg +"')";
}

function DisplaySubmenu(menutype,Id) {
  
    array=getArray(menutype);
    array[getIndex(array,Id)].on=true;
    for (x in array) {
        if (array[x].parentId==Id) {
           Display(array[x].Id)
        }
    }
}

function HideSubmenu(menutype,Id) {
    if (Id!="") {
            array=getArray(menutype);
            array[getIndex(array,Id)].on=false;}
        for (x in array) {
            if (Id=="") {
                if (array[x].parentId!="") {Hide(array[x].Id)}
            } else {
            if (array[x].parentId==Id) {
               Hide(array[x].Id)
            }
        }
    }
}

function getMenuPageElement(objName) {
    var obj;
    if (navigator.appName.indexOf("Microsoft") != -1) {
        obj=parent.menupage.window[objName]
    }
    else {
        obj=parent.menupage.document[objName]
    }
    return(obj);
}
function setLinkedImage(img) {
    
    try     {
    var obj;
    var obj2;
    var obj3;
    var obj4;
    var obj5;
    
   obj=parent.window["linkedIMG"];
    obj2=parent.window["linkedIMG2"];
    obj3=parent.window["up0"];
    obj4=parent.window["dn0"];
    obj5=parent.window["thumb0"];
  
    if (img == 'images/linkedImages/ourtrustees.jpg') {
        obj.style.display='none';
        obj2.style.display='block';
        obj3.style.display='none';
        obj4.style.display='none';
        obj5.style.display='none';
    } else {
        obj2.style.display='none';
        obj.style.display='block';
        obj.src=img;    
        obj3.style.display='block';
        obj4.style.display='block';
        obj5.style.display='block';

        
    }
    }
     
     catch(err) {}
}

function MouseOut(menutype,Id) {
    array=getArray(menutype);
    
    var index=getIndex(array,Id);
    if ((array[index].keepon) == false) {
        obj = document.getElementById(Id);
        obj.style.backgroundColor=array[index].bgcolor;    
        obj.style.color=array[index].textcolor;        
   }
}

function getIndex(array,Id) {
    for (x in array) {
        if (array[x].Id==Id) {
            return array[x].index;
        }
    }
}

function AddMenuItem(menuItem,addSpace)
{


	objMenuItem = document.getElementById(menuItem.Id);
	objMenuItem.innerHTML = "";
	space="";
	if (addSpace==1) {
	    space="&nbsp" + "&nbsp" 
	}
	
	if (addSpace==2) {
	    space="&nbsp" + "&nbsp" +"&nbsp" + "&nbsp" 
	} 
	
  
	if (menuItem.parentId=="") {
	    objMenuItem.innerHTML = "<div class='separator2px'></div><div class='txtMenu'>" + menuItem.Text +  space+ "</div>";
	    objMenuItem.style.display="block";
	} 
	else {
	 //   objMenuItem.style.display="none";
        objMenuItem.innerHTML = "<div class='separator2px'></div><div class='txtMenu'>" + menuItem.Text +  space+ "</div>";
	}
}

function menu(index,Id,Text,linkedIMG,menuLink,parentId,bgpicture,last,top,bgcolor,textcolor,bgcolorsel,textcolorsel) {
    this.Text=Text;
    this.Id=Id;
    this.top=top;
    this.left=1;
    this.parentId=parentId;
    this.index=index;
    this.on=false;
    this.keepon=false;
    this.linkedIMG=linkedIMG;
    this.menuLink=menuLink;
    this.bgpicture=bgpicture;
    this.last=last;
    this.bgcolor=bgcolor;
    this.textcolor=textcolor;
    this.bgcolorsel=bgcolorsel;
    this.textcolorsel=textcolorsel;
}

function MouseClick(menutype,Id) {
   array=getArray(menutype);
   parentId=array[getIndex(array,Id)].parentId
   bgpicture=array[getIndex(array,Id)].bgpicture
   isOn=array[getIndex(array,Id)].on 
   
    if (parentId=="") {
	     if (menutype==1) { 
	        for (x in array) {
                array[x].on=false;
            }
           
    }
    
    if (!isOn) {
        for (x in array) {
           // HideSubmenu(menutype,array[x].Id);
        }
        DisplaySubmenu(menutype,array[getIndex(array,Id)].Id)
        array[getIndex(array,Id)].on=true;
    } else {
        array[getIndex(array,Id)].on=false;}
	}
	
}


menuItem[0]=    new menu(0,"menu_0"     ,"WHO WE ARE"          ,"whoweare.jpg" ,"whoweare.htm"           ,""        ,"l_9C1F31.gif",0,1,"#E7E8E9","#5A4A42","#9C1F31","white");
  menuItem[1]=  new menu(1,"menu_0_0"   ,"Our approach"        ,"ourapproach.jpg" ,"ourapproach.htm"        ,"menu_0"  ,"l_9C1F31.gif",0,0,"white","#BA8816","white","#9C1F31");
  menuItem[2]=  new menu(2,"menu_0_1"   ,"Our trustees"        ,"blank.jpg" ,"ourtrustees.htm"        ,"menu_0"  ,"l_9C1F31.gif",1,0,"white","#BA8816","white","#9C1F31");

menuItem[3]=    new menu(3,"menu_1"     ,"HOW WE HELP"         ,"howwehelp.jpg" ,"howwehelp.htm"         ,""         ,"l_008554.gif",0,1,"#E7E8E9","#5A4A42","#008554","white");
  menuItem[4]=  new menu(4,"menu_1_0"   ,"Advice & support"    ,"adviceandsupport.jpg" ,"adviceandsupport.htm"  ,"menu_1"   ,"l_008554.gif",0,0,"white","#BA8816","white","#9C1F31");
  menuItem[5]=  new menu(5,"menu_1_1"   ,"Loans & grants"      ,"loansandgrants.jpg" ,"loansandgrants.htm"    ,"menu_1"   ,"l_008554.gif",0,0,"white","#BA8816","white","#9C1F31");
  menuItem[27]= new menu(27,"menu_1_2"   ,"Good practice"       ,"goodpractice.jpg", "goodpractice.htm", "menu_1", "l_008554.gif", 0, 0, "white", "#BA8816", "white", "#9C1F31");
  menuItem[6]=  new menu(6,"menu_1_3"   ,"Ethical banking"     ,"ethicalbanking.jpg" ,"ethicalbanking.htm"    ,"menu_1"   ,"l_008554.gif",0,0,"white","#BA8816","white","#9C1F31");
  menuItem[7]=  new menu(7,"menu_1_4"   ,"Spiritual concern"   ,"spiritualconcern.jpg" ,"spiritualconcern.htm"  ,"menu_1"   ,"l_008554.gif",0,0,"white","#BA8816","white","#9C1F31");
  menuItem[8]=  new menu(8,"menu_1_5"   ,"What we cannot do"   ,"whatwecannotdo.jpg" ,"whatwecannotdo.htm"    ,"menu_1"   ,"l_008554.gif",1,0,"white","#BA8816","white","#9C1F31");

menuItem[9]=    new menu(9,"menu_2"     ,"WHO WE HELP"         ,"whowehelp.jpg" ,"whowehelp.htm"                ,""         ,"l_BA8816.gif",0,1,"#E7E8E9","#5A4A42","#BA8816","white");
 menuItem[10]=  new menu(10,"menu_2_0"  ,"Eligibility"         ,"eligibility.jpg" ,"eligibility.htm"            ,"menu_2"   ,"l_BA8816.gif",0,0,"white","#BA8816","white","#9C1F31");
 menuItem[11]=  new menu(11,"menu_2_1"  ,"Housing projects"    ,"housingprojects.jpg" ,"housingprojects.htm"   ,"menu_2"   ,"l_BA8816.gif",0,0,"white","#BA8816","white","#9C1F31");
 menuItem[12]=  new menu(12,"menu_2_2"  ,"Older people"        ,"olderpeople.jpg" ,"olderpeople.htm"           ,"menu_2"   ,"l_BA8816.gif",1,0,"white","#BA8816","white","#9C1F31");

menuItem[13]=   new menu(13, "menu_3"   ,"HOW YOU HELP"        ,"howyouhelp.jpg" ,"howyouhelp.htm"              ,""             ,"l_00667D.gif",0,1,"#E7E8E9","#5A4A42","#00667D","white");
 menuItem[14]=  new menu(14,"menu_3_0"  ,"Your housing project","yourhousingproject.jpg" ,"yourhousingproject.htm"     ,"menu_3","l_00667D.gif",0,0,"white","#BA8816","white","#9C1F31");
 menuItem[15]=  new menu(15,"menu_3_1"  ,"Spread the word"     ,"spreadtheword.jpg" ,"spreadtheword.htm"       ,"menu_3"        ,"l_00667D.gif",0,0,"white","#BA8816","white","#9C1F31");
 menuItem[16]=  new menu(16,"menu_3_2"  ,"Donations"           ,"donations.jpg" ,"donations.htm" ,"menu_3"        ,"l_00667D.gif",0,0,"white","#BA8816","white","#9C1F31");
 menuItem[17]=  new menu(17,"menu_3_3"  ,"Loans & legacies"    ,"loansandlegacies.jpg" ,"loansandlegacies.htm" ,"menu_3"        ,"l_00667D.gif",0,0,"white","#BA8816","white","#9C1F31");
 menuItem[18]=  new menu(18,"menu_3_4"  ,"QSHA Account"        ,"qsha.jpg" ,"qsha.htm"                         ,"menu_3"        ,"l_00667D.gif",0,0,"white","#BA8816","white","#9C1F31");
 menuItem[19]=  new menu(19,"menu_3_5"  ,"Support and service" ,"supportandservice.jpg" ,"supportandservice.htm"           ,"menu_3"        ,"l_00667D.gif",1,0,"white","#BA8816","white","#9C1F31");

menuItem[20]=   new menu(20,"menu_4"   ,"HOW TO APPLY"        ,"howtoapply.jpg" ,"howtoapply.htm"         ,""         ,"l_830055.gif",0,1,"#E7E8E9","#5A4A42","#830055","white");

menuItem[21]=   new menu(21,"menu_5"   ,"PROJECTS"            ,"projects.jpg" ,"projects.htm"           ,""         ,"l_D85620.gif",0,1,"#E7E8E9","#5A4A42","#D85620","white");  
menuItem[22]=   new menu(22,"menu_9"   ,"NEWS"                ,"news.jpg"         ,"news.htm"          ,""          ,"l_D85620.gif",0,1,"#E7E8E9","#5A4A42","#D85620","white");  
menuItem[23]=   new menu(23,"menu_10"  ,"PUBLICATIONS"        ,"publications.jpg" ,"publications.htm"  ,""          ,"l_D85620.gif",0,1,"#E7E8E9","#5A4A42","#D85620","white");
menuItem[28] = new menu(28, "menu_12"  ,"SPIRIT OF PLACE"     ,"spiritofplace.jpg", "spiritofplace.htm",         "", "l_D85620.gif", 0, 1, "#E7E8E9", "#5A4A42", "#D85620", "white");  
 
menuItem[24]=   new menu(24,"menu_6"   ,"FAQS"                ,"faqs.jpg"      ,"faqs.htm"              ,""          ,"l_FBAD1D.gif"   ,0,1,"#E7E8E9","#5A4A42","#FBAD1D","white");  
menuItem[25]=   new menu(25,"menu_7"   ,"LINKS"               ,"links.jpg"     ,"links.htm"             ,""          ,"l_FBAD1D.gif"  ,0,1,"#E7E8E9","#5A4A42","#FBAD1D","white");  
menuItem[26]=   new menu(26,"menu_8"   ,"CONTACT US"          ,"contactus.jpg" ,"contactus.htm"         ,""          ,"l_FBAD1D.gif"  ,0,1,"#E7E8E9","#5A4A42","#FBAD1D","white");  


function AddMenu() {

    for (x in menuItem) {
        AddMenuItem(menuItem[x],0);
    }
   
}

function submenuClick(submenuId) {

    var index=getIndex(menuItem,submenuId);
    var parentIndex=getIndex(menuItem,menuItem[index].parentId); 
    var bgpicture=menuItem[index].bgpicture
    clearSelection();

    MouseOver (menuItem[index].top,menuItem[index].parentId)
    
  
    menuItem[index].keepon=true;
    MouseOver(menuItem[index].top,menuItem[index].Id);
    menuItem[parentIndex].keepon=true;
    MouseOver(menuItem[parentIndex].top,menuItem[parentIndex].Id);
    setLinkedImage('images/linkedImages/'+  menuItem[index].linkedIMG);
    LoadImg('logo','images/logos/' + menuItem[index].bgpicture);
    
    var obj = top.document.getElementById("datapage");
    obj.src= menuItem[index].menuLink;

}

function NoSubmenuClick(menuId) {
    
    var index=getIndex(menuItem,menuId);
     
    clearSelection();
    
    
    MouseOver (menuItem[index].top,menuItem[index].Id)
    
        var obj = top.document.getElementById("datapage");
    obj.src= menuItem[index].menuLink;


    
    menuItem[index].keepon=true;
    MouseOver(menuItem[index].top, menuItem[index].Id);
    var bgpicture=menuItem[index].bgpicture
    setLinkedImage('images/linkedImages/'+  menuItem[index].linkedIMG);
    LoadImg('logo','images/logos/' + menuItem[index].bgpicture);
}

function clearSelection() {
    for (x in menuItem) {
        menuItem[x].keepon=false;
        MouseOut(menuItem[x].top, menuItem[x].Id);
    }
}

function getArray(menutype) {
    return(menuItem);
}


