	// character test: åäö ÅÄÖ

	function agreement(type, form) {
		
		if ("show" == type) {
			document.getElementById(form).style.display = "none";
			document.getElementById(form + '-avtal').style.display = "block";
		}
		if ("hide" == type) {
			document.getElementById(form + '-avtal').style.display = "none";
			document.getElementById(form).style.display = "block";
		}
	}

	function manage_image(image_nr) {
		var features = 'status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=450,height=400';
		var winName = 'Bild';
		var theURL = '/special/bilder/manageimage.php?image_nr=' + image_nr;
		window.open(theURL,winName,features);
	}

	function manage_image_admin(image_nr) {
		var features = 'status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=450,height=400';
		var winName = 'Bild';
		var theURL = '/special/bilder/manageimage-admin.php?image_nr=' + image_nr;
		window.open(theURL,winName,features);
	}

	function add_imagelink(artikeltyp, artikel_id, hook) {
		var features = 'status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=450,height=400';
		var winName = 'Bild';
		var theURL = '/special/bilder/manageimage.php?add_image=yes&artikeltyp=' + artikeltyp + '&artikel_id=' + artikel_id + '&hook=' + hook;
		window.open(theURL,winName,features);
	}

	function add_imagelink_admin(artikeltyp, artikel_id) {
		var features = 'status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=450,height=400';
		var winName = 'Bild';
		var theURL = '/special/bilder/manageimage-admin.php?add_image=yes&artikeltyp=' + artikeltyp + '&artikel_id=' + artikel_id;
		window.open(theURL,winName,features);
	}

	function remove_imagelink(artikeltyp, artikel_id, hook, fil_id) {
		var features = 'status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=450,height=400';
		var winName = 'Bild';
		var theURL = '/special/bilder/manageimage.php?remove_image=yes&artikeltyp=' + artikeltyp + '&artikel_id=' + artikel_id + '&hook=' + hook + '&fil_id=' + fil_id;
		window.open(theURL,winName,features);
	}

	function remove_imagelink_admin(artikeltyp, artikel_id, hook, fil_id) {
		var features = 'status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=450,height=400';
		var winName = 'Bild';
		var theURL = '/special/bilder/manageimage-admin.php?remove_image=yes&artikeltyp=' + artikeltyp + '&artikel_id=' + artikel_id + '&hook=' + hook + '&fil_id=' + fil_id;
		window.open(theURL,winName,features);
	}

	function remove_image(image_nr, newbuttonname) {
		document.getElementById("bild" + image_nr).value = "";
		document.getElementById("miniatyr" + image_nr).value = "";
		document.getElementById("imageplace" + image_nr).innerHTML = "";
		document.getElementById('removeimage' + image_nr + '_button').style.display = "none";
		// document.getElementById('addimage' + image_nr + '_button').style.display = "none";
		document.getElementById("addimage" + image_nr + "_button").value = newbuttonname;
		if (1 == image_nr) {
			document.getElementById('addimage2_button').style.display = "none";
			document.getElementById("imageplace" + image_nr).style.background = "none";
		}
		if (2 == image_nr) {
			document.getElementById('addimage3_button').style.display = "none";
			document.getElementById("imageplace" + image_nr).style.background = "none";
		}
		if (3 == image_nr) {
			document.getElementById("imageplace" + image_nr).style.background = "none";
		}
	}

	function writeToOpenerAndClose(imagename, thumbname, newbuttonname, reminder, image_nr, imagepath) {
		window.opener.document.getElementById("bild" + image_nr).value = imagename;
		window.opener.document.getElementById("miniatyr" + image_nr).value = thumbname;
		var image_link = '<img src="' + imagepath + thumbname + '">';
		var inputfield = '<label for="bildtext' + image_nr + '">Bildtext:</label>';
		inputfield = inputfield  + '<input type="text" id="bildtext' + image_nr + '" name="bildtext' + image_nr + '">';
		window.opener.document.getElementById("imageplace" + image_nr).innerHTML = image_link + inputfield;
		window.opener.document.getElementById("addimage" + image_nr + "_button").value = newbuttonname;
		if (1 == image_nr) {
			window.opener.document.getElementById('removeimage1_button').style.display = "inline";
			window.opener.document.getElementById('addimage2_button').style.display = "inline";
			window.opener.document.getElementById("imageplace" + image_nr).style.background = "#ECF5F5";
		}
		if (2 == image_nr) {
			window.opener.document.getElementById('removeimage2_button').style.display = "inline";
			window.opener.document.getElementById('addimage3_button').style.display = "inline";
			window.opener.document.getElementById("imageplace" + image_nr).style.background = "#ECF5F5";
		}
		if (3 == image_nr) {
			window.opener.document.getElementById('removeimage3_button').style.display = "inline";
			window.opener.document.getElementById("imageplace" + image_nr).style.background = "#ECF5F5";
		}
		// window.opener.document.getElementById("md-picture-reminder").innerHTML = '<i><font color="red">' + reminder + '</font></i>';
		window.close();
	}

/*
	function openMovieWindow(movie_id) {
		var features = 'status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=450,height=400';
		var winName = 'ShowMovie';
		var theURL = 'popups/show-movie.php?movie_id=' + movie_id;
		window.open(theURL,winName,features);
	}
*/

	function Disab(val) {
		if(val == "1") {
	 		document.laddaupp.submit.disabled = true;
	 		document.laddaupp.submit.value = "Laddar upp...";
	 		// document.getElementById('statusmessage').innerHTML = statusmessage;
	 		document.getElementById('errormessage').innerHTML = "";
	 		document.getElementById('statusmessage').style.display = "block";
	 	}
	 }

	function clear_status(val) {
		if(val == "1") {
	 		document.getElementById('statusmessage').style.display = "none";
	 	}
	 }

// submit form and close window
function closeAndSubmitParentArticleForm(typeOfArticle) {
	// window.opener.artikel_form.action.value = "save_temp_article";
	if (typeOfArticle == "artikel_admin") {
		// window.opener.document.getElementById("artikel_form").action.value = "save_temp_article";
		// alert("Debug!") // debug
		window.opener.document.artikel_form.submit();
	} else if (typeOfArticle == "artikel_public") {
		// alert(typeOfArticle) // debug
		window.opener.document.getElementById("artikel_form").action.value = "save_temp_article";
		window.opener.document.artikel_form.submit();
	}
	window.close();
}

