function customOnClick(id, area, table, method, type, parameters) {
	var record = axRecord(id);
	switch (method) {
		case "Oppsummering":
			getRedirect("/oppsummering.pdf", "&tilpassetRecord=" + record, "Tilpasset læreplan");
			break;
		default:
			var url = "";
			switch (method) {
				case "moveDown":
					url = "/4daction/WA_Move_Gjoremal_Down";
					break;
				default:
					url = "/4daction/jegvilblino_" + method;
					break;
			}
			var options;
			options = {};
			options.timeout = 400000;
			var theValues = new Array();
			theValues["ASP"] = my_asp;
			theValues["Random"] = my_ran;
			theValues["id"] = id;
			theValues["div"] = area;
			theValues["table"] = table;
		
			if(parameters)
				theValues["axParameters"] = parameters;
			
			HTTP.post(url, theValues, setCustom, null);
	}
	
	function setCustom(response) {
		var error = getXMLElement(response, "error");
		if(error.length>0) {
			displayError(error);
		}
		else {
			redrawElements(response, "", area, table);
			switch (method) {
				case "nyTilpassetPlan":
				case "tilpassPlan":
				case "getOmrade":
				case "getLokalMal":
				case "getKonkretiseringer":
					if(type == "expand") {
						id = id.substring(2,id.length);
					}
					setSelectedRow(id, area);
					break;
				case "moveDown":
					var source = getXMLElement(response, "source");
					if(source) {
						var pos = id.lastIndexOf(".");
						if(pos > 0)
							id = id.substring(0, pos);
						moveRowDown(id, source);
					}
					break;
				default:
					break;
			}
		}
	}
}

function customDeleteText(tableNr) {
	var table = fileName[tableNr];
	var txt = "";
	switch (table) {
		case "Konkretiseringer":
			txt = "";
			break;
		case "Elevplaner":
			txt = "Vil du virkelig slette denne elevplanen? All vurdering og dokumentasjon knyttet til denne vil bli slettet.";
			break;
	}
	return txt;
}



function recordIsDeleted(values) {
	var table = fileName[values["table"]];
	switch (table) {
		case "Planer":
			planSlettet(values);
			break;
		case "Aktiviteter":
			aktivitetSlettet(values);
			break;
		case "Aktivitetsplaner":
			aktivitetsplanSlettet(values);
			break;
	}
	return;
}

function customRedrawElements(xmlDoc, path, area, table) {
	//skal skjule/vise tp og view
	switch (area) {
		case "view":
			break;
		default:
			break;
	}
}

function selectRelatedParameters(theValues) {
	var id = theValues["id"];
	
	var fieldName = axIdFieldName(id);
	switch (fieldName) {
		case "[Elevplaner]Tilpasset_plan":
			theValues["type"] = axGetValue(id, "[45]RelatertTilpassetType");
			break;
		case "[Aktivitetsplaner]Byggerpa":
			theValues["Plan"] = axGetValue(id, "[Aktivitetsplaner]Plan");
			theValues["Fra"] = axGetValue(id, "[Aktivitetsplaner]Fra");
			break;
		case "[Aktivitetsplaner]Til":
			theValues["Fra"] = axGetValue(id, "[Aktivitetsplaner]Fra");
			break;
		default:
			break;
	}
}

function customValidateInput (id, oldValue, newValue) {
	var feltNavn = "";
	var tabellNavn = "";
	feltNavn = axIdFieldName(id);
	if(feltNavn) tabellNavn = axFileNameFromFieldname(feltNavn);
	var response = ["1", newValue];
	switch (tabellNavn) {
		case "[Handlekurv]":
			switch (feltNavn) {
				case "[Handlekurv]GjentaEPost":
					var epost = axGetValue(id, "[Handlekurv]Epost");
					if((newValue != epost) && (newValue.length > 0)) {
						response[0] = "0";
						response[1] = "";
						alert("Gjentatt e-post adresse forskjellig fra oppgitt e-post adresse.");
					}
					break;
				case "[Handlekurv]Epost":					
					if(newValue.length>0) {
						if(newValue.indexOf("@") == -1) {
							alert("Ulovlig e-post adresse");
							response[0] = "0";
						}
						else {
							response[1] = newValue.toLowerCase();
						}
					}
					break;
				default:
					break;
			}
		default:
			break;
	}
	return response;
}

function customInput(id, oldValue, newValue) {
	var feltNavn = "";
	var tabellNavn = "";
	feltNavn = axIdFieldName(id);
	if(feltNavn) tabellNavn = axFileNameFromFieldname(feltNavn);
	var response = ["1", newValue];
	switch (tabellNavn) {
		case "[Elever]":
			switch (feltNavn) {
				default:
					break;
			}
			break;
		default:
			break;
	}
	return response;
}

function customValidateRecord(tabellNavn, id) {
	switch (tabellNavn) {
		case "[Elever]":
			var nyttPassord = axGetValue(id, "[Elever]Nytt");
			var gjentattPassord = axGetValue(id, "[Elever]Gjentatt");
			if ((nyttPassord != gjentattPassord) && (nyttPassord.length>0)) {
				alert("Gjenta nytt passord");
				axSetFocus(id, "[Elever]Gjentatt");
				return false;
			}
			break;
		case "[Aktiviteter]":
			
			break;
		default:
			break;
	}	
	return true;
}

function customUpdateRow(id, name) {
	switch (name) {
		case "[Ordre]MVA":
			oppdaterOrdrelinje(id);
			break;
	}
}

function customUpdateRowEnd(id, name) {
	switch (name) {
		case "[Ordre]MVA":
			oppdaterOrdre(id);
			break;
	}
}

function customRowDeleted(id, bool) {
	var feltNavn = axIdFieldName(id);
	var tabellNavn = axFileNameFromFieldname(feltNavn);
	
	switch (tabellNavn) {
		case "[Ordrelinjer]":
			oppdaterOrdre(id.substring(2));
			break;
	}
}

function visHjelp() {

}


function customWindowOnLoad() {

}


function custom_FindRecords(theValues) {
	
}


function customRecordSaved(button, responseXML, path, area, table, row, theValues) {
	var tabellNavn = fileName[table];
	switch (tabellNavn) {
		case "Handlekurv":
			gotoHandlekurv("Handlekurv");
			break;
		default:
			break;
	}

}


function customLogout(name) {
	window.location = window.location.protocol + "//" + window.location.hostname + ":8091/4daction/ax";
	
	return true;
}