/* ================================================ 
glisada.js for Glisda.com

Copyright (c) 2008 Jesse Nahan. All rights reserved.
jesse@myactivemind.com
==================================================== */

function alerton() {

	document.getElementById('alertLevel').style.visibility = 'visible';
	document.getElementById('alertBox').innerHTML = 'TEST TEXT';
}

function alertoff() {

	document.getElementById('alertLevel').style.visibility = 'hidden';
	document.getElementById('alertBox').innerHTML = '';
}

function emailTest() {
	
	document.getElementById('alertLevel').style.visibility = 'visible';

	getData('email_linkDIV.php?gallery_id='+current_galleryID+'&ie6=N','alertLevel');

}

var XMLHttpRequestObject = false; 

if (window.XMLHttpRequest) {
XMLHttpRequestObject = new XMLHttpRequest();
} else if (window.ActiveXObject) {
XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
}

function getData(dataSource, divID) 
{ 
if(XMLHttpRequestObject) {
  var obj = document.getElementById(divID); 
  XMLHttpRequestObject.open("GET", dataSource); 

  XMLHttpRequestObject.onreadystatechange = function() 
  { 
	if (XMLHttpRequestObject.readyState == 4 && 
	  XMLHttpRequestObject.status == 200) { 
		obj.innerHTML = XMLHttpRequestObject.responseText; 
	} 
  } 

  XMLHttpRequestObject.send(null); 
}
}

function getData1(dataSource, divID) 
{ 
if(XMLHttpRequestObject) {
  var obj = document.getElementById(divID); 
  XMLHttpRequestObject.open("GET", dataSource); 

  XMLHttpRequestObject.onreadystatechange = function() 
  { 
	if (XMLHttpRequestObject.readyState == 4 && 
	  XMLHttpRequestObject.status == 200) { 
		obj.innerHTML = XMLHttpRequestObject.responseText; 
		showHeadshotSlideShow();
	} 
  } 

  XMLHttpRequestObject.send(null); 
}
}


// Search value tracking variables
var	searchSterm = '';
var	searchRestrict = 'any';
var	searchOffset = 0;
var	searchThumbDisplay = 'true';
var	searchStart = 'sets';
var searchClientID = -1;


// IE6 uses jpgs matching the background instead of transparent pngs. 
var imageSuffix;

if (explorer6) {

	switch (backgroundColor) {
	
		case "ffffff":
			imageSuffix = "_white.jpg";
			break;		
		
		case "333333":
			imageSuffix = "_gray.jpg";
			break;		
		
		default:
			imageSuffix = "_black.jpg";
		
	}
} else {

	imageSuffix = ".png";

}


function fetchPhotoSetName(galleryID) {

	getData('fetchPhotoSetName.php?gallery_id='+galleryID+'&background='+backgroundColor,'photoSetName');

}

function showHelp() {

	// Disable e-mail,download,add sets
	disableFeatures();
	
	document.getElementById('photoSetName').innerHTML = ''; 

	// Clear bottom rule on monoslideshow
	//document.getElementById('monoSlideshow').style['borderBottom'] = '1px solid #999999';
	
	if (explorer6 == true) {

		getData('showhelp.php?showH='+showH+'&showW='+showW+'&gallery_id='+current_galleryID+'&current_album='+current_album+'&ie6=Y', 'monoSlideshow');

	} else {
	
		getData('showhelp.php?showH='+showH+'&showW='+showW+'&gallery_id='+current_galleryID+'&current_album='+current_album+'&ie6=N', 'monoSlideshow');
	
	}
}

function showRestricted(gid,pid,accessID) {

	// Disable e-mail,download,add sets
	disableFeatures();

	document.getElementById('photoSetName').innerHTML = ''; 

	if (explorer6 == true) {

		getData('showrestricted.php?showH='+showH+'&showW='+showW+'&gallery_id='+gid+'&photo_id='+pid+'&access_confirm='+accessID+'&ie6=Y', 'monoSlideshow');
		
	} else {
	
		getData('showrestricted.php?showH='+showH+'&showW='+showW+'&gallery_id='+gid+'&photo_id='+pid+'&access_confirm='+accessID+'&ie6=N', 'monoSlideshow');

	}
}

function returnToSet() {

	switchAlbum(current_album,current_galleryID);
	
}

function showContact() {

	document.getElementById('photoSetName').innerHTML = ''; 

	// Disable e-mail,download,add sets
	disableFeatures();

	// Clear bottom rule on monoslideshow
	document.getElementById('monoSlideshow').style['borderBottom'] = '0px';

	// Naf site: disabled
	/*
	document.getElementById('nav_food').innerHTML = '';
	document.getElementById('nav_fashion').innerHTML = '';
	document.getElementById('nav_kids').innerHTML = '';
	document.getElementById('nav_about').innerHTML = '<img src="images/nav_about_gray'+imageSuffix+'" width="60" height="25" border="0" name="nav_about"/>';
	//document.getElementById('nav_control').innerHTML = '';
	document.getElementById('nav_projects').innerHTML = '';
	document.getElementById('nav_history').innerHTML = '';

	document.getElementById('photoSetName').innerHTML = ''; 

	if (user_id >=0) {
	
		document.getElementById('nav_mysets').innerHTML = '';
	
	}
	*/




	if (explorer6 == true) {

		// Use variation getData1 so that the slideshow is triggered after the page is loaded
		// Headshot not being use for naf's site.
		getData('showcontact.php?showH='+showH+'&showW='+showW+'&ie6=Y', 'monoSlideshow');
		
	} else {
	
		getData('showcontact.php?showH='+showH+'&showW='+showW+'&ie6=N', 'monoSlideshow');

	}
	

}

function showAboutSite() {

	document.getElementById('photoSetName').innerHTML = ''; 

	// Disable e-mail,download,add sets
	disableFeatures();

	// Clear bottom rule on monoslideshow
	document.getElementById('monoSlideshow').style['borderBottom'] = '0px';

	if (explorer6 == true) {

		// Use variation getData1 so that the slideshow is triggered after the page is loaded
		getData1('showAboutSite.php?showH='+showH+'&showW='+showW+'&ie6=Y', 'monoSlideshow');
		
	} else {
	
		getData1('showAboutSite.php?showH='+showH+'&showW='+showW+'&ie6=N', 'monoSlideshow');

	}
	

}

function showAccount() {

	document.getElementById('photoSetName').innerHTML = ''; 

	// Disable e-mail,download,add sets
	disableFeatures();

	// Clear bottom rule on monoslideshow
	document.getElementById('monoSlideshow').style['borderBottom'] = '0px';

	if (explorer6 == true) {
	
		getData('showaccount.php?showH='+showH+'&showW='+showW+'&user_id='+user_id+'&ie6=Y', 'monoSlideshow');

	} else {
	
		getData('showaccount.php?showH='+showH+'&showW='+showW+'&user_id='+user_id+'&ie6=N', 'monoSlideshow');

	}

}

function showRemove(userIDToRemove) {

	document.getElementById('photoSetName').innerHTML = ''; 

	// Clear bottom rule on monoslideshow
	document.getElementById('monoSlideshow').style['borderBottom'] = '0px';

	if (explorer6 == true) {
	
		getData('showremove.php?showH='+showH+'&showW='+showW+'&user_id='+userIDToRemove+'&ie6=Y', 'monoSlideshow');

	} else {
	
		getData('showremove.php?showH='+showH+'&showW='+showW+'&user_id='+userIDToRemove+'&ie6=N', 'monoSlideshow');

	}

}

