function loadPage(background_img)
{
	if (document.getElementById('transparency'))
	{
		document.getElementById('transparency').style.height = document.body.clientHeight + "px";
		//document.getElementById('wrapper').className += " transparent";
	}
	
	if (background_img !== null)
	{
		var divHeaderImg = document.getElementById('divHeaderImg');
		if (divHeaderImg)
		{
			divHeaderImg.style.backgroundImage = 'url("' + background_img + '")';
		}
		else
		{
			var header = document.getElementById('header');
			if (header)
			{
				header.style.backgroundImage = 'url("' + background_img + '")';
			}
		}
	}
	
	if (document.getElementById('dropDownNav'))
	{
		dropDownNavHover('dropDownNav');
	}
	
	setFocus();
	new ElementMaxHeight();
	setColumnWidths();
	setTabGroupWidth(1);
	
	if (document.getElementById('frmNewBlogEntry'))
	{
		renderBlogPostDateCalendar();
		var tdBlogPostDateTextBox = document.getElementById("tdBlogPostDateTextBox");
		divLeft = getPos(tdBlogPostDateTextBox)[0];
		divTop = getPos(tdBlogPostDateTextBox)[1];
		var divBlogPostDate = document.getElementById("divBlogPostDate");
		divBlogPostDate.style.position = "absolute";
		newTop = divTop;
		newLeft = divLeft + 200;
		divBlogPostDate.style.top = newTop;
		divBlogPostDate.style.left = newLeft;
	}
	
	if (document.getElementById('frmNewJobPosting'))
	{
		var tdJobPostingDateTextBox = document.getElementById("tdJobPostingDateTextBox");
		divLeft = getPos(tdJobPostingDateTextBox)[0];
		divTop = getPos(tdJobPostingDateTextBox)[1];
		var spnJobPostingDateCalendarButton = document.getElementById("spnJobPostingDateCalendarButton");
		spnJobPostingDateCalendarButton.style.position = "absolute";
		spnJobPostingDateCalendarButton.style.top = divTop;
		spnJobPostingDateCalendarButton.style.left = divLeft + 200;
		
		var tdJobClosingDateTextBox = document.getElementById("tdJobClosingDateTextBox");
		divLeft = getPos(tdJobClosingDateTextBox)[0];
		divTop = getPos(tdJobClosingDateTextBox)[1];
		var spnJobClosingDateCalendarButton = document.getElementById("spnJobClosingDateCalendarButton");
		spnJobClosingDateCalendarButton.style.position = "absolute";
		spnJobClosingDateCalendarButton.style.top = divTop;
		spnJobClosingDateCalendarButton.style.left = divLeft + 200;
	}
	
	if (document.getElementById('tblSecondaryNav'))
	{
		var lastSlash = document.URL.lastIndexOf("/");
		var pageName = document.URL.substr(lastSlash + 1);
		if (document.getElementById('SecondaryNav_' + pageName))
		{
			document.getElementById('SecondaryNav_' + pageName).className += ' SecondaryNavActive';
		}
		else
		{
			var tblSecondaryNav = document.getElementById('tblSecondaryNav');
			var links = tblSecondaryNav.getElementsByTagName('a');
			links[0].className += ' SecondaryNavActive';
		}
	}
}

