function clearDefaultText(thisfield, defaulttext) {
  if (thisfield.value == defaulttext)
    thisfield.style.textAlign="left";
    thisfield.value = "";
}

function displayDefaultText(thisfield, defaulttext){
  if (thisfield.value == "")
    thisfield.value = defaulttext;
}

function hideDiv(divId) {
    document.getElementById(divId).className="hide";
}

function showDiv(divId) {
    document.getElementById(divId).className="show";
}

function toggleDivs(div1, div2, class1, class2) {
    document.getElementById(div1).className = class1;
    document.getElementById(div2).className = class2;
}

function dim (divId) {
    document.getElementById(divId).className = "offColor";
}

function showImg(imgName,divName,cssclass) {
imgHtml= "<img src='" + imgName + "' class='" + cssclass + "'>";
    document.getElementById(divName).innerHTML=imgHtml;
}

function clearDiv(divName) {
    html = "";
    document.getElementById(divName).innerHTML = html;
}

function filter(strSchool, strPos, strFunc) {
    var regAll = new RegExp('All');
    var regS; var regP; var regF;
    var row;
    var found = 0;
    var lastmatch = ""; cellid = "";

    if (regAll.test(strSchool)) strSchool = '';
    if (regAll.test(strPos)) strPos = '';
    if (regAll.test(strFunc)) strFunc = '';

    for (i = 0; i < arrData.length; i++) {
        regS = new RegExp(strSchool);
        regP = new RegExp(strPos);
        regF = new RegExp(strFunc);
        row = 'row' + (i + 1);

        if (regS.test(arrData[i][0]) && regP.test(arrData[i][1]) && regF.test(arrData[i][2])) {
            document.getElementById(row).style.display = '';
            found = 1;
            cellid = row + 'cell1';
            if (arrData[i][0] == lastmatch) {
                document.getElementById(cellid).innerHTML = "";
                for (j = 1; j <= 4; j++) {
                    cellid = row + 'cell' + j;                  
                    document.getElementById(cellid).className = 'nextItem'; 
                }
            }
            else {
                cellid = row + 'cell1';
                document.getElementById(cellid).innerHTML = "<p>" + arrData[i][0] + "</p>";
                for (j = 1; j <= 4; j++) {
                    cellid = row + 'cell' + j;
                    document.getElementById(cellid).className = 'topBorder';
                }
            }
            lastmatch = arrData[i][0];
        }
        else document.getElementById(row).style.display = 'none';
    }

    if (!found) document.getElementById('message').innerHTML = "<p>Sorry, no events match the current filters.</p>";
    else document.getElementById('message').innerHTML = "";
}

function clearForms() {
var i;
  for (i = 0; (i < document.forms.length); i++) {
    document.forms[i].reset();
  }
}