// mae'r sgript yma yn galw tudalen ASP i gofnodi'r gwall HTTP
function galw_cofnodwr() {
	var req = nolXMLHttp();
	var statws = document.getElementById("codStatws").innerHTML;
	
	if(!req) {
		return false;
	}
	
	req.onreadystatechange = function() {
		if(req.readyState == 4) {
			if(req.status == 200) {
				//document.getElementById("neges").innerHTML = req.responseText;
				if(statws == "404") {
					document.getElementById("negesCofnodiCy").innerHTML = "Mae'r broblem wedi cael ei chofnodi.";
					document.getElementById("negesCofnodiEn").innerHTML = "The problem has been recorded.";
				}
				else if(statws == "403") {
					document.getElementById("negesCofnodiCy").innerHTML = "Mae hyn wedi ei gofnodi.";
					document.getElementById("negesCofnodiEn").innerHTML = "This has been recorded.";
				}
			}
			else {
				// methiant - gadael y neges sy'n dweud wrthynt am ebostio
			}
		}
	};
	
	var porth = location.port;
	if(!porth) {
		porth = 80;
	}
	
	req.open("POST", "/corcyffredinol/gwallau/cofnodi_gwall.asp", true);
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
	req.send(	"url_ceisiedig=" + escape(location.href) +
					"&url_cyfeiriedig=" + escape(document.referrer) +
					"&cod=" + statws +
					"&enw_gweinyddwr=" + location.hostname +
					"&porth_gweinyddwr=" + porth
				);
	
	return true;
}

function gosodTestunJS() {
	document.getElementById("enwTudalenCy").innerHTML = "<b>" + location.href + "</b>";
	document.getElementById("enwTudalenEn").innerHTML = "<b>" + location.href + "</b>";
	
	document.getElementById("ynOlCy").innerHTML = "Mynd <a href=\"javascript:history.back()\" title=\"yn &ocirc;l\">yn &ocirc;l</a>";
	document.getElementById("ynOlEn").innerHTML = "Go <a href=\"javascript:history.back()\" title=\"back\">back</a>";
}

function nolXMLHttp() {
	if(window.XMLHttpRequest) {
		return new XMLHttpRequest();
	}
	else if(window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");	// ar gyfer IE5 ac IE6
	}
	return null;		// os ddim yn cefnogi
}