function renderBlogPostDateCalendar()
{
	var Event = YAHOO.util.Event,
	Dom = YAHOO.util.Dom;

	Event.onDOMReady(
		function () 
		{
			var oCalendarMenu1;

			var onButtonClick = function ()
			{
				if (document.getElementById("divHiddenCalendar1").innerHTML !== "")
				{
					document.getElementById("calendarmenu1").innerHTML = document.getElementById("divHiddenCalendar1").innerHTML;
				}
				
				// Create a Calendar instance and render it into the body 
				// element of the Overlay.

				var oCalendar = new YAHOO.widget.Calendar("buttoncalendar1", oCalendarMenu1.body.id);
				oCalendar.render();

				// Subscribe to the Calendar instance's "select" event to 
				// update the month, day, year form fields when the user
				// selects a date.

				oCalendar.selectEvent.subscribe(function (p_sType, p_aArgs) {

					var aDate;
	//								var aTime;

					if (p_aArgs) {
							
						aDate = p_aArgs[0][0];
							
						if (aDate[1] < 10)
						{
							aDate[1] = "0" + aDate[1];
						}
						if (aDate[2] < 10)
						{
							aDate[2] = "0" + aDate[2];
						}
						
	//									aTime = document.getElementById("txtBlogPostDate").value.substr(11);
						var date = new Date();
						
						Dom.get("txtBlogPostDate").value = aDate[0] + "-" + aDate[1] + "-" + aDate[2] + " " + date.toTimeString().substr(0,8);

					}
					
					oCalendarMenu1.hide();
					document.getElementById("divHiddenCalendar1").innerHTML = document.getElementById("calendarmenu1").innerHTML;
					document.getElementById("calendarmenu1").innerHTML = "";
					document.getElementById("divBlogPostDate").style.height = "32px";
					//document.getElementById("tdBlogPostDateCalendarButton").style.height = "32px";
					document.getElementById("tdBlogPostDateTextBox").style.height = "32px";
					document.getElementById("tdStartDateLabel").style.height = "32px";
					document.getElementById("trBlogPostDate").style.height = "38px";
				});


				// Pressing the Esc key will hide the Calendar Menu and send focus back to 
				// its parent Button

				Event.on(oCalendarMenu1.element, "keydown", function (p_oEvent) {
				
					if (Event.getCharCode(p_oEvent) === 27) {
						oCalendarMenu1.hide();
						this.focus();
					}
				
				}, null, this);
				
				
				var focusDay = function () {

					var oCalendarTBody = Dom.get("buttoncalendar1").tBodies[0],
						aElements = oCalendarTBody.getElementsByTagName("a"),
						oAnchor;

					
					if (aElements.length > 0) {
					
						Dom.batch(aElements, function (element) {
						
							if (Dom.hasClass(element.parentNode, "today")) {
								oAnchor = element;
							}
						
						});
						
						
						if (!oAnchor) {
							oAnchor = aElements[0];
						}


						// Focus the anchor element using a timer since Calendar will try 
						// to set focus to its next button by default
						
						YAHOO.lang.later(0, oAnchor, function () {
							try {
								oAnchor.focus();
							}
							catch(e) {}
						});
					
					}
					
				};


				// Set focus to either the current day, or first day of the month in 
				// the Calendar	when it is made visible or the month changes

				oCalendarMenu1.subscribe("show", focusDay);
				oCalendar.renderEvent.subscribe(focusDay, oCalendar, true);


				// Give the Calendar an initial focus
				
				focusDay.call(oCalendar);


				// Re-align the CalendarMenu to the Button to ensure that it is in the correct
				// position when it is initial made visible
				
				oCalendarMenu1.align();
				

				// Unsubscribe from the "click" event so that this code is 
				// only executed once

				//this.unsubscribe("click", onButtonClick);

			};

			// Create an Overlay instance to house the Calendar instance

			oCalendarMenu1 = new YAHOO.widget.Overlay("calendarmenu1", { visible: false });

			// Create a Button instance of type "menu"

			var oButton = new YAHOO.widget.Button({ 
												type: "menu", 
												id: "calendarpicker", 
												label: "Choose A Date", 
												menu: oCalendarMenu1, 
												container: "divBlogPostDate"});

			oButton.on("appendTo", function ()
			{ 

				// Create an empty body element for the Overlay instance in order  
				// to reserve space to render the Calendar instance into. 
			 
				oCalendarMenu1.setBody(" "); 
			 
				oCalendarMenu1.body.id = "calendarcontainer1"; 
			}); 

			/*
				Add a "click" event listener that will render the Overlay, and 
				instantiate the Calendar the first time the Button instance is 
				clicked.
			*/

			oButton.on("click", onButtonClick);
		});
}

function renderJobPostingDateCalendar()
{
	var Event = YAHOO.util.Event,
	Dom = YAHOO.util.Dom;
	
	Event.onDOMReady(
		function () 
		{
			var oCalendarMenu1;

			var onButtonClick = function ()
			{
				if (document.getElementById("divHiddenCalendar1").innerHTML !== "")
				{
					document.getElementById("calendarmenu1").innerHTML = document.getElementById("divHiddenCalendar1").innerHTML;
				}
				
				// Create a Calendar instance and render it into the body 
				// element of the Overlay.

				var oCalendar = new YAHOO.widget.Calendar("buttoncalendar1", oCalendarMenu1.body.id);
				oCalendar.render();

				// Subscribe to the Calendar instance's "select" event to 
				// update the month, day, year form fields when the user
				// selects a date.

				oCalendar.selectEvent.subscribe(function (p_sType, p_aArgs) {

					var aDate;

					if (p_aArgs) {
							
						aDate = p_aArgs[0][0];
							
						if (aDate[1] < 10)
						{
							aDate[1] = "0" + aDate[1];
						}
						if (aDate[2] < 10)
						{
							aDate[2] = "0" + aDate[2];
						}
						Dom.get("txtJobPostingDate").value = aDate[0] + "-" + aDate[1] + "-" + aDate[2];

					}
					
					oCalendarMenu1.hide();
					document.getElementById("divHiddenCalendar1").innerHTML = document.getElementById("calendarmenu1").innerHTML;
					document.getElementById("calendarmenu1").innerHTML = "";
					document.getElementById("spnJobPostingDateCalendarButton").style.height = "32px";
					document.getElementById("tdJobPostingDateTextBox").style.height = "32px";
					document.getElementById("tdJobPostingDateLabel").style.height = "32px";
					document.getElementById("trJobPostingDate").style.height = "38px";
				});


				// Pressing the Esc key will hide the Calendar Menu and send focus back to 
				// its parent Button

				Event.on(oCalendarMenu1.element, "keydown", function (p_oEvent) {
				
					if (Event.getCharCode(p_oEvent) === 27) {
						oCalendarMenu1.hide();
						this.focus();
					}
				
				}, null, this);
				
				
				var focusDay = function () {

					var oCalendarTBody = Dom.get("buttoncalendar1").tBodies[0],
						aElements = oCalendarTBody.getElementsByTagName("a"),
						oAnchor;

					
					if (aElements.length > 0) {
					
						Dom.batch(aElements, function (element) {
						
							if (Dom.hasClass(element.parentNode, "today")) {
								oAnchor = element;
							}
						
						});
						
						
						if (!oAnchor) {
							oAnchor = aElements[0];
						}


						// Focus the anchor element using a timer since Calendar will try 
						// to set focus to its next button by default
						
						YAHOO.lang.later(0, oAnchor, function () {
							try {
								oAnchor.focus();
							}
							catch(e) {}
						});
					
					}
					
				};


				// Set focus to either the current day, or first day of the month in 
				// the Calendar	when it is made visible or the month changes

				oCalendarMenu1.subscribe("show", focusDay);
				oCalendar.renderEvent.subscribe(focusDay, oCalendar, true);


				// Give the Calendar an initial focus
				
				focusDay.call(oCalendar);


				// Re-align the CalendarMenu to the Button to ensure that it is in the correct
				// position when it is initial made visible
				
				oCalendarMenu1.align();
				

				// Unsubscribe from the "click" event so that this code is 
				// only executed once

				//this.unsubscribe("click", onButtonClick);

			};

			// Create an Overlay instance to house the Calendar instance

			oCalendarMenu1 = new YAHOO.widget.Overlay("calendarmenu1", { visible: false });

			// Create a Button instance of type "menu"

			var oButton = new YAHOO.widget.Button({ 
												type: "menu", 
												id: "calendarpicker", 
												label: "Choose A Date", 
												menu: oCalendarMenu1, 
												container: "spnJobPostingDateCalendarButton"});
			oButton.on("appendTo", function ()
			{ 

				// Create an empty body element for the Overlay instance in order  
				// to reserve space to render the Calendar instance into. 
			 
				oCalendarMenu1.setBody(" "); 
			 
				oCalendarMenu1.body.id = "calendarcontainer1"; 
			}); 

			/*
				Add a "click" event listener that will render the Overlay, and 
				instantiate the Calendar the first time the Button instance is 
				clicked.
			*/

			oButton.on("click", onButtonClick);
		});
}

