<!--
// -- TECKEN KVAR --------------------------------------------------------------------
function limitText(limitField, limitCount, limitNum)
{
	if (limitField.value.length > limitNum)
	{
		limitField.value = limitField.value.substring(0, limitNum);
	}
	else
	{
		limitCount.value = limitNum - limitField.value.length;
	}
}

// -- ANTAL TECKEN ------------------------------------------------------------------
function nbrText(limitField, limitCount)
{
	{
		limitCount.value = limitField.value.length;
	}
}


// -- KONTAKTA OSS -------------------------------------------------------------------
function checkMail()
{
	var errorMess = "";
	if (document.frmMail.strName.value.length < 2)
	{
		document.frmMail.strName.style.backgroundColor='#FFF0B3';
		errorMess += '# Ditt namn måste innehålla minst 2 tecken.\n';
	}
	else
	{
		document.frmMail.strName.style.backgroundColor='#FFFFFF';
	}
	
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.frmMail.strMail.value)))
	{
		document.frmMail.strMail.style.backgroundColor='#FFF0B3';
		errorMess += '# Du har inte angivit en giltig e-postadress.\n';
	}
	else
	{
		document.frmMail.strMail.style.backgroundColor='#FFFFFF';
	}

	if (document.frmMail.strMess.value.length < 10 || document.frmMail.strMess.value.length > 1000)
	{
		document.frmMail.strMess.style.backgroundColor='#FFF0B3';
		errorMess += '# Ditt meddelande måste innehålla 10-1000 tecken.\n';
	}
	else
	{
		document.frmMail.strMess.style.backgroundColor='#FFFFFF';
	}
	
	if (errorMess.length > 1)
	{
		alert(errorMess);
		return false
	}
	else
	{
		return true;
	}
}


// -- LÄGG TILL BUTIK ----------------------------------------------------------
function checkAdd()
{
	var errorMess = "";
	if (document.frmAdd.strName.value.length < 2)
	{
		document.frmAdd.strName.style.backgroundColor='#FFF0B3';
		errorMess += '# Butiksnamnet måste innehålla minst 2 tecken.\n';
	}
	else
	{
		document.frmAdd.strName.style.backgroundColor='#FFFFFF';
	}

	if (document.frmAdd.strInfo.value.length < 100 || document.frmAdd.strInfo.value.length > 250)
	{
		document.frmAdd.strInfo.style.backgroundColor='#FFF0B3';
		errorMess += '# Beskrivningen måste innehålla 100-250 tecken.\n';
	}
	else
	{
		document.frmAdd.strInfo.style.backgroundColor='#FFFFFF';
	}
	
	if (document.frmAdd.strLinkURL.value.length < 10)
	{
		document.frmAdd.strLinkURL.style.backgroundColor='#FFF0B3';
		errorMess += '# URL:en är felaktigt angiven.\n';
	}
	else
	{
		document.frmAdd.strLinkURL.style.backgroundColor='#FFFFFF';
	}
	
	if (document.frmAdd.intCat.value.length != 4)
	{
		document.frmAdd.intCat.style.backgroundColor='#FFF0B3';
		errorMess += '# Du har inte valt någon kategori.\n';
	}
	else
	{
		document.frmAdd.intCat.style.backgroundColor='#FFFFFF';
	}
	
	if (errorMess.length > 1)
	{
		alert(errorMess);
		return false
	}
	else
	{
		return true;
	}
}


// -- KOMMENTAR -------------------------------------------------------------
function checkComment()
{
	var errorMess = "";
	if (document.frmComment.strName.value.length < 2)
	{
		document.frmComment.strName.style.backgroundColor='#FFF0B3';
		errorMess += '# Ditt namn måste innehålla minst 2 tecken.\n';
	}
	else
	{
		document.frmComment.strName.style.backgroundColor='#FFFFFF';
	}

	if (document.frmComment.strComment.value.length < 10 || document.frmComment.strComment.value.length > 1000)
	{
		document.frmComment.strComment.style.backgroundColor='#FFF0B3';
		errorMess += '# Din kommentar måste innehålla 10-1000 tecken.\n';
	}
	else
	{
		document.frmComment.strComment.style.backgroundColor='#FFFFFF';
	}
	
	if (document.frmComment.codeInput.value.length != 4)
	{
		document.frmComment.codeInput.style.backgroundColor='#FFF0B3';
		errorMess += '# Koden är felaktig.\n';
	}
	else
	{
		document.frmComment.codeInput.style.backgroundColor='#FFFFFF';
	}
	
	if (errorMess.length > 1)
	{
		alert(errorMess);
		return false
	}
	else
	{
		return true;
	}
}

// -->
