//ver 1.1
var popup_array = Array();
function open_popup(url, popup_name, options) {
	var cur_popup = popup_array[popup_name];
	var is_popup_defined = (typeof(cur_popup) == 'object');
	var is_popup_open = (is_popup_defined)
		? !(cur_popup.closed)
		: false;

	if ( is_popup_defined && is_popup_open ) {
		cur_popup.document.write (' ');
		cur_popup.focus();
		cur_popup.location.href = url;
		cur_popup.focus();
	} else if ((is_popup_defined && !is_popup_open) || !is_popup_defined) {
		popup_array[popup_name] = window.open(url, popup_name, options);
	}
}



//copyright 2005 Trinet Internet Solutions, Inc. 
//This code may not be copied or used without permission from Trinet Internet Solutions, Inc. 
//Please contact info@trinetsolutions.com for more information

var menu_x = 0;
var menu_y = 0;
var offsetHeight = 0;
var menu_displacement_x = -1;
var menu_displacement_y = 2;
var dhtml = (document.all || document.getElementById);

var menu_persist_interval = 400; 
var menu_hover_states = Array();
var menu_interval_objects = Array();
var menu_interval_states = Array();

//determine if we should use the iframe mask trick to prevent <select> lists from showing through the menus
//(think it only works in ie6 and higher, though possibly ie5.5)
var hide_div = get_hide_div();

function get_hide_div() {
	var agt = navigator.userAgent.toLowerCase();	
	var idx = agt.indexOf('msie');
	if (idx == -1 || agt.indexOf('opera') != -1) {
		return true;
	} else {
		//browser detection code from http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
		var is_major = parseInt(navigator.appVersion);
		var is_minor = parseFloat(navigator.appVersion);
		var is_ie3    = (is_major < 4);
		var is_ie4    = ((is_major == 4) && (agt.indexOf("msie 4")!=-1) );
		var is_ie4up  = (is_major >= 4);
		var is_ie5    = ((is_major == 4) && (agt.indexOf("msie 5")!=-1) );
		var is_ie6up =(!is_ie3 && !is_ie4 && !is_ie5);
		//end cited code
		if (is_ie6up) {
			return false;
		} else {
			return true;
		}
	}
}
function menu_link_mouseover (menu_name, parent) {

	if (parent != 'menu_none') {
		get_element(parent).allow_hide = false;
		get_element(menu_name).parent_menu = parent;
		menu_hover_states[parent] = true;
		//alert(menu_name + ' ' + parent);
	} else {
		close_all_menus();
		//document.images[menu_name + '_bar'].src = 'images/bg_blue.jpg';
	}
	menu_hover_states[menu_name] = true;
	set_and_show(menu_name);
}

function menu_link_mouseout(menu_name, child_menu) {
	menu_hover_states[menu_name] = false;
	schedule_menu_closing(menu_name);
	menu_hover_states[child_menu] = false;
}

function clear_menu_over(menu_name) {
	if ((get_element(menu_name).allow_hide != false) && !menu_hover_states[menu_name]) {
		clearInterval(menu_interval_objects[menu_name]);
		menu_interval_states[menu_name]=false;
		hide_menu(menu_name);
	}
}
function schedule_menu_closing(menu_name) {
	if (!menu_interval_states[menu_name]) {
		menu_interval_objects[menu_name] = setInterval('clear_menu_over("' + menu_name + '")', menu_persist_interval);
		menu_interval_states[menu_name]=true;
	}
}
function close_all_menus() {
	for (menu_name in menu_hover_states) {
		if (!get_element(menu_name)) {
			//alert(menu_name);
		} else {
			if (get_element(menu_name).allow_hide == true) {
				menu_hover_states[menu_name]=false;
				if (menu_interval_states[menu_name]) {
					clearInterval(menu_interval_objects[menu_name]);
					menu_interval_states[menu_name] = false;
					hide_menu(menu_name);
				}
			}
		}
	}
}

function set_and_show(menu_name) {
	e=document.images[menu_name + '_anchor'];
	//alert(typeof(e));
	menu_x=GetXOffset(e);
	menu_y=GetYOffset(e);
	offsetHeight = e.offsetHeight;
	if (hide_div == false) {
		//prevent <select> elements from showing through
		mask = get_element('iframe_mask' + get_menu_depth(menu_name));
		mask.style.left = (menu_x + menu_displacement_x) + 'px';
		mask.style.top = (menu_y + offsetHeight + menu_displacement_y) + "px";
		mask.style.height = get_element(menu_name).offsetHeight;
		mask.style.width = get_element(menu_name).offsetWidth;		

		mask.style.visibility = "visible";
	}
	show_menu(menu_name);
	schedule_menu_closing(menu_name);
}
function get_menu_depth(menu_name) {
	var i=1;
	e = get_element(menu_name);
	while (e.parent_menu) {
		e = get_element(e.parent_menu);
		i++;
	}
	return i;
}
		