function showRelated(pickGalleryID,pickPhotoID) {

	document.getElementById('photoSetName').innerHTML = ''; 

	// Show bottom rule on monoslideshow
	//document.getElementById('monoSlideshow').style['borderBottom'] = '1px solid #999999';

	if (explorer6 == true) {
	
		getData('showrelated.php?showH='+showH+'&showW='+showW+'&gallery_id='+pickGalleryID+'&photo_id='+pickPhotoID+'&ie6=Y', 'monoSlideshow');

	} else {
	
		getData('showrelated.php?showH='+showH+'&showW='+showW+'&gallery_id='+pickGalleryID+'&photo_id='+pickPhotoID+'&ie6=N', 'monoSlideshow');
	}

}

function showClassic() {

	window.open("classic/andyryan.html","displayWindow",'width=800' + ',height=600' + ',resizable=1,scrollbars=1,toolbar=no,location=no,status=no' )

}

function showLogin() {
	
	// Disable e-mail,download,add sets
	disableFeatures();
	
	document.getElementById('photoSetName').innerHTML = ''; 

	// Clear bottom rule on monoslideshow
	document.getElementById('monoSlideshow').style['borderBottom'] = '0px';

	if (explorer6 == true) {
	
		getData('showlogin.php?showH='+showH+'&showW='+showW+'&error_msg='+error_msg+'&ie6=Y', 'monoSlideshow');

	} else {
	
		// This is the new code. Launching into separate window.
		alert('j '+document.getElementById('loadingTEST').style['visibility']);
		document.getElementById('loadingTEST').style['visibility'] = 'visible';	
		getData('showloginTEST.php?showH='+showH+'&showW='+showW+'&error_msg='+error_msg+'&ie6=N', 'contentTEST');
		//getData('showlogin.php?showH='+showH+'&showW='+showW+'&error_msg='+error_msg+'&ie6=N', 'monoSlideshow');

	}
	
	// reset error_msg -- if there is an error message, it should only appear once.
	error_msg = 0;

}

function showLogin1(gid,pid) {
	
	// Variation of login to include gallery and photo_ids passed from e-mail ink
	document.getElementById('photoSetName').innerHTML = ''; 

	// Clear bottom rule on monoslideshow
	document.getElementById('monoSlideshow').style['borderBottom'] = '0px';

	if (explorer6 == true) {
	
		getData('showlogin.php?showH='+showH+'&showW='+showW+'&error_msg='+error_msg+'&ie6=Y&gallery_id='+gid+'&photo_id='+pid, 'monoSlideshow');

	} else {

		getData('showlogin.php?showH='+showH+'&showW='+showW+'&error_msg='+error_msg+'&ie6=N&gallery_id='+gid+'&photo_id='+pid, 'monoSlideshow');

	}
	
	// reset error_msg -- if there is an error message, it should only appear once.
	error_msg = 0;

}


function showMysets(show_parent_id) {

	// Disable e-mail,download,add sets
	disableFeatures();

	// update navigation highlight
	// Naf site:disabled
	/*
	document.getElementById('nav_food').innerHTML = '';
	document.getElementById('nav_fashion').innerHTML = '';
	document.getElementById('nav_kids').innerHTML = '';
	document.getElementById('nav_about').innerHTML = '';
	//document.getElementById('nav_control').innerHTML = '';
	document.getElementById('nav_projects').innerHTML = '';
	document.getElementById('nav_history').innerHTML = '';
	document.getElementById('nav_mysets').innerHTML = '<img src="images/nav_mysets_gray'+imageSuffix+'" width="65" height="25" border="0" name="nav_mysets"/>';

	document.getElementById('photoSetName').innerHTML = ''; 
	*/
	// Clear bottom rule on monoslideshow
	document.getElementById('monoSlideshow').style['borderBottom'] = '0px';

	getData('showmysets.php?showH='+showH+'&showW='+showW+'&thumbnailtoggle='+thumbnailsOnSearch+'&user_id='+user_id+'&show_parent_id='+show_parent_id, 'monoSlideshow');


}

function showHistory(show_parent_id) {

	// Disable e-mail,download,add sets
	disableFeatures();

	// update navigation highlight
	// Naf site:disabled
    /*
	document.getElementById('nav_food').innerHTML = '';
	document.getElementById('nav_fashion').innerHTML = '';
	document.getElementById('nav_kids').innerHTML = '';
	document.getElementById('nav_about').innerHTML = '';
	//document.getElementById('nav_control').innerHTML = '';
	document.getElementById('nav_projects').innerHTML = '';
	document.getElementById('nav_history').innerHTML = '<img src="images/nav_myviewhistory_gray'+imageSuffix+'" width="116" height="25" border="0" name="nav_history"/>';

	if (user_id >=0) {
	
		document.getElementById('nav_mysets').innerHTML = '';
	
	}
	*/
	document.getElementById('photoSetName').innerHTML = ''; 
	
	// Clear bottom rule on monoslideshow
	document.getElementById('monoSlideshow').style['borderBottom'] = '0px';


	getData('showhistory.php?showH='+showH+'&showW='+showW+'&thumbnailtoggle='+thumbnailsOnSearch+'&show_parent_id='+show_parent_id, 'monoSlideshow');


}

function showProjects(show_parent_id) {

	// Disable e-mail,download,add sets
	disableFeatures();

 	show_parent_id = typeof(show_parent_id) != 'undefined' ? show_parent_id : 0;
	
	// update navigation highlight

	document.getElementById('nav_food').innerHTML = '';
	document.getElementById('nav_fashion').innerHTML = '';
	document.getElementById('nav_kids').innerHTML = '';
	document.getElementById('nav_about').innerHTML = '';
	//document.getElementById('nav_control').innerHTML = '';
	document.getElementById('nav_projects').innerHTML = '<img src="images/nav_projects_gray'+imageSuffix+'" width="65" height="25" border="0" name="nav_projects"/>';
	document.getElementById('nav_history').innerHTML = '';

	document.getElementById('photoSetName').innerHTML = ''; 

	if (user_id >=0) {
	
		document.getElementById('nav_mysets').innerHTML = '';
	
	}
	
	document.getElementById('photoSetName').innerHTML = ''; 

	// Clear bottom rule on monoslideshow
	document.getElementById('monoSlideshow').style['borderBottom'] = '0px';

	getData('showprojects.php?showH='+showH+'&showW='+showW+'&thumbnailtoggle='+thumbnailsOnSearch+'&show_parent_id='+show_parent_id, 'monoSlideshow');

}


function showSearch() {

	// Disable e-mail,download,add sets
	disableFeatures();

	// update navigation highlight
	// Naf site:disabled
	/*	
	document.getElementById('nav_food').innerHTML = '';
	document.getElementById('nav_fashion').innerHTML = '';
	document.getElementById('nav_kids').innerHTML = '';
	document.getElementById('nav_about').innerHTML = '';
	//document.getElementById('nav_control').innerHTML = '';
	document.getElementById('nav_projects').innerHTML = '';
	document.getElementById('nav_history').innerHTML = '';
	if (user_id >=0) {
	
		document.getElementById('nav_mysets').innerHTML = '';
	
	}
	*/
	
	// Clear bottom rule on monoslideshow
	document.getElementById('monoSlideshow').style['borderBottom'] = '0px';

	getData('showsearch.php?showH='+showH+'&showW='+showW, 'monoSlideshow');

}