function renderJobClosingDateCalendar()
{
	var Event = YAHOO.util.Event,
	Dom = YAHOO.util.Dom;
	
	Event.onDOMReady(
		function () 
		{
			var oCalendarMenu2;

			var onButtonClick = function ()
			{
				if (document.getElementById("divHiddenCalendar2").innerHTML !== "")
				{
					document.getElementById("calendarmenu2").innerHTML = document.getElementById("divHiddenCalendar2").innerHTML;
				}
				
				// Create a Calendar instance and render it into the body 
				// element of the Overlay.

				var oCalendar = new YAHOO.widget.Calendar("buttoncalendar2", oCalendarMenu2.body.id);

				oCalendar.render();


				// Subscribe to the Calendar instance's "select" event to 
				// update the month, day, year form fields when the user
				// selects a date.

				oCalendar.selectEvent.subscribe(function (p_sType, p_aArgs) {

					var aDate;

					if (p_aArgs) {
							
						aDate = p_aArgs[0][0];
							
						if (aDate[1] < 10)
						{
							aDate[1] = "0" + aDate[1];
						}
						if (aDate[2] < 10)
						{
							aDate[2] = "0" + aDate[2];
						}
						Dom.get("txtJobClosingDate").disabled = false;
						Dom.get("txtJobClosingDate").value = aDate[0] + "-" + aDate[1] + "-" + aDate[2];
						Dom.get("chkNoClosingDate").checked = false;
					}
					else
					{
						if (Dom.get("txtJobClosingDate").value = "")
						{
							Dom.get("txtJobClosingDate").disabled = false;
						}
					}
					
					oCalendarMenu2.hide();
					document.getElementById("divHiddenCalendar2").innerHTML = document.getElementById("calendarmenu2").innerHTML;
					document.getElementById("calendarmenu2").innerHTML = "";
					document.getElementById("spnJobClosingDateCalendarButton").style.height = "32px";
					document.getElementById("tdJobClosingDateTextBox").style.height = "32px";
					document.getElementById("tdJobClosingDateLabel").style.height = "32px";
					document.getElementById("trJobClosingDate").style.height = "38px";
				});


				// Pressing the Esc key will hide the Calendar Menu and send focus back to 
				// its parent Button

				Event.on(oCalendarMenu2.element, "keydown", function (p_oEvent) {
				
					if (Event.getCharCode(p_oEvent) === 27) {
						oCalendarMenu2.hide();
						this.focus();
					}
				
				}, null, this);
				
				
				var focusDay = function () {

					var oCalendarTBody = Dom.get("buttoncalendar2").tBodies[0],
						aElements = oCalendarTBody.getElementsByTagName("a"),
						oAnchor;

					
					if (aElements.length > 0) {
					
						Dom.batch(aElements, function (element) {
						
							if (Dom.hasClass(element.parentNode, "today")) {
								oAnchor = element;
							}
						
						});
						
						
						if (!oAnchor) {
							oAnchor = aElements[0];
						}


						// Focus the anchor element using a timer since Calendar will try 
						// to set focus to its next button by default
						
						YAHOO.lang.later(0, oAnchor, function () {
							try {
								oAnchor.focus();
							}
							catch(e) {}
						});
					
					}
					
				};


				// Set focus to either the current day, or first day of the month in 
				// the Calendar	when it is made visible or the month changes

				oCalendarMenu2.subscribe("show", focusDay);
				oCalendar.renderEvent.subscribe(focusDay, oCalendar, true);


				// Give the Calendar an initial focus
				
				focusDay.call(oCalendar);


				// Re-align the CalendarMenu to the Button to ensure that it is in the correct
				// position when it is initial made visible
				
				oCalendarMenu2.align();
				

				// Unsubscribe from the "click" event so that this code is 
				// only executed once

				//this.unsubscribe("click", onButtonClick);

			};

			// Create an Overlay instance to house the Calendar instance

			oCalendarMenu2 = new YAHOO.widget.Overlay("calendarmenu2", { visible: false });

			// Create a Button instance of type "menu"

			var oButton = new YAHOO.widget.Button({ 
												type: "menu", 
												id: "calendarpicker2", 
												label: "Choose A Date", 
												menu: oCalendarMenu2, 
												container: "spnJobClosingDateCalendarButton"});

			oButton.on("appendTo", function ()
			{ 

				// Create an empty body element for the Overlay instance in order  
				// to reserve space to render the Calendar instance into. 
			 
				oCalendarMenu2.setBody(" "); 
			 
				oCalendarMenu2.body.id = "calendarcontainer2"; 
			}); 

			/*
				Add a "click" event listener that will render the Overlay, and 
				instantiate the Calendar the first time the Button instance is 
				clicked.
			*/

			oButton.on("click", onButtonClick);
		});
}

