function changeSessionMode(mode) {
	document.loginForm.sessionMode.value = mode;
	document.loginForm.submit();
}

function changeLanguage() {		
	if (currentAddress.indexOf("?") == -1) {
		document.location.href = kidspaceUrl + '/' + currentAddress + '?langID=' + document.languageForm.languageId.options[document.languageForm.languageId.selectedIndex].value;
	} else {
		document.location.href = kidspaceUrl + '/' + currentAddress + '&langID=' + document.languageForm.languageId.options[document.languageForm.languageId.selectedIndex].value;
	}
}

function editPage() {
//	popupWin = window.open(kidspaceUrl + '/editPage.php?HoldNode=' + holdNode + '&parentId=0', 'editPage', 'width=' + screen.width + ',height=' + screen.height + ',scrollbars=yes');
	popupWin = window.open(kidspaceUrl + '/editPageNew.php?HoldNode=' + holdNode + '&parentId=0', 'editPage', 'width=770, height=920, scrollbars=yes resizable');
}

function createPage() {
	popupWin = window.open(kidspaceUrl + '/createPage.php?parentId=' + holdNode + '&HoldNode=0', 'createPage', 'width=770, height=920,scrollbars=yes');
}

function addComment() {
	document.location.href = kidspaceUrl + '/addComment.php?HoldNode=' + holdNode;
}

function goBackFromComment() {
	document.location.href = kidspaceUrl + '/start.php?HoldNode=' + holdNode;
}

function addCommentCheck() {
	if (document.addCommentForm.commentDescription.value.length == 0) {
		alert(commentAlert);
	} else {
		document.addCommentForm.submit();
	}
}

function kwCheck() {
	if (document.searchForm.searchKeyword.value.length == 0) {
		alert(searchAlert);
	} else {
		document.searchForm.submit();
	}
}

function uploadImg() {
	document.location.href = kidspaceUrl + '/uploadImage.php?HoldNode=' + holdNode;
}

function goBackFromUploadImg() {
	document.location.href = kidspaceUrl + '/editPage.php?HoldNode=' + holdNode;
}

function changePage() {
	if (document.nodeForm.nodeId.options[document.nodeForm.nodeId.selectedIndex].value != "select") {
		document.location.href = kidspaceUrl + '/' + document.nodeForm.nodeId.options[document.nodeForm.nodeId.selectedIndex].value;
	}
}

function GetXmlHttpObject(handler) { 
	var objXMLHttp = null;
		
	if (window.XMLHttpRequest) {
		objXMLHttp = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
		
	return objXMLHttp;
}

window.onbeforeunload = function() {
	xmlHttp = GetXmlHttpObject();
	
	var pageUrl = kidspaceUrl + '/deleteTrack.php?userName=' + userName;
	xmlHttp.open("GET", pageUrl, false);
	xmlHttp.send(null);
}

function previewPage() {
	document.getElementById('editBox').style.visibility = 'hidden';
	document.getElementById('node_WYSIWYG_Editor').style.display = 'none';
	document.getElementById('node_toolbars').style.visibility = 'hidden';
	document.getElementById('previewBox').innerHTML = '<center class="title">' + element5 + ': ' + document.editNodeForm.nodeTitle.value + '&nbsp;&nbsp;-&nbsp;&nbsp;' + element11 + ': ' + userName + '</center><br>';
	document.getElementById('previewBox').innerHTML += document.getElementById('nodeDescription').value;
	document.getElementById('previewBox').style.visibility = 'visible';
	document.getElementById('editPageButton').disabled = false;
}

function continueEditting() {
	document.getElementById('editBox').style.visibility = 'visible';
	document.getElementById('node_toolbars').style.visibility = 'visible';
	document.getElementById('node_WYSIWYG_Editor').style.display = 'block';
	document.getElementById('previewBox').innerHTML = '&nbsp;';
	document.getElementById('previewBox').style.visibility = 'hidden';
	document.getElementById('editPageButton').disabled = true;
}

function insertEmoticon() {
	popupWin = window.open(kidspaceUrl + '/insertEmoticon.php', 'insertEmoticon', 'width=600,height=400,resizable');
}

//This is so that i can actually execute stuff behind the scenes
function GetXmlHttpObject() {
	var xmlHttp = null;

	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp = new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	
	return xmlHttp;
}