function showImage(photoIDFromSearch) {

	//alert('show ID: ' + photoIDFromSearch);
	// For now, this displays a single photo from the search page	
	
	photoIDToStart =  photoIDFromSearch;
	current_galleryID = -1;
	switchAlbum(current_album,current_galleryID);


}

function showAccountRequest() {

	// Disable e-mail,download,add sets
	disableFeatures();

	// Clear bottom rule on monoslideshow
	document.getElementById('monoSlideshow').style['borderBottom'] = '0px';

	document.getElementById('photoSetName').innerHTML = ''; 
	
	if (explorer6 == true) {
	
		getData('login_request.php?showH='+showH+'&showW='+showW+'&ie6=Y', 'monoSlideshow');

	} else {
	
		getData('login_request.php?showH='+showH+'&showW='+showW+'&ie6=N', 'monoSlideshow');

	}


}

function disableFeatures() {

	// Temp - do not run.
	return;
	
	// Unless there is a photo or a set displayed, features such as email this set, download this set
	// should be disabled
	var tag1;

	tag1 = '<span class="lefthandGrayDisabled">EmDLDail this Set</span>';
	document.getElementById('emailSet').innerHTML = tag1;
	
	// if have download access
	if (allow_downloads == "Y") {
	
		tag1 = '<span class="lefthandGrayDisabled">Download</span>';
		document.getElementById('downloadSet').innerHTML = tag1;

	}

	// if Logged in
	if (user_email != "") {
	
		tag1 = '<span class="lefthandGrayDisabled">Add to My Sets</span>';
		document.getElementById('addToSet').innerHTML = tag1;
	
	}
}

function clearSearchResults() {

	// Clear search term and return to search results link
	searchSterm = '';
	document.getElementById('returnToSearch').innerHTML = '';

}

function showReturnToSearch() {

	// Displays return to search results link
	var returnToClass = (backgroundColor == 'ffffff')? 'returnToSearchGray' : 'returnToSearchWhite';
	
	// TO DO 3/21/08
	// How to handle searching clientID searching? searchClientID > -1???
	
	document.getElementById('returnToSearch').innerHTML = "<a href=\"javascript:switchPageSearchResults('" +searchSterm + "', '" +searchRestrict + "', " +searchOffset + ", '"
		+ searchThumbDisplay + "','" +searchStart + "'," + searchClientID + ");\" class=\""+returnToClass+"\">< Return to search results</a>" +
	" <a href=\"javascript:clearSearchResults();\" class=\""+returnToClass+"\">(clear)</a>";


}


function sendForgottenPassword() {

	if (explorer6 == true) {
	
		getData('showSendPassword.php?showH='+showH+'&showW='+showW+'&error_msg='+error_msg+'&ie6=Y', 'monoSlideshow');

	} else {
	
		getData('showSendPassword.php?showH='+showH+'&showW='+showW+'&error_msg='+error_msg+'&ie6=N', 'monoSlideshow');

	}


}

function toggleThumbnails(module,thumbnailValue,show_parent_id) {

 	show_parent_id = typeof(show_parent_id) != 'undefined' ? show_parent_id : 0;
  
	if (thumbnailValue == "true") {
	
		thumbnailsOnSearch = "true";
		
	} else {
	
		thumbnailsOnSearch = "false";
	
	}

	switch(module) {
	
		case 'showprojects':
			showProjects(show_parent_id);
			break;
			
		case 'showmysets':
			showMysets(show_parent_id);
			break;
			
		case 'showhistory':
			showHistory(show_parent_id);
			break;
	}
}

function switchPageProjects(offset,show_parent_id) {

	getData('showprojects.php?showH='+showH+'&showW='+showW+'&thumbnailtoggle='+thumbnailsOnSearch+'&rowOffset='+offset+'&show_parent_id='+show_parent_id, 'monoSlideshow');

}

function switchPageMySets(offset,show_parent_id) {

	getData('showmysets.php?showH='+showH+'&showW='+showW+'&thumbnailtoggle='+thumbnailsOnSearch+'&rowOffset='+offset+'&user_id='+user_id, 'monoSlideshow');

}

function switchViewHistory(offset,show_parent_id) {

	getData('showhistory.php?showH='+showH+'&showW='+showW+'&thumbnailtoggle='+thumbnailsOnSearch+'&rowOffset='+offset+'&show_parent_id='+show_parent_id, 'monoSlideshow');

}

function switchPageSearchResults(sterm,srestrict,offset,thumbnailDisplay,startSearchWith,clientID) {

	//var returnToClass = (backgroundColor == 'ffffff')? 'returnToSearchGray' : 'returnToSearchWhite';
	
	// Update values:
	searchSterm = sterm;
	searchRestrict = srestrict;
	searchOffset = offset;
	searchThumbDisplay = thumbnailDisplay;
	searchStart = startSearchWith;
	searchClientID = clientID
	
	document.getElementById('photoSetName').innerHTML = ''; 
	
	// Clear bottom rule on monoslideshow
	document.getElementById('monoSlideshow').style['borderBottom'] = '0px';

	showReturnToSearch();
	//document.getElementById('returnToSearch').innerHTML = "<a href=\"javascript:switchPageSearchResults('" +sterm + "', '" +srestrict + "', " +offset + ", '" + thumbnailDisplay + "','" +startSearchWith +"');\" class=\""+returnToClass+"\">< Return to search results</a>";

	if (searchClientID == -1) {
	
		getData('showSearchResults.php?showH='+showH+'&showW='+showW+'&searchterm='+sterm+'&restrict='+srestrict+'&rowOffset='+offset+'&thumbnailtoggle='+thumbnailDisplay+'&startWith='+startSearchWith, 'monoSlideshow');
	
	} else {
	
		getData('showSearchResults.php?showH='+showH+'&showW='+showW+'&client_id='+clientID+'&restrict='+srestrict+'&rowOffset='+offset+'&thumbnailtoggle='+thumbnailDisplay+'&startWith='+startSearchWith, 'monoSlideshow');
	
	}
}


function submitAccountRequest() {

	if (verifyLoginRequest()) {
	
		var myForm = document.loginRequestForm;
		var firstname = encodeURIComponent(myForm.firstname.value);
		var lastname = encodeURIComponent(myForm.lastname.value);
		var email = encodeURIComponent(myForm.email.value);
		var company = encodeURIComponent(myForm.company.value);
		var city = encodeURIComponent(myForm.city.value);
		var state = encodeURIComponent(myForm.state.value);
		var country = encodeURIComponent(myForm.country.value);
		
		getData('login_request_process.php?showH='+showH+'&showW='+showW+'&firstname='+firstname+'&lastname='+lastname+'&email='+email+'&company='+company+'&city='+city+'&state='+state+'&country='+country, 'monoSlideshow');
		
	} else {
	
		alert('Verify false');
	}
	

}

function submitUpdatePassword() {

	var myForm = document.updatePassword;

	if (myForm.curpassword.value == '') {
	
		alert('You must enter your original password.');
		
	} else if (myForm.newpassword.value.length < 6) {
	
			alert('Your new password must be at least 6 characters long.');
			
	} else if (myForm.newpassword.value != myForm.newpassword1.value) {
	
			alert('Your new passwords don\'t match.');
	
	} else {
	
		var newpassword = encodeURIComponent(myForm.newpassword.value);
		var curpassword = encodeURIComponent(myForm.curpassword.value);
		getData('updatePassword.php?showH='+showH+'&showW='+showW+'&curpassword='+curpassword+'&newpassword='+newpassword+'&user_id='+user_id, 'monoSlideshow');

	}

}