function setFocus()
{
	lastSlash = document.location.pathname.lastIndexOf("/");
	pageName = document.location.pathname.substr(lastSlash + 1);
	
	switch (pageName)
	{
		case "login":
			// we are on the login page. Set the focus according to whether or not the 'incorrect password' message is visible.
			
			if (document.getElementById("spnIncorrectPassword") && document.getElementById("spnIncorrectPassword").style.visibility == "hidden")
			{
				if (document.getElementById("txtUserID"))
				{
					txtUserID = document.getElementById("txtUserID");
					txtUserID.focus();
				}
			}
			else
			{
				if (document.getElementById("txtPassword"))
				{
					txtPassword = document.getElementById("txtPassword");
					txtPassword.focus();
				}
			}
			break;
			
		case "password":
			// we are on the forgotten password page. Set the focus to the email address field.
			
			if (document.getElementById("txtEmail"))
			{
				txtEmail = document.getElementById("txtEmail");
				txtEmail.focus();
			}
			break;
			
		default:
			if (document.referrer.substr(document.referrer.lastIndexOf("/") + 1).toLowerCase() == "registration")
			{
				// we are on the Registration page. Set the focus to the first input field in the form, which is the third input element on the page - 
				// the search box and button don't count.
				textboxes = document.getElementsByTagName("input");
				textboxes[2].focus();
			}
			break;
	}
}

function setTabGroupWidth(galleryNumber)
{
	var tabGroupWidth = 0;
	var pageTabs = document.getElementsByTagName('div');
	for (var i = 0; i < pageTabs.length; i++)
	{
		if (pageTabs[i].id.indexOf('tabGroup') >= 0)
		{
			var tabGroupList = pageTabs[i].getElementsByTagName('ul');
			for (var j = 0; j < tabGroupList.length; j++)
			{
				if (tabGroupList[j].id.indexOf('obtabs') >= 0)
				{
					tabGroupWidth = tabGroupList[j].clientWidth;	// + 4;
					j = tabGroupList.length;
				}
			}

			tabPlacementDivWidth = document.getElementById("tabGroup" + galleryNumber).offsetWidth;
			var tabGroupDivs = pageTabs[i].getElementsByTagName('div');
			for (var j = 0; j < tabGroupDivs.length; j++)
			{
				if (tabGroupDivs[j].className.indexOf('TabPageContent') >= 0 && tabGroupDivs[j].offsetWidth < tabGroupWidth)
				{
					tabGroupDivs[j].style.width = (tabGroupWidth + 3) + "px";
					var pageTab = tabGroupDivs[j].getElementsByTagName('ul');
					for (var k = 0; k < pageTab.length; k++)
					{
						pageTab[k].style.width = (tabGroupWidth + 3) + "px";
						// if (pageTab[k].className.indexOf('currentphotos') >= 0)
						// {
							// pageTab[k].style.borderWidth = "0px";
						// }
						var listItems = pageTab[k].getElementsByTagName('li');
						var maxHeight = 0;
						for (var l = 0; l < listItems.length; l++)
						{
							listItems[l].style.width = tabGroupWidth + "px";
							if (listItems[l].clientHeight > maxHeight)
							{
								maxHeight = listItems[l].clientHeight;
							}
						}
						maxHeight += 30;
						
						if (pageTab[k].id.indexOf('Page') >= 0 && pageTab[k].id.indexOf('Tab') >= 0 && pageTab[k].id.indexOf('Content') >= 0)
						{
							pageTab[k].style.height = maxHeight + "px";
						}
					}
				}
			}
		}
	}
}

function ClearConsultationForm(button)
{
	var form = button.form;
	var inputs = form.getElementsByTagName('input');
	for (var i = 0; i < inputs.length; i++)
	{
		//var fieldId = inputs[i].id;
		switch (inputs[i].type)
		{
			case 'text':
				inputs[i].value = "";
				break;
				
			case 'checkbox':
			case 'radio':
				inputs[i].checked = false;
				break;
		}
	}
	
	inputs = form.getElementsByTagName('select');
	for (i = 0; i < inputs.length; i++)
	{
		inputs[i].selectedIndex = 0;
	}
}

function ClearSearch()
{
	document.getElementById('txtSearchCriteria').value = "";
}

