if(window.location.hash.length!=0)
	document.getElementById(window.location.hash.substr(1)).className = "highlight"; 

var state = false;

function ShowEmoticons() {
	var Fenster1 = window.open("emotes.php", "_blank", "width=200,height=400,top=200,left=200,scrollbars=yes");
	Fenster1.focus();
}

function OpenWindow() {
	state = !state;
	if(state) {
		document.getElementById("CommentWindow").style["display"] = "";
		document.comment.cmt.focus();
		document.getElementById("CommentWindow").scrollIntoView(false);
	}
	else document.getElementById("CommentWindow").style["display"] = "none";
}

function SubmitComment() {	
	if(document.comment.cmt.value.length == 0) {
		alert("Kommentar fehlt");
		return;
	}
	
	if(document.comment.cmt.value.length > 4000 && !privileged) {
		alert("Kommentar zu lang (max. 4000 Zeichen)");
		return;
	}
	
	var req = null;
	
	document.getElementById("progress").style["display"] = "";
	
	if(window.XMLHttpRequest)	req = new XMLHttpRequest();
	else
		if(window.ActiveXObject) 
			try {
				req = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
					try {
						req = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}

 	req.onreadystatechange = function() {
		if(req.readyState == 4) {
			 if(req.status == 200) {
					var comments = document.getElementById("comments");			
					comments.innerHTML = hline + req.responseText+comments.innerHTML;
					OpenWindow();
					document.comment.cmt.value = "";
					document.getElementById("progress").style["display"] = "none";
					hline = '';
					
			 } else
					 alert("Sorry. Did not work. Error code " + req.status);
		}
	}; 
	req.open("POST", "comments.php?cmtact=wr2", true);
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	var data = "file="+myfile+"&rid="+rid;
	data += "&cmt="+encodeURIComponent(document.comment.cmt.value);
	
	req.send(data);
}