function sendPassword() {

	if (document.sendPasswordForm.email.value == '') {
	
		alert('You must enter an e-mail address.');
		
	} else {
	
		var email = encodeURIComponent(document.sendPasswordForm.email.value);
	
		if (explorer6 == true) {
		
			getData('showSendPassword.php?showH='+showH+'&showW='+showW+'&ie6=Y&email='+email, 'monoSlideshow');
		
		} else {
		
			getData('showSendPassword.php?showH='+showH+'&showW='+showW+'&ie6=N&email='+email, 'monoSlideshow');

		}
	}

}

function submitSearch() {

	// fields: searchterm, restrict
	var searchtermVal,restrictVal;
	
	searchtermVal = document.searchForm.searchterm.value;
	restrictVal =document.searchForm.restrict.value;
	
	searchSterm = searchtermVal;
	searchRestrict = restrictVal;
	searchOffset = 0;
	searchThumbDisplay = 'true';
	searchStart = 'sets';
	searchClientID = -1;
		
	showReturnToSearch();

	document.getElementById('photoSetName').innerHTML = ''; 

	getData('showSearchResults.php?showH='+showH+'&showW='+showW+'&searchterm='+searchtermVal+'&restrict='+restrictVal, 'monoSlideshow');

}



function submitSearchTag(tagTerm) {

	//var returnToClass = (backgroundColor == 'ffffff')? 'returnToSearchGray' : 'returnToSearchWhite';
	document.getElementById('photoSetName').innerHTML = ''; 
	//document.getElementById('returnToSearch').innerHTML = "<a href=\"javascript:switchPageSearchResults('" +tagTerm + "', 'any', 0, 'true','sets');\" class=\""+returnToClass+"\">< Return to search results</a>";

	searchSterm = tagTerm;
	searchRestrict = 'any';
	searchOffset = 0;
	searchThumbDisplay = 'true';
	searchStart = 'sets';
	searchClientID = -1;
		
	showReturnToSearch();

	getData('showSearchResults.php?showH='+showH+'&showW='+showW+'&searchterm='+tagTerm, 'monoSlideshow');

}

function submitSearchClient(clientID) {

	document.getElementById('photoSetName').innerHTML = ''; 

	searchSterm = '';
	searchRestrict = 'any';
	searchOffset = 0;
	searchThumbDisplay = 'true';
	searchStart = 'sets';
	searchClientID = clientID;
		
	showReturnToSearch();

	getData('showSearchResults.php?showH='+showH+'&showW='+showW+'&client_id='+clientID, 'monoSlideshow');

}


function addToMySets() {

	var confirmMessage = (current_galleryID > 0)? 'Add this set to "My Sets"?' : 'Add this photo to "My Sets"?'; 
	
	if (confirm(confirmMessage)) {
	
		// Display 'saving' alert box when needed
		document.getElementById('savingAlert').innerHTML = '<span class="savingAlert">Saving...</span>';
		
		getData('addtomysets.php?user_id='+user_id+'&gallery_id='+current_galleryID+'&photo_id='+photoIDToStart, 'savingAlert');
		
	}

	return;
	
	/*
		PICK UP HERE
	*/

	document.getElementById('monoSlideshow').style.visibility = "hidden";
	document.getElementById('fullscreen').style.visibility = "visible";
	/*
	document.getElementById('fullscreen').className ="overlayBG";
	document.getElementById('fullscreen').style.left = leftNavWidth + "px";
	document.getElementById('fullscreen').style.width = showW + "px";
	document.getElementById('fullscreen').style.height = showH + "px";
	*/
	//document.getElementById('fullscreen').style.height = "400px";
	
	if (explorer6 == true) {

		getData('showaddtomysets.php?showH='+showH+'&showW='+showW+'user_id='+user_id+'&gallery_id='+current_galleryID+'&photo_id='+photoIDToStart+'&ie6=Y', 'fullscreen');
		
	} else {
	
		getData('showaddtomysets.php?showH='+showH+'&showW='+showW+'&user_id='+user_id+'&gallery_id='+current_galleryID+'&photo_id='+photoIDToStart+'&ie6=N', 'fullscreen');

	}

	/*
	var confirmMessage = (current_galleryID > 0)? 'Add this set to "My Sets"?' : 'Add this photo to "My Sets"?'; 
	
	if (confirm(confirmMessage)) {
	
		// Display 'saving' alert box when needed
		document.getElementById('savingAlert').innerHTML = '<span class="savingAlert">Saving...</span>';
		
		getData('addtomysets.php?user_id='+user_id+'&gallery_id='+current_galleryID+'&photo_id='+photoIDToStart, 'savingAlert');
		
	}
	*/
	
	//document.getElementById('fullscreen').className ="overlayBG-invisible";


}

function addToMySetsClose() {

	//document.getElementById('fullscreen').className ="overlayBG-invisible";
	document.getElementById('fullscreen').style.visibility = "hidden";
	document.getElementById('monoSlideshow').style.visibility = "visible";
	

}

function testEscape(e) {

	var keynum;
	var keychar;
	var numcheck;
	
	if(window.event) // IE
	  {
	  keynum = e.keyCode;
	  }
	else if(e.which) // Netscape/Firefox/Opera
	  {
	  keynum = e.which;
	  }
	keychar = String.fromCharCode(keynum);
	
	if (keynum == 13) {
	
		alert('escape key');
		
	} else {
	
		alert('keychar = '+keychar);
		
	}

}

function returnToAlbum(photoIDForReturn) {

	photoIDToStart = photoIDForReturn;
	switchAlbum(current_album,current_galleryID);

}

function returnToPhoto(photoIDForReturn) {

	photoIDToStart = photoIDForReturn;
	current_galleryID = -1;
	switchAlbum(current_album,current_galleryID);

}

function showPhoto(galleryIDToShow,photoIDToShow) {

	photoIDToStart = photoIDToShow;
	current_galleryID = galleryIDToShow;
	switchAlbum(current_album,current_galleryID);

}

