function popUp(imageFile, width, height, title) {
	var html = '<title>' + title + ' - Click to close </title><body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 onblur=\"self.close()\" onclick=\"javascript:window.close()\"><img src=\"' + imageFile + '\" alt=\"Click to close\"></body>';
	var popup = window.open(imageFile, 'kuvagalleria', 'width=' + width+ ', height=' + height + ', status=no');
	popup.document.write(html);
	popup.focus();
}

function protect(name, address, display){
	var link = name + "@" + address
	if(!display) { display = link; }
		document.write("<a href='mailto:" + link + "'>" + display + "</a>");
}

function CountLeft(field, count, max) {
	// if the length of the string in the input field is greater than the max value, trim it 
	if (field.value.length > max)
		field.value = field.value.substring(0, max);
	else
	// calculate the remaining characters  
		count.value = max - field.value.length;
}

function varmista_poisto() {
	var agree=confirm("Haluatko nyt aivan varmasti poistaa valitut kohteet?");
	if (agree)
		return true ;
	else
		return false ;
}

function tarkasta_palaute(form) {
	if (form.viesti.value == "") {
		alert("Palaute ei saa olla tyhjä.\nFeedback can't be empty.");
		form.viesti.focus();
		return false;
	}
	return true;
}

function tarkasta_vieraskirja(form) {
	if (form.nimi.value == "") {
		alert("Nimi/nimimerkki ei saa olla tyhjä.\nName/nickname can't be empty.");
		form.nimi.focus();
		return false;
	}
	if (form.viesti.value == "") {
		alert("Viesti ei saa olla tyhjä.\nMessage can't be empty.");
		form.viesti.focus();
		return false;
	}
	return true;
}