// JavaScript Document

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

var submitted = false;


function loadAdres(plaats) {
	//alert(plaats);
	if(submitted == false) {
		if((plaats == "") || (plaats == '0')) {
			alert('U dient een plaats te selecteren.');
			return false;
		}
		document.frm.afleveradres_plaats.value = plaats;
		document.frm.submit();
		submitted = true;
	}
}


function loadCat(cat,nr) {
	if(submitted == false) {
		if((cat == "") || (cat == '0')) {
			// alert('U dient een categorie te selecteren.');
			return false;
		}
		if (nr == "1") document.frm.cat1.value = cat;
		if (nr == "2") document.frm.cat2.value = cat;
		if (nr == "3") document.frm.cat3.value = cat;
		if (nr == "4") document.frm.cat4.value = cat;
		if (nr == "5") document.frm.cat5.value = cat;
		document.frm.submit();
		submitted = true;
	}
}

function submitForm() {
	wp_submit_editors();
	return true;
}

function formSave(val) {
	document.frm.bookmark.value = val;
	wp_submit_editors();
	document.frm.submit();
}

var target_field = null;

function openImageWindow(field) {
	target_field = field;
	var return_function = "setImage" // must be the name of the function you want to call when an item is chosen. This should be string containing only letters and numbers.
	wp_openDialog('/editor/dialog_frame.php?window=image.php&return_function='+return_function, 'modal',730,466)
}

function setImage(iurl, iwidth, iheight, ialign, ialt, iborder, imargin) {
	//document.frm.article1_download.value=iurl;
	target_field.value=iurl;
	target_field = null;
}

function openDocWindow(field) {
	target_field = field;
	var return_function = "setDocument" // must be the name of the function you want to call when an item is chosen. This should be string containing only letters and numbers.
	wp_openDialog('/editor/dialog_frame.php?window=document.php&return_function='+return_function, 'modal',730,466)
}

function setDocument(iHref,iTarget,iTitle) {
	//document.form1.document.value=iHref;
	target_field.value=iHref;
	target_field = null;
}

function previewDocument(field) {
	if((field == null) || (field.value == '')) {
	   alert('Selecteer eerst een afbeelding');
	   return;
	}

	PopUp(field.value,'Preview',400,400,'YES','center');
}

var win=null;
function PopUp(page,name,w,h,scroll,pos){ 
	if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
	if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
	else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';
	win=window.open(page,name,settings);
	win.focus();
}