function FillSearch()
{
	txtSearch = document.getElementById('txtSearchCriteria');
	if (txtSearch.value == "")
	{
		document.getElementById('txtSearchCriteria').value = "Search...";
	}
}

function ClearTextField(input_field)
{
	input_field.value = "";
}

function FillTextField(input_field, value_to_fill)
{
	if (input_field.value == "")
	{
		input_field.value = value_to_fill;
	}
}

function SaveOutboundLink(link, referring_url)
{
	var xmlhttp;
	if (window.XMLHttpRequest)
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		// code for IE6, IE5
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		alert("Your browser does not support XMLHTTP!");
	}
	
	url = "saveoutboundlink.php?url=" + link + "&referring_url=" + referring_url;

	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function ActivateTab(columnType, galleryType, galleryNumber, tabNumber, moduleTitle, caption)
{
	if (galleryType == "gallerymini")
	{
		photoType = "MiniGalleryPhoto";
		tabType = "PhotoGallery";
		tabControlType = "Gallery";
		tabsClicked = columnType + "PhotoGallery" + galleryNumber + "Tabs";
		tabId = columnType + "galleryTab" + galleryNumber + "_" + tabNumber;
		contentID = columnType + "Gallery" + galleryNumber + "Tab" + tabNumber + "Content";
		listItemType = "ul";
		
		if (moduleTitle !== null)
		{
			document.getElementById(columnType + 'galleryTitle_' + galleryNumber).innerHTML = moduleTitle;
		}
		
		if (caption !== null)
		{
			document.getElementById(columnType + 'galleryCaption_' + galleryNumber).innerHTML = caption;
		}
	}
	else if (galleryType == "galleryfull")
	{
		photoType = "ImageGalleryPhoto";
		tabType = "PhotoGallery";
		tabControlType = "Gallery";
		tabsClicked = columnType + "PhotoGallery" + galleryNumber + "Tabs";
		tabId = columnType + "galleryTab" + galleryNumber + "_" + tabNumber;
		contentID = columnType + "Gallery" + galleryNumber + "Tab" + tabNumber + "Content";
		listItemType = "ul";
		
		if (moduleTitle !== null)
		{
			document.getElementById(columnType + 'galleryTitle_' + galleryNumber).innerHTML = moduleTitle;
		}
		
		if (caption !== null)
		{
			document.getElementById(columnType + 'galleryCaption_' + galleryNumber).innerHTML = caption;
		}
	}
	else if (galleryType == "most popular posts")
	{
		//photoType = "MiniGalleryPhoto";
		photoType = "";
		tabType = "MostPopular";
		tabControlType = "MostPopular";
		tabId = columnType + "mostPopularTab" + tabNumber;
		contentID = "";
		listItemType = "ol";
	}
	else if (galleryType == "page")
	{
		photoType = "";
		tabType = "Page";
		tabControlType = "Page";
		tabsClicked = "obtabs";
		tabId = columnType + "Page" + galleryNumber + "Tab" + tabNumber;
		contentID = columnType + "Page" + galleryNumber + "Tab" + tabNumber + "Content";
		listItemType = "ul";
	}
	
	photoGalleryId = columnType + tabType + galleryNumber;
	tabControlId = columnType + tabControlType + galleryNumber + "Tab" + tabNumber + "Content";
	
	tabClicked = document.getElementById(tabId);
	photoGalleryClickedTabs = document.getElementById(photoGalleryId + "Tabs");
	photoGalleryClickedPage = document.getElementById(photoGalleryId);
	photoGalleryTabs = photoGalleryClickedTabs.getElementsByTagName("li");

	for (i=0; i < photoGalleryTabs.length; i++)
	{
		if (photoGalleryTabs[i].className == "TabCurrent")
		{
			photoGalleryTabs[i].className = "TabHidden";
		}
		
		if (photoGalleryTabs[i].id == tabId)
		{
			photoGalleryTabs[i].className = "TabCurrent";
		}
	}
	
	//tabClicked.className = "TabCurrent";
	
	photoGalleryClickedPageList = photoGalleryClickedPage.getElementsByTagName(listItemType);

	for (i=0; i < photoGalleryClickedPageList.length; i++)
	{
		if (photoGalleryClickedPageList[i].id == tabControlId)
		{
			if (tabType == "PhotoGallery")
			{
				photoGalleryClickedPageList[i].className = photoType + " currentphotos";
			}
			else if (tabType == "MostPopular")
			{
				photoGalleryClickedPageList[i].className = photoType + " currentpopular";
			}
			else if (tabType == "Page")
			{
				photoGalleryClickedPageList[i].className = photoType + " currentPageTab";
				setColumnHeights();
			}
			// set height
			var listItems = photoGalleryClickedPageList[i].getElementsByTagName('li');
			var maxHeight = 0;
			for (var l = 0; l < listItems.length; l++)
			{
				if (listItems[l].clientHeight > maxHeight)
				{
					maxHeight = listItems[l].clientHeight;
				}
			}
			maxHeight += 30;
			
			if (photoGalleryClickedPageList[i].id.indexOf('Page') >= 0 && photoGalleryClickedPageList[i].id.indexOf('Tab') >= 0 && photoGalleryClickedPageList[i].id.indexOf('Content') >= 0)
			{
				photoGalleryClickedPageList[i].style.height = maxHeight + "px";
			}
			//
		}
		else if (tabType == "PhotoGallery" && photoGalleryClickedPageList[i].id !== contentID && photoGalleryClickedPageList[i].id !== tabsClicked)
		{
			photoGalleryClickedPageList[i].className = photoType + " hiddenphotos";
		}		
		else if ((tabType == "MostPopular" && 
			(photoGalleryClickedPageList[i].id.indexOf("MostPopular") >= 0 || photoGalleryClickedPageList[i].id.indexOf("MostEmailed") >= 0))
			&& photoGalleryClickedPageList[i].id.indexOf("Tab") >= 0)
		{
			//photoGalleryClickedPageList[i].className = photoType + " hiddenphotos";
			photoGalleryClickedPageList[i].className = photoType + " hiddenpopular";
		}
		else if ((tabType == "Page" && (photoGalleryClickedPageList[i].id.indexOf("Page") >= 0))
			&& photoGalleryClickedPageList[i].id.indexOf("Tab") >= 0)
		//else if (tabType == "Page" && photoGalleryClickedPageList[i].id.indexOf("Content") >= 0 && photoGalleryClickedPageList[i].id !== contentID)
		{
			photoGalleryClickedPageList[i].className = photoType + " hiddenPageTab";
		}
	}
	
	setTabGroupWidth(galleryNumber);
}

