// nep browsercheck voor oude surveys
var browsername = "MSIE";
var browserversion = 5;

// browsercheck
var isff = (navigator.userAgent.indexOf("Gecko") != -1) ? 1 : 0;
var isie = (navigator.userAgent.indexOf("MSIE") != -1) ? 1 : 0;

// set browserspecific vars
if (isie == 1) {
avail_width = document.documentElement.offsetWidth;
avail_height = document.documentElement.offsetHeight;
width_lijntjerood = avail_width-565;
doc = "document.all";
styl = ".style";
html = "";
xpos =  "event.x";
ypos =  "event.y";
}
else if (isff == 1) {
avail_width = window.innerWidth;
avail_height = window.innerHeight;
width_lijntjerood = avail_width-565;
doc = "document";
styl = ".style";
html = ".document";
xpos =  "e.pageX";
ypos =  "e.pageY";
}
else {
// set standard height and width
avail_height = 550;
avail_width = 800;
width_lijntjerood = avail_width-545;
doc = "document.all";
styl = ".style";
html = "";
xpos =  "event.x";
ypos =  "event.y";
};
//note: van ff weet ik het niet zeker

// checkresize
function herlaad() {
window.location.href = window.location.href;
}

// pulldown autojump
 function surfto(form) {
        var myindex=form.select1.selectedIndex
        if (form.select1.options[myindex].value != "0") {
        window.location.href=form.select1.options[myindex].value;}
}

// netscape resize fix
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


//Newwindow script
function new_window(url) {
link = window.open(url,"Link","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=1,width=500,height=400,left=10,top=10");
}

// select all, select nothing, or reversie selection with checkboxes in form.
function alles(formObj) {
	for (var i=0;i < formObj.length;i++) {
      fldObj = formObj.elements[i];
      if (fldObj.type == 'checkbox') { fldObj.checked = true; }
	}
}
function niets(formObj) {
	for (var i=0;i < formObj.length;i++) {
      fldObj = formObj.elements[i];
      if (fldObj.type == 'checkbox') { fldObj.checked = false; }
	}
}
function inverse(formObj) {
	for (var i=0;i < formObj.length;i++) {
      fldObj = formObj.elements[i];
      if (fldObj.type == 'checkbox') { fldObj.checked = (fldObj.checked) ? false : true;}
	}
}

// confirmation of deletion of items
function zeker(id_nummer) {
	if (confirm("Are you sure?")) {	
	tempvartje = "./index.cfm?fuseaction=delete&id=" + id_nummer
location.href=tempvartje; }
	else { void(0); }
}

//toggle script is for hiding and showing a table row -- used in large lists of, ie, respondents
function toggle( targetId ){
  		target = document.getElementById( targetId );
  			if (target.style.display == "none"){
				target.style.display = "block";
  			} else {
  				target.style.display = "none";
  			}
}
//end toggle

//function to randomize elements of an array in javascript
function randomsort(w1,w2) {
return Math.floor(Math.random()*3)-1;
}
//end of function
//in order to use, call function in sort function as follows:
//arrayname = arrayname.sort(randomsort);

// trim function, to trim spaces from string
function trim(strToTrim) {
	return(strToTrim.replace(/^\s+|\s+$/g, ''));
}


// change text dynamically in a page
//usage: wrap text to be changes in span or div wioth an id.
//call the function as follows: OnWhatEver="changetext('divname','newtexthere')"
function changetext(divname, newtext) {
   var newtitle = newtext;
   var tempje = document.getElementById(divname);
   tempje.firstChild.nodeValue=newtext;
}