function gotoUpdator(updator_sid) {
	window.location = '../userNetwork/userProfile.php?usid='+updator_sid;
}

function walkTheDOM(node, func) {
       func(node);
       node = node.firstChild;
       while (node) {
           walkTheDOM(node, func); 
           node = node.nextSibling; 
       }
   }

$(document).ready(function(){
	$('.fix_links a').attr("target", "_blank");
	$('textarea.FCK').each( function(n) {
		var oFCKeditor2 = new FCKeditor(this.name, '100%', '200');
		oFCKeditor2.BasePath = "/FCKeditor/";
		oFCKeditor2.ToolbarSet = 'Stickymap';
		oFCKeditor2.ReplaceTextarea();
	});
	
	//Make sure that the top page displays the correct view.
	if (parent.viewLocalNetwork) {
		parent.viewLocalNetwork();
	}
	
	//If the parent page has no move function, remove the move option
	if (!parent.moveMarker) {
		if (document.getElementById('moveOption')) {
			document.getElementById('moveOption').style.display = "none";
		}
	}
});

function checkCatString() {
	var catString = document.getElementById("catstring").value;
	if (catString == "") {
		alert("You must type in a category before submitting");
		return false;
	}
	
	return true;
}

function maxZoomToCatId(maxzoom) {
	if (maxzoom > 15) return 1;
	if (maxzoom > 10) return 2;
	if (maxzoom > 5) return 3;
	return 4;
}

function validateTitle() {
	newtitle = document.getElementById('editedTitle').value;
	if (!trimAll(newtitle)) {
		alert('Your title must contain some text other than whitespace.');
		return false;
	}
	
	return true;
}
		
function trimAll(sString) {
	while (sString.substring(0,1) == ' ') {
		sString = sString.substring(1, sString.length);
	}
	
	while (sString.substring(sString.length-1, sString.length) == ' ') {
		sString = sString.substring(0,sString.length-1);
	}
		
	return sString;
}

function validateLoginForm() {
	var pass = document.getElementById("password").value;
	document.getElementById("password").value = encrypt(pass);
	return true;
}

function validateCommentForm() {
	var isChecked = document.getElementById("tosStatement").checked;
	if (!isChecked) {
		alert("You must check the certification box.");
		return false;
	}
	return true;
}

function validateVideoForm() {
	var vid = document.getElementById("youtube_id").value;
	if (!vid) {
		alert("You must type in a youtube id.");
		return false;
	}
	return true;
}

	function validateUploadPhotoForm() {
		var isChecked = document.getElementById("tosStatement").checked;
		if (!isChecked) {
		alert("You must check the certification box.");
			return false;
		}
		return true;
	}