function changeupdate(currentDIR) {

	var directoryString = "";
	var updateActionString = "";
	if (document.getElementById('updateelement').value == 2){
		updateActionString = "updateAction=1";
	}
	if (currentDIR != 0){ 
		directoryString = "directoryID="+currentDIR+"&";
	}
	document.location = "index.php?"+directoryString+updateActionString;
}





function changecomments(itemID, currentDIR, currentPhoto) {

	var photoString = "";
	var directoryString = "";
	var updateActionString = "";
	if (document.getElementById('commentdisplay'+itemID).value == 1){
		updateActionString = "commentdisplay"+itemID+"=1";
	}
	else if (document.getElementById('commentdisplay'+itemID).value == 2){
		updateActionString = "commentdisplay"+itemID+"=2";
	}
	
	if (currentDIR != 0){ 
		directoryString = "directoryID="+currentDIR+"&";
	}
	if (currentPhoto != 0) {
		photoString = "photoID="+currentPhoto+"&";	
	}
	
	document.location = "index.php?"+directoryString+photoString+updateActionString;
}



function changegallery (currentDIR, currentPhoto) {
	
	var photoString = "";
	var directoryString = "";
	var updateActionString = "";
	if (document.getElementById('galleryelement').value == 2){
		updateActionString = "updateAction=1";
	}
	else if (document.getElementById('galleryelement').value == 3){
		updateActionString = "updateAction=2";
	}
	else if (document.getElementById('galleryelement').value == 4){
		updateActionString = "updateAction=3";
	}
	if (currentDIR != 0){ 
		directoryString = "directoryID="+currentDIR+"&";
	}
	if (currentPhoto != 0) {
		photoString = "photoID="+currentPhoto+"&";	
	}
	
	document.location = "index.php?"+directoryString+photoString+updateActionString;
	
	//alert("currentDIR="+currentDIR+", currentPhoto="+currentPhoto);	
	
}





var background1 = "";
var border1 = "solid #ddd 1px";
var background2 = "#BEFF97";
var border2 = "solid #ddd 1px";



function displayGallery (thiselement, jsselection){
	if (thiselement.className!="selectedtd") {
		undoSelect ();
		thiselement.className="selectedtd";
		//thiselement.style.border=border1;
		document.getElementById('gallerycontents').innerHTML = document.getElementById(jsselection).innerHTML;
		document.getElementById('gallerycontents').className = "background1";
	}
}

function displayGalleryLookup (jsselection, i){
	if (document.getElementById("tablediv"+i).className!="selectedtd") {
		undoSelect ();
		document.getElementById("tablediv"+i).className="selectedtd";
		//document.getElementById("tablediv"+i).style.border=border1;
	
		
		document.getElementById('gallerycontents').innerHTML = document.getElementById(jsselection+i).innerHTML;
		document.getElementById('gallerycontents').className = "background1";
	}
}//fc6

function undoSelect () {
	if (gimble < 2) {
		/*do nothing... nothing to undo!*/	
	}
	else {
		for (var i=1; i<=gimble; i++) {
			document.getElementById("tablediv"+i).className = "normalBackground";
			//document.getElementById("tablediv"+i).style.border = "solid black 0px";
			//alert('i='+i);
		}
	}
}


function setcontent(jscontainer, i, xx){
	
	displayGalleryLookup(jscontainer, xx);
	
	if (i != xx) {
		setTimeout("setcontent('"+jscontainer+"', "+i+", "+(xx+1)+");" , 600);
	}
	else{
		setTimeout("displayGalleryLookup('"+jscontainer+"', "+1+");" , 600);
	}
}




function displayFolder (thiselement, jsselection){
	if (thiselement.className!="selectedtd") {
		undoSelect2 ();
		thiselement.className="selectedtd";
		//thiselement.style.border="solid #ddd 1px";
		document.getElementById('foldercontents').innerHTML = document.getElementById(jsselection).innerHTML;
		document.getElementById('foldercontents').className = "background2";
	}
}

function displayGalleryLookup2 (jsselection, i){
	if (document.getElementById("tablediv2"+i).className!="selectedtd") {
		undoSelect2 ();
		document.getElementById("tablediv2"+i).className="selectedtd";
		//document.getElementById("tablediv"+i).style.border="solid #ddd 1px";
	
		
		document.getElementById('foldercontents').innerHTML = document.getElementById(jsselection+i).innerHTML;
		document.getElementById('foldercontents').className = "background2";
	}
}

function undoSelect2 () {
	if (gimble2 < 2) {
		/*do nothing... nothing to undo!*/	
	}
	else {
		for (var i=1; i<=gimble2; i++) {
			document.getElementById("tablediv2"+i).className = "normalbackground";
			//document.getElementById("tablediv"+i).style.border = "solid black 0px";
			//alert('i='+i);
		}
	}
}


function setcontent2(jscontainer, i, xx){
	
	displayGalleryLookup2(jscontainer, xx);
	
	if (i != xx) {
		setTimeout("setcontent2('"+jscontainer+"', "+i+", "+(xx+1)+");" , 600);
	}
	else{
		setTimeout("displayGalleryLookup2('"+jscontainer+"', "+1+");" , 600);
	}
}







function onsubmit(commentsform) {
	if (commentsform.commentText.value.length > 0) {
		//replaceTags(document.forms.commentsform.userName);
		replaceTags(commentsform.commentText);
		/*commentsform.submit();*/
		return 1;
	}
	if (commentsform.commentText.value.length < 1){
		commentsform.commentText.style.backgroundColor = "#F1B066";
		return 0;
	}
}






//loop through string, replacing ANY occurance of tags with &lt; | &gt;
function replaceTags(objectt) {
	for(i=0; i<objectt.value.length; i++){ 
		if(objectt.value.indexOf("<") > -1){ 
			objectt.value = objectt.value.replace("<", "&lt;");
			
		}
		else if(objectt.value.indexOf(">") > -1){  
			objectt.value = objectt.value.replace(">", "&gt;");
			
		}
	}
}