function AddHeart(articleId)
{
	var xmlhttp;
	if (window.XMLHttpRequest)
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		// code for IE6, IE5
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		alert("Your browser does not support XMLHTTP!");
	}
	
	url = "addheart.php?article_id=" + articleId;

	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState == 4)
		{
			// if (xmlhttp.responseText < 0)
			// {
				// alert("You have already hearted this article during this session.");
			// }
			// else
			// {
				//alert("Article hearted.");
//				document.getElementById("spnAddHeart").style.visibility = "hidden";
				divNumHearts = document.getElementById("NumHearts");
				if (divNumHearts)
				{
					document.getElementById("NumHearts").innerHTML = xmlhttp.responseText;
				}
			// }
		}
	}

	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function DeleteFromCMS(tableName, recordID, subRecordID)
{
	var xmlhttp;
	if (window.XMLHttpRequest)
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		// code for IE6, IE5
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		alert("Your browser does not support XMLHTTP!");
	}
	
	url = "cmsdelete.php?table=" + tableName + "&id=" + recordID;

	if (subRecordID == null)
	{
		url += "&subid=0";
	}
	else
	{
		url += "&subid=" + subRecordID;
	}
	
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState == 4)
		{
			if (xmlhttp.responseText < 0)
			{
				alert("The record could not be deleted from table " + tableName + ", record ID " + recordID + ".");
			}
			else
			{
				alert("Record deleted successfully!");
			}
		}
	}

	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function Share_Facebook(u)
{
	//u=location.href;
	t=document.title;
	//window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	window.open('http://www.facebook.com/sharer.php?u='+u+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}

function Share_Delicious()
{
	window.open('http://delicious.com/save?v=5&amp;noui&amp;jump=close&amp;url='+encodeURIComponent(location.href)+'&amp;title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=550,height=550');
	return false;
}

function Share_Digg(url)
{
	window.open(url,'digg','toolbar=0,status=0,width=626,height=436');
}

function Share_Fark()
{
	window.open('http://www.fark.com/cgi/submit.pl');
}

function EmailArticle(articleTitle)
{
	window.open('sendarticle/'+articleTitle,'email','toolbar=0,status=0,width=800,height=600');
}

function ErasePhoto(fileInputField)
{
	chkNoImage = document.getElementById("chkNoImage");
	if (chkNoImage && chkNoImage.checked)
	{
		filPhoto = document.getElementById(fileInputField);
		if (filPhoto)
		{
			filPhoto.value = "";
		}
	}
}

function UncheckNoPhotoBox()
{
	chkNoImage = document.getElementById("chkNoImage");
	if (chkNoImage)
	{
		chkNoImage.checked = false;
	}
}

function UncheckNoMouseoverPhotoBox()
{
	chkNoMouseoverImage = document.getElementById("chkNoMouseoverImage");
	if (chkNoMouseoverImage)
	{
		chkNoMouseoverImage.checked = false;
	}
}

function ChangeActiveFlag(action, blogEntryTitle)
{
	var xmlhttp;
	if (window.XMLHttpRequest)
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		// code for IE6, IE5
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		alert("Your browser does not support XMLHTTP!");
	}
	
	url = "activateblogpost.php?title=" + blogEntryTitle + "&action=" + action;

	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	window.location.replace("blogadmin.php");
}

function ChangeInterestActiveFlag(action, interestID)
{
	var xmlhttp;
	if (window.XMLHttpRequest)
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		// code for IE6, IE5
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		alert("Your browser does not support XMLHTTP!");
	}
	
	url = "activateinterest.php?id=" + interestID + "&action=" + action;

	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	window.location.replace("interests.php");
}

function GetPollAnswer(pollId, answerId)
{
	txtPollResponse = document.getElementById("txtPollResponse_" + pollId);
	if (txtPollResponse)
	{
		txtPollResponse.value = answerId;
	}
}

