function enhancePopupLinks() {
	var allLinks = document.getElementsByTagName('a');
	for (i=0;i<allLinks.length;i++) {
		if(allLinks[i].className == 'popup') {
			allLinks[i].onclick = function() {
				window.open(this.href,'popup','width=600,height=735,scrollbars=1');
				return false;
			}
		}
	}
}

function log(msg) {
	if(window.console != null) {
		console.log(msg);
	}
}

function enhanceSubmitForm() {
	var allForms = document.getElementsByTagName('form');
	for (i=0;i<allForms.length;i++) {
		if(allForms[i].className.indexOf('tips') != -1) {
			allForms[i].onsubmit = function() {
				if(document.getElementById('email1').value == '' || document.getElementById('email2').value == '' || document.getElementById('email3').value == '' || document.getElementById('email1').value == '' || document.getElementById('email4').value == '' || document.getElementById('email5').value == '') {
					alert('Alla E-postfält verkar inte vara ordentligt ifyllda.');
					return false;
				}
			}
		}
	}
}

window.onload = function() {
	enhancePopupLinks();
	enhanceSubmitForm();
}
