// By Studio Sophisti
// info@studiosophisti.nl
// for Graphic Design Museum collection website

function getHttpRequest() {
	var xmlhttp=null;
	
	// Provide the XMLHttpRequest class for IE 5.x-6.x:
	// Other browsers (including IE 7.x-8.x) ignore this
	//   when XMLHttpRequest is predefined
	if (typeof XMLHttpRequest == "undefined") {
	  XMLHttpRequest = function () {
		try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); }
		  catch (e1) {}
		try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); }
		  catch (e2) {}
		try { return new ActiveXObject("Msxml2.XMLHTTP"); }
		  catch (e3) {}
		try { return new ActiveXObject("Microsoft.XMLHTTP"); }
		  catch (e4) {}
		throw new Error("This browser does not support XMLHttpRequest.");
	  };
	}
	
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
	}
		
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
		}
	}	
	
	return xmlhttp;
}


function submitComment() {
	
	if (document.getElementById("commentText").value == "" || document.getElementById("senderName").value == "") {
		return;
	}
	
	var httpReq = getHttpRequest();
	
	if (httpReq == null) return;
	
	var urlString = "/proto/commentinsert.php?id="+
		document.getElementById("itemId").value+"&comment="+
		escape(document.getElementById("commentText").value)+"&name="+
		escape(document.getElementById("senderName").value);
	
	//alert (urlString);
	httpReq.open("GET", urlString, true);
	httpReq.onreadystatechange=function() {
		if (httpReq.readyState==4) {
			window.location.reload(true);
		}
	}
	httpReq.send(null);
			
}

function vote(score) {
	
}