function Vote(pollId, userId)
{
	var xmlhttp;
	if (window.XMLHttpRequest)
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		// code for IE6, IE5
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		alert("Your browser does not support XMLHTTP!");
	}
	
	txtPollResponse = document.getElementById("txtPollResponse_" + pollId);
	if (txtPollResponse)
	{
		response = txtPollResponse.value;
	}
	
	url = "vote.php?poll_id=" + pollId + "&user_id=" + userId + "&response=" + response;

	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState == 4)
		{
			// voteButton = document.getElementById("VoteButton");
			// if (voteButton)
			// {
				// voteButton.innerHTML = '<span class="VoteThankYouButton">Thanks!</span>';
			// }
			window.location.replace(document.URL);
		}
	}

	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function getPos(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent)
	{
		do
		{
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	return [curleft,curtop];
	}
}

function displayToolTip(tooltipTagID)
{
	divToolTip = document.getElementById(tooltipTagID);
	if (divToolTip)
	{
		divToolTip.style.visibility = "visible";
		divToolTip.style.display = 'block';
		divToolTip.style.whiteSpace = 'normal';
		divToolTip.style.width = '200px';
	}
}

function hideToolTip(tooltipTagID)
{
	divToolTip = document.getElementById(tooltipTagID);
	if(divToolTip)
	{
		divToolTip.style.visibility = "hidden";
		divToolTip.style.display = "none";
	}
}

function CheckLength(fieldName, maxLength)
{
	var textBox = document.getElementById(fieldName);
	if (textBox.value.length >= 500)
	{
		textBox.value = textBox.value.substr(0,500);
	}
}

function CheckAllInterests(interestTypeID)
{
	var checkboxes = document.getElementsByTagName("input");
	for (var i = 0; i < checkboxes.length; i++)
	{
		if ((checkboxes[i].id == ("chkAllInterests_" + checkboxes[i].value)) && checkboxes[i].value == interestTypeID)
		{
			var chkAllInterests = checkboxes[i];
			var checkAllBoxes = !(chkAllInterests.checked);
		}

		if (checkboxes[i].id == "chkInterests_" + interestTypeID + "_" + checkboxes[i].value)
		{
			checkboxes[i].checked = checkAllBoxes ? "" : "checked";
		}
	}
}

