/***********************************************
* Pop-it menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var defaultMenuWidth="150px" //set default menu width.

var linkset=new Array()
var MenuOffsets = new Array();

var CurrentCellObject;

//SPECIFY MENU SETS AND THEIR LINKS. FOLLOW SYNTAX LAID OUT

linkset[0]='<table cellpadding="10"><tr><td width="130" bgcolor="black">'
linkset[0]+='<a href="beliefs.php">Beliefs</a>'
linkset[0]+='<a href="history.php">History</a>'
linkset[0]+='</td></tr></table>'
MenuOffsets[0] = -71;

/*linkset[1]='<table cellpadding="10"><tr><td width="130" bgcolor="black">'
linkset[1]+='<a href="media_center.php">Media Center</a>'
linkset[1]+='<a href="http://www.realradioactive.org" target="_blank">Real Radio</a>'
linkset[1]+='</td></tr></table>'
MenuOffsets[1] = -70;*/

linkset[1]='<table cellpadding="10"><tr><td valign="top" bgcolor="black">'
linkset[1]+='<a href="media_center.php">Media Center</a>'
linkset[1]+='<a href="photo_gallery.php">Photo Gallery</a>'
linkset[1]+='<a href="http://www.realradioactive.org" target="_blank">Real Radio</a>'
linkset[1]+='</td><td cellpadding="0"><img src="images/vert_line_menu2.png" /></td>'
linkset[1]+='<td bgcolor="black" valign="top" width="170">'
linkset[1]+='<a href="http://www.oneyearbibleonline.com/oneyearweekly.php?version=51&startmmdd=0101" target="_blank">One Year Bible Online </a>'
linkset[1]+='<a href="http://www.oneyearaudiobible.org/?a_aid=841662e1" target="_blank">One Year Audio Bible Online </a>'
linkset[1]+='</td></tr></table>'
MenuOffsets[1] = -99;

linkset[2]='<table cellpadding="10"><tr><td valign="top" bgcolor="black">'
/*linkset[2]+='<a href="ministries_info.php">Ministry Info</a>'*/
linkset[2]+='<a href="prayer.php">Prayer</a>'
linkset[2]+='<a href="missions.php">Missions</a>'
linkset[2]+='<a href="new_beginnings.php">New Beginnings</a>'
linkset[2]+='<a href="childrens_ministry.php">Children</a>'
linkset[2]+='<a href="jr_high_ministry.php">Junior High</a>'
linkset[2]+='<a href="high_school_ministry.php">High School</a>'
linkset[2]+='</td><td cellpadding="0"><img src="images/vert_line_menu.png" /></td>'
linkset[2]+='<td bgcolor="black" valign="top">'
linkset[2]+='<a href="revive.php">Revive Young Adults</a>'
linkset[2]+='<a href="mens_ministry.php">Men</a>'
linkset[2]+='<a href="womens_ministry.php">Women</a>'
linkset[2]+='<a href="http://www.watchmenministry.com/" target="_blank">Watchmen</a>'
linkset[2]+='</td></tr></table>'
MenuOffsets[2] = -175;

linkset[3]='<table cellpadding="10"><tr><td width="130" bgcolor="black">'
linkset[3]+='<a href="http://www.facebook.com/calvarychapelchinohills" target="_blank">Facebook</a>'
linkset[3]+='<a href="http://www.twitter.com/calvarycch" target="_blank">Twitter</a>'
linkset[3]+='<a href="http://www.e-bulletinonline.com" target="_blank">Ebulletin</a>'
linkset[3]+='<a href="http://www.ccchevents.com/" target="_blank">Events</a>'
/*linkset[3]+='<a href="discipleship.php">Discipleship</a>'*/
/*linkset[3]+='<a href="support_our_troops.php">Support Our Troops</a>'*/

linkset[3]+='</td></tr></table>'
MenuOffsets[3] = -120;

