

function highlightNav(catId, numPages) {

	divObj = document.getElementById("topNav" + catId);
	//divLink = document.getElementById("topNavLink" + catId);

	//divObj.style.background = '#9C0021';
	//divLink.style.color = '#FFFFFF';

	if (numPages > 0) {
		divSubNav = document.getElementById("subNav" + catId);
		divSubNav.style.visibility = 'Visible';
	}


}

function unHighlightNav(catId, numPages) {



	divObj = document.getElementById("topNav" + catId);
	//divLink = document.getElementById("topNavLink" + catId);


	//divObj.style.background = '';
	//divLink.style.color = '#333333';

	if (numPages > 0) {
		divSubNav = document.getElementById("subNav" + catId);
		divSubNav.style.visibility = 'hidden';
	}

}


var screenWidth = screen.availWidth;
var screenHeight = screen.availHeight;
var halfScreenWidth = screenWidth / 2;
var halfScreenHeight = screenHeight / 2;


function popup(url, name, width, height) {


	var xPos = 0;
	if (screenWidth == null) {
		xPos = 50;
	} else if (width > screenWidth) {
		width = screenWidth - 20;
		xPos = 5;
	} else {
		xPos = halfScreenWidth - ( width / 2 );
	}

	var yPos = 0;
	if (screenHeight == null) {
		yPos = 50;
	} else if (height > screenHeight) {
		height = screenHeight - 40;
		yPos = 5;
	} else {
		yPos = halfScreenHeight - ( height / 2 );
	}

	var tempWin = window.open(url, name, 'width=' + width + ',height=' + height + ',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=yes,resizable=yes,left=' + xPos + ',top=' + yPos);
	tempWin.focus();
}

function popupImage(picId, width, height) {
	popup('/pages/viewPicture.aspx?picId=' + picId, 'pic' + picId, width + 30, height + 60);
}


function popupSelectImage(pageId, pagePictureCode) {
	popup('/admin/pictures/selectPicture.aspx?pageId=' + pageId + '&code=' + pagePictureCode, 'selectImage', 700, 500);
}

function makeLink(textboxName, catId) {
	popup('/admin/makeLink.aspx?catId=' + catId + '&textboxName=' + textboxName, 'makeLink', 300, 400);
}




// adds a link to a textfield
function addLink(mytextfield) {
	var link = prompt('Please enter the link url, eg. http://www.google.com/', 'http://');
	if (link == null) {
		// is null when user presses escape (at least in IE5.0)
		return;
	}
	if (link.indexOf(':') < 0) {
		alert('Not a valid link. Examples of valid links:\n\nhttp://www.google.com - website link\nmailto:someone@somewhere.com - email link');
		return;
	}
	var linkName = "";
	while (linkName == "") {
		linkName = prompt('Please enter the link name, eg Google', '');
		if (linkName == null) {
			// is null when user presses escape (at least in IE5.0)
			return;
		}
		if (linkName.length == 0) {
			if (!confirm('Please enter a name for this link. This will be the text that users can click on.\nOtherwise, press \'cancel\' if you do not wish to add a link.')) {
				return;
			}
		}
	}
	mytextfield.value += "<a href=\"" + link + "\">" + linkName + "</a>";
	mytextfield.focus();
}
