/************************************************************
Het resetten van een formulier naar de orginele waardes, indien 
geen orginele waardes dan worden de ingevulde velden leeg
************************************************************/
function resetFormulier(strName){
	var blnReset = confirm("formuliergegevens worden gereset!")
	if (blnReset == true){
		document.forms[strName].reset();
	}
}

/************************************************************
Bepalen of er een editor is gebruikt, ja dan de HTML opslaan in een
variabele(<naam_editor>_HTMLContent.
Opdracht op opslaan zetten en URL zetten, waar het formulier naar toe
moet worden gestuurd.
************************************************************/
function opslaanRecord(arrObjEditors,arrEditorNaam,strURL){
	if(arrObjEditors != null){
		for(i=0;i<arrObjEditors.length;i++){
			save(arrObjEditors[i]);
		}
	}
	for(i=0;i<arrEditorNaam.length;i++){
		document.forms[0]["editorNaam"+i].value = arrEditorNaam[i];
		//alert(document.forms[0]["editorNaam"+i].value);
	}
	document.forms["frm_toevoegen"].cmdActie.value = "opslaan";
	document.forms["frm_toevoegen"].action = strURL;
	document.forms["frm_toevoegen"].submit();
}

/************************************************************
Bepalen of er een editor is gebruikt, ja dan de HTML opslaan in een
variabele(<naam_editor>_HTMLContent.
Formulier opdracht update zetten en URL waar formulier naar toe moet
worden gestuurd.
************************************************************/
function updateRecord(arrObjEditors,arrEditorNaam,strURL){
	if(arrObjEditors != null){
		for(i=0;i<arrObjEditors.length;i++){
			save(arrObjEditors[i]);
		}
	}
	for(i=0;i<arrEditorNaam.length;i++){
		document.forms["frm_wijzigen"]["editorNaam"+i].value = arrEditorNaam[i];
		//alert(document.forms[0]["editorNaam"+i].value);
	}	
	document.forms["frm_wijzigen"].action = strURL;
	document.forms["frm_wijzigen"].cmdActie.value = "update";
	document.forms["frm_wijzigen"].submit();
}
/************************************************************
Indien bevestiging ok, dan formulier opdracht verwijderen zetten
en URL waar formulier naar toe moet worden gestuurd.
************************************************************/
function verwijderenRecords(strURL){
	if (confirm("Weet u zeker dat u dit item wilt verwijderen?") == true){
		document.forms["frm_verwijderen"].cmdActie.value = "verwijderen";
		document.forms["frm_verwijderen"].action = strURL;
		document.forms["frm_verwijderen"].submit();		
	}
}

/************************************************************
Openen van een simpele window;
Argumenten: URL, titel window, breedte en hoogte.
Eigenschappen window:
	toolbar=no;
	location=no;
	directories=no;
	status=no;
	menubar=no;
	scrollbars=yes;
	resizable=no;
	copyhistory=no;
************************************************************/
function openWindowSimpel(strURL,strWindowName,intWidth,intHeight){
	intLeftPosition = (screen.width) ? (screen.width-intWidth)/2 : 0;
	intTopPosition = (screen.height) ? (screen.height-intHeight)/2 : 0;
	window.open(strURL,strWindowName,"top="+intTopPosition+",left="+intLeftPosition+",toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=" + intWidth + ", height=" + intHeight);
}

/************************************************************
Functie voor het veranderen van de positie van bijvoorbeeld
items in een lijst.
************************************************************/
function positieOmhoog(recordID,strURL){
	document.forms[0].action = strURL;
	document.forms[0].recordID.value = recordID;
	document.forms[0].cmdActie.value = "positieOmhoog";
	document.forms[0].submit();	
}

/************************************************************
Functie voor het veranderen van de positie van bijvoorbeeld
items in een lijst.
************************************************************/
function positieOmlaag(recordID,strURL){
	document.forms[0].action = strURL;
	document.forms[0].recordID.value = recordID;
	document.forms[0].cmdActie.value = "positieOmlaag";
	document.forms[0].submit();	
}

/************************************************************
Functie voor het invoegen van een afbeelding bij bijvoorbeeld
een nieuwsitem. Functie opent een dialog met de afmetingen 580 bij 640 pixels.
************************************************************/
function weergevenInvoegenAfbeelding(strFrmNaam,strVeldnaam,strURL,strPad,lngMaxSize){
	var strAttr, strBestandsnaam;
	
	strAttr = "status:no;dialogWidth:580px;dialogHeight:640px; scroll: no; resizable: yes; help:no";
	strURL = strURL + "?GP=" + strPad + "&MaxImageSize=" + lngMaxSize;
	if(document.forms[strFrmNaam][strVeldnaam].value != ""){
		strBestandsnaam = showModalDialog(strURL,strPad + document.forms[0][strVeldnaam].value,strAttr);
	}
	else{
		strBestandsnaam = showModalDialog(strURL,"",strAttr);
	}
	
	if(strBestandsnaam == undefined){
		if(document.forms[strFrmNaam][strVeldnaam].value == ""){
			document.forms[strFrmNaam][strVeldnaam].value = "";
		}
	}
	else{
		document.forms[strFrmNaam][strVeldnaam].value = strBestandsnaam;
		
	}
}

/************************************************************
Functie zet waarde van checkbox op True of False. Zodat bij het
opslaan doormiddel van CBool conversie de waarde direct goed
wordt opgeslagen in de database.
************************************************************/
function check(refCheckbox){
	if(refCheckbox.checked == true){
		refCheckbox.value = "True";
	}
	else{
		refCheckbox.value = "False";
	}
}


/************************************************************
Functie bepaald of er wel tekst in zoekveld is ingevuld. Zo ja
dan URL en actie zetten.
************************************************************/
function zoeken(strActie,strURL){
	if(document.forms["frm_zoeken"].zoekTekst.value != ""){
		document.forms["frm_zoeken"].action = strURL;
		document.forms["frm_zoeken"].cmdActie.value = strActie;
		document.forms["frm_zoeken"].submit();
	}
	else{
		return false;
	}
}

/************************************************************
Functie voor sorteren veld in oplopende of aflopende volgorde.
************************************************************/
function doeSorteren(strVeldNaam,strActie,strURL){
	document.forms["sorteren"].action = strURL;
	document.forms["sorteren"].cmdActie.value = strActie;
	document.forms["sorteren"].sorteerveld.value = strVeldNaam;
	if(document.forms["sorteren"].sorteervolgorde.value == "ASC") {
		document.forms["sorteren"].sorteervolgorde.value = "DESC";
	}
	else{
		document.forms["sorteren"].sorteervolgorde.value = "ASC";
	}
	document.forms["sorteren"].submit();
}

/************************************************************
Indien pagina gesorteerd dan deze sorterings volgorde versturen.
Wanneer er een volgende pagina wordt opgevraagd.
************************************************************/
function paginaNavigatie(intPaginanr,strURL){
	document.forms["sorteren"].action = strURL;
	document.forms["sorteren"].paginanr.value = intPaginanr;
	document.forms["sorteren"].submit();
}