<!--
/* blur border of hyperlinks in Internet Explorer */
function ExplorerFix() { 
   for (a in document.links) document.links[a].onfocus = document.links[a].blur; 
} 

if (document.all) document.onmousedown = ExplorerFix;
/* end */



/* reloads the window to fix the Netscape Navigator 4 resize bug */
function NetscapeFix(init) {
   if (init == true) with (navigator) {
      if ((appName == "Netscape") && (parseInt(appVersion) == 4)) {
         document.PageWidth = innerWidth;
         document.PageHeight = innerHeight;
         onresize = NetscapeFix;
      }
   }
   else if (innerWidth != document.PageWidth || innerHeight != document.PageHeight)
      location.reload();
}
NetscapeFix(true);
/* end */



/* don't open this site in an frameset */
if (top.frames.length != 0)
   top.location = self.document.location;
/* end */



/* don't open this site in an frameset */
function initArray() {
   this.length = initArray.arguments.length;

   for (var i = 0; i < this.length; i++)
      this[i+1] = initArray.arguments[i];
}



/* mark form elements */
function mark(face,field_color,text_color) {
   if (document.documentElement) { // if browser is IE5+ or NS6+
      face.style.backgroundColor = field_color;
      face.style.color = text_color;
   }
}
/* end */


var dayArray = new initArray("zondag","maandag", "dinsdag","woensdag","donderdag","vrijdag","zaterdag");
var monthArray = new initArray("januari","februari","maart","april","mei","juni","juli", "augustus","september","oktober","november","december");

var now = new Date();
var dayName = dayArray[(now.getDay()+1)];
var day = now.getDate();
var monthName = monthArray[(now.getMonth()+1)];
var year = now.getYear();
var correctYear = ((year < 1900) ? (year + 1900) : (year));


var showDate = "Het is vandaag " + dayName + " " + day + " " + monthName + " " + correctYear;
/* end */



/* preload and higlighten images */
browserName    = navigator.appName;
browserVersion = parseFloat(navigator.appVersion); 

if (browserName == "Netscape" && browserVersion >= 3.0)
   goOn = 'true';
else if (browserName == "Microsoft Internet Explorer" && browserVersion >= 4.0)
   goOn = 'true';
else
   goOn = 'false';


if (document.images && goOn == 'true') {
   if (document.images) {

      /* menu buttons on */
      image1on = new Image();  image1on.src = "images/but_home_on.gif";  
      image2on = new Image();  image2on.src = "images/but_downloads_on.gif";  
      image3on = new Image();  image3on.src = "images/but_email_on.gif";  


      /* menu buttons off */
      image1off = new Image();  image1off.src = "images/but_home_off.gif";  
      image2off = new Image();  image2off.src = "images/but_downloads_off.gif";  
      image3off = new Image();  image3off.src = "images/but_email_off.gif";  

   }

   function turnOn(imageName) {
      if (document.images && goOn == 'true') {
         if (browserName == "Netscape" && browserVersion >= 3.0)
            document[imageName].src = eval(imageName + "on.src");
         else
            document[imageName].src = eval(imageName + "on.src");
      }
   }

   function turnOff(imageName) {
      if (document.images && goOn == 'true') {
         if (browserName == "Netscape" && browserVersion >= 3.0)
            document[imageName].src = eval(imageName + "off.src");
         else
            document[imageName].src = eval(imageName + "off.src");
      }
   }

}
/* end */



/* confirms */
function DeleteItem()	{
	return confirm ("Weet u zeker dat u dit item wilt verwijderen?");
}
/* end */


/* check / uncheck all checkboxes in the form */
function CA(theElement) {
	var theForm = theElement.form, i = 0;

	while (theForm[i].type == 'checkbox' && theForm[i].name != 'checkall') {
		theForm[i].checked = theElement.checked;
		i++;
	}
}
/* end */


/* check the 'checkall' checkbox if all checkboxes are checked */
function CAE(theElement) {
	var theForm = theElement.form, i = 0, a = 0;

	while (theForm[i].type == 'checkbox' && theForm[i].name != 'checkall') {
		if (theForm[i].checked)  {
			a++;
		}
		i++;
	}

	if (i == a)	theForm.checkall.checked = theElement.checked;
	else theForm.checkall.checked = '';
}
/* end */


/* mark / unmark rows in a table */
var marked_row = new Array;

/*
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   integer   the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */

function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor) {
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
    if (currentColor.indexOf("rgb") >= 0)
    {
        var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
                                     currentColor.indexOf(')'));
        var rgbValues = rgbStr.split(",");
        currentColor = "#";
        var hexChars = "0123456789ABCDEF";
        for (var i = 0; i < 3; i++)
        {
            var v = rgbValues[i].valueOf();
            currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
        }
    }

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // Garvin: deactivated onclick marking of the checkbox because it's also executed
            // when an action (like edit/delete) on a single item is performed. Then the checkbox
            // would get deactived, even though we need it activated. Maybe there is a way
            // to detect if the row was clicked, and not an item therein...
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
            // document.getElementById('id_rows_to_delete' + theRowNum).checked = false;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
}
/* end */


/* define confirm function */
function ConfirmItem(action, theElement) {
	var theForm = theElement.form, i = 0, a = 0;
	
	// define confirm actions (actions are defined in the form)
	if (action == 'delete_item') {
		error_message = "Het geselecteerde item zal definitief verwijderd worden.";
		return confirm(error_message);
	}
	else if (action == 'default_values') { 
		error_message = "Weet u zeker dat u de beginwaarden wilt toepassen?";
		return confirm(error_message);
	}
	else {
		// define confirm actions that depends on the checkboxes in the form
		while (theForm[i].type == 'checkbox' && theForm[i].name != 'checkall') {
			if (theForm[i].checked)  {
				a++;
			}
			i++;
		}

		if (a == 0)	{
			// show alert if no checkboxes are checked
			alert("Selecteer eerst één of meer items om deze actie uit te voeren.");
			return false;	
		}
		else {
			// show confirm based on an action (actions are defined in the form)
			if (action == 'activate') { error_message = "De geselecteerde items zullen op de website zichtbaar zijn.";}
			else if (action == 'inactivate') { error_message = "De geselecteerde items zullen niet op de website te zien zijn, maar wel bewaard worden."; }
			else if (action == 'delete_items') { error_message = "De geselecteerde items zullen definitief verwijderd worden."; }

			return confirm(error_message);
		}
	}
}
/* end */


function AllowEdit(xHow, a) {
	// place onload="AllowEdit(true)" in the <BODY>-tag or
	// place DISABLED in the tag of the field that should be disabled
	TheForm = document.forms[0].elements;  //get form elements list    	   
	
	for(i=0 ;i<TheForm.length; i++) {
		if(TheForm[i].name != "wijzig") // do not disable the element to enable all form fields
		TheForm[i].disabled = xHow;

	}


}


/*  hide all layers exept the current one */
function hideAllExcept(id) {
	for (var i = 0; i < states.length; i++) {
		var layer = document.getElementById(states[i]);

		if (id != states[i]) {
			layer.style.display = "none";
		}
		else {
			if (layer.style.display == "none") {
				layer.style.display = "";
			}
			else {
				layer.style.display = "";
			}
		}
	}
}
/* end */


/* function to count characters (useful for form elements) */
function textCounter(field, countfield, maxlimit) {
	/* trim characters when we've more characters in the field than is allowed */
	if (field.value.length > maxlimit) {
		field.value = field.value.substring(0, maxlimit);
	}
	else {
	/* counter for showing how many characters are left */
	countfield.value = maxlimit - field.value.length;
	}
}
/* end */
//-->