function switchAlbum(album,galleryID) {

	// Add bottom rule on monoslideshow
	//document.getElementById('monoSlideshow').style['borderBottom'] = '1px solid #999999';
	
	/* Google ads not used in Naphtaliphoto
	// Only update ad iframe if after the initial load
	if (initialLoad == true) {
	
		initialLoad = false;
		
	} else {

		// Try updating the ads each time a new set is loaded -- how does this look? Is it disturbing visually?
		// Update ad iframe
		// switch google src
		altGoogleSrc();
		var adFrame = document.getElementById('AdFrame');
		adFrame.src = google_src;
		
	}
	*/


	// Update nextPrev array
	if (nextPrevIndex < 0) {
	
		nextPrevIndex = nextPrev.push(galleryID) - 1;
		nextPrevCurIndex++;
		

	} else if (galleryID != nextPrev[nextPrevCurIndex]) {
	
		// if this is a different gallery than the current selected OR the one selected through next and previous
		// then add it to the end of the array, removing everything else in the array. 
		// if this just a set to add to the array, i.e. nextPrevCurIndex == nextPrevIndex, then do so.
		if (nextPrevCurIndex == nextPrevIndex) {
		
			nextPrevIndex = nextPrev.push(galleryID) - 1;
			nextPrevCurIndex++;

		} else {
		
			nextPrev.splice(nextPrevCurIndex+1,nextPrevIndex-nextPrevCurIndex,galleryID);
			nextPrevIndex = nextPrev.length - 1;
			nextPrevCurIndex = nextPrevIndex;		
		}
	}
	
	// Naf:not using next previous
	/*
	// Update previous button
	if (nextPrevCurIndex > 0) {
	
		// display previous button
		//alert('prev active: next_page_hwarner_off'+imageSuffix);
		document.getElementById('navpanel0a').innerHTML = '<a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'prevPage\',\'\',\'images/prev_page_hwarner_on'+imageSuffix+'\',1)" onclick="gotoPrev();" id="prevPageButton" title="Previous Set"><img src="images/prev_page_hwarner_off'+imageSuffix+'" width="29" height="25" border="0" name="prevPage"></a>';

	} else {
	
		//alert('prev not active: prev_page_hwarner_gray'+imageSuffix); 
		document.getElementById('navpanel0a').innerHTML = '<img src="images/prev_page_hwarner_gray'+imageSuffix+'" width="29" height="25" border="0">';	
	
	}
	*/
	
	var nextPageID=(user_id > 0)? "a" : "b" ;
	nextPageID = "navpanel8"+nextPageID ;

	// Naf:not using next previous
	/*
	if (nextPrevCurIndex > 0 && (nextPrevCurIndex < nextPrevIndex)) {

		//alert('next active: next_page_hwarner_off'+imageSuffix);
		// Display active button. Position depends on whether user is logged in
		document.getElementById(nextPageID).innerHTML = '<a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'nextPage\',\'\',\'images/next_page_hwarner_on'+imageSuffix+'\',1)" onclick="gotoNext();" id="nextPageButton" title="Next Set"><img src="images/next_page_hwarner_off'+imageSuffix+'" width="29" height="25" border="0" name="nextPage"></a>';

	} else {
		
		//alert('next not active: next_page_hwarner_gray'+imageSuffix); 
		document.getElementById(nextPageID).innerHTML = '<img src="images/next_page_hwarner_gray'+imageSuffix+'" width="29" height="25" border="0">';

	}
	*/
	
	current_album = album;
	
	// TEST THIS. If the galleryID is different than the current, reset the photoID to start. So far, that is ONLY passed through a link when index.php is first loaded. 
	// THIS WILL CHANGE.
		// Reset photoIDToStart
		
	if (galleryID != current_galleryID) {
	
		photoIDToStart =  -1 ;
		current_galleryID = galleryID;
		
	}
	
	// Fetch PhotoSetName for display if not one of the main categories
	// Naf: Disable this
	/*
	if (galleryID > 4) {
	
		fetchPhotoSetName(galleryID);
	
	} else {
	
		document.getElementById('photoSetName').innerHTML = ''; 

	} 
	*/
	
	// Naf default background color is 666666
	//backgroundColorMain = "#" + backgroundColor;
	backgroundColorMain = "#666666";
	
	var motionSetting, thumbnailSetting;
	
	// Update email this set link
	if (galleryID > -1) {
	
		updateEmailSet(galleryID);
		
	} else {
	
		updateEmailImage();
	
	}
	
	motionSetting = (motion)?"true":"false";
	thumbnailSetting = (thumbnailsOn)?"true":"false";
		
	// 'X' is delimiter due to Safari issues with semicolon
	xmlfile="./display.php/NOXgallery_id=" + galleryID + "XshowW=" + showW + "XshowH=" + showH + "Xmotion=" +  motionSetting + "XbackgroundColor=" + backgroundColor + "Xsound=" + soundSetting + "Xstart=" + startWith + "XthumbSize=" + thumbnailSize + "XphotoID=" +photoIDToStart + "XgroupToStart=" + gpToStart;
	
	// For debugging
	//document.getElementById('photoSetName').innerHTML = xmlfile;
	
	// 3/11/08 so.addParam("wmode","transparent"); adding this line to display dialog box on top of the display
	var so = new SWFObject("monoslideshow.swf", "SOmonoSlideshow", showW, showH,  "7", backgroundColorMain);
	so.addVariable("dataFile", xmlfile); 
	so.addVariable("showLogo", "false");
	so.addVariable("showVersionInfo", "false");
	so.addParam("wmode","transparent");
	so.write("monoSlideshow");
	
}

function pickAlbum(choose_album,gallery_ID) {

	if (((choose_album == 'history') || (choose_album == 'mysets')) && (gallery_ID < 5)) {
	
		switch (gallery_ID) {
		
			case '1':
				current_album = "food";
				break;
				
			case '2':
				current_album = "fashion";
				break;

			case '3':
				current_album = "kids";
				break;
		
			case '4':
				current_album = "events";
				break;
				
			/*
			case '5':
				current_album = "books";
				break;
			*/
				
			default:
				current_album = choose_album;
				break;	
		}
		
	} else {

		current_album = choose_album;
		
	}
	
	// Naf site:disabled
	/*
	switch (current_album) {
	
		case 'food':
			document.getElementById('nav_food').innerHTML = '<img src="images/nav_food_gray'+imageSuffix+'" width="54" height="25" border="0" name="nav_arch"/>';
			document.getElementById('nav_fashion').innerHTML = '';
			document.getElementById('nav_kids').innerHTML = '';
			document.getElementById('nav_about').innerHTML = '';
			//document.getElementById('nav_control').innerHTML = '';
			document.getElementById('nav_projects').innerHTML = '';
			document.getElementById('nav_history').innerHTML = '';
			if (user_id > -1 && error_msg == 0) {

				document.getElementById('nav_mysets').innerHTML = '';
			
			}
			break;

		
		case 'fashion':
			document.getElementById('nav_food').innerHTML = '';
			document.getElementById('nav_fashion').innerHTML = '<img src="images/nav_fashion_gray'+imageSuffix+'" width="66" height="25" border="0" name="nav_arch"/>';
			document.getElementById('nav_kids').innerHTML = '';
			document.getElementById('nav_about').innerHTML = '';
			//document.getElementById('nav_control').innerHTML = '';
			document.getElementById('nav_projects').innerHTML = '';
			document.getElementById('nav_history').innerHTML = '';
			if (user_id > -1 && error_msg == 0) {

				document.getElementById('nav_mysets').innerHTML = '';
			
			}
			break;

		
		case 'kids':
			document.getElementById('nav_food').innerHTML = '';
			document.getElementById('nav_fashion').innerHTML = '';
			document.getElementById('nav_kids').innerHTML = '<img src="images/nav_kids_gray'+imageSuffix+'" width="49" height="25" border="0" name="nav_arch"/>';
			document.getElementById('nav_about').innerHTML = '';
			//document.getElementById('nav_control').innerHTML = '';
			document.getElementById('nav_projects').innerHTML = '';
			document.getElementById('nav_history').innerHTML = '';
			if (user_id > -1 && error_msg == 0) {

				document.getElementById('nav_mysets').innerHTML = '';
			
			}
			break;

		case 'events':
			document.getElementById('nav_food').innerHTML = '';
			document.getElementById('nav_fashion').innerHTML = '';
			document.getElementById('nav_kids').innerHTML = '';
			document.getElementById('nav_events').innerHTML ='<img src="images/nav_events_gray'+imageSuffix+'" width="60" height="25" border="0" name="nav_events"/>';
			//document.getElementById('nav_control').innerHTML = '';
			document.getElementById('nav_projects').innerHTML = '';
			document.getElementById('nav_history').innerHTML = '';
			if (user_id > -1 && error_msg == 0) {

				document.getElementById('nav_mysets').innerHTML = '';
			
			}
			break;

		case 'controldrawings':
			document.getElementById('nav_toydev').innerHTML = '';
			document.getElementById('nav_vehicles').innerHTML = '';
			document.getElementById('nav_concept').innerHTML = '';
			document.getElementById('nav_illustrations').innerHTML = '';
			document.getElementById('nav_control').innerHTML = '<img src="images/nav_control_gray'+imageSuffix+'" width="104" height="25" border="0" name="nav_arch"/>';
			document.getElementById('nav_projects').innerHTML = '';
			document.getElementById('nav_history').innerHTML = '';
			if (user_id > -1 && error_msg == 0) {

				document.getElementById('nav_mysets').innerHTML = '';
			
			}
			break;

		default:
			document.getElementById('nav_food').innerHTML = '';
			document.getElementById('nav_fashion').innerHTML = '';
			document.getElementById('nav_kids').innerHTML = '';
			document.getElementById('nav_about').innerHTML = '';
			//document.getElementById('nav_illustrations').innerHTML = '';
			//document.getElementById('nav_control').innerHTML = '';
			document.getElementById('nav_projects').innerHTML = '';
			if (user_id > -1 && error_msg == 0) {

				document.getElementById('nav_mysets').innerHTML = '';
			}
			break;
		

	}
	*/
	switchAlbum(current_album,gallery_ID);

}

