/* use setCurrent for setting "selected" link or menu 
item; call from body onLoad and specify "cl" as the 
selected class in css document and "d" as the id of 
the element containing links(i.e. ul or div) */

function setCurrent(cl,d){
	var i,ob,tA;
	var currentPage = document.location.href;
	if(document.getElementById){
	ob=(d)?document.getElementById(d):document;
	if(ob){
	tA=ob.getElementsByTagName('A');
	for(i=0;i<tA.length;i++){
	if(tA[i].href==currentPage){
	tA[i].className=cl;
}}}}}

/* NEXT PAGE and PREVIOUS PAGE functions; pages in gallery must be named ending in "_#" where
"#" represents the page order desired */

function prevPage (linkArea) {
	var pageNumber = document.location.href.substring(document.location.href.lastIndexOf('_')+1,document.location.href.length-4);
	if (pageNumber > 1) {
		var	newPage = pageNumber * 1;
		window.location = "http://www.safersexinthecity.org/gallery/photos_" + (newPage-1) + ".htm";
		}
}

function nextPage (linkArea) {
	var ob,linkArray;
	var pageNumber = document.location.href.substring(document.location.href.lastIndexOf('_')+1,document.location.href.length-4);
	pageNumber * 1;
	ob=(linkArea)?document.getElementById(linkArea):document;
	if(ob){
		linkArray=ob.getElementsByTagName('A');
	if (pageNumber < linkArray.length) {
		var newPage = pageNumber * 1;
		window.location = "http://www.safersexinthecity.org/gallery/photos_" + (newPage+1) + ".htm";
		}
}}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}