if (document.images) {
	HomeOff = new Image();
	HomeOff.src = "new_images/nav_home_off.jpg";
	AboutOff = new Image();
	AboutOff.src = "new_images/nav_about_us_off.jpg";
	MeetOff = new Image();
	MeetOff.src = "new_images/nav_meet_off.jpg";
	MediaOff = new Image();
	MediaOff.src = "new_images/nav_multimedia_off.jpg";
	LinksOff = new Image();
	LinksOff.src = "new_images/nav_links_off.jpg";
	BoardOff = new Image();
	BoardOff.src = "new_images/nav_board_off.jpg";
	ContactOff = new Image();
	ContactOff.src = "new_images/nav_contact_off.jpg";
	CalendarOff = new Image();
	CalendarOff.src = "new_images/nav_calendars_off.jpg";
	LoginOff = new Image();
	LoginOff.src = "new_images/nav_login_off.jpg";
	LogoutOff = new Image();
	LogoutOff.src = "new_images/nav_logout_off.jpg";
	AdminOff = new Image();
	AdminOff.src = "new_images/nav_admin_off.jpg";
	RenOff = new Image();
	RenOff.src = "new_images/nav_ren_off.jpg";
	ChildrensOff = new Image();
	ChildrensOff.src = "new_images/nav_children_off.jpg";
	WorshipOff = new Image();
	WorshipOff.src = "new_images/nav_worship_off.jpg";
	DownloadsOff = new Image();
	DownloadsOff.src = "new_images/nav_downloads_off.jpg";
	BlogOff = new Image();
	BlogOff.src = "new_images/nav_tomblog_off.jpg";

	HomeOn = new Image();
	HomeOn.src = "new_images/nav_home_on.jpg";
	AboutOn = new Image();
	AboutOn.src = "new_images/nav_about_us_on.jpg";
	MeetOn = new Image();
	MeetOn.src = "new_images/nav_meet_on.jpg";
	MediaOn = new Image();
	MediaOn.src = "new_images/nav_multimedia_on.jpg";
	LinksOn = new Image();
	LinksOn.src = "new_images/nav_links_on.jpg";
	BoardOn = new Image();
	BoardOn.src = "new_images/nav_board_on.jpg";
	CalendarOn = new Image();
	CalendarOn.src = "new_images/nav_calendars_on.jpg";
	ContactOn = new Image();
	ContactOn.src = "new_images/nav_contact_on.jpg";
	LoginOn = new Image();
	LoginOn.src = "new_images/nav_login_on.jpg";
	LogoutOn = new Image();
	LogoutOn.src = "new_images/nav_logout_on.jpg";
	AdminOn = new Image();
	AdminOn.src = "new_images/nav_admin_on.jpg";
	RenOn = new Image();
	RenOn.src = "new_images/nav_ren_on.jpg";
	ChildrensOn = new Image();
	ChildrensOn.src = "new_images/nav_children_on.jpg";
	WorshipOn = new Image();
	WorshipOn.src = "new_images/nav_worship_on.jpg";
	DownloadsOn = new Image();
	DownloadsOn.src = "new_images/nav_downloads_on.jpg";
	BlogOn = new Image();
	BlogOn.src = "new_images/nav_tomblog_on.jpg";
}


function light(imgName, subItem) {
	if (subItem == "1") {
		subMenu('SubMenu' + imgName, '1');
	}
    if (document.images) {
         document[imgName].src = eval( imgName + "On.src" );
    }
}

function dim(imgName, subItem) {
	if (subItem == "1") {
		t = 1;
		delayHide('SubMenu' + imgName);
	}
    if (document.images) {
         document[imgName].src = eval( imgName + "Off.src" );
    }
}

var t = 0;
var lCount = 0;
var lDelay = 3;
var pause = 100;

var object = "";

function subMenu(obj1, onOff) {
		if (onOff == "1") {
			dispType = 'visible';
		} else {
			dispType = 'hidden';
		}
		
		if (object != "") {
			t=0;
			delayHide();
		} 
		
		object = obj1;
		
 		if (document.getElementById)
 		{
  			document.getElementById(obj1).style.visibility = dispType;
  			t = 2;
		}
 		else if (document.all)
 		{
  			t = 2;
			document.all[obj1].style.visibility = dispType;
 		}
 		else alert ('This form will not work in your browser.');
}

function delayHide() {
	if ((t == 0) && (object != "")) {
		if (document.getElementById)
 		{
  			document.getElementById(object).style.visibility = 'hidden';
		}
 		else if (document.all)
 		{
			document.all[object].style.visibility = 'hidden';
 		}
		lCount = 0;
		object = "";
	}
	if (t == 2) {lCount = 0; }
	if (t == 1) {
		lCount = lCount + 1;
		if (lDelay <= lCount) { t = 0; }
		if (lDelay >= lCount) { setTimeout('delayHide(' + t + ')', pause); }
	}
}


function passwordMatch() {
			if (document.members.new_password.value == document.members.new_password2.value) {
				return true;
			} else {
				alert("Your passwords do not match");
				return false;
			}
}

function showAlert(str) {
			if (str.length > 1) {
				alert(str);
			}
}

function showEvent(id, date, time) {
		eventPage = window.open('showEvent.php?event_id='+id+'&date='+date+'&time='+time, 'portPageWin', 'width=400,height=300,scrollbars=yes,resizable=yes');
		eventPage.focus();
}

function showGallery(user) {
		galleryPage = window.open('photos.php?user='+user, 'galleryWin', 'width=900,height=700,scrollbars=yes,resizable=no');
		galleryPage.focus();
}

function editContent(page) {
		editWindow = window.open('admin/edit_content.php?page='+page, 'galleryWin', 'width=800,height=500,scrollbars=yes,resizable=no');
		editWindow.focus();
}

function editBlog(owner, blogID) {
		editWindow = window.open('admin/edit_blog.php?owner='+owner+'&blogID='+blogID, 'blogWin', 'width=800,height=600,scrollbars=yes,resizable=no');
		editWindow.focus();
}


function avatars() {
		avatarPage = window.open('avatars.php', 'avatarWin', 'width=375,height=300,scrollbars=yes');
		avatarPage.focus();
}

function getWindowWidth() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return myWidth;
}

function setSubmenus(menus) {
		var winWidth = getWindowWidth();
		if (winWidth >= 750) {
			fromLeft = (winWidth / 2) - 320;
		} else {
			fromLeft = 130;
		}

		for (i=0; i<menus.length; i++) {
			var menu = menus[i];
			if (menu.length > 0) {
				if (document.getElementById)
 				{
  					document.getElementById(menu).style.left = fromLeft;
				}
 				else if (document.all)
 				{
					document.all[menu].style.left = fromLeft;
 				}
			}
		}
}