function pickMotion(choose_motion) {

	motion = (choose_motion == "motion" ? true : false);

	if (motion == true) {
	
		// Change link to turn autoplay off
		document.getElementById('navMotion').innerHTML = '<a href="#" onmousedown="pickMotion(\'still\');" id="button_still_link" title="Turn Auto-play Off" class="lefthandNavOrange">Auto-play Off</a>';

	} else {
	
		// Change link to turn autoplay on
		document.getElementById('navMotion').innerHTML = '<a href="#" onmousedown="pickMotion(\'motion\');" id="button_motion_link" title="Turn Auto-play On" class="lefthandNavOrange">Auto-play On</a>';

	}

	switchAlbum(current_album,current_galleryID);

}


function setSound(soundToggle) {

	// soundToggle is "on" or "off"
	soundSetting = soundToggle;
	
	// Update link on panel
	if (soundSetting == "on") {
	
		// Change link to turn sound off
		document.getElementById('navSound').innerHTML = '<a href="#" onmousedown="setSound(\'off\');" id="button_sound_off_link" title="Turn Sound Off" class="lefthandNavOrange">Sound Off</a>';

	} else {
	
		document.getElementById('navSound').innerHTML = '<a href="#" onmousedown="setSound(\'on\');" id="button_sound_off_link" title="Turn Sound On" class="lefthandNavOrange">Sound On</a>';
	}
	
	switchAlbum(current_album,current_galleryID);

}

function setStartWith(startToggle) {

	// startToggle is "photos", "photothumbs" or "thumbs"
	startWith = startToggle;
	switchAlbum(current_album,current_galleryID);
	
}


function pickBackground(choose_background) {

	backgroundColor = choose_background;
	setBodyColor();		
	
	// Update search results if exist
	if (searchSterm != '') {
	
		showReturnToSearch();
		
	}
	switchAlbum(current_album,current_galleryID);
}

function setThumbSize(newThumbSize) {

	thumbnailSize = newThumbSize;

	if (thumbnailSize == "large") {
	
		// Change link to turn autoplay off
		document.getElementById('navThumbnails').innerHTML = '<a href="#" onmousedown="setThumbSize(\'small\');" id="button_thumbnailsize" title="Display small thumbnails" class="lefthandNavOrange">Small Thumbs</a>';

	} else {
	
		// Change link to turn autoplay on
		document.getElementById('navThumbnails').innerHTML = '<a href="#" onmousedown="setThumbSize(\'large\');" id="button_thumbnailsize" title="Display large thumbnails" class="lefthandNavOrange">Large Thumbs</a>';

	}

	switchAlbum(current_album,current_galleryID);

}

function setThumbnails(thumbsetting) {

	thumbnailsOn = (thumbsetting == "on")?true:false;
	switchAlbum(current_album,current_galleryID);
	
}

function setNav() {

	// This function is deprecated. Remove in next revision.
	var navToggle;
	
	switch (backgroundColor) {
	
		case "ffffff":
			navToggle = "b";
			break;
			
		case "333333":
			navToggle = "c";
			break;
			
		default:
			navToggle = "a";
			break;
	
	}

	navToggle = "a";

    var navHTML = '<li id="navpanel9a"><a href="#" id="nav_books" onclick="pickAlbum(\'books\',5);"></a></li>\n';
    navHTML += '<li id="navpanel1a"><a href="#" id="nav_arch" onclick="pickAlbum(\'architecture\',1);"></a></li>\n';
	navHTML += '<li id="navpanel2a"><a href="#" id="nav_food" onclick="pickAlbum(\'food\',3);"></a></li>\n';
	navHTML += '<li id="navpanel3a"><a href="#" id="nav_about" onclick="javascript:showContact();"></a></li>\n';
	navHTML += '<li id="navpanel4a"><a href="#" id="nav_advert"></a></li>\n';
	navHTML += '<li id="navpanel5a"><a href="#" id="nav_projects" onmousedown="showProjects();"></a></li>\n';
	navHTML += '<li id="navpanel6a"><a href="#" id="nav_history" onmousedown="showHistory();"></a></li>';

	// if user is logged in, display the mysets link
	if (user_email != "" && error_msg == 0) {
		
		navHTML += '<li id="navpanel7a"><a href="#" id="nav_mysets"  onmousedown="showMysets();"></a></li>\n';
	
	}
			 	
	document.getElementById('naviconmenu').innerHTML = navHTML;

}

function swaplayers() {

	document.getElementById('controlbuttons1').style.visibility = "visible";
	document.getElementById('kooldude').style.visibility = "hidden";
	document.getElementById('navPersonalize').innerHTML = '<a href="javascript:swapback();" class="lefthandNavOrange">Hide Options</a>';

}

function swapback() {

	document.getElementById('controlbuttons1').style.visibility = "hidden";
	document.getElementById('kooldude').style.visibility = "visible";
	document.getElementById('navPersonalize').innerHTML = '<a href="javascript:swaplayers();" class="lefthandNavOrange">Display Options</a>';

}

// IE6
function swapmenu() {

	if (user_id > -1 ) {
	
		document.getElementById('toolsMenu').style.visibility = "visible";
		
	} else {	
	
		document.getElementById('toolsMenuLogin').style.visibility = "visible";

	}
}

// IE6
function swapmenuback() {

	if (user_id > -1 ) {
	
		document.getElementById('toolsMenu').style.visibility = "hidden";
		
	} else {	
	
		document.getElementById('toolsMenuLogin').style.visibility = "hidden";

	}

}

function updateVar(newBackground) {

	// IE6 requires a reload to change background and load the matching jpgs. 
	// All other browsers can change background without a reload
	document.getElementById('backgroundToPass').value = (newBackground == null)?backgroundColor:newBackground;
	document.getElementById('galleryIDToPass').value = current_galleryID;
	document.getElementById('motionToPass').value = (motion ? "true" : "false");
	document.getElementById('thumbnailSettingToPass').value = thumbnailsOn;
	document.getElementById('thumbnailSizeToPass').value = thumbnailSize;
	document.getElementById('soundSettingToPass').value = soundSetting;
	document.getElementById('startWithToPass').value = startWith;

	// Update history variable to pass with fit to window
	document.getElementById('historyList').value = nextPrev.toString();
	document.getElementById('nextPrevToPass').value = nextPrevCurIndex;

}

