function initadmin() {
	var menuItem = document.getElementById("menuitem_"+1);	
}


function gotoSect(sect){

	if(sect){
		this.location.href="default.asp?sect="+sect;
	}
}

function dogoto(url){

	if(url){
		this.location.href=url;
	}
}

function color(menuItem){
	menuItem.style.background = '#EEEEEE';
	menuItem.style.filter = "progid:DXImageTransform.Microsoft.Gradient(gradientType=1,startColorStr=#DDDDDD,endColorStr=#FFFFFF)";


}

function uncolor(menuItem){
	menuItem.style.background = '#FFFFFF';
	menuItem.style.filter = "progid:DXImageTransform.Microsoft.Gradient(gradientType=1,startColorStr=#FFFFFF,endColorStr=#FFFFFF)";
}

function xstandardSubmitHandler() {
	/*
	for(i=1;i<10;i++){
		try{
			document.getElementById('editor'+i).EscapeUnicode = true;
			document.getElementById('xhtml'+i).value = document.getElementById('editor'+i).value;
		}
		catch(e){ 
			alert('could not save:' +document.getElementById('editor'+i).value);
		}
	}
	*/
}



function showhideDiv(id) { 

	el = document.getElementById(id);
	var display = el.style.display ? '' : 'none';
	el.style.display = display;

	/*var divstate = 'hidden'; 
	
	if (divstate == 'visible') { 
	divstate = 'hidden';
	} 

	else { 
	divstate = 'visible'; 
	} 
	if (document.all) { //IS IE 4 or 5 (or 6 beta) 
	eval( "document.all." + layer_ref + ".style.visibility = divstate"); 
	eval( "document.all." + layer_ref + ".style.overflow = divstate"); 
	} 
	if (document.layers) { //IS NETSCAPE 4 or below 
	document.layers[layer_ref].visibility = divstate; 
	} 
	if (document.getElementById && !document.all) { 
	maxwell_smart = document.getElementById(layer_ref); 
	maxwell_smart.style.visibility = divstate; 
	} 
	*/
}

function parseForm(FormName){
	thisForm = document.forms["mailForm"];
	operation = thisForm.operation.value;
	
	switch(operation) {
	
		case "1"	: alert("1");break;
		case "sendmail"	:
				  mailing_id = thisForm.mailing_id[thisForm.mailing_id.selectedIndex].value;
				  sendto = radioValue(thisForm.sendto)
				  tomail = thisForm.tomail.value;
				  qstr = "mailer.asp?id=" +mailing_id + "&sendto=" + sendto + "&tomail=" + tomail;
				  document.intframe.location.href=qstr;
				  document.all.intframe.style.display = '';
				  //alert(qstr)
				  break;
		default		: break;
	}
	
}

function radioValue(radioButton)
{
    for (i = 0; i <= radioButton.length; i++)
    {
        if (radioButton[i].checked == true) return radioButton[i].value; 
    } 
         // if it didn't find anything, return the .value  (behaviour of single radio btn)
        return radioButton.value;
}

function validEmail(formvalue)
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(formvalue)){return true;}
	else { alert('S.v.p. een geldig emailadres opgeven.'); return false;}
}

/* 
	Clean Form Validation was written from scratch by Marc Grabanski
// http://marcgrabanski.com/code/clean-form-validation
/* Under the Creative Commons Licence http://creativecommons.org/licenses/by/3.0/
	Share or Remix it but please Attribute the authors. */

var cleanValidator = {
	init: function (settings) {
		this.settings = settings;
		this.form = document.getElementById(this.settings["formId"]);
		formInputs = this.form.getElementsByTagName("input");
		
		// change color of inputs on focus
		for(i=0;i<formInputs.length;i++)
		{
			if(formInputs[i].getAttribute("type") != "submit") {
				input = formInputs[i];
				input.style.background = settings["inputColors"][0];
				input.onblur = function () {
					this.style.background = settings["inputColors"][0];
				}
				input.onfocus = function () {
					this.style.background = settings["inputColors"][1];
				}
			}
		};
		this.form.onsubmit = function () {
			error = cleanValidator.validate();
			if(error.length < 1) {
				return true;
			} else {
				cleanValidator.printError(error);
				return false;
			}
		};
	},
	validate: function () {
		error = '';
		validationTypes = new Array("isRequired", "isEmail", "isNumeric");
		for(n=0; n<validationTypes.length; n++) {
			var x = this.settings[validationTypes[n]];
			if(x != null) {
				for(i=0; i<x.length; i++) 
				{
					inputField = document.getElementById(x[i]);
					switch (validationTypes[n]) {
						case "isRequired" :
						valid = !isRequired(inputField.value);
						errorMsg = "is een verplicht veld.";
						break;
						case "isEmail" :
						valid = isEmail(inputField.value);
						errorMsg = "is een ongeldig e-mail adres.";
						break;
						case "isNumeric" :
						valid = isNumeric(inputField.value);
						errorMsg = "alleen nummers.";
						break;
					}
					if(!valid) {
						error += x[i]+" "+errorMsg+"\n";
						inputField.style.background = this.settings["errorColors"][0];
						inputField.style.border = "1px solid "+this.settings["errorColors"][1];
					} else {
						inputField.style.background = this.settings["inputColors"][0];
						inputField.style.border = '1px solid';
					}
				}
			}
		}
		return error;
	},
	printError: function (error) {
		alert(error);
	}
};

// returns true if the string is not empty
function isRequired(str){
	return (str == null) || (str.length == 0);
}
// returns true if the string is a valid email
function isEmail(str){
	if(isRequired(str)) return false;
	var re = /^[^\s()<>@,;:\/]+@\w[\w\.-]+\.[a-z]{2,}$/i
	return re.test(str);
}
// returns true if the string only contains characters 0-9 and is not null
function isNumeric(str){
	if(isRequired(str)) return false;
	var re = /[\D]/g
	if (re.test(str)) return false;
	return true;
}

