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) {
	$.ajax({
		type: 'GET',
	  url: '/plugins/content_types/matrix/load_matrix_item.php?m='+matrixID+'&r='+rijID+'&c='+colID+'&v='+v+'&b='+b,
	  dataType: "json",
	  success: function(cellInfo) {
			$('#matrixUitleg').show();
			$('#matrixUitlegKolom').hide();
			$('#matrixUitlegTitel').html("<h2>"+cellInfo.title+"</h2>");
			$('#matrixUitlegTekst').html(cellInfo.content);
			if (b==1 && cellInfo.editlink) {
				$('#matrixUitlegTekst').html(cellInfo.editlink+$('#matrixUitlegTekst').html());
			}
			$('html').animate({
				scrollTop: $('#matrixUitleg').offset().top
			}, 500);
		},
		error: function (xhr, desc, exceptionobj) {
			alert("Het opgevraagde artikel is momenteel niet beschikbaar.");
		}
	});
}


function loadColumnInfo(matrixID,colID,v,b) {
	$.ajax({
		type: 'GET',
	  url: '/plugins/content_types/matrix/load_matrix_item.php?m='+matrixID+'&r=0&c='+colID+'&v='+v+'&b='+b,
	  dataType: "json",
		success: function(columnInfo) {
			$('#matrixUitleg').hide();
			$('#matrixUitlegKolom').show();
			$('#matrixUitlegKolom').html(columnInfo.content);
			$('html').animate({
				scrollTop: $('#matrixUitlegKolom').offset().top
			}, 500);
		},
		error: function (xhr, desc, exceptionobj) {
			alert("Het opgevraagde artikel is momenteel niet beschikbaar.");
		}
	});
}


function hh(cellID,colID,rowID) {
	if (ac!="") $('#'+ac).get(0).className="matrixCell";
	$('#'+cellID).get(0).className="matrixCellActive";
	ac=cellID;

	if (ah!="") {
		$('#matrix_heading'+ah).get(0).className="matrixHeading";
	}
	$('#matrix_heading'+colID).get(0).className="matrixHeadingActive";
	ah=colID;

	if (arh!="") {
		$('#matrixRowHeading'+arh).get(0).className="matrixRowHeading";
	}

	$('#matrixRowHeading'+rowID).get(0).className="matrixRowHeadingActive";
	arh=rowID;
}


function hheading(colID) {
	if (ah!="") $('#matrix_heading'+ah).get(0).className="matrixHeading";
	$('#matrix_heading'+colID).get(0).className="matrixHeadingActive";
	ah=colID;

	if (ac!="") {
		$('#'+ac).get(0).className="matrixCell";
	}
	ac="";

	if (arh!="") {
		$('#matrixRowHeading'+arh).get(0).className="matrixRowHeading";
	}
	arh="";
}