function show_menu(menu_name) {
	if (dhtml) {
		var tempVar=get_element(menu_name);
		//document.getElementById('floater_text').innerHTML=menu_text;
		//tempVar.style.left= (menu_x + menu_displacement_x) + "px";
		//tempVar.style.top = (menu_y + offsetHeight + menu_displacement_y) + "px";
		tempVar.style.visibility="visible";
		tempVar.style.display='';
		tempVar.allow_hide=true;
	}
}
function hide_menu(menu_name) {
	if ( dhtml ){
		var tempVar = get_element(menu_name);
		tempVar.style.visibility="hidden";
		get_element('iframe_mask' + get_menu_depth(menu_name)).style.visibility = 'hidden';
		if ( get_element(tempVar.parent_menu) )  {
			get_element(tempVar.parent_menu).allow_hide=true;
			clear_menu_over(tempVar.parent_menu);
		} else {
			//document.images[menu_name + '_bar'].src='images/clear.gif';
		}
	}
}
function get_element(elem_id) {
	if (document.getElementById) {
		return document.getElementById(elem_id);
	} else if (document.all) {
		return document.all[elem_id];
	} else {
		return false;
	}
}	
function GetXOffset(e) {
	var x=e.offsetLeft;
	var pe;
	pe=e.offsetParent;
	while (pe !=null ) {
		x+=pe.offsetLeft;
		pe=pe.offsetParent;
	}
	return x;
}
function GetYOffset(e) {
	var y=e.offsetTop;
	var pe;
	pe=e.offsetParent;
	while (pe !=null ) {
		y+=pe.offsetTop;
		pe=pe.offsetParent;
	}
	return y;
}

function focusClearOn (field) {
	if (field.value == "email")
		field.value = "";
}

function focusClearOff (field) {
	if (field.value == "")
		field.value = "email";
}

/*function webcast_interface(section, id, event) {
	if (section == 'current') {
		open_popup('/webcast/index.php?section=' + section + '&id=' + id, 'webcast_window', 'width=760,height=406,scrollbars=no,resizable=yes,location=no,menubar=no,status=no,toolbar=no,directories=no,personalbar=no');
	} else if (section == 'archive') {
		open_popup('/webcast/index.php?section=' + section + '&id=' + id + '&event=' + event, 'webcast_window', 'width=760,height=406,scrollbars=no,resizable=yes,location=no,menubar=no,status=no,toolbar=no,directories=no,personalbar=no');
	}
}

menus = {
			   'about_menu':{'visible':false, 'timeout':null, 'image_name':'nav_1_about_us'},
			   'get_involved_menu':{'visible':false, 'timeout':null, 'image_name':'nav_2_get_involved'},
			   'events_menu':{'visible':false, 'timeout':null, 'image_name':'nav_3_events'},
			   'ministries_menu':{'visible':false, 'timeout':null, 'image_name':'nav_4_ministries'},
			   'spiritual_help_menu':{'visible':false, 'timeout':null, 'image_name':'nav_5_spiritual_help'},
			   'resources_menu':{'visible':false, 'timeout':null, 'image_name':'nav_6_resources'},
			   'audio_video_menu':{'visible':false, 'timeout':null, 'image_name':'nav_7_audio_video'}
			  };
function hide_all_menus() {
	for (menu in menus) {
		document.getElementById(menu).style.display='none';
		if (menus[menu].image_name != null) {
			document.images[menus[menu].image_name].src = document.images[menus[menu].image_name].inactive_src;
		}
	}
}

function show_menu(menu_id) {
	if (page_is_loaded == true) {
		if (menus[menu_id].timeout != null) {
			clearTimeout(menus[menu_id].timeout);
			menus[menu_id].timeout = null;
		}
		if (menus[menu_id].visible == false) {
			hide_all_menus();
			document.getElementById(menu_id).style.display='inline';
			menus[menu_id].visible=true;
			if (menus[menu_id].image_name != null) {
				document.images[menus[menu_id].image_name].src = document.images[menus[menu_id].image_name].active_src;
			}
		}
	}
}
function hide_menu(menu_id) {
	if (page_is_loaded == true) {
		if (menus[menu_id].timeout == null) {
			
			var command = "document.getElementById('" + menu_id + "').style.display='none';menus['" + menu_id + "'].timeout=null;menus['" + menu_id + "'].visible=false; "
			if (menus[menu_id].image_name != null) {
				command += "document.images[menus['" + menu_id + "'].image_name].src = document.images[menus['" + menu_id + "'].image_name].inactive_src;";
			}
			menus[menu_id].timeout = setTimeout("" + command, 200);
			
		}
	}
}
//This function takes care of preloading and setting mouse events
page_is_loaded = false;
function do_rollovers() {
	if (document.getElementsByTagName) {
		var images = document.getElementsByTagName('img');
		var preload_images = Array();
		var j=0;
		for (var i=0; i< images.length; i++) {
			if (images[i].className == 'rollover') {
				cur_src = images[i].src;
				images[i].inactive_src = cur_src;
				images[i].active_src = cur_src.replace(/_inactive/g, '_active');
				preload_images[j] = images[i].active_src;
				j++;
			}
		}
		//preload the images
		document.preloaded_images = Array();
		for (var i=0; i<preload_images.length; i++) {
			document.preloaded_images[i] = new Image;
			document.preloaded_images[i].src = preload_images[i];
		}
		
		//initialize objects for all pseudo_menus
		var all_divs = document.getElementsByTagName('div');
		for (var i=0; i< all_divs.length; i++) {
			if (all_divs[i].className == 'pseudo_menu') {
				menus[all_divs[i].id] = new Object();
				menus[all_divs[i].id].visible = false;
				menus[all_divs[i].id].timeout = null;
				menus[all_divs[i].id].image_name = null;
				
				//with (menus[all_divs[i].id]) {
				//	visible = false;
				//	timeout = null;
				//	image_name = null;
				//}
			}
		}
	}
	page_is_loaded = true;
}
*/

