function openWindow(src, width, height) {
	window.open(src, 'myName', 'width=' + width + ', height=' + height);
}

function tooLong(field,limit) {
	if (field.value.length > limit) {
		alert('Max '+ limit + ' liter. / Max '+ limit + ' fletteri.');
		field.value = field.value.substring(0,limit);
		field.focus();
    }
}

function countCharacters(field, textField) {
	tf = document.getElementById(textField)
	tf.value = field.value.length;
}
 
function changeAddress() {
	if (document.getElementById('country').selectedIndex != 2 && document.getElementById('country').selectedIndex != 3) {
		document.getElementById('country_other').style.display="none";
		document.getElementById('country_other').style.display="none";
		document.getElementById('country_other').value="";
		
		document.getElementById('country_uk').style.display="none";
		document.getElementById('country_uk').style.display="none";
	}
	
	if (document.getElementById('country').selectedIndex == 2) {
		document.getElementById('country_other').style.display="none";
		document.getElementById('country_other').style.display="none";
		document.getElementById('country_other').value="";
		
		document.getElementById('country_uk').style.display="block";
		document.getElementById('country_uk').style.display="block";
	}
	
	if (document.getElementById('country').selectedIndex == 3) {
		document.getElementById('country_uk').style.display="none";
		document.getElementById('country_uk').style.display="none";

		document.getElementById('country_other').style.display="block";
		document.getElementById('country_other').style.display="block";		
	}
}

function confirmAction(message, url) {
	if (confirm(message)) {
		location.href = url;
	}
}

function confirmAndSubmit(message, form) {
	if (confirm(message)) {
		form.submit();
	}
}

function showPhoto(url) {
	msg=window.open('','photo','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,top=50,left=200,width=600,height=400');
	msg.document.open();
	msg.document.write('<html><head><title>Preview</title></head><body bgcolor=\"#000000\" topmargin=\"0\" leftmargin=\"0\" onload=\"javascript:window.resizeTo(document.photo.width,document.photo.height+40);\"><img src=\"'+url+'\" name=\"photo\" onclick=\"window.close()\"></body></HTML>');
	msg.document.close();
	msg.focus();
}
