var win= null;
function NewWindow(mypage,myname,w,h,scroll){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  var settings  ='height='+h+',';
      settings +='width='+w+',';
      settings +='top='+wint+',';
      settings +='left='+winl+',';
      settings +='scrollbars='+scroll+',';
      settings +='resizable=no';
  win=window.open(mypage,myname,settings);
  if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is vereist.\n'; }
  } if (errors) alert('Wilt u alstublieft onderstaande gegevens nog invoeren:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function firstimagecheck() {
	checknomis = document.getElementById( 'file' ).value;
	charno = checknomis.length;
	checkext = checknomis.substring(charno-4, charno);
	checkext = checkext.toLowerCase()
}

function delfunc(a) {
	if(confirm("Weet u zeker dat u dit bestand wilt verwijderen?")) {
		parent.document.location = "imgselect.php?module=mappen&fold=pdf&action=deleteafb&naam=" +a;
	}
}

function delfunc2(a) {
	if(confirm("Weet u zeker dat u dit bestand wilt verwijderen?")) {
		parent.document.location = "imageselect.php?module=mappen&fold=pdf&action=deleteafb&naam=" +a;
	}
}

function delimage(a) {
	if(confirm("Weet u zeker dat u deze foto wilt verwijderen?")) {
		parent.document.location = "banner_admin.php?module=mappen&fold=pdf&action=deleteafb&naam=" +a;
	}
}

function delflash(a) {
	if(confirm("Weet u zeker dat u dit flash-bestand wilt verwijderen?")) {
		parent.document.location = "media_admin.php?module=mappen&fold=pdf&action=deleteafb&naam=" +a;
	}
}

function delmap(b) {
	if(confirm("Weet u zeker dat u deze map wilt verwijderen? \nDe map moet wel eerst leeg zijn.")) {
		parent.document.location = "imgselect.php?module=mappen&action=deletefold&naam=" +b;
	}
}
function checkfields() {
	if(document.getElementById("file").value == ""|| document.getElementById("folder").value == "") {
		alert("Voert u alle velden in a.u.b.");
	} else {
		document.getElementById("form").submit(); 
	}
}

function imgselect(a) {
	locatie = "imgselect.php?img=" +a;
	raam = window.open(locatie, "afbeeldingselector", "location=0,status=0,scrollbars=1,width=1105,height=700");
}

function mediaselect(a) {
	locatie = "mediaselect.php?naam=" +a;
	raam = window.open(locatie, "mediaselector", "location=0,status=0,scrollbars=1,width=1105,height=700");
}


function AddPDF(bestand) {
	tekst = prompt('Voer de tekst van de link in:', '');
  var html = '<a href="http://www.ta-survey.nl/pdf/' + bestand + '" target="_blank">' + tekst  +'</a>';
	window.opener.insertHTML(html);
	window.close();
}

function AddImage(bestand) {
	tekst = prompt('Voer de tekst van de titel in:', '');
  var html = '<img src="http://www.ta-survey.nl/images/' + bestand + '" title="' + tekst + '">';
	window.opener.insertHTML(html);
	window.close();
}


function AddImage2(bestand,img) {
	// ja, ik weet dat dit geen mooie oplossing is!			 
	if (img==1){			 
		 opener.document.getElementById('foto1').value = bestand;
	}
	if (img==2){			 
		 opener.document.getElementById('foto2').value = bestand;
	}
	if (img==3){			 
		 opener.document.getElementById('foto3').value = bestand;
	}
	if (img==4){			 
		 opener.document.getElementById('foto4').value = bestand;
	}
	if (img==5){			 
		 opener.document.getElementById('foto5').value = bestand;
	}
	if (img==6){			 
		 opener.document.getElementById('foto6').value = bestand;
	}
	window.close();
}