/*

	PICK UP HERE!
	NEW TAG FOR email set and downloads
	document.write('		<li id="emailSet"><a href="email_link.php?gallery_id=3&ie6=N" class="lefthandNavOrange" onclick="displayWindow(\'\',720,640)" target="displayWindow" class="lefthandNavOrange">Email this Set</a></li>');
	document.write('		<li id="downloadSet"><a href="javascript:alert(\'Download not yet implemented for HarryWarner.com\');"  onclick="displayWindow(\'\',720,640)" target="displayWindow" class="lefthandNavOrange">Download Images</a></li>');


*/

function updateEmailSet(gallery_ID) {

	// TMP REMOVE
	return;

	// IE6 uses gif, others use png
	var suffix,ie6toggle;
	
	if (explorer6 == true) {
	
		suffix = "gif";
		ie6toggle = "Y";
		
	} else {
	
		suffix = "png";
		ie6toggle = "N";
		
	} 
	
	// Update email tag and, if applicable, download tag
	var tag1,tag2;

	tag1 = '<a href="email_link.php?ie6='+ie6toggle+'&gallery_id=';
	
	// Version 1
	//tag2 = '" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'nav_tools_email\',\'\',\'images//nav6_email_on.'+suffix+'\',1)" onclick="displayWindow(\'\',720,640)" target="displayWindow"><img src="images/nav6_email_off.'+suffix+'" width="80" height="14" border="0" name="nav_tools_email"></a>';

	// Version 2
	tag2 = '" class="lefthandNavOrange" onclick="displayWindow(\'\',720,640)" target="displayWindow" class="lefthandNavOrange">Email this Set</a>';



	document.getElementById('emailSet').innerHTML = tag1 + gallery_ID + tag2;
	
	if (allow_downloads == "Y") {
	
		tag1 = '<a href="download.php?ie6='+ie6toggle+'&gallery_id=';

		// Version 1
		//tag2 = '" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'nav_tools_download\',\'\',\'images/nav6_download_on.'+suffix+'\',1)" onclick="displayWindow(\'\',720,640)" target="displayWindow"><img src="images/nav6_download_off.'+suffix+'" width="80" height="14" border="0" name="nav_tools_download"></a>';

		// Version 2
		tag2 = '"  onclick="displayWindow(\'\',720,640)" target="displayWindow" class="lefthandNavOrange">Download</a>';

		document.getElementById('downloadSet').innerHTML = tag1 + gallery_ID + tag2;

	}

	// Update add to sets, too:
	
	if (user_email != "") {
	
		// photoID is important if only a single image is displayed.
		tag1 = '<a href="addToMySets.php?ie6='+ie6toggle+'&gallery_id=' + gallery_ID +'&photo_id='+photoIDToStart+'" class="lefthandNavOrange">Add to My Sets</a>';
		// Version 1
		//tag2 = '" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'nav_tools_addToSets\',\'\',\'images/nav6_addtosets_on.'+suffix+'\',1)" onclick="displayWindow(\'\',720,640)" target="displayWindow"><img src="images/nav6_addtosets_off.'+suffix+'" width="80" height="14" border="0" name="nav_tools_addToSets"></a>';
	
		//document.getElementById('addToSet').innerHTML = tag1 + gallery_ID +'&photo_id='+photoIDToStart + tag2;
		document.getElementById('addToSet').innerHTML = tag1;
	
	}

}

function updateEmailImage() {

	// TMP REMOVE
	return;

	// IE6 uses gif, others use png
	var suffix,ie6toggle;
	
	if (explorer6 == true) {
	
		suffix = "gif";
		ie6toggle = "Y";
		
	} else {
	
		suffix = "png";
		ie6toggle = "N";
		
	} 
	
	// Update email tag and, if applicable, download tag
	var tag1,tag2;

	tag1 = '<a href="email_image.php?ie6='+ie6toggle+'&photo_id=';
	//tag2 = '" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'nav_tools_email\',\'\',\'images//nav6_email_on.'+suffix+'\',1)" onclick="displayWindow(\'\',720,640)" target="displayWindow"><img src="images/nav6_email_off.'+suffix+'" width="80" height="14" border="0" name="nav_tools_email"></a>';

	// Version 2
	tag2 = '" class="lefthandNavOrange" onclick="displayWindow(\'\',720,640)" target="displayWindow" class="lefthandNavOrange">Email this Set</a>';

	document.getElementById('emailSet').innerHTML = tag1 + photoIDToStart + tag2;
	
	/*
		NOTE: This does not yet work for downloading a single image. 5/13/08
	*/
	
	if (allow_downloads == "Y") {
	
		tag1 = '<a href="download.php?ie6='+ie6toggle+'&gallery_id=';
		//tag2 = '" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'nav_tools_download\',\'\',\'images/nav6_download_on.'+suffix+'\',1)" onclick="displayWindow(\'\',720,640)" target="displayWindow"><img src="images/nav6_download_off.'+suffix+'" width="80" height="14" border="0" name="nav_tools_download"></a>';

		// Version 2
		tag2 = '"  onclick="displayWindow(\'\',720,640)" target="displayWindow" class="lefthandNavOrange">Download</a>';

		//document.getElementById('downloadSet').innerHTML = tag1 + gallery_ID + tag2;
		document.getElementById('downloadSet').innerHTML = tag1 + '-1' + tag2;

	}

	if (user_email != "") {

		// Update add to sets, too:
		// photoID is important if only a single image is displayed.
		tag1 = '<a href="addToMySets.php?ie6='+ie6toggle+'&gallery_id=-1&photo_id='+photoIDToStart+'" class="lefthandNavOrange">Add to My Sets</a></li>';
		// Version 1
		//tag2 = '" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'nav_tools_addToSets\',\'\',\'images/nav6_addtosets_on.'+suffix+'\',1)" onclick="displayWindow(\'\',720,640)" target="displayWindow"><img src="images/nav6_addtosets_off.'+suffix+'" width="80" height="14" border="0" name="nav_tools_addToSets"></a>';
	
		//document.getElementById('addToSet').innerHTML = tag1 + gallery_ID +'&photo_id='+photoIDToStart + tag2;
		document.getElementById('addToSet').innerHTML = tag1;


	}

}

