var visibleMatrixItem="";
var ah="",arh="",ac="";


function displayMatrixItem(id) {
	if (visibleMatrixItem!="") {
		document.getElementById(visibleMatrixItem).style.display="none";
	}
	document.getElementById(id).style.display="block";
	visibleMatrixItem=id;
}

function loadCellInfo(matrixID,rijID,colID,v,b) {
	var url='/plugins/content_types/matrix/load_matrix_item.php?m='+matrixID+'&r='+rijID+'&c='+colID+'&v='+v+'&b='+b;
	new Ajax.Request(url, {
		method: 'get',
		onSuccess: function(serverReply) {
			if (serverReply.responseText.isJSON()) {
				var cellInfo=serverReply.responseText.evalJSON();
				$('matrixUitleg').show();
				$('matrixUitlegKolom').hide();
				$('matrixUitlegTitel').update("<h2>"+cellInfo.title+"</h2>");
				$('matrixUitlegTekst').update(cellInfo.content);
				if (b==1 && cellInfo.editlink) {
					$('matrixUitlegTekst').innerHTML=cellInfo.editlink+$('matrixUitlegTekst').innerHTML;
				}
				$('matrixUitleg').scrollTo();
			} else {
				alert("Ongeldige response van de server." + serverReply.responseText);
			}
		},
		onFailure: function(serverReply) {
			alert("Het opgevraagde artikel is momenteel niet beschikbaar.");
		}
	});
}


function loadColumnInfo(matrixID,colID,v,b) {
	var url='/plugins/content_types/matrix/load_matrix_item.php?m='+matrixID+'&r=0&c='+colID+'&v='+v+'&b='+b;
	new Ajax.Request(url, {
		method: 'get',
		onSuccess: function(serverReply) {
			if (serverReply.responseText.isJSON()) {
				var columnInfo=serverReply.responseText.evalJSON();
				$('matrixUitleg').hide();
				$('matrixUitlegKolom').show();
				$('matrixUitlegKolom').update(columnInfo.content);
				$('matrixUitlegKolom').scrollTo();
			} else {
				alert("Ongeldige response van de server." + serverReply.responseText);
			}
		},
		onFailure: function(serverReply) {
			alert("Het opgevraagde artikel is momenteel niet beschikbaar.");
		}
	});
}


function hh(cellID,colID,rowID) {
	if (ac!="") $(ac).className="matrixCell";
	$(cellID).className="matrixCellActive";
	ac=cellID;

//alert(ah);
	if (ah!="") $('matrix_heading'+ah).className="matrixHeading";
	$('matrix_heading'+colID).className="matrixHeadingActive";
	ah=colID;

	if (arh!="") $('matrixRowHeading'+arh).className="matrixRowHeading";
	$('matrixRowHeading'+rowID).className="matrixRowHeadingActive";
	arh=rowID;
}


function hheading(colID) {
	if (ah!="") $('matrix_heading'+ah).className="matrixHeading";
	$('matrix_heading'+colID).className="matrixHeadingActive";
	ah=colID;

	if (ac!="") $(ac).className="matrixCell";
	ac="";

	if (arh!="") $('matrixRowHeading'+arh).className="matrixRowHeading";
	arh="";
}