// Åpner et bilde i et eget vindu
function hele(f)
{
	var vindu = window.open(f, "bildevindu", "toolbar=no, location=no, resizable=yes, scrollbars=yes width=500, height=300");
	vindu.focus();
}

function slettGalleri()
{
	return confirm("Ønsker du å slette dette galleriet og alt innholdet i det?");
}

// Viser en verifiseringsboks i forbindelse med sletting
function slett(galleri, id)
{
	var slette = confirm("Ønsker du å slette dette bildet?");
	if (slette)
	{
		window.location.href="redigergalleri.jsp?galleri=" + galleri + "&slett=" + id;
	}
}

// Åpner vindu for å skrive inn bildetekst
function tekst(galleri, id)
{
	window.location="bildetekst.jsp?galleri=" + galleri + "&id=" + id;
}

// Flere opplastingsbokser
function flere()
{
	antall = eval(document.lastopp.antall.value);
	if (antall < 20)
	{
		antall = antall + 1;
		nummer = "nr" + antall;
		obj = document.getElementById(nummer);
		obj.style.display=(obj.style.display=='none') ? 'inline' : 'none';
		document.lastopp.antall.value = antall;
	}
	else
	{
		alert("Du kan maks laste opp 20 bilder på en gang");
	}
}

// Færre opplastingsbokser
function faerre()
{
	antall = eval(document.lastopp.antall.value);
	if (antall > 1)
	{
		nummer = "nr" + antall;
		obj = document.getElementById(nummer);
		obj.style.display=(obj.style.display=='none') ? 'inline' : 'none';
		antall = antall - 1;
		document.lastopp.antall.value = antall;
	}
}

// Validering av skjema for opplasting av fil
function validerFilNavn()
{
	var i;
	antall = eval(document.lastopp.antall.value);
	
	for (i = 1; i <= antall;i++)
	{
		obj = document.getElementById("filnavn" + i);
		
		if (obj.value == "")
		{
		alert("Du har glemt å fylle inn ett eller flere av fil-feltene!");
		return false;
		}			
	}
	return true;
}

function validerGalleriTekst()
{
	obj = document.getElementById("tittel");
	
	if (obj.value == "")
	{
		alert("Du må skrive en tittel på galleriet");
		return false;
	}
	return true;
}