function GetWidget(path, step_number)
{
	if (step_number == 1)
	{
		window.location.replace(path + "getwidget/2");
	}
	else if (step_number == 2)
	{
		var xmlhttp;
		if (window.XMLHttpRequest)
		{
			// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp = new XMLHttpRequest();
		}
		else if (window.ActiveXObject)
		{
			// code for IE6, IE5
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		else
		{
			alert("Your browser does not support XMLHTTP!");
		}

		var txtURL = null;
		var inputs = document.getElementsByTagName('input');
		for (var i = 0; i < inputs.length; i++)
		{
			if (inputs[i].id.indexOf('txtURL') >= 0)
			{
				txtURL = inputs[i];
				break;
			}
		}
			
		if (txtURL)
		{
			if (txtURL.value !== "" &&  txtURL.value !== 'www.YOUR-DOMAIN-NAME.com/SUBFOLDER')
			{
				url = "getwidget.php?txtURL=" + txtURL.value;

				xmlhttp.onreadystatechange=function()
				{
					if (xmlhttp.readyState == 4)
					{
						window.location.replace(path + "getwidget/3/" + txtURL.value);
					}
				}

				xmlhttp.open("GET",url,true);
				xmlhttp.send(null);
			}
			else
			{
				alert("You must enter the URL of your website.");
			}
		}
		else
		{
			alert("You must enter the URL of your website.");
		}
	}
}

function ClearWidgetURL()
{
	var txtURL = null;
	var inputs = document.getElementsByTagName('input');
	for (var i = 0; i < inputs.length; i++)
	{
		if (inputs[i].id.indexOf('txtURL') >= 0)
		{
			txtURL = inputs[i];
			break;
		}
	}
			
	txtURL.value = "";
}

function BlankSubscriptionEmail(sender)
{
	sender.value = '';
}

function PopulateSubscriptionEmail(sender, phrase)
{
	if (sender.value == '')
	{
		sender.value = phrase;
	}
}

function PopUpImageGallery(image, height, width)
{
	window.open(image, '_blank', 'height=' + (height + 40) + 'px,width=' + (width + 40) + 'px,scrollbars=no,resizable=no');
}

function EditArticle(path, articleID)
{
	window.location.href = path + "blogadmin.php?id=" + articleID + "&action=edit#input";
}

function SearchBlogEntries()
{
	txtSearchBlogEntries = document.getElementById('txtSearchBlogEntries');
	var xmlhttp;
	if (window.XMLHttpRequest)
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		// code for IE6, IE5
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else
	{
		alert("Your browser does not support XMLHTTP!");
	}
	
	url = "searchblog.php?title=" + txtSearchBlogEntries.value;

	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState == 4)
		{
			divSearchResults = document.getElementById('divSearchResults');
			if (xmlhttp.responseText !== '')
			{
				divSearchResults.style.visibility = 'visible';
				divSearchResults.style.border = '1px solid #000000';
				divSearchResults.innerHTML = xmlhttp.responseText.replace(/'/,"\'");
			}
			else
			{
				divSearchResults.innerHTML = '';
				divSearchResults.style.visibility = 'hidden';
			}
			var tdBlogPostDateTextBox = document.getElementById("tdBlogPostDateTextBox");
			divLeft = getPos(tdBlogPostDateTextBox)[0];
			divTop = getPos(tdBlogPostDateTextBox)[1];
			var divBlogPostDate = document.getElementById("divBlogPostDate");
			divBlogPostDate.style.position = "absolute";
			divBlogPostDate.style.top = divTop;
			divBlogPostDate.style.left = divLeft + 200;
		}
	}

	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function ActivateBlogTitle(spanID)
{
	spanToColour = document.getElementById(spanID);
	spanToColour.style.backgroundColor = "#FFFF00";
	spanToColour.style.color = "#0000FF";
	spanToColour.style.cursor = "pointer";
}

function DeactivateBlogTitle(spanID)
{
	spanToColour = document.getElementById(spanID);
	spanToColour.style.backgroundColor = "#FFFFFF";
	spanToColour.style.color = "#000000";
	spanToColour.style.cursor = "default";
}

function PopulateBlogTitleSearch(blogEntryTitle)
{
	document.getElementById('txtSearchBlogEntries').value = blogEntryTitle;
	document.getElementById('divSearchResults').style.visibility = 'hidden';
	document.getElementById('divSearchResults').style.height = '0px';
}

function returnEnter(e)
{
    return(checkWhichKeyPressed(e) == 13);
}

function checkWhichKeyPressed(e)
{
    var keynum;
    if(window.event) // IE
    {
		keynum = e.keyCode;
    }
	else if(e.which) // Netscape/Firefox/Opera
    {
		keynum = e.which;
    }
	
    return keynum;
}

function SubmitForm(form_name, zipcode)
{
	var form = document[form_name];
	document[form_name].submit();
}

function dropDownNavHover(nav)
{
    var sfEls = document.getElementById(nav).getElementsByTagName("li");
    for (var i=0; i<sfEls.length; i++)
	{
		sfEls[i].onmouseover=function()
		{
			this.className+=" sfhover";
		}
    
		sfEls[i].onmouseout=function()
		{
			this.className=this.className.replace(new RegExp("\\s?sfhover\\b"), "");
		}
    }

	var listItem = document.getElementById(nav).getElementsByTagName('ul');
	for (var i=0; i < listItem.length; i++)
	{
		listItem[i].onmouseover=function()
		{
			var changeStyle = this.parentNode.getElementsByTagName('a');
			changeStyle[0].className+=" active";
		}

		listItem[i].onmouseout=function()
		{
			var changeStyle = this.parentNode.getElementsByTagName('a');
			changeStyle[0].className=this.className.replace(new RegExp("\\s?active\\b"), "");
		}
	}
}

function addEvent( obj, type, fn )
{
	if ( obj.attachEvent )
	{
		obj['e'+type+fn] = fn;
		obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
		obj.attachEvent( 'on'+type, obj[type+fn] );
	}
	else
	{
		obj.addEventListener( type, fn, false );
	}
}

function removeEvent( obj, type, fn )
{
	if ( obj.detachEvent )
	{
		obj.detachEvent( 'on'+type, obj[type+fn] );
		obj[type+fn] = null;
	}
	else
	{
		obj.removeEventListener( type, fn, false );
	}
}

function MM_swapImgRestore()
{
	//v3.0
	var i,x,a=document.MM_sr; 
	for (i=0; a && i < a.length && (x = a[i]) && x.oSrc;i++)
		x.src = x.oSrc;
}

function MM_preloadImages()
{
	//v3.0
	var d = document; 
	if (d.images)
	{
		if (!d.MM_p)
			d.MM_p=new Array();
		var i, j = d.MM_p.length, a = MM_preloadImages.arguments; 
		for (i = 0; i < a.length; i++)
			if (a[i].indexOf("#") != 0)
			{
				d.MM_p[j] = new Image; 
				d.MM_p[j++].src = a[i];
			}
	}
}

function MM_findObj(n, d)
{
	//v4.01
	var p,i,x;  
	if(!d) 
		d=document; 
		
	if ((p = n.indexOf("?")) > 0 && parent.frames.length)
	{
		d=parent.frames[n.substring(p+1)].document; 
		n = n.substring(0,p);
	} 
  
	if (!(x=d[n])&&d.all) 
		x=d.all[n]; 
		
	for (i = 0; !x && i < d.forms.length;i++)
		x=d.forms[i][n]; 
	
	for (i = 0; !x && d.layers && i < d.layers.length;i++)
		x=MM_findObj(n,d.layers[i].document);
	
	if (!x && d.getElementById)
		x = d.getElementById(n); 
		
	return x;
}

function MM_swapImage() 
{
	//v3.0
	var i, j = 0, x, a = MM_swapImage.arguments; 
	
	document.MM_sr = new Array;
	for (i = 0; i < (a.length-2); i += 3)
		if ((x = MM_findObj(a[i])) != null)
		{
			document.MM_sr[j++] = x;
			if (!x.oSrc)
				x.oSrc = x.src;
			x.src = a[i+2];
		}
}

function MM_newSwapImage(anchor, url)
{
//	anchor.parentNode.style.backgroundImage = "url(" + url + ")";
	anchor.style.backgroundImage = "url(" + url + ")";
}

function CloseSEMModule()
{
	if (document.getElementById('semModule'))
	{
		document.getElementById('semModule').innerHTML = '';
	}
	
	if (document.getElementById('wrapper'))
	{
		document.getElementById('wrapper').className = 'wrapper';
	}
}
