var oldColor;

function callMe(form) {
	var result = false;
	var filter = /^[0-9 -+]{9,}/;

	if (form.Name.value == "") {
		alert('Please fill in your name.');
		form.Name.focus();
	}
	else if (form.Company.value == "") {
		alert('Please fill in your company name.');
		form.Company.focus();
	}
	else if (form.Telephone.value == "") {
		alert('Please fill in your telephone number.');
		form.Telephone.focus();
	}
	else if (!filter.test(form.Telephone.value)) {
		alert('Invalid telephone number.\nPlease fill in a valid telephone number.');
		form.Telephone.focus();
	}
	else {
		result = true;
	}
	return result;
}

function checkboxes(form, checked) {
	if (document.all || document.getElementById) {
		for (i = 0; i < form.length; i++) {
			var tempobj = form.elements[i];
			if (tempobj.type.toLowerCase() == "checkbox") {
				tempobj.checked = checked;
			}
		}
	}
}

function copyToClipboard(string) {
	result = false;
	if (window.clipboardData) {
		window.clipboardData.setData('Text', string);
		result = true;
	}
	return result;
}

function downloadDocumentation(form) {
	var type = form.Type.options[form.Type.selectedIndex].value;
	if (type == "") {
		alert('Please choose an interface.');
	}
	else if (type == "email") {
		alert('Please contact support for the technical documents of this interface.');
	}
	else {
		redirect(type);
	}
	return false;
}

function login(form) {
	var result = false;

	if (form.Username.value == "") {
		alert('Please fill in the username of the account.');
		form.Username.focus();
	}
	else if (form.Password.value == "") {
		alert('Please fill in the password of the account.');
		form.Password.focus();
	}
	else {
		result = true;
	}
	return result;
}

function maximizeWindow() {
	window.moveTo(0, 0);
	window.resizeTo(screen.width, screen.height);
}

function menuClick(url) {
	redirect(url);
}

function menuOut(obj) {
	if (typeof(obj.style) != 'undefined') {
		obj.style.backgroundColor = '#FBFBFC';
	}
}

function menuOver(obj) {
	if (typeof(obj.style) != 'undefined') {
		obj.style.backgroundColor = '#F5F5F8';
	}
}

function password(form) {
	var result = false;

	if (form.Email.value == "") {
		alert('Please fill in the e-mail address of the commercial contact.');
		form.Email.focus();
	}
	else {
		result = true;
	}
	return result;
}

function profile(form, checkLimit)  {
	var result = true;
	var filter = /^[0-9A-Z]+$/i;
	if (form.BedrijfsNaam.value == "") {
		alert('Please fill in the company name.');
		form.BedrijfsNaam.focus();
		result = false;
	}
	else if (form.Naam.value == "") {
		alert('Please fill in a name.');
		form.Naam.focus();
		result = false;
	}
	else if (form.Adres.value == "") {
		alert('Please fill in an address');
		form.Adres.focus();
		result = false;
	}
	else if (form.Postcode.value == "") {
		alert('Please fill in the postal code.');
		form.Postcode.focus();
		result = false;
	}
	else if (form.Plaats.value == "") {
		alert('Please fill in the city.');
		form.Plaats.focus();
		result = false;
	}
	else if (form.Telefoon.value == "") {
		alert('Please fill in the telephone number.');
		form.Telefoon.focus();
		result = false;
	}
	else if (form.Email.value == "") {
		alert('Please fill in the e-mail address.');
		form.Email.focus();
		result = false;
	}
	else if (form.TechContactEmail.value == "") {
		alert('Please fill in the e-mail address of the technical contact');
		form.TechContactEmail.focus();
		result = false;
	}
	else if ((form.Password.value != "") && !filter.test(form.Password.value)) {
		alert('The password is invalid. Please use only the characters A-Z and the digits 0-9');
		form.Password.focus();
		result = false;
	}
	else if ((form.Password.value != "") && (form.Password.value != form.Password2.value)) {
		alert('The passwords do not match');
		form.Password.focus();
		result = false;
	}
	else if (form.Originator.value == "") {
		alert('Please fill in the default originator.');
		form.Originator.focus();
		result = false;
	}
	else if ((checkLimit == 1) && (form.WarnLimit.value == "")) {
		alert('Please fill in the warning limit.');
		form.WarnLimit.focus();
		result = false;
	}
	return result;
}

function redirect(url) {
	this.location = url;
}

function redirectSelect(obj) {
	redirect(obj.options[obj.selectedIndex].value);
}

function register(form) {
	var result = false;
	var filter = /^[0-9A-Z\-]+$/i;
	if (form.Naam.value == "") {
		alert('Please fill in a valid name.');
		form.Naam.focus();
	}
	else if (form.Adres.value == "") {
		alert('Please fill in a valid address.');
		form.Adres.focus();
	}
	else if (form.Postcode.value == "") {
		alert('Please fill in a valid postal code.');
		form.Postcode.focus();
	}
	else if (form.Plaats.value == "") {
		alert('Please fill in a valid city.');
		form.Plaats.focus();
	}
	else if (form.Email.value == "") {
		alert('Please fill in a valid e-mail address.');
		form.Email.focus();
	}
	else if ((form.Username.value == "") || !filter.test(form.Username.value)) {
		alert('Please fill in a valid username.');
		form.Username.focus();
	}
	else {
		result = true;
	}
	return result;
}

function sms(form) {
	var result = true;
	if (form.Message.value == "") {
		alert('Please type in a message.');
		form.Message.focus();
		result = false;
	}
	return result;
}

function tableOut(obj, index) {
	if (typeof(obj.style) != 'undefined') {
		obj.style.backgroundColor = '';
	}
}

function tableOver(obj) {
	if (typeof(obj.style) != 'undefined') {
		obj.style.backgroundColor = '#DDE5EE';
	}
}