linkset[4]='<table cellpadding="10"><tr><td width="130" bgcolor="black">'
linkset[4]+='<a href="https://webview.shelbyinc.com/app/04564/Default.aspx" target="_blank">Online Giving</a>'
linkset[4]+='<a href="https://webview.shelbyinc.com/app/04564/Default.aspx" target="_blank">Event Registration</a>'
linkset[4]+='</td></tr></table>'
MenuOffsets[4] = -71;
////No need to edit beyond here

var ie5=document.all && !window.opera
var ns6=document.getElementById

if (ie5||ns6)
document.write('<div id="popitmenu" onMouseover="clearhidemenu();" onMouseout="dynamichide(event)"></div>')


function ShowMenuLink(e, which, oReference){

    if (!document.all&&!document.getElementById)
        return;
    
    clearhidemenu();
    
    oReference.style.cursor='pointer';
    oReference.style.color = '#750803';
    
    //If we have moved off of another cell, then change the color of that previous
    //cell back to the background
    if(CurrentCellObject)
        ChangeBackground(CurrentCellObject, '')
  
    //Note the current cell object we are in to change its color later
    CurrentCellObject = oReference;
  
    //Highlight the current cell color
    ChangeBackground(oReference, '#000')
    
    
    
    menuobj=document.getElementById("popitmenu");
    
    menuobj.style.visibility="hidden";

    return false
    
}

function showmenu(e, which, oReference){

    if (!document.all&&!document.getElementById)
        return;
    
    oReference.style.cursor='pointer';
    
    
    //If we have moved off of another cell, then change the color of that previous
    //cell back to the background
    if(CurrentCellObject)
        ChangeBackground(CurrentCellObject, '')
  
    //Note the current cell object we are in to change its color later
    CurrentCellObject = oReference;
  
    //Highlight the current cell color
    ChangeBackground(oReference, '#000')
    
    
    
    menuobj=document.getElementById("popitmenu")
    
    //Used if you want to perform other tasks in this function except dont show a menu (Home)
    if (which == -1)
        return;
    
    clearhidemenu();
    
    menuobj.innerHTML=linkset[which]
    //menuobj.style.width=(typeof optWidth!="undefined")? optWidth : defaultMenuWidth
    menuobj.contentwidth=menuobj.offsetWidth
    menuobj.contentheight=menuobj.offsetHeight
    eventX=e.clientX
    eventY=e.clientY


    
        
    //Place the menu in the correct spot on the screen
    menuobj.style.top = GetObjectY(oReference, MenuOffsets[which]) + "px";
    menuobj.style.left = GetObjectX(oReference) + "px";
    
        
    //Show the menu
    menuobj.style.visibility="visible"
    menuobj.style.zIndex = 100;
    return false
    
}

function contains_ns6(a, b) {
//Determines if 1 element in contained in another- by Brainjar.com
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function hidemenu(){
    if (window.menuobj)
    {
         ChangeBackground(CurrentCellObject, '')
         CurrentCellObject.style.color = '#ffffff';
         menuobj.style.visibility="hidden"
    }
}

function dynamichide(e){
if (ie5&&!menuobj.contains(e.toElement))
hidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
hidemenu()
}

function delayhidemenu(oObject){
    CurrentCellObject.style.color = '#ffffff';
    delayhide=setTimeout("hidemenu()",500);

}

function OpenLink(linkURI)
{
    window.location = linkURI;
}

function clearhidemenu(){
    if (window.delayhide)
        clearTimeout(delayhide)
}

if (ie5||ns6)
document.onclick=hidemenu

function GetObjectY(objElement, intOffset)
{
    var iReturnValue = 0;
    elementid=objElement
    while( elementid != null ){
    iReturnValue += elementid.offsetTop;
    elementid = elementid.offsetParent;
    }
    
    //console.log(iReturnValue);
    
    return iReturnValue + intOffset;
}

function GetObjectX(objElement)
{
    var iReturnValue = 0;
    elementid=objElement
    while( elementid != null ){
    iReturnValue += elementid.offsetLeft;
    elementid = elementid.offsetParent;
    }
    
    //console.log(iReturnValue);
    
    return iReturnValue;
}

function ChangeBackground(oObject, strColor)
{
    oObject.style.backgroundColor = strColor;
}