function setBodyColor() {
	
  	document.bgColor= '#'+backgroundColor; 
  	
  	// Update google ad to match background
	//var adFrame = document.getElementById('AdFrame');
	var imageSuffix;
	var copyrightStyle = (backgroundColor=='ffffff')?'copyrightHomePageBlack' : 'copyrightHomePageWhite';
	var emailStyle = (backgroundColor=='ffffff')?'emailSmallLinkBlack' : 'emailSmallLink';


	switch (backgroundColor) {
		
		// Naf default gray is 666666 not 333333
		//case '333333':
		case '666666':
			/* 160x600, Harry Warner Gray BG */
			//google_ad_slot = "4785947076";
			//google_ad_slot = "5599627975";
			//google_src = "google-hw-graybg.html";
			imageSuffix = "gray";
			break;
			
		case '000000':
			/* 160x600, Harry Warner Black BG */
			//google_ad_slot = "9763710934";
			//google_ad_slot = "9051928258";
			//google_src = "google-hw-blackbg.html";
			imageSuffix = "black";
			break;
			
		case 'ffffff':
			/* 160x600, Harry Warner White BG */
			//google_ad_slot = "4984501868";
			//google_ad_slot = "0699996936";
			//google_src = "google-hw-whitebg.html";
			imageSuffix = "white";
			break;
			
		case 'FFFFFF':
			/* 160x600, Harry Warner White BG */
			//google_ad_slot = "4984501868";
			//google_ad_slot = "0699996936";
			//google_src = "google-hw-whitebg.html";
			imageSuffix = "white";
			break;
			
		default:
			/* 160x600, Harry Warner Gray BG */
			//google_ad_slot = "4785947076";
			//google_ad_slot = "5599627975";
			//google_src = "google-hw-graybg.html";
			imageSuffix = "gray";
			break;
	
	}		
	//
	// Update ad iframe
	//adFrame.src = google_src;
	
	// TMP REMOVIE 5/5/09
	return;

	// Version 2 -- add welcome after Kooldude text
	var welcomeNameHTML = "";
	
	if (user_name != "") {
	
		var nameBoxPos = navpos - 40;
		var first_name = user_name.split(' ');
		var welcomeName = first_name[0];

		// Exception in the case of Name & Name
		if ((first_name[1] == "and") || (first_name[1] == "&")) {
		
			welcomeName = welcomeName + ' ' + first_name[1] + ' ' + first_name[2];
			
		} 
		//document.write('<div id="nameBox" style="position:absolute;text-align:center;top:' + nameBoxPos + 'px;left:1px;width:106px;z-index:1;">');
		
		// loginTextOrange or loginTextGray depending on background.
		
		//document.write('<span class="loginTextOrange">Welcome,<br />'+welcomeName+'</span>');
		//document.write('</div>');
		
		welcomeNameHTML = '<p style="margin-top:20px"><span class="loginTextOrange">Welcome,<br />'+welcomeName+'</span></p>'
		
		
	
	}
	

	// Version 1 for hwarner
	// Update kooldude icon and copyright based on background color
	/*document.getElementById('kooldude').innerHTML = '<img src="images/final-art_'+imageSuffix+'.jpg" width="104" height="152">' +
	'<p class="' + copyrightStyle + '">All Images<br />Copyright 2007 - '+currentYear+'<br />Harry Warner Design</p>'+
	'<p class="' + copyrightStyle + '">&nbsp;<a href="mailto:harry@harrywarner.com" class="' + emailStyle + '">harry@harrywarner.com</a><br />'+
	'401-932-6729</p>'+welcomeNameHTML;
	*/

	// Version 2 for naphtaliphoto
	// Update kooldude icon and copyright based on background color
	document.getElementById('kooldude').innerHTML = '<p style="margin: 152px 0px 0px 0px">&nbsp;</p><p class="' + copyrightStyle + '">All Images<br />Copyright 2005 - '+currentYear+'<br />Naphtali Visser'+
	'<br /><a href="mailto:naf@nafster.com" class="' + emailStyle + '">naf@nafster.com</a>'+
	'</p>'+welcomeNameHTML;



	// Load mini slideshow based on background color -- identical except for the markfileloaded to match the background
	showMiniSlideShow();
		
}

function altGoogleSrc() {

	// Trying to force a reload of the google adframe when a new set is loaded

	switch (google_src) {
	
		case "google-hw-graybg.html":
			google_src = "google-hw-graybg_alt.html";
			break;
			
		case "google-hw-graybg_alt.html":
			google_src = "google-hw-graybg.html";
			break;
			
		case "google-hw-blackbg.html":
			google_src = "google-hw-blackbg_alt.html";
			break;
			
		case "google-hw-blackbg_alt.html":
			google_src = "google-hw-blackbg.html";
			break;
			
		case "google-hw-whitebg.html":
			google_src = "google-hw-whitebg_alt.html";
			break;
			
		case "google-hw-whitebg_alt.html":
			google_src = "google-hw-whitebg.html";
			break;
			
	}

	// default is no change			
}




function showMiniSlideShow() {

	// Load miniSlideShow
	
	var xmlfile="./display_mini.php/NOXbackgroundColor=" + backgroundColor;
	var	backgroundColorMain = "#" + backgroundColor;
	
	var so = new SWFObject("monoslideshow.swf", "SOmonoSlideshow", 104,104,  "7", backgroundColorMain);
	so.addVariable("dataFile", xmlfile); 
	so.addVariable("showLogo", "false");
	so.addVariable("showVersionInfo", "false");
	so.addParam("wmode","transparent");
	so.write("miniSlideShow");

}

function showHeadshotSlideShow() {

	// Load miniSlideShow
	//alert('load head shot');
	var xmlfile="./display_headshot.php/NOXbackgroundColor=" + backgroundColor;
	//var	backgroundColorMain = "#" + backgroundColor;
	
	var so = new SWFObject("monoslideshow.swf", "SOmonoSlideshow", 162,247,  "7", "#ffffff");
	so.addVariable("dataFile", xmlfile); 
	so.addVariable("showLogo", "false");
	so.addVariable("showVersionInfo", "false");
	so.addParam("wmode","transparent");
	so.write("headshotSlideShow");

}


function addcomma(msg) {

	if (msg != "") {

		return msg + ", ";

	} else {

		return msg;
	}
	
}


function verifyLogin(passForm) {

	if (passForm.email.value == "") {
	
		alert("You must enter an email address");
		passForm.email.focus();
		return false;
		
	}

}

function verifyLoginRequest() {

	// This is a variation of an open source field verification function
	myForm = document.loginRequestForm;
	
	var themessage = "";
	var count = 0;
	if (myForm.firstname.value=="") {
		themessage = themessage + "First Name";
		count = count + 1;
	}
	if (myForm.lastname.value=="") {
		themessage = addcomma(themessage);
		themessage = themessage + "Last Name";
		count = count + 1;
	}
	if (myForm.email.value=="") {
		themessage = addcomma(themessage);
		themessage = themessage + "E-mail";
		count = count + 1;
	}
	
	//alert if fields are empty, then cancel form submit
	if (themessage == "") {
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.email.value)){				
			return (true)
		} else {
			alert("There is an error in the e-mail address. Please re-enter.");
			return (false)
		}
	}
	else {
		if (count > 1) {
			var field_text = "these fields: ";
		} else {
			var field_text = "this field: ";
		}
		alert("You are required to enter " + field_text + themessage);
		return false;
	}
}


function gotoNext() {

	if (nextPrevCurIndex < nextPrevIndex) {
	
		nextPrevCurIndex++;
		switchAlbum(current_album,nextPrev[nextPrevCurIndex]);
		
	} else {
	
		alert("There is no next set.");
		
	}

}


function gotoPrev() {

	if (nextPrevCurIndex > 0) {
	
		nextPrevCurIndex--;
		switchAlbum(current_album,nextPrev[nextPrevCurIndex]);
		
	} else {
	
		alert("There is no previous set.");
		
	}

}

var gpToStart = gpd;

// Following four functions are open source
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_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 displayWindow(url, width, height) {

	if (!window.Win || Win.closed) {
	
		var Win = window.open(url,"displayWindow",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=1' );
	
	} else {
	
		Win.location = url;
	}
	
	Win.focus();
		
}


