// Tabs change of state code

if (document.images) {
	
	tabs_about_on = new Image
	tabs_about_off = new Image
	tabs_bulletin_on = new Image
	tabs_bulletin_off = new Image
	tabs_catholiclife_on = new Image
	tabs_catholiclife_off = new Image
	tabs_home_off = new Image
	tabs_home_on = new Image
	tabs_kids_off = new Image
	tabs_kids_on = new Image
	tabs_ministries_off = new Image
	tabs_ministries_on = new Image
		
	tabs_about_off.src = "./images/tabs_about_off.gif"
	tabs_about_on.src = "./images/tabs_about_on.gif"	
	tabs_bulletin_off.src = "./images/tabs_bulletin_off.gif"
	tabs_bulletin_on.src =  "./images/tabs_bulletin_on.gif"
	tabs_catholiclife_off.src =  "./images/tabs_catholiclife_off.gif"
	tabs_catholiclife_on.src =  "./images/tabs_catholiclife_on.gif"
	tabs_home_off.src =  "./images/tabs_home_off.gif"
	tabs_home_on.src =  "./images/tabs_home_on.gif"
	tabs_kids_off.src =  "./images/tabs_kids_off.gif"
	tabs_kids_on.src =  "./images/tabs_kids_on.gif"
	tabs_ministries_off.src =  "./images/tabs_ministries_off.gif"
	tabs_ministries_on.src =  "./images/tabs_ministries_on.gif"

} else {
	tabs_about_off = ""
	tabs_about_on = ""
	tabs_bulletin_on = ""
	tabs_bulletin_off = ""
	tabs_catholiclife_on = ""
	tabs_catholiclife_off = ""
	tabs_home_off = ""
	tabs_home_on = ""
	tabs_kids_off = ""
	tabs_kids_on = ""
	tabs_ministries_off = ""
	tabs_ministries_on = ""
	document.tab = ""
}

// Thanks to Matt Kruse's work (http://www.mattkruse.com/) from which this script is used under license.
// functions: getAnchorPosition, getAnchorWindowPosition, AnchorPosition_getPageOffsetLeft, AnchorPosition_getWindowOffsetLeft, AnchorPosition_getPageOffsetTop, AnchorPosition_getWindowOffsetTop


function getAnchorPosition(anchorname) {
	// This function will return an Object with x and y properties
	var useWindow=false;
	var coordinates=new Object();
	var x=0,y=0;
	// Browser capability sniffing
	var use_gebi=false, use_css=false, use_layers=false;
	if (document.getElementById) { use_gebi=true; }
	else if (document.all) { use_css=true; }
	else if (document.layers) { use_layers=true; }
	// Logic to find position
 	if (use_gebi && document.all) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_gebi) {
		var o=document.getElementById(anchorname);
		x=AnchorPosition_getPageOffsetLeft(o);
		y=AnchorPosition_getPageOffsetTop(o);
		}
 	else if (use_css) {
		x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
		y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
		}
	else if (use_layers) {
		var found=0;
		for (var i=0; i<document.anchors.length; i++) {
			if (document.anchors[i].name==anchorname) { found=1; break; }
			}
		if (found==0) {
			coordinates.x=0; coordinates.y=0; return coordinates;
			}
		x=document.anchors[i].x;
		y=document.anchors[i].y;
		}
	else {
		coordinates.x=0; coordinates.y=0; return coordinates;
		}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
	}

// getAnchorWindowPosition(anchorname)
//   This function returns an object having .x and .y properties which are the coordinates
//   of the named anchor, relative to the window
function getAnchorWindowPosition(anchorname) {
	var coordinates=getAnchorPosition(anchorname);
	var x=0;
	var y=0;
	if (document.getElementById) {
		if (isNaN(window.screenX)) {
			x=coordinates.x-document.body.scrollLeft+window.screenLeft;
			y=coordinates.y-document.body.scrollTop+window.screenTop;
			}
		else {
			x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
			y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
			}
		}
	else if (document.all) {
		x=coordinates.x-document.body.scrollLeft+window.screenLeft;
		y=coordinates.y-document.body.scrollTop+window.screenTop;
		}
	else if (document.layers) {
		x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
		y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
		}
	coordinates.x=x;
	coordinates.y=y;
	return coordinates;
	}

// Functions for IE to get position of an object

function AnchorPosition_getPageOffsetLeft (el) {
	var ol=el.offsetLeft;
	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
	return ol;
	}
function AnchorPosition_getWindowOffsetLeft (el) {
	return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
	}	
function AnchorPosition_getPageOffsetTop (el) {
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null) { ot += el.offsetTop; }
	return ot;
	}
	
function AnchorPosition_getWindowOffsetTop (el) {
	return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
	}

// makes the layer visible by finding the posotion of the tab and then drawing the menu near it
function drawMenu(name) {
	
	var c = getAnchorPosition(name);
	// alert("X = "+c.x+" , Y = "+c.y);
	if (document.getElementById) {
		var o = document.getElementById("submenu_" + name);
		if (o.style) {
			o.style.visibility = "visible";
			o.style.left = c.x + -5;
			o.style.top = c.y + 20;
			}
		}
		
	}
	
// makes the layer invisible

function closeSubMenu(menuname) {

 	   document.getElementById(menuname).style.visibility = "hidden";
}